1 /* Copyright (C) 1996-2002, 2003, 2004, 2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 /* All data returned by the network data base library are supplied in
20 host order and returned in network order (suitable for use in
28 #include <netinet/in.h>
30 #if defined __USE_MISC && defined __UCLIBC_HAS_RPC__
31 /* This is necessary to make this include file properly replace the
33 # include <rpc/netdb.h>
37 # define __need_sigevent_t
38 # include <bits/siginfo.h>
39 # define __need_timespec
43 #include <bits/netdb.h>
45 /* Absolute file name for network data base files. */
46 #define _PATH_HEQUIV "/etc/hosts.equiv"
47 #define _PATH_HOSTS "/etc/hosts"
48 #define _PATH_NETWORKS "/etc/networks"
49 #define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
50 #define _PATH_PROTOCOLS "/etc/protocols"
51 #define _PATH_SERVICES "/etc/services"
56 /* Error status for non-reentrant lookup functions.
57 We use a macro to access always the thread-specific `h_errno' variable. */
58 #define h_errno (*__h_errno_location ())
60 /* Function to get address of global `h_errno' variable. */
61 extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
63 # ifndef __UCLIBC_HAS_TLS__
64 extern int weak_const_function *__h_errno_location(void);
67 libc_hidden_proto(__h_errno_location)
69 /* Macros for accessing h_errno from inside libc. */
71 # ifdef __UCLIBC_HAS_THREADS__
72 # if defined __UCLIBC_HAS_TLS__ \
73 && (!defined NOT_IN_libc || defined IS_IN_libpthread)
76 # define h_errno __libc_h_errno
78 # define h_errno h_errno /* For #ifndef h_errno tests. */
80 extern __thread int h_errno attribute_tls_model_ie;
81 # define __set_h_errno(x) (h_errno = (x))
83 static inline int __set_h_errno (int __err)
85 return *__h_errno_location () = __err;
87 # endif /* __UCLIBC_HAS_TLS__ */
90 # define __set_h_errno(x) (h_errno = (x))
92 # endif /* __UCLIBC_HAS_THREADS__ */
95 /* Possible values left in `h_errno'. */
96 #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
97 #define TRY_AGAIN 2 /* Non-Authoritative Host not found,
99 #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
101 #define NO_DATA 4 /* Valid name, no data record of requested
103 #if defined __USE_MISC || defined __USE_GNU
104 # define NETDB_INTERNAL -1 /* See errno. */
105 # define NETDB_SUCCESS 0 /* No problem. */
106 # define NO_ADDRESS NO_DATA /* No address, look for MX record. */
110 /* Highest reserved Internet port number. */
111 # define IPPORT_RESERVED 1024
115 /* Scope delimiter for getaddrinfo(), getnameinfo(). */
116 # define SCOPE_DELIMITER '%'
119 #if defined __USE_MISC || defined __USE_GNU
120 /* Print error indicated by `h_errno' variable on standard error. STR
121 if non-null is printed before the error string. */
122 extern void herror (__const char *__str) __THROW;
123 libc_hidden_proto(herror)
125 /* Return string associated with error ERR_NUM. */
126 extern __const char *hstrerror (int __err_num) __THROW;
130 /* Description of data base entry for a single host. */
133 char *h_name; /* Official name of host. */
134 char **h_aliases; /* Alias list. */
135 int h_addrtype; /* Host address type. */
136 int h_length; /* Length of address. */
137 char **h_addr_list; /* List of addresses from name server. */
138 #if defined __USE_MISC || defined __USE_GNU
139 # define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
143 /* Open host data base files and mark them as staying open even after
144 a later search if STAY_OPEN is non-zero.
146 This function is a possible cancellation point and therefore not
147 marked with __THROW. */
148 extern void sethostent (int __stay_open);
150 /* Close host data base files and clear `stay open' flag.
152 This function is a possible cancellation point and therefore not
153 marked with __THROW. */
154 extern void endhostent (void);
156 /* Get next entry from host data base file. Open data base if
159 This function is a possible cancellation point and therefore not
160 marked with __THROW. */
161 extern struct hostent *gethostent (void);
163 /* Return entry from host data base which address match ADDR with
164 length LEN and type TYPE.
166 This function is a possible cancellation point and therefore not
167 marked with __THROW. */
168 extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
170 libc_hidden_proto(gethostbyaddr)
172 /* Return entry from host data base for host with NAME.
174 This function is a possible cancellation point and therefore not
175 marked with __THROW. */
176 extern struct hostent *gethostbyname (__const char *__name);
177 libc_hidden_proto(gethostbyname)
180 /* Return entry from host data base for host with NAME. AF must be
181 set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
184 This function is not part of POSIX and therefore no official
185 cancellation point. But due to similarity with an POSIX interface
186 or due to the implementation it is a cancellation point and
187 therefore not marked with __THROW. */
188 extern struct hostent *gethostbyname2 (__const char *__name, int __af);
189 libc_hidden_proto(gethostbyname2)
191 /* Reentrant versions of the functions above. The additional
192 arguments specify a buffer of BUFLEN starting at BUF. The last
193 argument is a pointer to a variable which gets the value which
194 would be stored in the global variable `herrno' by the
195 non-reentrant functions.
197 These functions are not part of POSIX and therefore no official
198 cancellation point. But due to similarity with an POSIX interface
199 or due to the implementation they are cancellation points and
200 therefore not marked with __THROW. */
201 extern int gethostent_r (struct hostent *__restrict __result_buf,
202 char *__restrict __buf, size_t __buflen,
203 struct hostent **__restrict __result,
204 int *__restrict __h_errnop);
205 libc_hidden_proto(gethostent_r)
207 extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
209 struct hostent *__restrict __result_buf,
210 char *__restrict __buf, size_t __buflen,
211 struct hostent **__restrict __result,
212 int *__restrict __h_errnop);
213 libc_hidden_proto(gethostbyaddr_r)
215 extern int gethostbyname_r (__const char *__restrict __name,
216 struct hostent *__restrict __result_buf,
217 char *__restrict __buf, size_t __buflen,
218 struct hostent **__restrict __result,
219 int *__restrict __h_errnop);
220 libc_hidden_proto(gethostbyname_r)
222 extern int gethostbyname2_r (__const char *__restrict __name, int __af,
223 struct hostent *__restrict __result_buf,
224 char *__restrict __buf, size_t __buflen,
225 struct hostent **__restrict __result,
226 int *__restrict __h_errnop);
227 libc_hidden_proto(gethostbyname2_r)
231 /* Open network data base files and mark them as staying open even
232 after a later search if STAY_OPEN is non-zero.
234 This function is a possible cancellation point and therefore not
235 marked with __THROW. */
236 extern void setnetent (int __stay_open);
237 libc_hidden_proto(setnetent)
239 /* Close network data base files and clear `stay open' flag.
241 This function is a possible cancellation point and therefore not
242 marked with __THROW. */
243 extern void endnetent (void);
244 libc_hidden_proto(endnetent)
246 /* Get next entry from network data base file. Open data base if
249 This function is a possible cancellation point and therefore not
250 marked with __THROW. */
251 extern struct netent *getnetent (void);
253 /* Return entry from network data base which address match NET and
256 This function is a possible cancellation point and therefore not
257 marked with __THROW. */
258 extern struct netent *getnetbyaddr (uint32_t __net, int __type);
260 /* Return entry from network data base for network with NAME.
262 This function is a possible cancellation point and therefore not
263 marked with __THROW. */
264 extern struct netent *getnetbyname (__const char *__name);
267 /* Reentrant versions of the functions above. The additional
268 arguments specify a buffer of BUFLEN starting at BUF. The last
269 argument is a pointer to a variable which gets the value which
270 would be stored in the global variable `herrno' by the
271 non-reentrant functions.
273 These functions are not part of POSIX and therefore no official
274 cancellation point. But due to similarity with an POSIX interface
275 or due to the implementation they are cancellation points and
276 therefore not marked with __THROW. */
277 extern int getnetent_r (struct netent *__restrict __result_buf,
278 char *__restrict __buf, size_t __buflen,
279 struct netent **__restrict __result,
280 int *__restrict __h_errnop);
281 libc_hidden_proto(getnetent_r)
283 extern int getnetbyaddr_r (uint32_t __net, int __type,
284 struct netent *__restrict __result_buf,
285 char *__restrict __buf, size_t __buflen,
286 struct netent **__restrict __result,
287 int *__restrict __h_errnop);
288 libc_hidden_proto(getnetbyaddr_r)
290 extern int getnetbyname_r (__const char *__restrict __name,
291 struct netent *__restrict __result_buf,
292 char *__restrict __buf, size_t __buflen,
293 struct netent **__restrict __result,
294 int *__restrict __h_errnop);
295 libc_hidden_proto(getnetbyname_r)
296 #endif /* __USE_MISC */
299 /* Description of data base entry for a single service. */
302 char *s_name; /* Official service name. */
303 char **s_aliases; /* Alias list. */
304 int s_port; /* Port number. */
305 char *s_proto; /* Protocol to use. */
308 /* Open service data base files and mark them as staying open even
309 after a later search if STAY_OPEN is non-zero.
311 This function is a possible cancellation point and therefore not
312 marked with __THROW. */
313 extern void setservent (int __stay_open);
314 libc_hidden_proto(setservent)
316 /* Close service data base files and clear `stay open' flag.
318 This function is a possible cancellation point and therefore not
319 marked with __THROW. */
320 extern void endservent (void);
321 libc_hidden_proto(endservent)
323 /* Get next entry from service data base file. Open data base if
326 This function is a possible cancellation point and therefore not
327 marked with __THROW. */
328 extern struct servent *getservent (void);
330 /* Return entry from network data base for network with NAME and
333 This function is a possible cancellation point and therefore not
334 marked with __THROW. */
335 extern struct servent *getservbyname (__const char *__name,
336 __const char *__proto);
338 /* Return entry from service data base which matches port PORT and
341 This function is a possible cancellation point and therefore not
342 marked with __THROW. */
343 extern struct servent *getservbyport (int __port, __const char *__proto);
344 libc_hidden_proto(getservbyport)
348 /* Reentrant versions of the functions above. The additional
349 arguments specify a buffer of BUFLEN starting at BUF.
351 These functions are not part of POSIX and therefore no official
352 cancellation point. But due to similarity with an POSIX interface
353 or due to the implementation they are cancellation points and
354 therefore not marked with __THROW. */
355 extern int getservent_r (struct servent *__restrict __result_buf,
356 char *__restrict __buf, size_t __buflen,
357 struct servent **__restrict __result);
358 libc_hidden_proto(getservent_r)
360 extern int getservbyname_r (__const char *__restrict __name,
361 __const char *__restrict __proto,
362 struct servent *__restrict __result_buf,
363 char *__restrict __buf, size_t __buflen,
364 struct servent **__restrict __result);
365 libc_hidden_proto(getservbyname_r)
367 extern int getservbyport_r (int __port, __const char *__restrict __proto,
368 struct servent *__restrict __result_buf,
369 char *__restrict __buf, size_t __buflen,
370 struct servent **__restrict __result);
371 libc_hidden_proto(getservbyport_r)
375 /* Description of data base entry for a single service. */
378 char *p_name; /* Official protocol name. */
379 char **p_aliases; /* Alias list. */
380 int p_proto; /* Protocol number. */
383 /* Open protocol data base files and mark them as staying open even
384 after a later search if STAY_OPEN is non-zero.
386 This function is a possible cancellation point and therefore not
387 marked with __THROW. */
388 extern void setprotoent (int __stay_open);
389 libc_hidden_proto(setprotoent)
391 /* Close protocol data base files and clear `stay open' flag.
393 This function is a possible cancellation point and therefore not
394 marked with __THROW. */
395 extern void endprotoent (void);
396 libc_hidden_proto(endprotoent)
398 /* Get next entry from protocol data base file. Open data base if
401 This function is a possible cancellation point and therefore not
402 marked with __THROW. */
403 extern struct protoent *getprotoent (void);
405 /* Return entry from protocol data base for network with NAME.
407 This function is a possible cancellation point and therefore not
408 marked with __THROW. */
409 extern struct protoent *getprotobyname (__const char *__name);
411 /* Return entry from protocol data base which number is PROTO.
413 This function is a possible cancellation point and therefore not
414 marked with __THROW. */
415 extern struct protoent *getprotobynumber (int __proto);
419 /* Reentrant versions of the functions above. The additional
420 arguments specify a buffer of BUFLEN starting at BUF.
422 These functions are not part of POSIX and therefore no official
423 cancellation point. But due to similarity with an POSIX interface
424 or due to the implementation they are cancellation points and
425 therefore not marked with __THROW. */
426 extern int getprotoent_r (struct protoent *__restrict __result_buf,
427 char *__restrict __buf, size_t __buflen,
428 struct protoent **__restrict __result);
429 libc_hidden_proto(getprotoent_r)
431 extern int getprotobyname_r (__const char *__restrict __name,
432 struct protoent *__restrict __result_buf,
433 char *__restrict __buf, size_t __buflen,
434 struct protoent **__restrict __result);
435 libc_hidden_proto(getprotobyname_r)
437 extern int getprotobynumber_r (int __proto,
438 struct protoent *__restrict __result_buf,
439 char *__restrict __buf, size_t __buflen,
440 struct protoent **__restrict __result);
441 libc_hidden_proto(getprotobynumber_r)
444 #ifdef __UCLIBC_HAS_NETGROUP__
445 /* Establish network group NETGROUP for enumeration.
447 This function is not part of POSIX and therefore no official
448 cancellation point. But due to similarity with an POSIX interface
449 or due to the implementation it is a cancellation point and
450 therefore not marked with __THROW. */
451 extern int setnetgrent (__const char *__netgroup);
453 /* Free all space allocated by previous `setnetgrent' call.
455 This function is not part of POSIX and therefore no official
456 cancellation point. But due to similarity with an POSIX interface
457 or due to the implementation it is a cancellation point and
458 therefore not marked with __THROW. */
459 extern void endnetgrent (void);
461 /* Get next member of netgroup established by last `setnetgrent' call
462 and return pointers to elements in HOSTP, USERP, and DOMAINP.
464 This function is not part of POSIX and therefore no official
465 cancellation point. But due to similarity with an POSIX interface
466 or due to the implementation it is a cancellation point and
467 therefore not marked with __THROW. */
468 extern int getnetgrent (char **__restrict __hostp,
469 char **__restrict __userp,
470 char **__restrict __domainp);
473 /* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
475 This function is not part of POSIX and therefore no official
476 cancellation point. But due to similarity with an POSIX interface
477 or due to the implementation it is a cancellation point and
478 therefore not marked with __THROW. */
479 extern int innetgr (__const char *__netgroup, __const char *__host,
480 __const char *__user, __const char *__domain);
482 /* Reentrant version of `getnetgrent' where result is placed in BUFFER.
484 This function is not part of POSIX and therefore no official
485 cancellation point. But due to similarity with an POSIX interface
486 or due to the implementation it is a cancellation point and
487 therefore not marked with __THROW. */
488 extern int getnetgrent_r (char **__restrict __hostp,
489 char **__restrict __userp,
490 char **__restrict __domainp,
491 char *__restrict __buffer, size_t __buflen);
492 #endif /* UCLIBC_HAS_NETGROUP */
496 /* ruserpass - remote password check.
497 This function also exists in glibc but is undocumented */
498 extern int ruserpass(const char *host, const char **aname, const char **apass);
499 libc_hidden_proto(ruserpass)
503 /* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
504 The local user is LOCUSER, on the remote machine the command is
505 executed as REMUSER. In *FD2P the descriptor to the socket for the
506 connection is returned. The caller must have the right to use a
507 reserved port. When the function returns *AHOST contains the
510 This function is not part of POSIX and therefore no official
511 cancellation point. But due to similarity with an POSIX interface
512 or due to the implementation it is a cancellation point and
513 therefore not marked with __THROW. */
514 extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
515 __const char *__restrict __locuser,
516 __const char *__restrict __remuser,
517 __const char *__restrict __cmd, int *__restrict __fd2p);
521 /* This is the equivalent function where the protocol can be selected
522 and which therefore can be used for IPv6.
524 This function is not part of POSIX and therefore no official
525 cancellation point. But due to similarity with an POSIX interface
526 or due to the implementation it is a cancellation point and
527 therefore not marked with __THROW. */
528 extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
529 __const char *__restrict __locuser,
530 __const char *__restrict __remuser,
531 __const char *__restrict __cmd, int *__restrict __fd2p,
535 /* Call `rexecd' at port RPORT on remote machine *AHOST to execute
536 CMD. The process runs at the remote machine using the ID of user
537 NAME whose cleartext password is PASSWD. In *FD2P the descriptor
538 to the socket for the connection is returned. When the function
539 returns *AHOST contains the official host name.
541 This function is not part of POSIX and therefore no official
542 cancellation point. But due to similarity with an POSIX interface
543 or due to the implementation it is a cancellation point and
544 therefore not marked with __THROW. */
545 extern int rexec (char **__restrict __ahost, int __rport,
546 __const char *__restrict __name,
547 __const char *__restrict __pass,
548 __const char *__restrict __cmd, int *__restrict __fd2p);
550 /* This is the equivalent function where the protocol can be selected
551 and which therefore can be used for IPv6.
553 This function is not part of POSIX and therefore no official
554 cancellation point. But due to similarity with an POSIX interface
555 or due to the implementation it is a cancellation point and
556 therefore not marked with __THROW. */
557 extern int rexec_af (char **__restrict __ahost, int __rport,
558 __const char *__restrict __name,
559 __const char *__restrict __pass,
560 __const char *__restrict __cmd, int *__restrict __fd2p,
562 libc_hidden_proto(rexec_af)
564 /* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
565 If SUSER is not zero the user tries to become superuser. Return 0 if
568 This function is not part of POSIX and therefore no official
569 cancellation point. But due to similarity with an POSIX interface
570 or due to the implementation it is a cancellation point and
571 therefore not marked with __THROW. */
572 extern int ruserok (__const char *__rhost, int __suser,
573 __const char *__remuser, __const char *__locuser);
577 /* This is the equivalent function where the protocol can be selected
578 and which therefore can be used for IPv6.
580 This function is not part of POSIX and therefore no official
581 cancellation point. But due to similarity with an POSIX interface
582 or due to the implementation it is a cancellation point and
583 therefore not marked with __THROW. */
584 extern int ruserok_af (__const char *__rhost, int __suser,
585 __const char *__remuser, __const char *__locuser,
589 /* Try to allocate reserved port, returning a descriptor for a socket opened
590 at this port or -1 if unsuccessful. The search for an available port
591 will start at ALPORT and continues with lower numbers.
593 This function is not part of POSIX and therefore no official
594 cancellation point. But due to similarity with an POSIX interface
595 or due to the implementation it is a cancellation point and
596 therefore not marked with __THROW. */
597 extern int rresvport (int *__alport);
598 libc_hidden_proto(rresvport)
602 /* This is the equivalent function where the protocol can be selected
603 and which therefore can be used for IPv6.
605 This function is not part of POSIX and therefore no official
606 cancellation point. But due to similarity with an POSIX interface
607 or due to the implementation it is a cancellation point and
608 therefore not marked with __THROW. */
609 extern int rresvport_af (int *__alport, sa_family_t __af);
614 /* Extension from POSIX.1g. */
616 /* Structure to contain information about address of a service provider. */
619 int ai_flags; /* Input flags. */
620 int ai_family; /* Protocol family for socket. */
621 int ai_socktype; /* Socket type. */
622 int ai_protocol; /* Protocol for socket. */
623 socklen_t ai_addrlen; /* Length of socket address. */
624 struct sockaddr *ai_addr; /* Socket address for socket. */
625 char *ai_canonname; /* Canonical name for service location. */
626 struct addrinfo *ai_next; /* Pointer to next in list. */
629 /* Possible values for `ai_flags' field in `addrinfo' structure. */
630 # define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
631 # define AI_CANONNAME 0x0002 /* Request for canonical name. */
632 # define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
633 # define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
634 # define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
635 # define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
636 returned address type.. */
638 # define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
639 in the current locale's character set)
640 before looking it up. */
641 # define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
642 # define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode
644 # define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to
647 # define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
649 /* Error values for `getaddrinfo' function. */
650 # define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
651 # define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
652 # define EAI_AGAIN -3 /* Temporary failure in name resolution. */
653 # define EAI_FAIL -4 /* Non-recoverable failure in name res. */
654 # define EAI_FAMILY -6 /* `ai_family' not supported. */
655 # define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
656 # define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
657 # define EAI_MEMORY -10 /* Memory allocation failure. */
658 # define EAI_SYSTEM -11 /* System error returned in `errno'. */
659 # define EAI_OVERFLOW -12 /* Argument buffer overflow. */
661 # define EAI_NODATA -5 /* No address associated with NAME. */
662 # define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
663 # define EAI_INPROGRESS -100 /* Processing request in progress. */
664 # define EAI_CANCELED -101 /* Request canceled. */
665 # define EAI_NOTCANCELED -102 /* Request not canceled. */
666 # define EAI_ALLDONE -103 /* All requests done. */
667 # define EAI_INTR -104 /* Interrupted by a signal. */
668 # define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
672 # define NI_MAXHOST 1025
673 # define NI_MAXSERV 32
676 # define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
677 # define NI_NUMERICSERV 2 /* Don't convert port number to name. */
678 # define NI_NOFQDN 4 /* Only return nodename portion. */
679 # define NI_NAMEREQD 8 /* Don't return numeric addresses. */
680 # define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
682 # define NI_IDN 32 /* Convert name from IDN format. */
683 # define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
685 # define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to
689 /* Translate name of a service location and/or a service name to set of
692 This function is a possible cancellation point and therefore not
693 marked with __THROW. */
694 extern int getaddrinfo (__const char *__restrict __name,
695 __const char *__restrict __service,
696 __const struct addrinfo *__restrict __req,
697 struct addrinfo **__restrict __pai);
698 libc_hidden_proto(getaddrinfo)
700 /* Free `addrinfo' structure AI including associated storage. */
701 extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
702 libc_hidden_proto(freeaddrinfo)
704 /* Convert error return from getaddrinfo() to a string. */
705 extern __const char *gai_strerror (int __ecode) __THROW;
707 /* Translate a socket address to a location and service name.
709 This function is a possible cancellation point and therefore not
710 marked with __THROW. */
711 extern int getnameinfo (__const struct sockaddr *__restrict __sa,
712 socklen_t __salen, char *__restrict __host,
713 socklen_t __hostlen, char *__restrict __serv,
714 socklen_t __servlen, unsigned int __flags);
715 libc_hidden_proto(getnameinfo)