| 62 |
|
|
| 63 |
|
static void comm_connect_callback(fde_t *fd, int status); |
| 64 |
|
static PF comm_connect_timeout; |
| 65 |
< |
static void comm_connect_dns_callback(void *vptr, struct DNSReply *reply); |
| 65 |
> |
static void comm_connect_dns_callback(void *, const struct irc_ssaddr *, const char *); |
| 66 |
|
static PF comm_connect_tryconnect; |
| 67 |
|
|
| 68 |
|
|
| 507 |
|
void *data, int aftype, int timeout) |
| 508 |
|
{ |
| 509 |
|
struct addrinfo hints, *res; |
| 510 |
< |
char portname[PORTNAMELEN+1]; |
| 510 |
> |
char portname[PORTNAMELEN + 1]; |
| 511 |
|
|
| 512 |
|
assert(callback); |
| 513 |
|
fd->connect.callback = callback; |
| 539 |
|
hints.ai_socktype = SOCK_STREAM; |
| 540 |
|
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; |
| 541 |
|
|
| 542 |
< |
snprintf(portname, PORTNAMELEN, "%d", port); |
| 542 |
> |
snprintf(portname, sizeof(portname), "%d", port); |
| 543 |
|
|
| 544 |
|
if (irc_getaddrinfo(host, portname, &hints, &res)) |
| 545 |
|
{ |
| 546 |
|
/* Send the DNS request, for the next level */ |
| 547 |
– |
fd->dns_query = MyMalloc(sizeof(struct DNSQuery)); |
| 548 |
– |
fd->dns_query->ptr = fd; |
| 549 |
– |
fd->dns_query->callback = comm_connect_dns_callback; |
| 547 |
|
if (aftype == AF_INET6) |
| 548 |
< |
gethost_byname_type(host, fd->dns_query, T_AAAA); |
| 548 |
> |
gethost_byname_type(comm_connect_dns_callback, fd, host, T_AAAA); |
| 549 |
|
else |
| 550 |
< |
gethost_byname_type(host, fd->dns_query, T_A); |
| 550 |
> |
gethost_byname_type(comm_connect_dns_callback, fd, host, T_A); |
| 551 |
|
} |
| 552 |
|
else |
| 553 |
|
{ |
| 605 |
|
* otherwise we initiate the connect() |
| 606 |
|
*/ |
| 607 |
|
static void |
| 608 |
< |
comm_connect_dns_callback(void *vptr, struct DNSReply *reply) |
| 608 |
> |
comm_connect_dns_callback(void *vptr, const struct irc_ssaddr *addr, const char *name) |
| 609 |
|
{ |
| 610 |
|
fde_t *F = vptr; |
| 611 |
|
|
| 612 |
< |
if (reply == NULL) |
| 612 |
> |
if (name == NULL) |
| 613 |
|
{ |
| 617 |
– |
MyFree(F->dns_query); |
| 618 |
– |
F->dns_query = NULL; |
| 614 |
|
comm_connect_callback(F, COMM_ERR_DNS); |
| 615 |
|
return; |
| 616 |
|
} |
| 624 |
|
* the DNS record around, and the DNS cache is gone anyway.. |
| 625 |
|
* -- adrian |
| 626 |
|
*/ |
| 627 |
< |
memcpy(&F->connect.hostaddr, &reply->addr, reply->addr.ss_len); |
| 627 |
> |
memcpy(&F->connect.hostaddr, addr, addr->ss_len); |
| 628 |
|
/* The cast is hacky, but safe - port offset is same on v4 and v6 */ |
| 629 |
|
((struct sockaddr_in *) &F->connect.hostaddr)->sin_port = |
| 630 |
|
F->connect.hostaddr.ss_port; |
| 631 |
< |
F->connect.hostaddr.ss_len = reply->addr.ss_len; |
| 631 |
> |
F->connect.hostaddr.ss_len = addr->ss_len; |
| 632 |
|
|
| 633 |
|
/* Now, call the tryconnect() routine to try a connect() */ |
| 639 |
– |
MyFree(F->dns_query); |
| 640 |
– |
F->dns_query = NULL; |
| 634 |
|
comm_connect_tryconnect(F, NULL); |
| 635 |
|
} |
| 636 |
|
|