Ruby  2.5.0dev(2017-10-22revision60238)
getaddrinfo.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the project nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  */
29 
30 /*
31  * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
32  *
33  * Issues to be discussed:
34  * - Thread safe-ness must be checked.
35  * - Return values. There are nonstandard return values defined and used
36  * in the source code. This is because RFC2133 is silent about which error
37  * code must be returned for which situation.
38  * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag.
39  */
40 
41 #include "ruby/config.h"
42 #ifdef RUBY_EXTCONF_H
43 #include RUBY_EXTCONF_H
44 #endif
45 #include <sys/types.h>
46 #ifndef _WIN32
47 #include <sys/param.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #if defined(HAVE_ARPA_INET_H)
51 #include <arpa/inet.h>
52 #endif
53 #if defined(HAVE_ARPA_NAMESER_H)
54 #include <arpa/nameser.h>
55 #endif
56 #include <netdb.h>
57 #if defined(HAVE_RESOLV_H)
58 #ifdef _SX
59 #include <stdio.h>
60 #endif
61 #include <resolv.h>
62 #endif
63 #include <unistd.h>
64 #else
65 #if defined(_MSC_VER) && _MSC_VER <= 1200
66 #include <windows.h>
67 #endif
68 #include <winsock2.h>
69 #include <ws2tcpip.h>
70 #include <io.h>
71 #endif
72 #include <string.h>
73 #include <stdio.h>
74 #include <stdlib.h>
75 #include <stddef.h>
76 #include <ctype.h>
77 
78 #ifdef SOCKS5
79 #include <socks.h>
80 #endif
81 
82 #ifndef HAVE_TYPE_SOCKLEN_T
83 typedef int socklen_t;
84 #endif
85 
86 #include "addrinfo.h"
87 #include "sockport.h"
88 
89 #define SUCCESS 0
90 #define ANY 0
91 #define YES 1
92 #define NO 0
93 
94 #ifdef FAITH
95 static int translate = NO;
96 static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
97 #endif
98 
99 static const char in_addrany[] = { 0, 0, 0, 0 };
100 static const char in6_addrany[] = {
101  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
102 };
103 static const char in_loopback[] = { 127, 0, 0, 1 };
104 static const char in6_loopback[] = {
105  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
106 };
107 
108 struct sockinet {
109  u_char si_len;
110  u_char si_family;
112 };
113 
114 static const struct afd {
115  int a_af;
116  int a_addrlen;
117  int a_socklen;
118  int a_off;
119  const char *a_addrany;
120  const char *a_loopback;
121 } afdl [] = {
122 #ifdef INET6
123 #define N_INET6 0
124  {PF_INET6, sizeof(struct in6_addr),
125  sizeof(struct sockaddr_in6),
126  offsetof(struct sockaddr_in6, sin6_addr),
127  in6_addrany, in6_loopback},
128 #define N_INET 1
129 #else
130 #define N_INET 0
131 #endif
132  {PF_INET, sizeof(struct in_addr),
133  sizeof(struct sockaddr_in),
134  offsetof(struct sockaddr_in, sin_addr),
135  in_addrany, in_loopback},
136  {0, 0, 0, 0, NULL, NULL},
137 };
138 
139 #ifdef INET6
140 #define PTON_MAX 16
141 #else
142 #define PTON_MAX 4
143 #endif
144 
145 static int get_name __P((const char *, const struct afd *,
146  struct addrinfo **, char *, struct addrinfo *,
147  int));
148 static int get_addr __P((const char *, int, struct addrinfo **,
149  struct addrinfo *, int));
150 static int str_isnumber __P((const char *));
151 
152 static const char *const ai_errlist[] = {
153  "success.",
154  "address family for hostname not supported.", /* EAI_ADDRFAMILY */
155  "temporary failure in name resolution.", /* EAI_AGAIN */
156  "invalid value for ai_flags.", /* EAI_BADFLAGS */
157  "non-recoverable failure in name resolution.", /* EAI_FAIL */
158  "ai_family not supported.", /* EAI_FAMILY */
159  "memory allocation failure.", /* EAI_MEMORY */
160  "no address associated with hostname.", /* EAI_NODATA */
161  "hostname nor servname provided, or not known.",/* EAI_NONAME */
162  "servname not supported for ai_socktype.", /* EAI_SERVICE */
163  "ai_socktype not supported.", /* EAI_SOCKTYPE */
164  "system error returned in errno.", /* EAI_SYSTEM */
165  "invalid value for hints.", /* EAI_BADHINTS */
166  "resolved protocol is unknown.", /* EAI_PROTOCOL */
167  "unknown error.", /* EAI_MAX */
168 };
169 
170 #define GET_CANONNAME(ai, str) \
171 if (pai->ai_flags & AI_CANONNAME) {\
172  if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
173  strcpy((ai)->ai_canonname, (str));\
174  } else {\
175  error = EAI_MEMORY;\
176  goto free;\
177  }\
178 }
179 
180 #define GET_AI(ai, afd, addr, port) {\
181  char *p;\
182  if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
183  ((afd)->a_socklen)))\
184  == NULL) {\
185  error = EAI_MEMORY;\
186  goto free;\
187  }\
188  memcpy((ai), pai, sizeof(struct addrinfo));\
189  (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
190  (ai)->ai_family = (afd)->a_af;\
191  (ai)->ai_addrlen = (afd)->a_socklen;\
192  INIT_SOCKADDR((ai)->ai_addr, (afd)->a_af, (afd)->a_socklen);\
193  ((struct sockinet *)(ai)->ai_addr)->si_port = (port);\
194  p = (char *)((ai)->ai_addr);\
195  memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\
196 }
197 
198 #define ERR(err) { error = (err); goto bad; }
199 
200 #ifndef HAVE_GAI_STRERROR
201 #ifdef GAI_STRERROR_CONST
202 const
203 #endif
204 char *
205 gai_strerror(int ecode)
206 {
207  if (ecode < 0 || ecode > EAI_MAX)
208  ecode = EAI_MAX;
209  return (char *)ai_errlist[ecode];
210 }
211 #endif
212 
213 void
215 {
216  struct addrinfo *next;
217 
218  do {
219  next = ai->ai_next;
220  if (ai->ai_canonname)
221  free(ai->ai_canonname);
222  /* no need to free(ai->ai_addr) */
223  free(ai);
224  } while ((ai = next) != NULL);
225 }
226 
227 static int
228 str_isnumber(const char *p)
229 {
230  char *q = (char *)p;
231  while (*q) {
232  if (! isdigit(*q))
233  return NO;
234  q++;
235  }
236  return YES;
237 }
238 
239 #ifndef HAVE_INET_PTON
240 
241 static int
242 inet_pton(int af, const char *hostname, void *pton)
243 {
244  struct in_addr in;
245 
246 #ifdef HAVE_INET_ATON
247  if (!inet_aton(hostname, &in))
248  return 0;
249 #else
250  int d1, d2, d3, d4;
251  char ch;
252 
253  if (sscanf(hostname, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 &&
254  0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 &&
255  0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) {
256  in.s_addr = htonl(
257  ((long) d1 << 24) | ((long) d2 << 16) |
258  ((long) d3 << 8) | ((long) d4 << 0));
259  }
260  else {
261  return 0;
262  }
263 #endif
264  memcpy(pton, &in, sizeof(in));
265  return 1;
266 }
267 #endif
268 
269 int
270 getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
271 {
272  struct addrinfo sentinel;
273  struct addrinfo *top = NULL;
274  struct addrinfo *cur;
275  int i, error = 0;
276  char pton[PTON_MAX];
277  struct addrinfo ai;
278  struct addrinfo *pai;
279  u_short port;
280 
281 #ifdef FAITH
282  static int firsttime = 1;
283 
284  if (firsttime) {
285  /* translator hack */
286  {
287  char *q = getenv("GAI");
288  if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
289  translate = YES;
290  }
291  firsttime = 0;
292  }
293 #endif
294 
295  /* initialize file static vars */
296  sentinel.ai_next = NULL;
297  cur = &sentinel;
298  pai = &ai;
299  pai->ai_flags = 0;
300  pai->ai_family = PF_UNSPEC;
301  pai->ai_socktype = ANY;
302  pai->ai_protocol = ANY;
303  pai->ai_addrlen = 0;
304  pai->ai_canonname = NULL;
305  pai->ai_addr = NULL;
306  pai->ai_next = NULL;
307  port = ANY;
308 
309  if (hostname == NULL && servname == NULL)
310  return EAI_NONAME;
311  if (hints) {
312  /* error check for hints */
313  if (hints->ai_addrlen || hints->ai_canonname ||
314  hints->ai_addr || hints->ai_next)
315  ERR(EAI_BADHINTS); /* xxx */
316  if (hints->ai_flags & ~AI_MASK)
317  ERR(EAI_BADFLAGS);
318  switch (hints->ai_family) {
319  case PF_UNSPEC:
320  case PF_INET:
321 #ifdef INET6
322  case PF_INET6:
323 #endif
324  break;
325  default:
326  ERR(EAI_FAMILY);
327  }
328  memcpy(pai, hints, sizeof(*pai));
329  switch (pai->ai_socktype) {
330  case ANY:
331  switch (pai->ai_protocol) {
332  case ANY:
333  break;
334  case IPPROTO_UDP:
335  pai->ai_socktype = SOCK_DGRAM;
336  break;
337  case IPPROTO_TCP:
338  pai->ai_socktype = SOCK_STREAM;
339  break;
340  default:
341 #if defined(SOCK_RAW)
342  pai->ai_socktype = SOCK_RAW;
343 #endif
344  break;
345  }
346  break;
347 #if defined(SOCK_RAW)
348  case SOCK_RAW:
349  break;
350 #endif
351  case SOCK_DGRAM:
352  if (pai->ai_protocol != IPPROTO_UDP &&
353  pai->ai_protocol != ANY)
354  ERR(EAI_BADHINTS); /*xxx*/
355  pai->ai_protocol = IPPROTO_UDP;
356  break;
357  case SOCK_STREAM:
358  if (pai->ai_protocol != IPPROTO_TCP &&
359  pai->ai_protocol != ANY)
360  ERR(EAI_BADHINTS); /*xxx*/
361  pai->ai_protocol = IPPROTO_TCP;
362  break;
363  default:
364  ERR(EAI_SOCKTYPE);
365  break;
366  }
367  }
368 
369  /*
370  * service port
371  */
372  if (servname) {
373  if (str_isnumber(servname)) {
374  if (pai->ai_socktype == ANY) {
375  /* caller accept *ANY* socktype */
376  pai->ai_socktype = SOCK_DGRAM;
377  pai->ai_protocol = IPPROTO_UDP;
378  }
379  port = htons((unsigned short)atoi(servname));
380  } else if (pai->ai_flags & AI_NUMERICSERV) {
381  ERR(EAI_NONAME);
382  } else {
383  struct servent *sp;
384  const char *proto;
385 
386  proto = NULL;
387  switch (pai->ai_socktype) {
388  case ANY:
389  proto = NULL;
390  break;
391  case SOCK_DGRAM:
392  proto = "udp";
393  break;
394  case SOCK_STREAM:
395  proto = "tcp";
396  break;
397  default:
398  fprintf(stderr, "panic!\n");
399  break;
400  }
401  if ((sp = getservbyname((char*)servname, proto)) == NULL)
402  ERR(EAI_SERVICE);
403  port = sp->s_port;
404  if (pai->ai_socktype == ANY)
405  if (strcmp(sp->s_proto, "udp") == 0) {
406  pai->ai_socktype = SOCK_DGRAM;
407  pai->ai_protocol = IPPROTO_UDP;
408  } else if (strcmp(sp->s_proto, "tcp") == 0) {
409  pai->ai_socktype = SOCK_STREAM;
410  pai->ai_protocol = IPPROTO_TCP;
411  } else
412  ERR(EAI_PROTOCOL); /*xxx*/
413  }
414  }
415 
416  /*
417  * hostname == NULL.
418  * passive socket -> anyaddr (0.0.0.0 or ::)
419  * non-passive socket -> localhost (127.0.0.1 or ::1)
420  */
421  if (hostname == NULL) {
422  const struct afd *afd;
423  int s;
424 
425  for (afd = &afdl[0]; afd->a_af; afd++) {
426  if (!(pai->ai_family == PF_UNSPEC
427  || pai->ai_family == afd->a_af)) {
428  continue;
429  }
430 
431  /*
432  * filter out AFs that are not supported by the kernel
433  * XXX errno?
434  */
435  s = socket(afd->a_af, SOCK_DGRAM, 0);
436  if (s < 0)
437  continue;
438 
439  close(s);
440 
441  if (pai->ai_flags & AI_PASSIVE) {
442  GET_AI(cur->ai_next, afd, afd->a_addrany, port);
443  /* xxx meaningless?
444  * GET_CANONNAME(cur->ai_next, "anyaddr");
445  */
446  } else {
447  GET_AI(cur->ai_next, afd, afd->a_loopback,
448  port);
449  /* xxx meaningless?
450  * GET_CANONNAME(cur->ai_next, "localhost");
451  */
452  }
453  cur = cur->ai_next;
454  }
455  top = sentinel.ai_next;
456  if (top)
457  goto good;
458  else
459  ERR(EAI_FAMILY);
460  }
461 
462  /* hostname as numeric name */
463  for (i = 0; afdl[i].a_af; i++) {
464  if (inet_pton(afdl[i].a_af, hostname, pton)) {
465  u_long v4a;
466 #ifdef INET6
467  u_char pfx;
468 #endif
469 
470  switch (afdl[i].a_af) {
471  case AF_INET:
472  v4a = ((struct in_addr *)pton)->s_addr;
473  if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
474  pai->ai_flags &= ~AI_CANONNAME;
475  v4a >>= IN_CLASSA_NSHIFT;
476  if (v4a == 0 || v4a == IN_LOOPBACKNET)
477  pai->ai_flags &= ~AI_CANONNAME;
478  break;
479 #ifdef INET6
480  case AF_INET6:
481  pfx = ((struct in6_addr *)pton)->s6_addr[0];
482  if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
483  pai->ai_flags &= ~AI_CANONNAME;
484  break;
485 #endif
486  }
487 
488  if (pai->ai_family == afdl[i].a_af ||
489  pai->ai_family == PF_UNSPEC) {
490  if (! (pai->ai_flags & AI_CANONNAME)) {
491  GET_AI(top, &afdl[i], pton, port);
492  goto good;
493  }
494  /*
495  * if AI_CANONNAME and if reverse lookup
496  * fail, return ai anyway to pacify
497  * calling application.
498  *
499  * XXX getaddrinfo() is a name->address
500  * translation function, and it looks strange
501  * that we do addr->name translation here.
502  */
503  get_name(pton, &afdl[i], &top, pton, pai, port);
504  goto good;
505  } else
506  ERR(EAI_FAMILY); /*xxx*/
507  }
508  }
509 
510  if (pai->ai_flags & AI_NUMERICHOST)
511  ERR(EAI_NONAME);
512 
513  /* hostname as alphabetical name */
514  error = get_addr(hostname, pai->ai_family, &top, pai, port);
515  if (error == 0) {
516  if (top) {
517  good:
518  *res = top;
519  return SUCCESS;
520  } else
521  error = EAI_FAIL;
522  }
523  free:
524  if (top)
525  freeaddrinfo(top);
526  bad:
527  *res = NULL;
528  return error;
529 }
530 
531 static int
532 get_name(const char *addr, const struct afd *afd, struct addrinfo **res, char *numaddr, struct addrinfo *pai, int port0)
533 {
534  u_short port = port0 & 0xffff;
535  struct hostent *hp;
536  struct addrinfo *cur;
537  int error = 0;
538 #ifdef INET6
539  int h_error;
540 #endif
541 
542 #ifdef INET6
543  hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
544 #else
545  hp = gethostbyaddr((char*)addr, afd->a_addrlen, AF_INET);
546 #endif
547  if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
548  GET_AI(cur, afd, hp->h_addr_list[0], port);
549  GET_CANONNAME(cur, hp->h_name);
550  } else
551  GET_AI(cur, afd, numaddr, port);
552 
553 #ifdef INET6
554  if (hp)
555  freehostent(hp);
556 #endif
557  *res = cur;
558  return SUCCESS;
559  free:
560  if (cur)
561  freeaddrinfo(cur);
562 #ifdef INET6
563  if (hp)
564  freehostent(hp);
565 #endif
566  /* bad: */
567  *res = NULL;
568  return error;
569 }
570 
571 static int
572 get_addr(const char *hostname, int af, struct addrinfo **res, struct addrinfo *pai, int port0)
573 {
574  u_short port = port0 & 0xffff;
575  struct addrinfo sentinel;
576  struct hostent *hp;
577  struct addrinfo *top, *cur;
578  const struct afd *afd;
579  int i, error = 0, h_error;
580  char *ap;
581 
582  top = NULL;
583  sentinel.ai_next = NULL;
584  cur = &sentinel;
585 #ifdef INET6
586  if (af == AF_UNSPEC) {
587  hp = getipnodebyname(hostname, AF_INET6,
588  AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error);
589  } else
590  hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error);
591 #else
592  if (strlen(hostname) >= NI_MAXHOST) ERR(EAI_NODATA);
593  hp = gethostbyname((char*)hostname);
594  h_error = h_errno;
595 #endif
596  if (hp == NULL) {
597  switch (h_error) {
598  case HOST_NOT_FOUND:
599  case NO_DATA:
600  error = EAI_NODATA;
601  break;
602  case TRY_AGAIN:
603  error = EAI_AGAIN;
604  break;
605  case NO_RECOVERY:
606  default:
607  error = EAI_FAIL;
608  break;
609  }
610  goto bad;
611  }
612 
613  if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||
614  (hp->h_addr_list[0] == NULL))
615  ERR(EAI_FAIL);
616 
617  for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {
618  switch (af) {
619 #ifdef INET6
620  case AF_INET6:
621  afd = &afdl[N_INET6];
622  break;
623 #endif
624 #ifndef INET6
625  default: /* AF_UNSPEC */
626 #endif
627  case AF_INET:
628  afd = &afdl[N_INET];
629  break;
630 #ifdef INET6
631  default: /* AF_UNSPEC */
632  if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
633  ap += sizeof(struct in6_addr) -
634  sizeof(struct in_addr);
635  afd = &afdl[N_INET];
636  } else
637  afd = &afdl[N_INET6];
638  break;
639 #endif
640  }
641 #ifdef FAITH
642  if (translate && afd->a_af == AF_INET) {
643  struct in6_addr *in6;
644 
645  GET_AI(cur->ai_next, &afdl[N_INET6], ap, port);
646  in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr;
647  memcpy(&in6->s6_addr, &faith_prefix,
648  sizeof(struct in6_addr) - sizeof(struct in_addr));
649  memcpy(&in6->s6_addr + sizeof(struct in_addr), ap,
650  sizeof(struct in_addr));
651  } else
652 #endif /* FAITH */
653  GET_AI(cur->ai_next, afd, ap, port);
654  if (cur == &sentinel) {
655  top = cur->ai_next;
656  GET_CANONNAME(top, hp->h_name);
657  }
658  cur = cur->ai_next;
659  }
660 #ifdef INET6
661  freehostent(hp);
662 #endif
663  *res = top;
664  return SUCCESS;
665  free:
666  if (top)
667  freeaddrinfo(top);
668 #ifdef INET6
669  if (hp)
670  freehostent(hp);
671 #endif
672  bad:
673  *res = NULL;
674  return error;
675 }
#define EAI_MAX
Definition: addrinfo.h:91
#define IPPROTO_UDP
Definition: constdefs.h:627
size_t strlen(const char *)
#define PF_INET
Definition: sockport.h:109
u_char si_family
Definition: getaddrinfo.c:110
#define EAI_BADFLAGS
Definition: addrinfo.h:80
#define d1
#define GET_CANONNAME(ai, str)
Definition: getaddrinfo.c:170
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
Definition: zonetab.h:883
#define freehostent
Definition: addrinfo.h:153
#define AI_PASSIVE
Definition: addrinfo.h:96
#define AI_CANONNAME
Definition: addrinfo.h:97
#define __P(args)
Definition: addrinfo.h:68
#define EAI_PROTOCOL
Definition: addrinfo.h:90
#define EAI_AGAIN
Definition: addrinfo.h:79
#define EAI_FAMILY
Definition: addrinfo.h:82
#define GET_AI(ai, afd, addr, port)
Definition: getaddrinfo.c:180
#define YES
Definition: getaddrinfo.c:91
#define IPPROTO_TCP
Definition: constdefs.h:610
char * ai_canonname
Definition: addrinfo.h:137
#define IN_CLASSA_NSHIFT
Definition: sockport.h:93
int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
Definition: getaddrinfo.c:270
#define u_short
Definition: vsnprintf.c:65
#define EAI_SOCKTYPE
Definition: addrinfo.h:87
#define SUCCESS
Definition: getaddrinfo.c:89
char * gai_strerror(int ecode)
Definition: getaddrinfo.c:205
#define N_INET
#define AI_ADDRCONFIG
Definition: addrinfo.h:108
int socklen_t
Definition: getaddrinfo.c:83
#define AI_V4MAPPED
Definition: addrinfo.h:109
void freeaddrinfo(struct addrinfo *ai)
Definition: getaddrinfo.c:214
#define PTON_MAX
Definition: getaddrinfo.c:142
#define EAI_BADHINTS
Definition: addrinfo.h:89
#define AI_NUMERICHOST
Definition: addrinfo.h:98
#define bad(x)
Definition: _sdbm.c:124
#define AI_ALL
Definition: addrinfo.h:106
int ai_protocol
Definition: addrinfo.h:135
#define getenv(name)
Definition: win32.c:71
unsigned int top
Definition: nkf.c:4310
#define AI_NUMERICSERV
Definition: addrinfo.h:99
#define EAI_FAIL
Definition: addrinfo.h:81
#define PF_UNSPEC
Definition: sockport.h:105
int ai_socktype
Definition: addrinfo.h:134
#define proto(p)
Definition: sdbm.h:60
#define EAI_SERVICE
Definition: addrinfo.h:86
u_char si_len
Definition: getaddrinfo.c:109
#define AF_UNSPEC
Definition: sockport.h:101
#define IN_EXPERIMENTAL(i)
Definition: sockport.h:89
struct addrinfo * ai_next
Definition: addrinfo.h:139
#define AI_MASK
Definition: addrinfo.h:103
#define NO
Definition: getaddrinfo.c:92
#define u_long
Definition: vsnprintf.c:64
u_short si_port
Definition: getaddrinfo.c:111
#define EAI_NONAME
Definition: addrinfo.h:85
#define ERR(err)
Definition: getaddrinfo.c:198
#define IN_LOOPBACKNET
Definition: sockport.h:97
size_t ai_addrlen
Definition: addrinfo.h:136
int ai_flags
Definition: addrinfo.h:132
#define EAI_NODATA
Definition: addrinfo.h:84
#define ANY
Definition: getaddrinfo.c:90
#define NULL
Definition: _sdbm.c:102
#define NI_MAXHOST
Definition: addrinfo.h:117
free(psz)
struct sockaddr * ai_addr
Definition: addrinfo.h:138
#define IN_MULTICAST(i)
Definition: sockport.h:85
int ai_family
Definition: addrinfo.h:133