Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

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;
111 u_short si_port;
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 #ifndef HAVE_GAI_STRERROR
153 static const char *const ai_errlist[] = {
154 "success.",
155 "address family for hostname not supported.", /* EAI_ADDRFAMILY */
156 "temporary failure in name resolution.", /* EAI_AGAIN */
157 "invalid value for ai_flags.", /* EAI_BADFLAGS */
158 "non-recoverable failure in name resolution.", /* EAI_FAIL */
159 "ai_family not supported.", /* EAI_FAMILY */
160 "memory allocation failure.", /* EAI_MEMORY */
161 "no address associated with hostname.", /* EAI_NODATA */
162 "hostname nor servname provided, or not known.",/* EAI_NONAME */
163 "servname not supported for ai_socktype.", /* EAI_SERVICE */
164 "ai_socktype not supported.", /* EAI_SOCKTYPE */
165 "system error returned in errno.", /* EAI_SYSTEM */
166 "invalid value for hints.", /* EAI_BADHINTS */
167 "resolved protocol is unknown.", /* EAI_PROTOCOL */
168 "unknown error.", /* EAI_MAX */
169 };
170 #endif
171
172 #define GET_CANONNAME(ai, str) \
173 if (pai->ai_flags & AI_CANONNAME) {\
174 if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
175 strcpy((ai)->ai_canonname, (str));\
176 } else {\
177 error = EAI_MEMORY;\
178 goto free;\
179 }\
180 }
181
182 #define GET_AI(ai, afd, addr, port) {\
183 char *p;\
184 if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
185 ((afd)->a_socklen)))\
186 == NULL) {\
187 error = EAI_MEMORY;\
188 goto free;\
189 }\
190 memcpy((ai), pai, sizeof(struct addrinfo));\
191 (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
192 (ai)->ai_family = (afd)->a_af;\
193 (ai)->ai_addrlen = (afd)->a_socklen;\
194 INIT_SOCKADDR((ai)->ai_addr, (afd)->a_af, (afd)->a_socklen);\
195 ((struct sockinet *)(ai)->ai_addr)->si_port = (port);\
196 p = (char *)((ai)->ai_addr);\
197 memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\
198 }
199
200 #define ERR(err) { error = (err); goto bad; }
201
202 #ifndef HAVE_GAI_STRERROR
203 #ifdef GAI_STRERROR_CONST
204 const
205 #endif
206 char *
207 gai_strerror(int ecode)
208 {
209 if (ecode < 0 || ecode > EAI_MAX)
210 ecode = EAI_MAX;
211 return (char *)ai_errlist[ecode];
212 }
213 #endif
214
215 void
216 freeaddrinfo(struct addrinfo *ai)
217 {
218 struct addrinfo *next;
219
220 do {
221 next = ai->ai_next;
222 if (ai->ai_canonname)
223 free(ai->ai_canonname);
224 /* no need to free(ai->ai_addr) */
225 free(ai);
226 } while ((ai = next) != NULL);
227 }
228
229 static int
230 str_isnumber(const char *p)
231 {
232 char *q = (char *)p;
233 while (*q) {
234 if (! isdigit(*q))
235 return NO;
236 q++;
237 }
238 return YES;
239 }
240
241 #ifndef HAVE_INET_PTON
242
243 static int
244 inet_pton(int af, const char *hostname, void *pton)
245 {
246 struct in_addr in;
247
248 #ifdef HAVE_INET_ATON
249 if (!inet_aton(hostname, &in))
250 return 0;
251 #else
252 int d1, d2, d3, d4;
253 char ch;
254
255 if (sscanf(hostname, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 &&
256 0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 &&
257 0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) {
258 in.s_addr = htonl(
259 ((long) d1 << 24) | ((long) d2 << 16) |
260 ((long) d3 << 8) | ((long) d4 << 0));
261 }
262 else {
263 return 0;
264 }
265 #endif
266 memcpy(pton, &in, sizeof(in));
267 return 1;
268 }
269 #endif
270
271 int
272 getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
273 {
274 struct addrinfo sentinel;
275 struct addrinfo *top = NULL;
276 struct addrinfo *cur;
277 int i, error = 0;
278 char pton[PTON_MAX];
279 struct addrinfo ai;
280 struct addrinfo *pai;
281 u_short port;
282
283 #ifdef FAITH
284 static int firsttime = 1;
285
286 if (firsttime) {
287 /* translator hack */
288 {
289 char *q = getenv("GAI");
290 if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
291 translate = YES;
292 }
293 firsttime = 0;
294 }
295 #endif
296
297 /* initialize file static vars */
298 sentinel.ai_next = NULL;
299 cur = &sentinel;
300 pai = &ai;
301 pai->ai_flags = 0;
302 pai->ai_family = PF_UNSPEC;
303 pai->ai_socktype = ANY;
304 pai->ai_protocol = ANY;
305 pai->ai_addrlen = 0;
306 pai->ai_canonname = NULL;
307 pai->ai_addr = NULL;
308 pai->ai_next = NULL;
309 port = ANY;
310
311 if (hostname == NULL && servname == NULL)
312 return EAI_NONAME;
313 if (hints) {
314 /* error check for hints */
315 if (hints->ai_addrlen || hints->ai_canonname ||
316 hints->ai_addr || hints->ai_next)
317 ERR(EAI_BADHINTS); /* xxx */
318 if (hints->ai_flags & ~AI_MASK)
319 ERR(EAI_BADFLAGS);
320 switch (hints->ai_family) {
321 case PF_UNSPEC:
322 case PF_INET:
323 #ifdef INET6
324 case PF_INET6:
325 #endif
326 break;
327 default:
328 ERR(EAI_FAMILY);
329 }
330 memcpy(pai, hints, sizeof(*pai));
331 switch (pai->ai_socktype) {
332 case ANY:
333 switch (pai->ai_protocol) {
334 case ANY:
335 break;
336 case IPPROTO_UDP:
337 pai->ai_socktype = SOCK_DGRAM;
338 break;
339 case IPPROTO_TCP:
340 pai->ai_socktype = SOCK_STREAM;
341 break;
342 default:
343 #if defined(SOCK_RAW)
344 pai->ai_socktype = SOCK_RAW;
345 #endif
346 break;
347 }
348 break;
349 #if defined(SOCK_RAW)
350 case SOCK_RAW:
351 break;
352 #endif
353 case SOCK_DGRAM:
354 if (pai->ai_protocol != IPPROTO_UDP &&
355 pai->ai_protocol != ANY)
356 ERR(EAI_BADHINTS); /*xxx*/
357 pai->ai_protocol = IPPROTO_UDP;
358 break;
359 case SOCK_STREAM:
360 if (pai->ai_protocol != IPPROTO_TCP &&
361 pai->ai_protocol != ANY)
362 ERR(EAI_BADHINTS); /*xxx*/
363 pai->ai_protocol = IPPROTO_TCP;
364 break;
365 default:
366 ERR(EAI_SOCKTYPE);
367 break;
368 }
369 }
370
371 /*
372 * service port
373 */
374 if (servname) {
375 if (str_isnumber(servname)) {
376 if (pai->ai_socktype == ANY) {
377 /* caller accept *ANY* socktype */
378 pai->ai_socktype = SOCK_DGRAM;
379 pai->ai_protocol = IPPROTO_UDP;
380 }
381 port = htons((unsigned short)atoi(servname));
382 } else if (pai->ai_flags & AI_NUMERICSERV) {
383 ERR(EAI_NONAME);
384 } else {
385 struct servent *sp;
386 const char *proto;
387
388 proto = NULL;
389 switch (pai->ai_socktype) {
390 case ANY:
391 proto = NULL;
392 break;
393 case SOCK_DGRAM:
394 proto = "udp";
395 break;
396 case SOCK_STREAM:
397 proto = "tcp";
398 break;
399 default:
400 fprintf(stderr, "panic!\n");
401 break;
402 }
403 if ((sp = getservbyname((char*)servname, proto)) == NULL)
404 ERR(EAI_SERVICE);
405 port = sp->s_port;
406 if (pai->ai_socktype == ANY)
407 if (strcmp(sp->s_proto, "udp") == 0) {
408 pai->ai_socktype = SOCK_DGRAM;
409 pai->ai_protocol = IPPROTO_UDP;
410 } else if (strcmp(sp->s_proto, "tcp") == 0) {
411 pai->ai_socktype = SOCK_STREAM;
412 pai->ai_protocol = IPPROTO_TCP;
413 } else
414 ERR(EAI_PROTOCOL); /*xxx*/
415 }
416 }
417
418 /*
419 * hostname == NULL.
420 * passive socket -> anyaddr (0.0.0.0 or ::)
421 * non-passive socket -> localhost (127.0.0.1 or ::1)
422 */
423 if (hostname == NULL) {
424 const struct afd *afd;
425 int s;
426
427 for (afd = &afdl[0]; afd->a_af; afd++) {
428 if (!(pai->ai_family == PF_UNSPEC
429 || pai->ai_family == afd->a_af)) {
430 continue;
431 }
432
433 /*
434 * filter out AFs that are not supported by the kernel
435 * XXX errno?
436 */
437 s = socket(afd->a_af, SOCK_DGRAM, 0);
438 if (s < 0)
439 continue;
440
441 close(s);
442
443 if (pai->ai_flags & AI_PASSIVE) {
444 GET_AI(cur->ai_next, afd, afd->a_addrany, port);
445 /* xxx meaningless?
446 * GET_CANONNAME(cur->ai_next, "anyaddr");
447 */
448 } else {
449 GET_AI(cur->ai_next, afd, afd->a_loopback,
450 port);
451 /* xxx meaningless?
452 * GET_CANONNAME(cur->ai_next, "localhost");
453 */
454 }
455 cur = cur->ai_next;
456 }
457 top = sentinel.ai_next;
458 if (top)
459 goto good;
460 else
461 ERR(EAI_FAMILY);
462 }
463
464 /* hostname as numeric name */
465 for (i = 0; afdl[i].a_af; i++) {
466 if (inet_pton(afdl[i].a_af, hostname, pton)) {
467 u_long v4a;
468 #ifdef INET6
469 u_char pfx;
470 #endif
471
472 switch (afdl[i].a_af) {
473 case AF_INET:
474 v4a = ((struct in_addr *)pton)->s_addr;
475 if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
476 pai->ai_flags &= ~AI_CANONNAME;
477 v4a >>= IN_CLASSA_NSHIFT;
478 if (v4a == 0 || v4a == IN_LOOPBACKNET)
479 pai->ai_flags &= ~AI_CANONNAME;
480 break;
481 #ifdef INET6
482 case AF_INET6:
483 pfx = ((struct in6_addr *)pton)->s6_addr[0];
484 if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
485 pai->ai_flags &= ~AI_CANONNAME;
486 break;
487 #endif
488 }
489
490 if (pai->ai_family == afdl[i].a_af ||
491 pai->ai_family == PF_UNSPEC) {
492 if (! (pai->ai_flags & AI_CANONNAME)) {
493 GET_AI(top, &afdl[i], pton, port);
494 goto good;
495 }
496 /*
497 * if AI_CANONNAME and if reverse lookup
498 * fail, return ai anyway to pacify
499 * calling application.
500 *
501 * XXX getaddrinfo() is a name->address
502 * translation function, and it looks strange
503 * that we do addr->name translation here.
504 */
505 get_name(pton, &afdl[i], &top, pton, pai, port);
506 goto good;
507 } else
508 ERR(EAI_FAMILY); /*xxx*/
509 }
510 }
511
512 if (pai->ai_flags & AI_NUMERICHOST)
513 ERR(EAI_NONAME);
514
515 /* hostname as alphabetical name */
516 error = get_addr(hostname, pai->ai_family, &top, pai, port);
517 if (error == 0) {
518 if (top) {
519 good:
520 *res = top;
521 return SUCCESS;
522 } else
523 error = EAI_FAIL;
524 }
525 free:
526 if (top)
527 freeaddrinfo(top);
528 bad:
529 *res = NULL;
530 return error;
531 }
532
533 static int
534 get_name(const char *addr, const struct afd *afd, struct addrinfo **res, char *numaddr, struct addrinfo *pai, int port0)
535 {
536 u_short port = port0 & 0xffff;
537 struct hostent *hp;
538 struct addrinfo *cur;
539 int error = 0;
540 #ifdef INET6
541 int h_error;
542 #endif
543
544 #ifdef INET6
545 hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
546 #else
547 hp = gethostbyaddr((char*)addr, afd->a_addrlen, AF_INET);
548 #endif
549 if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
550 GET_AI(cur, afd, hp->h_addr_list[0], port);
551 GET_CANONNAME(cur, hp->h_name);
552 } else
553 GET_AI(cur, afd, numaddr, port);
554
555 #ifdef INET6
556 if (hp)
557 freehostent(hp);
558 #endif
559 *res = cur;
560 return SUCCESS;
561 free:
562 if (cur)
563 freeaddrinfo(cur);
564 #ifdef INET6
565 if (hp)
566 freehostent(hp);
567 #endif
568 /* bad: */
569 *res = NULL;
570 return error;
571 }
572
573 static int
574 get_addr(const char *hostname, int af, struct addrinfo **res, struct addrinfo *pai, int port0)
575 {
576 u_short port = port0 & 0xffff;
577 struct addrinfo sentinel;
578 struct hostent *hp;
579 struct addrinfo *top, *cur;
580 const struct afd *afd;
581 int i, error = 0, h_error;
582 char *ap;
583
584 top = NULL;
585 sentinel.ai_next = NULL;
586 cur = &sentinel;
587 #ifdef INET6
588 if (af == AF_UNSPEC) {
589 hp = getipnodebyname(hostname, AF_INET6,
590 AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error);
591 } else
592 hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error);
593 #else
594 if (strlen(hostname) >= NI_MAXHOST) ERR(EAI_NODATA);
595 hp = gethostbyname((char*)hostname);
596 h_error = h_errno;
597 #endif
598 if (hp == NULL) {
599 switch (h_error) {
600 case HOST_NOT_FOUND:
601 case NO_DATA:
602 error = EAI_NODATA;
603 break;
604 case TRY_AGAIN:
605 error = EAI_AGAIN;
606 break;
607 case NO_RECOVERY:
608 default:
609 error = EAI_FAIL;
610 break;
611 }
612 goto bad;
613 }
614
615 if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||
616 (hp->h_addr_list[0] == NULL))
617 ERR(EAI_FAIL);
618
619 for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {
620 switch (af) {
621 #ifdef INET6
622 case AF_INET6:
623 afd = &afdl[N_INET6];
624 break;
625 #endif
626 #ifndef INET6
627 default: /* AF_UNSPEC */
628 #endif
629 case AF_INET:
630 afd = &afdl[N_INET];
631 break;
632 #ifdef INET6
633 default: /* AF_UNSPEC */
634 if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
635 ap += sizeof(struct in6_addr) -
636 sizeof(struct in_addr);
637 afd = &afdl[N_INET];
638 } else
639 afd = &afdl[N_INET6];
640 break;
641 #endif
642 }
643 #ifdef FAITH
644 if (translate && afd->a_af == AF_INET) {
645 struct in6_addr *in6;
646
647 GET_AI(cur->ai_next, &afdl[N_INET6], ap, port);
648 in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr;
649 memcpy(&in6->s6_addr, &faith_prefix,
650 sizeof(struct in6_addr) - sizeof(struct in_addr));
651 memcpy(&in6->s6_addr + sizeof(struct in_addr), ap,
652 sizeof(struct in_addr));
653 } else
654 #endif /* FAITH */
655 GET_AI(cur->ai_next, afd, ap, port);
656 if (cur == &sentinel) {
657 top = cur->ai_next;
658 GET_CANONNAME(top, hp->h_name);
659 }
660 cur = cur->ai_next;
661 }
662 #ifdef INET6
663 freehostent(hp);
664 #endif
665 *res = top;
666 return SUCCESS;
667 free:
668 if (top)
669 freeaddrinfo(top);
670 #ifdef INET6
671 if (hp)
672 freehostent(hp);
673 #endif
674 bad:
675 *res = NULL;
676 return error;
677 }
AF_UNSPEC
#define AF_UNSPEC
Definition: sockport.h:101
sockinet::si_port
u_short si_port
Definition: getaddrinfo.c:111
AI_PASSIVE
#define AI_PASSIVE
Definition: addrinfo.h:96
IN_MULTICAST
#define IN_MULTICAST(i)
Definition: sockport.h:85
proto
#define proto(p)
Definition: sdbm.h:60
AI_CANONNAME
#define AI_CANONNAME
Definition: addrinfo.h:97
close
int close(int __fildes)
IPPROTO_UDP
#define IPPROTO_UDP
Definition: constdefs.h:627
freehostent
#define freehostent
Definition: addrinfo.h:153
IPPROTO_TCP
#define IPPROTO_TCP
Definition: constdefs.h:610
GET_AI
#define GET_AI(ai, afd, addr, port)
Definition: getaddrinfo.c:182
IN_LOOPBACKNET
#define IN_LOOPBACKNET
Definition: sockport.h:97
IN_EXPERIMENTAL
#define IN_EXPERIMENTAL(i)
Definition: sockport.h:89
NO
#define NO
Definition: getaddrinfo.c:92
addrinfo::ai_addrlen
size_t ai_addrlen
Definition: addrinfo.h:136
offsetof
#define offsetof(p_type, field)
Definition: addrinfo.h:186
getenv
#define getenv(name)
Definition: win32.c:73
IN_CLASSA_NSHIFT
#define IN_CLASSA_NSHIFT
Definition: sockport.h:93
else
else
Definition: rb_mjit_min_header-2.7.0.h:13246
addrinfo.h
atoi
int atoi(const char *__nptr)
AI_MASK
#define AI_MASK
Definition: addrinfo.h:103
AI_NUMERICHOST
#define AI_NUMERICHOST
Definition: addrinfo.h:98
sockinet
Definition: getaddrinfo.c:108
NULL
#define NULL
Definition: _sdbm.c:101
socklen_t
int socklen_t
Definition: getaddrinfo.c:83
error
const rb_iseq_t const char * error
Definition: rb_mjit_min_header-2.7.0.h:13506
strlen
size_t strlen(const char *)
EAI_SOCKTYPE
#define EAI_SOCKTYPE
Definition: addrinfo.h:87
if
if((ID)(DISPID) nameid !=nameid)
Definition: win32ole.c:357
EAI_AGAIN
#define EAI_AGAIN
Definition: addrinfo.h:79
memcpy
void * memcpy(void *__restrict, const void *__restrict, size_t)
fprintf
int fprintf(FILE *__restrict, const char *__restrict,...) __attribute__((__format__(__printf__
u_long
unsigned long u_long
Definition: rb_mjit_min_header-2.7.0.h:1293
AI_V4MAPPED
#define AI_V4MAPPED
Definition: addrinfo.h:109
i
uint32_t i
Definition: rb_mjit_min_header-2.7.0.h:5464
u_char
unsigned char u_char
Definition: rb_mjit_min_header-2.7.0.h:1287
addrinfo::ai_canonname
char * ai_canonname
Definition: addrinfo.h:137
EAI_NODATA
#define EAI_NODATA
Definition: addrinfo.h:84
addrinfo::ai_addr
struct sockaddr * ai_addr
Definition: addrinfo.h:138
bad
#define bad(x)
Definition: _sdbm.c:123
stderr
#define stderr
Definition: rb_mjit_min_header-2.7.0.h:1485
addrinfo::ai_family
int ai_family
Definition: addrinfo.h:133
AI_NUMERICSERV
#define AI_NUMERICSERV
Definition: addrinfo.h:99
NI_MAXHOST
#define NI_MAXHOST
Definition: addrinfo.h:117
PF_INET
#define PF_INET
Definition: sockport.h:109
addrinfo::ai_protocol
int ai_protocol
Definition: addrinfo.h:135
ANY
#define ANY
Definition: getaddrinfo.c:90
PF_UNSPEC
#define PF_UNSPEC
Definition: sockport.h:105
strcmp
int strcmp(const char *, const char *)
addrinfo::ai_next
struct addrinfo * ai_next
Definition: addrinfo.h:139
EAI_PROTOCOL
#define EAI_PROTOCOL
Definition: addrinfo.h:90
sscanf
int int int int int sscanf(const char *__restrict, const char *__restrict,...) __attribute__((__format__(__scanf__
N_INET
#define N_INET
EAI_MAX
#define EAI_MAX
Definition: addrinfo.h:91
AI_ADDRCONFIG
#define AI_ADDRCONFIG
Definition: addrinfo.h:108
freeaddrinfo
void freeaddrinfo(struct addrinfo *ai)
Definition: getaddrinfo.c:216
AI_ALL
#define AI_ALL
Definition: addrinfo.h:106
EAI_SERVICE
#define EAI_SERVICE
Definition: addrinfo.h:86
ERR
#define ERR(err)
Definition: getaddrinfo.c:200
addrinfo::ai_socktype
int ai_socktype
Definition: addrinfo.h:134
io.h
EAI_FAMILY
#define EAI_FAMILY
Definition: addrinfo.h:82
__P
#define __P(args)
Definition: addrinfo.h:68
free
#define free(x)
Definition: dln.c:52
addrinfo::ai_flags
int ai_flags
Definition: addrinfo.h:132
GET_CANONNAME
#define GET_CANONNAME(ai, str)
Definition: getaddrinfo.c:172
EAI_BADFLAGS
#define EAI_BADFLAGS
Definition: addrinfo.h:80
gai_strerror
char * gai_strerror(int ecode)
Definition: getaddrinfo.c:207
EAI_NONAME
#define EAI_NONAME
Definition: addrinfo.h:85
top
unsigned int top
Definition: nkf.c:4323
u_short
unsigned short u_short
Definition: rb_mjit_min_header-2.7.0.h:1289
EAI_BADHINTS
#define EAI_BADHINTS
Definition: addrinfo.h:89
getaddrinfo
int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
Definition: getaddrinfo.c:272
sockinet::si_family
u_char si_family
Definition: getaddrinfo.c:110
sockinet::si_len
u_char si_len
Definition: getaddrinfo.c:109
PTON_MAX
#define PTON_MAX
Definition: getaddrinfo.c:142
sockport.h
addrinfo
Definition: addrinfo.h:131
EAI_FAIL
#define EAI_FAIL
Definition: addrinfo.h:81
SUCCESS
#define SUCCESS
Definition: getaddrinfo.c:89
d1
#define d1
YES
#define YES
Definition: getaddrinfo.c:91