| 23 |
|
*/ |
| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
– |
#ifndef _WIN32 |
| 26 |
|
#include <netinet/in_systm.h> |
| 27 |
|
#include <netinet/ip.h> |
| 28 |
|
#include <netinet/tcp.h> |
| 29 |
< |
#endif |
| 29 |
> |
#include "list.h" |
| 30 |
|
#include "fdlist.h" |
| 31 |
|
#include "s_bsd.h" |
| 32 |
|
#include "client.h" |
| 37 |
|
#include "irc_getnameinfo.h" |
| 38 |
|
#include "irc_getaddrinfo.h" |
| 39 |
|
#include "ircd.h" |
| 41 |
– |
#include "list.h" |
| 40 |
|
#include "listener.h" |
| 41 |
|
#include "numeric.h" |
| 42 |
|
#include "packet.h" |
| 58 |
|
|
| 59 |
|
struct Callback *setup_socket_cb = NULL; |
| 60 |
|
|
| 61 |
< |
static void comm_connect_callback(fde_t *fd, int status); |
| 61 |
> |
static void comm_connect_callback(fde_t *, int); |
| 62 |
|
static PF comm_connect_timeout; |
| 63 |
|
static void comm_connect_dns_callback(void *, const struct irc_ssaddr *, const char *); |
| 64 |
|
static PF comm_connect_tryconnect; |
| 78 |
|
else |
| 79 |
|
{ |
| 80 |
|
ServerInfo.can_use_v6 = 1; |
| 83 |
– |
#ifdef _WIN32 |
| 84 |
– |
closesocket(v6); |
| 85 |
– |
#else |
| 81 |
|
close(v6); |
| 87 |
– |
#endif |
| 82 |
|
} |
| 83 |
|
#else |
| 84 |
|
ServerInfo.can_use_v6 = 0; |
| 94 |
|
int |
| 95 |
|
get_sockerr(int fd) |
| 96 |
|
{ |
| 103 |
– |
#ifndef _WIN32 |
| 97 |
|
int errtmp = errno; |
| 105 |
– |
#else |
| 106 |
– |
int errtmp = WSAGetLastError(); |
| 107 |
– |
#endif |
| 98 |
|
#ifdef SO_ERROR |
| 99 |
|
int err = 0; |
| 100 |
|
socklen_t len = sizeof(err); |
| 156 |
|
setsockopt(fd, IPPROTO_IP, IP_TOS, &opt, sizeof(opt)); |
| 157 |
|
#endif |
| 158 |
|
|
| 169 |
– |
#ifndef _WIN32 |
| 159 |
|
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); |
| 171 |
– |
#endif |
| 160 |
|
|
| 161 |
|
return NULL; |
| 162 |
|
} |
| 213 |
|
* If the connection has been up for a long amount of time, schedule |
| 214 |
|
* a 'quick' reconnect, else reset the next-connect cycle. |
| 215 |
|
*/ |
| 216 |
< |
if ((conf = find_conf_exact(SERVER_TYPE, |
| 217 |
< |
client_p->name, client_p->username, |
| 230 |
< |
client_p->host))) |
| 216 |
> |
if ((conf = find_conf_exact(SERVER_TYPE, client_p->name, |
| 217 |
> |
client_p->username, client_p->host))) |
| 218 |
|
{ |
| 219 |
|
/* |
| 220 |
|
* Reschedule a faster reconnect, if this was a automatically |
| 222 |
|
* a rehash in between, the status has been changed to |
| 223 |
|
* CONF_ILLEGAL). But only do this if it was a "good" link. |
| 224 |
|
*/ |
| 225 |
< |
aconf = (struct AccessItem *)map_to_conf(conf); |
| 226 |
< |
aclass = (struct ClassItem *)map_to_conf(aconf->class_ptr); |
| 225 |
> |
aconf = map_to_conf(conf); |
| 226 |
> |
aclass = map_to_conf(aconf->class_ptr); |
| 227 |
|
aconf->hold = time(NULL); |
| 228 |
|
aconf->hold += (aconf->hold - client_p->since > HANGONGOODLINK) ? |
| 229 |
|
HANGONRETRYDELAY : ConFreq(aclass); |
| 243 |
– |
if (nextconnect > aconf->hold) |
| 244 |
– |
nextconnect = aconf->hold; |
| 230 |
|
} |
| 231 |
|
} |
| 232 |
|
else if (IsClient(client_p)) |
| 324 |
|
memcpy(&new_client->localClient->ip, irn, sizeof(struct irc_ssaddr)); |
| 325 |
|
|
| 326 |
|
irc_getnameinfo((struct sockaddr*)&new_client->localClient->ip, |
| 327 |
< |
new_client->localClient->ip.ss_len, new_client->sockhost, |
| 328 |
< |
HOSTIPLEN, NULL, 0, NI_NUMERICHOST); |
| 327 |
> |
new_client->localClient->ip.ss_len, new_client->sockhost, |
| 328 |
> |
sizeof(new_client->sockhost), NULL, 0, NI_NUMERICHOST); |
| 329 |
|
new_client->localClient->aftype = new_client->localClient->ip.ss.ss_family; |
| 330 |
|
#ifdef IPV6 |
| 331 |
|
if (new_client->sockhost[0] == ':') |
| 643 |
|
/* Error? */ |
| 644 |
|
if (retval < 0) |
| 645 |
|
{ |
| 661 |
– |
#ifdef _WIN32 |
| 662 |
– |
errno = WSAGetLastError(); |
| 663 |
– |
#endif |
| 646 |
|
/* |
| 647 |
|
* If we get EISCONN, then we've already connect()ed the socket, |
| 648 |
|
* which is a good thing. |
| 701 |
|
*/ |
| 702 |
|
fd = socket(family, sock_type, proto); |
| 703 |
|
if (fd < 0) |
| 722 |
– |
{ |
| 723 |
– |
#ifdef _WIN32 |
| 724 |
– |
errno = WSAGetLastError(); |
| 725 |
– |
#endif |
| 704 |
|
return -1; /* errno will be passed through, yay.. */ |
| 727 |
– |
} |
| 705 |
|
|
| 706 |
|
execute_callback(setup_socket_cb, fd); |
| 707 |
|
|
| 734 |
|
* reserved fd limit, but we can deal with that when comm_open() |
| 735 |
|
* also does it. XXX -- adrian |
| 736 |
|
*/ |
| 737 |
< |
newfd = accept(lptr->fd.fd, (struct sockaddr *)pn, (socklen_t *)&addrlen); |
| 737 |
> |
newfd = accept(lptr->fd.fd, (struct sockaddr *)pn, &addrlen); |
| 738 |
|
if (newfd < 0) |
| 762 |
– |
{ |
| 763 |
– |
#ifdef _WIN32 |
| 764 |
– |
errno = WSAGetLastError(); |
| 765 |
– |
#endif |
| 739 |
|
return -1; |
| 767 |
– |
} |
| 740 |
|
|
| 741 |
|
#ifdef IPV6 |
| 742 |
|
remove_ipv6_mapping(pn); |