2 * A rewrite of Darren Reeds original res.c As there is nothing
3 * left of Darrens original code, this is now licensed by the hybrid group.
4 * (Well, some of the function names are the same, and bits of the structs..)
5 * You can use it where it is useful, free even. Buy us a beer and stuff.
7 * The authors takes no responsibility for any damage or loss
8 * of property which results from the use of this software.
10 * $Id: res.c 3301 2007-03-28 15:04:06Z jilles $
11 * from Hybrid Id: res.c 459 2006-02-12 22:21:37Z db $
13 * July 1999 - Rewrote a bunch of stuff here. Change hostent builder code,
14 * added callbacks and reference counting of returned hostents.
15 * --Bleep (Thomas Helvey <tomh@inxpress.net>)
17 * This was all needlessly complicated for irc. Simplified. No more hostent
18 * All we really care about is the IP -> hostname mappings. Thats all.
20 * Apr 28, 2003 --cryogen and Dianora
22 * DNS server flooding lessened, AAAA-or-A lookup removed, ip6.int support
23 * removed, various robustness fixes
25 * 2006 --jilles and nenolod
27 * Resend queries to other servers if the DNS server replies with an error or
28 * an invalid response. Also, avoid servers that return errors or invalid
31 * October 2012 --mr_flea
35 #include "ircd_defs.h"
42 #include "client.h" /* SNO_* */
48 #error this code needs to be able to address individual octets
51 static PF res_readreply
;
53 #define MAXPACKET 1024 /* rfc sez 512 but we expand names so ... */
54 #define RES_MAXALIASES 35 /* maximum aliases allowed */
55 #define RES_MAXADDRS 35 /* maximum addresses allowed */
56 #define AR_TTL 600 /* TTL in seconds for dns cache entries */
58 /* RFC 1104/1105 wasn't very helpful about what these fields
59 * should be named, so for now, we'll just name them this way.
60 * we probably should look at what named calls them or something.
62 #define TYPE_SIZE (size_t)2
63 #define CLASS_SIZE (size_t)2
64 #define TTL_SIZE (size_t)4
65 #define RDLENGTH_SIZE (size_t)2
66 #define ANSWER_FIXED_SIZE (TYPE_SIZE + CLASS_SIZE + TTL_SIZE + RDLENGTH_SIZE)
74 char queryname
[IRCD_RES_HOSTLEN
+ 1]; /* name currently being queried */
75 char retries
; /* retry counter */
76 char sends
; /* number of sends (>1 means resent) */
79 int lastns
; /* index of last server sent to */
80 struct rb_sockaddr_storage addr
;
82 struct DNSQuery
*query
; /* query callback for this request */
85 static rb_fde_t
*res_fd
;
86 static rb_dlink_list request_list
= { NULL
, NULL
, 0 };
87 static int ns_failure_count
[IRCD_MAXNS
]; /* timeouts and invalid/failed replies */
89 static void rem_request(struct reslist
*request
);
90 static struct reslist
*make_request(struct DNSQuery
*query
);
91 static void gethost_byname_type_fqdn(const char *name
, struct DNSQuery
*query
,
93 static void do_query_name(struct DNSQuery
*query
, const char *name
, struct reslist
*request
, int);
94 static void do_query_number(struct DNSQuery
*query
, const struct rb_sockaddr_storage
*,
95 struct reslist
*request
);
96 static void query_name(struct reslist
*request
);
97 static int send_res_msg(const char *buf
, int len
, int count
);
98 static void resend_query(struct reslist
*request
);
99 static int check_question(struct reslist
*request
, HEADER
* header
, char *buf
, char *eob
);
100 static int proc_answer(struct reslist
*request
, HEADER
* header
, char *, char *);
101 static struct reslist
*find_id(int id
);
102 static struct DNSReply
*make_dnsreply(struct reslist
*request
);
107 * looks up "inp" in irc_nsaddr_list[]
109 * server ID or -1 for not found
111 * paul vixie, 29may94
112 * revised for ircd, cryogen(stu) may03
113 * slightly modified for charybdis, mr_flea oct12
115 static int res_ourserver(const struct rb_sockaddr_storage
*inp
)
118 const struct sockaddr_in6
*v6
;
119 const struct sockaddr_in6
*v6in
= (const struct sockaddr_in6
*)inp
;
121 const struct sockaddr_in
*v4
;
122 const struct sockaddr_in
*v4in
= (const struct sockaddr_in
*)inp
;
125 for (ns
= 0; ns
< irc_nscount
; ns
++)
127 const struct rb_sockaddr_storage
*srv
= &irc_nsaddr_list
[ns
];
129 if (srv
->ss_family
!= inp
->ss_family
)
133 v6
= (const struct sockaddr_in6
*)srv
;
135 v4
= (const struct sockaddr_in
*)srv
;
137 /* could probably just memcmp(srv, inp, srv.ss_len) here
138 * but we'll err on the side of caution - stu
140 switch (srv
->ss_family
)
144 if (v6
->sin6_port
== v6in
->sin6_port
)
145 if ((memcmp(&v6
->sin6_addr
.s6_addr
, &v6in
->sin6_addr
.s6_addr
,
146 sizeof(struct in6_addr
)) == 0) ||
147 (memcmp(&v6
->sin6_addr
.s6_addr
, &in6addr_any
,
148 sizeof(struct in6_addr
)) == 0))
155 if (v4
->sin_port
== v4in
->sin_port
)
156 if ((v4
->sin_addr
.s_addr
== INADDR_ANY
)
157 || (v4
->sin_addr
.s_addr
== v4in
->sin_addr
.s_addr
))
171 * timeout_query_list - Remove queries from the list which have been
172 * there too long without being resolved.
174 static time_t timeout_query_list(time_t now
)
177 rb_dlink_node
*next_ptr
;
178 struct reslist
*request
;
179 time_t next_time
= 0;
182 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, request_list
.head
)
185 timeout
= request
->sentat
+ request
->timeout
;
189 ns_failure_count
[request
->lastns
]++;
190 request
->sentat
= now
;
191 request
->timeout
+= request
->timeout
;
192 resend_query(request
);
195 if ((next_time
== 0) || timeout
< next_time
)
201 return (next_time
> now
) ? next_time
: (now
+ AR_TTL
);
205 * timeout_resolver - check request list
207 static void timeout_resolver(void *notused
)
209 timeout_query_list(rb_current_time());
212 static struct ev_entry
*timeout_resolver_ev
= NULL
;
215 * start_resolver - do everything we need to read the resolv.conf file
216 * and initialize the resolver file descriptor if needed
218 static void start_resolver(void)
223 for (i
= 0; i
< irc_nscount
; i
++)
224 ns_failure_count
[i
] = 0;
228 if ((res_fd
= rb_socket(irc_nsaddr_list
[0].ss_family
, SOCK_DGRAM
, 0,
229 "UDP resolver socket")) == NULL
)
232 /* At the moment, the resolver FD data is global .. */
233 rb_setselect(res_fd
, RB_SELECT_READ
, res_readreply
, NULL
);
234 timeout_resolver_ev
= rb_event_add("timeout_resolver", timeout_resolver
, NULL
, 1);
239 * init_resolver - initialize resolver and resolver library
241 void init_resolver(void)
244 srand48(rb_current_time());
250 * restart_resolver - reread resolv.conf, reopen socket
252 void restart_resolver(void)
256 rb_event_delete(timeout_resolver_ev
); /* -ddosen */
261 * add_local_domain - Add the domain to hostname, if it is missing
262 * (as suggested by eps@TOASTER.SFSU.EDU)
264 void add_local_domain(char *hname
, size_t size
)
266 /* try to fix up unqualified names */
267 if (strchr(hname
, '.') == NULL
)
271 size_t len
= strlen(hname
);
273 if ((strlen(irc_domain
) + len
+ 2) < size
)
276 strcpy(hname
+ len
, irc_domain
);
283 * rem_request - remove a request from the list.
284 * This must also free any memory that has been allocated for
285 * temporary storage of DNS results.
287 static void rem_request(struct reslist
*request
)
289 rb_dlinkDelete(&request
->node
, &request_list
);
290 rb_free(request
->name
);
295 * make_request - Create a DNS request record for the server.
297 static struct reslist
*make_request(struct DNSQuery
*query
)
299 struct reslist
*request
= rb_malloc(sizeof(struct reslist
));
301 request
->sentat
= rb_current_time();
302 request
->retries
= 3;
303 request
->timeout
= 4; /* start at 4 and exponential inc. */
304 request
->query
= query
;
307 * generate a unique id
308 * NOTE: we don't have to worry about converting this to and from
309 * network byte order, the nameserver does not interpret this value
310 * and returns it unchanged
312 * we generate an id per request now (instead of per send) to allow
313 * late replies to be used.
318 request
->id
= (request
->id
+ lrand48()) & 0xffff;
319 } while (find_id(request
->id
));
323 gettimeofday(&tv
, NULL
);
326 request
->id
= (request
->id
+ k
+ tv
.tv_usec
) & 0xffff;
328 } while (find_id(request
->id
));
329 #endif /* HAVE_LRAND48 */
331 rb_dlinkAdd(request
, &request
->node
, &request_list
);
337 * delete_resolver_queries - cleanup outstanding queries
338 * for which there no longer exist clients or conf lines.
340 void delete_resolver_queries(const struct DNSQuery
*query
)
343 rb_dlink_node
*next_ptr
;
344 struct reslist
*request
;
346 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, request_list
.head
)
348 if ((request
= ptr
->data
) != NULL
)
350 if (query
== request
->query
)
351 rem_request(request
);
357 * retryfreq - determine how many queries to wait before resending
358 * if there have been that many consecutive timeouts
360 static int retryfreq(int timeouts
)
378 * send_res_msg - sends msg to a nameserver.
379 * This should reflect /etc/resolv.conf.
380 * Returns number of nameserver successfully sent to
381 * or -1 if no successful sends.
383 static int send_res_msg(const char *msg
, int len
, int rcount
)
390 /* First try a nameserver that seems to work.
391 * Every once in a while, try a possibly broken one to check
392 * if it is working again.
394 for (i
= 0; i
< irc_nscount
; i
++)
396 ns
= (i
+ rcount
- 1) % irc_nscount
;
397 if (ns_failure_count
[ns
] && retrycnt
% retryfreq(ns_failure_count
[ns
]))
399 if (sendto(rb_get_fd(res_fd
), msg
, len
, 0,
400 (struct sockaddr
*)&(irc_nsaddr_list
[ns
]),
401 GET_SS_LEN(&irc_nsaddr_list
[ns
])) == len
)
405 /* No known working nameservers, try some broken one. */
406 for (i
= 0; i
< irc_nscount
; i
++)
408 ns
= (i
+ rcount
- 1) % irc_nscount
;
409 if (!ns_failure_count
[ns
])
411 if (sendto(rb_get_fd(res_fd
), msg
, len
, 0,
412 (struct sockaddr
*)&(irc_nsaddr_list
[ns
]),
413 GET_SS_LEN(&irc_nsaddr_list
[ns
])) == len
)
421 * find_id - find a dns request id (id is determined by dn_mkquery)
423 static struct reslist
*find_id(int id
)
426 struct reslist
*request
;
428 RB_DLINK_FOREACH(ptr
, request_list
.head
)
432 if (request
->id
== id
)
440 * gethost_byname_type - get host address from name, adding domain if needed
442 void gethost_byname_type(const char *name
, struct DNSQuery
*query
, int type
)
444 char fqdn
[IRCD_RES_HOSTLEN
+ 1];
447 rb_strlcpy(fqdn
, name
, sizeof fqdn
);
448 add_local_domain(fqdn
, IRCD_RES_HOSTLEN
);
449 gethost_byname_type_fqdn(fqdn
, query
, type
);
453 * gethost_byname_type_fqdn - get host address from fqdn
455 static void gethost_byname_type_fqdn(const char *name
, struct DNSQuery
*query
,
459 do_query_name(query
, name
, NULL
, type
);
463 * gethost_byaddr - get host name from address
465 void gethost_byaddr(const struct rb_sockaddr_storage
*addr
, struct DNSQuery
*query
)
467 do_query_number(query
, addr
, NULL
);
471 * do_query_name - nameserver lookup name
473 static void do_query_name(struct DNSQuery
*query
, const char *name
, struct reslist
*request
,
478 request
= make_request(query
);
479 request
->name
= rb_strdup(name
);
482 rb_strlcpy(request
->queryname
, name
, sizeof(request
->queryname
));
483 request
->type
= type
;
488 * do_query_number - Use this to do reverse IP# lookups.
490 static void do_query_number(struct DNSQuery
*query
, const struct rb_sockaddr_storage
*addr
,
491 struct reslist
*request
)
493 const unsigned char *cp
;
497 request
= make_request(query
);
498 memcpy(&request
->addr
, addr
, sizeof(struct rb_sockaddr_storage
));
499 request
->name
= (char *)rb_malloc(IRCD_RES_HOSTLEN
+ 1);
502 if (addr
->ss_family
== AF_INET
)
504 const struct sockaddr_in
*v4
= (const struct sockaddr_in
*)addr
;
505 cp
= (const unsigned char *)&v4
->sin_addr
.s_addr
;
507 rb_sprintf(request
->queryname
, "%u.%u.%u.%u.in-addr.arpa", (unsigned int)(cp
[3]),
508 (unsigned int)(cp
[2]), (unsigned int)(cp
[1]), (unsigned int)(cp
[0]));
511 else if (addr
->ss_family
== AF_INET6
)
513 const struct sockaddr_in6
*v6
= (const struct sockaddr_in6
*)addr
;
514 cp
= (const unsigned char *)&v6
->sin6_addr
.s6_addr
;
516 (void)sprintf(request
->queryname
, "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x."
517 "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa",
518 (unsigned int)(cp
[15] & 0xf), (unsigned int)(cp
[15] >> 4),
519 (unsigned int)(cp
[14] & 0xf), (unsigned int)(cp
[14] >> 4),
520 (unsigned int)(cp
[13] & 0xf), (unsigned int)(cp
[13] >> 4),
521 (unsigned int)(cp
[12] & 0xf), (unsigned int)(cp
[12] >> 4),
522 (unsigned int)(cp
[11] & 0xf), (unsigned int)(cp
[11] >> 4),
523 (unsigned int)(cp
[10] & 0xf), (unsigned int)(cp
[10] >> 4),
524 (unsigned int)(cp
[9] & 0xf), (unsigned int)(cp
[9] >> 4),
525 (unsigned int)(cp
[8] & 0xf), (unsigned int)(cp
[8] >> 4),
526 (unsigned int)(cp
[7] & 0xf), (unsigned int)(cp
[7] >> 4),
527 (unsigned int)(cp
[6] & 0xf), (unsigned int)(cp
[6] >> 4),
528 (unsigned int)(cp
[5] & 0xf), (unsigned int)(cp
[5] >> 4),
529 (unsigned int)(cp
[4] & 0xf), (unsigned int)(cp
[4] >> 4),
530 (unsigned int)(cp
[3] & 0xf), (unsigned int)(cp
[3] >> 4),
531 (unsigned int)(cp
[2] & 0xf), (unsigned int)(cp
[2] >> 4),
532 (unsigned int)(cp
[1] & 0xf), (unsigned int)(cp
[1] >> 4),
533 (unsigned int)(cp
[0] & 0xf), (unsigned int)(cp
[0] >> 4));
537 request
->type
= T_PTR
;
542 * query_name - generate a query based on class, type and name.
544 static void query_name(struct reslist
*request
)
550 memset(buf
, 0, sizeof(buf
));
553 irc_res_mkquery(request
->queryname
, C_IN
, request
->type
, (unsigned char *)buf
, sizeof(buf
))) > 0)
555 HEADER
*header
= (HEADER
*)(void *)buf
;
556 header
->id
= request
->id
;
559 ns
= send_res_msg(buf
, request_len
, request
->sends
);
561 request
->lastns
= ns
;
565 static void resend_query(struct reslist
*request
)
567 if (--request
->retries
<= 0)
569 (*request
->query
->callback
) (request
->query
->ptr
, NULL
);
570 rem_request(request
);
574 switch (request
->type
)
577 do_query_number(NULL
, &request
->addr
, request
);
583 do_query_name(NULL
, request
->name
, request
, request
->type
);
591 * check_question - check if the reply really belongs to the
592 * name we queried (to guard against late replies from previous
593 * queries with the same id).
595 static int check_question(struct reslist
*request
, HEADER
* header
, char *buf
, char *eob
)
597 char hostbuf
[IRCD_RES_HOSTLEN
+ 1]; /* working buffer */
598 unsigned char *current
; /* current position in buf */
599 int n
; /* temp count */
601 current
= (unsigned char *)buf
+ sizeof(HEADER
);
602 if (header
->qdcount
!= 1)
604 n
= irc_dn_expand((unsigned char *)buf
, (unsigned char *)eob
, current
, hostbuf
,
608 if (strcasecmp(hostbuf
, request
->queryname
))
614 * proc_answer - process name server reply
616 static int proc_answer(struct reslist
*request
, HEADER
* header
, char *buf
, char *eob
)
618 char hostbuf
[IRCD_RES_HOSTLEN
+ 100]; /* working buffer */
619 unsigned char *current
; /* current position in buf */
620 int type
; /* answer type */
621 int n
; /* temp count */
623 struct sockaddr_in
*v4
; /* conversion */
625 struct sockaddr_in6
*v6
;
627 current
= (unsigned char *)buf
+ sizeof(HEADER
);
629 for (; header
->qdcount
> 0; --header
->qdcount
)
631 if ((n
= irc_dn_skipname(current
, (unsigned char *)eob
)) < 0)
634 current
+= (size_t) n
+ QFIXEDSZ
;
638 * process each answer sent to us blech.
640 while (header
->ancount
> 0 && (char *)current
< eob
)
644 n
= irc_dn_expand((unsigned char *)buf
, (unsigned char *)eob
, current
, hostbuf
,
657 * no more answers left
662 hostbuf
[IRCD_RES_HOSTLEN
] = '\0';
664 /* With Address arithmetic you have to be very anal
665 * this code was not working on alpha due to that
666 * (spotted by rodder/jailbird/dianora)
668 current
+= (size_t) n
;
670 if (!(((char *)current
+ ANSWER_FIXED_SIZE
) < eob
))
673 type
= irc_ns_get16(current
);
674 current
+= TYPE_SIZE
;
676 (void) irc_ns_get16(current
);
677 current
+= CLASS_SIZE
;
679 request
->ttl
= irc_ns_get32(current
);
682 rd_length
= irc_ns_get16(current
);
683 current
+= RDLENGTH_SIZE
;
686 * Wait to set request->type until we verify this structure
691 if (request
->type
!= T_A
)
695 * check for invalid rd_length or too many addresses
697 if (rd_length
!= sizeof(struct in_addr
))
699 v4
= (struct sockaddr_in
*)&request
->addr
;
700 SET_SS_LEN(&request
->addr
, sizeof(struct sockaddr_in
));
701 v4
->sin_family
= AF_INET
;
702 memcpy(&v4
->sin_addr
, current
, sizeof(struct in_addr
));
707 if (request
->type
!= T_AAAA
)
709 if (rd_length
!= sizeof(struct in6_addr
))
711 SET_SS_LEN(&request
->addr
, sizeof(struct sockaddr_in6
));
712 v6
= (struct sockaddr_in6
*)&request
->addr
;
713 v6
->sin6_family
= AF_INET6
;
714 memcpy(&v6
->sin6_addr
, current
, sizeof(struct in6_addr
));
719 if (request
->type
!= T_PTR
)
721 n
= irc_dn_expand((unsigned char *)buf
, (unsigned char *)eob
, current
,
722 hostbuf
, sizeof(hostbuf
));
724 return (0); /* broken message */
726 return (0); /* no more answers left */
728 rb_strlcpy(request
->name
, hostbuf
, IRCD_RES_HOSTLEN
+ 1);
733 /* real answer will follow */
734 current
+= rd_length
;
738 /* XXX I'd rather just throw away the entire bogus thing
739 * but its possible its just a broken nameserver with still
740 * valid answers. But lets do some rudimentary logging for now...
742 ilog(L_MAIN
, "irc_res.c bogus type %d", type
);
751 * res_read_single_reply - read a dns reply from the nameserver and process it.
752 * Return value: 1 if a packet was read, 0 otherwise
754 static int res_read_single_reply(rb_fde_t
*F
, void *data
)
756 char buf
[sizeof(HEADER
) + MAXPACKET
]
757 /* Sparc and alpha need 16bit-alignment for accessing header->id
758 * (which is uint16_t). Because of the header = (HEADER*) buf;
759 * lateron, this is neeeded. --FaUl
761 #if defined(__sparc__) || defined(__alpha__)
762 __attribute__ ((aligned(16)))
766 struct reslist
*request
= NULL
;
767 struct DNSReply
*reply
= NULL
;
770 socklen_t len
= sizeof(struct rb_sockaddr_storage
);
771 struct rb_sockaddr_storage lsin
;
774 rc
= recvfrom(rb_get_fd(F
), buf
, sizeof(buf
), 0, (struct sockaddr
*)&lsin
, &len
);
777 if (rc
== 0 || rc
== -1)
781 if (rc
<= (int)(sizeof(HEADER
)))
785 * convert DNS reply reader from Network byte order to CPU byte order.
787 header
= (HEADER
*)(void *)buf
;
788 header
->ancount
= ntohs(header
->ancount
);
789 header
->qdcount
= ntohs(header
->qdcount
);
790 header
->nscount
= ntohs(header
->nscount
);
791 header
->arcount
= ntohs(header
->arcount
);
794 * response for an id which we have already received an answer for
795 * just ignore this response.
797 if (0 == (request
= find_id(header
->id
)))
801 * check against possibly fake replies
803 ns
= res_ourserver(&lsin
);
807 if (ns
!= request
->lastns
)
810 * We'll accept the late reply, but penalize it a little more to make
811 * sure a laggy server doesn't end up favored.
813 ns_failure_count
[ns
] += 3;
817 if (!check_question(request
, header
, buf
, buf
+ rc
))
820 if ((header
->rcode
!= NO_ERRORS
) || (header
->ancount
== 0))
823 * RFC 2136 states that in the event of a server returning SERVFAIL
824 * or NOTIMP, the request should be resent to the next server.
825 * Additionally, if the server refuses our query, resend it as well.
828 if (SERVFAIL
== header
->rcode
|| NOTIMP
== header
->rcode
||
829 REFUSED
== header
->rcode
)
831 ns_failure_count
[ns
]++;
832 resend_query(request
);
837 * Either a fatal error was returned or no answer. Cancel the
840 if (NXDOMAIN
== header
->rcode
)
842 /* If the rcode is NXDOMAIN, treat it as a good response. */
843 ns_failure_count
[ns
] /= 4;
845 (*request
->query
->callback
) (request
->query
->ptr
, NULL
);
846 rem_request(request
);
851 * If this fails there was an error decoding the received packet.
854 answer_count
= proc_answer(request
, header
, buf
, buf
+ rc
);
858 if (request
->type
== T_PTR
)
860 if (request
->name
== NULL
)
863 * Got a PTR response with no name, something strange is
864 * happening. Try another DNS server.
866 ns_failure_count
[ns
]++;
867 resend_query(request
);
872 * Lookup the 'authoritative' name that we were given for the
876 if (request
->addr
.ss_family
== AF_INET6
)
877 gethost_byname_type_fqdn(request
->name
, request
->query
, T_AAAA
);
880 gethost_byname_type_fqdn(request
->name
, request
->query
, T_A
);
881 rem_request(request
);
886 * got a name and address response, client resolved
888 reply
= make_dnsreply(request
);
889 (*request
->query
->callback
) (request
->query
->ptr
, reply
);
891 rem_request(request
);
894 ns_failure_count
[ns
] /= 4;
898 /* Invalid or corrupt reply - try another resolver. */
899 ns_failure_count
[ns
]++;
900 resend_query(request
);
905 static void res_readreply(rb_fde_t
*F
, void *data
)
907 while (res_read_single_reply(F
, data
))
909 rb_setselect(F
, RB_SELECT_READ
, res_readreply
, NULL
);
912 static struct DNSReply
*make_dnsreply(struct reslist
*request
)
915 s_assert(request
!= 0);
917 cp
= (struct DNSReply
*)rb_malloc(sizeof(struct DNSReply
));
919 cp
->h_name
= request
->name
;
920 memcpy(&cp
->addr
, &request
->addr
, sizeof(cp
->addr
));
924 void report_dns_servers(struct Client
*source_p
)
929 for (i
= 0; i
< irc_nscount
; i
++)
931 if (!rb_inet_ntop_sock((struct sockaddr
*)&(irc_nsaddr_list
[i
]),
932 ipaddr
, sizeof ipaddr
))
933 rb_strlcpy(ipaddr
, "?", sizeof ipaddr
);
934 sendto_one_numeric(source_p
, RPL_STATSDEBUG
,
935 "A %s %d", ipaddr
, ns_failure_count
[i
]);