1 /* Copyright (C) 1996-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/* All data returned by the network data base library are supplied in
19 host order and returned in network order (suitable for use in
20 system calls). */
21
22#ifndef _NETDB_H
23#define _NETDB_H 1
24
25#include <features.h>
26
27#include <netinet/in.h>
28#include <stdint.h>
29#ifdef __USE_MISC
30/* This is necessary to make this include file properly replace the
31 Sun version. */
32# include <rpc/netdb.h>
33#endif
34
35#ifdef __USE_GNU
36# define __need_sigevent_t
37# include <bits/siginfo.h>
38# define __need_timespec
39# include <time.h>
40#endif
41
42#include <bits/netdb.h>
43
44/* Absolute file name for network data base files. */
45#define _PATH_HEQUIV "/etc/hosts.equiv"
46#define _PATH_HOSTS "/etc/hosts"
47#define _PATH_NETWORKS "/etc/networks"
48#define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf"
49#define _PATH_PROTOCOLS "/etc/protocols"
50#define _PATH_SERVICES "/etc/services"
51
52
53__BEGIN_DECLS
54
55#if defined __USE_MISC || !defined __USE_XOPEN2K8
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 ())
59
60/* Function to get address of global `h_errno' variable. */
61extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
62
63
64/* Possible values left in `h_errno'. */
65# define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */
66# define TRY_AGAIN 2 /* Non-Authoritative Host not found,
67 or SERVERFAIL. */
68# define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED,
69 NOTIMP. */
70# define NO_DATA 4 /* Valid name, no data record of requested
71 type. */
72#endif
73#if defined __USE_MISC || defined __USE_GNU
74# define NETDB_INTERNAL -1 /* See errno. */
75# define NETDB_SUCCESS 0 /* No problem. */
76# define NO_ADDRESS NO_DATA /* No address, look for MX record. */
77#endif
78
79#if defined __USE_XOPEN2K || defined __USE_XOPEN_EXTENDED
80/* Highest reserved Internet port number. */
81# define IPPORT_RESERVED 1024
82#endif
83
84#ifdef __USE_GNU
85/* Scope delimiter for getaddrinfo(), getnameinfo(). */
86# define SCOPE_DELIMITER '%'
87#endif
88
89#ifdef __USE_MISC
90/* Print error indicated by `h_errno' variable on standard error. STR
91 if non-null is printed before the error string. */
92extern void herror (const char *__str) __THROW;
93
94/* Return string associated with error ERR_NUM. */
95extern const char *hstrerror (int __err_num) __THROW;
96#endif
97
98
99/* Description of data base entry for a single host. */
100struct hostent
101{
102 char *h_name; /* Official name of host. */
103 char **h_aliases; /* Alias list. */
104 int h_addrtype; /* Host address type. */
105 int h_length; /* Length of address. */
106 char **h_addr_list; /* List of addresses from name server. */
107#if defined __USE_MISC || defined __USE_GNU
108# define h_addr h_addr_list[0] /* Address, for backward compatibility.*/
109#endif
110};
111
112/* Open host data base files and mark them as staying open even after
113 a later search if STAY_OPEN is non-zero.
114
115 This function is a possible cancellation point and therefore not
116 marked with __THROW. */
117extern void sethostent (int __stay_open);
118
119/* Close host data base files and clear `stay open' flag.
120
121 This function is a possible cancellation point and therefore not
122 marked with __THROW. */
123extern void endhostent (void);
124
125/* Get next entry from host data base file. Open data base if
126 necessary.
127
128 This function is a possible cancellation point and therefore not
129 marked with __THROW. */
130extern struct hostent *gethostent (void);
131
132/* Return entry from host data base which address match ADDR with
133 length LEN and type TYPE.
134
135 This function is a possible cancellation point and therefore not
136 marked with __THROW. */
137extern struct hostent *gethostbyaddr (const void *__addr, __socklen_t __len,
138 int __type);
139
140/* Return entry from host data base for host with NAME.
141
142 This function is a possible cancellation point and therefore not
143 marked with __THROW. */
144extern struct hostent *gethostbyname (const char *__name);
145
146#ifdef __USE_MISC
147/* Return entry from host data base for host with NAME. AF must be
148 set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
149 for IPv6.
150
151 This function is not part of POSIX and therefore no official
152 cancellation point. But due to similarity with an POSIX interface
153 or due to the implementation it is a cancellation point and
154 therefore not marked with __THROW. */
155extern struct hostent *gethostbyname2 (const char *__name, int __af);
156
157/* Reentrant versions of the functions above. The additional
158 arguments specify a buffer of BUFLEN starting at BUF. The last
159 argument is a pointer to a variable which gets the value which
160 would be stored in the global variable `herrno' by the
161 non-reentrant functions.
162
163 These functions are not part of POSIX and therefore no official
164 cancellation point. But due to similarity with an POSIX interface
165 or due to the implementation they are cancellation points and
166 therefore not marked with __THROW. */
167extern int gethostent_r (struct hostent *__restrict __result_buf,
168 char *__restrict __buf, size_t __buflen,
169 struct hostent **__restrict __result,
170 int *__restrict __h_errnop);
171
172extern int gethostbyaddr_r (const void *__restrict __addr, __socklen_t __len,
173 int __type,
174 struct hostent *__restrict __result_buf,
175 char *__restrict __buf, size_t __buflen,
176 struct hostent **__restrict __result,
177 int *__restrict __h_errnop);
178
179extern int gethostbyname_r (const char *__restrict __name,
180 struct hostent *__restrict __result_buf,
181 char *__restrict __buf, size_t __buflen,
182 struct hostent **__restrict __result,
183 int *__restrict __h_errnop);
184
185extern int gethostbyname2_r (const char *__restrict __name, int __af,
186 struct hostent *__restrict __result_buf,
187 char *__restrict __buf, size_t __buflen,
188 struct hostent **__restrict __result,
189 int *__restrict __h_errnop);
190#endif /* misc */
191
192
193/* Open network data base files and mark them as staying open even
194 after a later search if STAY_OPEN is non-zero.
195
196 This function is a possible cancellation point and therefore not
197 marked with __THROW. */
198extern void setnetent (int __stay_open);
199
200/* Close network data base files and clear `stay open' flag.
201
202 This function is a possible cancellation point and therefore not
203 marked with __THROW. */
204extern void endnetent (void);
205
206/* Get next entry from network data base file. Open data base if
207 necessary.
208
209 This function is a possible cancellation point and therefore not
210 marked with __THROW. */
211extern struct netent *getnetent (void);
212
213/* Return entry from network data base which address match NET and
214 type TYPE.
215
216 This function is a possible cancellation point and therefore not
217 marked with __THROW. */
218extern struct netent *getnetbyaddr (uint32_t __net, int __type);
219
220/* Return entry from network data base for network with NAME.
221
222 This function is a possible cancellation point and therefore not
223 marked with __THROW. */
224extern struct netent *getnetbyname (const char *__name);
225
226#ifdef __USE_MISC
227/* Reentrant versions of the functions above. The additional
228 arguments specify a buffer of BUFLEN starting at BUF. The last
229 argument is a pointer to a variable which gets the value which
230 would be stored in the global variable `herrno' by the
231 non-reentrant functions.
232
233 These functions are not part of POSIX and therefore no official
234 cancellation point. But due to similarity with an POSIX interface
235 or due to the implementation they are cancellation points and
236 therefore not marked with __THROW. */
237extern int getnetent_r (struct netent *__restrict __result_buf,
238 char *__restrict __buf, size_t __buflen,
239 struct netent **__restrict __result,
240 int *__restrict __h_errnop);
241
242extern int getnetbyaddr_r (uint32_t __net, int __type,
243 struct netent *__restrict __result_buf,
244 char *__restrict __buf, size_t __buflen,
245 struct netent **__restrict __result,
246 int *__restrict __h_errnop);
247
248extern int getnetbyname_r (const char *__restrict __name,
249 struct netent *__restrict __result_buf,
250 char *__restrict __buf, size_t __buflen,
251 struct netent **__restrict __result,
252 int *__restrict __h_errnop);
253#endif /* misc */
254
255
256/* Description of data base entry for a single service. */
257struct servent
258{
259 char *s_name; /* Official service name. */
260 char **s_aliases; /* Alias list. */
261 int s_port; /* Port number. */
262 char *s_proto; /* Protocol to use. */
263};
264
265/* Open service data base files and mark them as staying open even
266 after a later search if STAY_OPEN is non-zero.
267
268 This function is a possible cancellation point and therefore not
269 marked with __THROW. */
270extern void setservent (int __stay_open);
271
272/* Close service data base files and clear `stay open' flag.
273
274 This function is a possible cancellation point and therefore not
275 marked with __THROW. */
276extern void endservent (void);
277
278/* Get next entry from service data base file. Open data base if
279 necessary.
280
281 This function is a possible cancellation point and therefore not
282 marked with __THROW. */
283extern struct servent *getservent (void);
284
285/* Return entry from network data base for network with NAME and
286 protocol PROTO.
287
288 This function is a possible cancellation point and therefore not
289 marked with __THROW. */
290extern struct servent *getservbyname (const char *__name, const char *__proto);
291
292/* Return entry from service data base which matches port PORT and
293 protocol PROTO.
294
295 This function is a possible cancellation point and therefore not
296 marked with __THROW. */
297extern struct servent *getservbyport (int __port, const char *__proto);
298
299
300#ifdef __USE_MISC
301/* Reentrant versions of the functions above. The additional
302 arguments specify a buffer of BUFLEN starting at BUF.
303
304 These functions are not part of POSIX and therefore no official
305 cancellation point. But due to similarity with an POSIX interface
306 or due to the implementation they are cancellation points and
307 therefore not marked with __THROW. */
308extern int getservent_r (struct servent *__restrict __result_buf,
309 char *__restrict __buf, size_t __buflen,
310 struct servent **__restrict __result);
311
312extern int getservbyname_r (const char *__restrict __name,
313 const char *__restrict __proto,
314 struct servent *__restrict __result_buf,
315 char *__restrict __buf, size_t __buflen,
316 struct servent **__restrict __result);
317
318extern int getservbyport_r (int __port, const char *__restrict __proto,
319 struct servent *__restrict __result_buf,
320 char *__restrict __buf, size_t __buflen,
321 struct servent **__restrict __result);
322#endif /* misc */
323
324
325/* Description of data base entry for a single service. */
326struct protoent
327{
328 char *p_name; /* Official protocol name. */
329 char **p_aliases; /* Alias list. */
330 int p_proto; /* Protocol number. */
331};
332
333/* Open protocol data base files and mark them as staying open even
334 after a later search if STAY_OPEN is non-zero.
335
336 This function is a possible cancellation point and therefore not
337 marked with __THROW. */
338extern void setprotoent (int __stay_open);
339
340/* Close protocol data base files and clear `stay open' flag.
341
342 This function is a possible cancellation point and therefore not
343 marked with __THROW. */
344extern void endprotoent (void);
345
346/* Get next entry from protocol data base file. Open data base if
347 necessary.
348
349 This function is a possible cancellation point and therefore not
350 marked with __THROW. */
351extern struct protoent *getprotoent (void);
352
353/* Return entry from protocol data base for network with NAME.
354
355 This function is a possible cancellation point and therefore not
356 marked with __THROW. */
357extern struct protoent *getprotobyname (const char *__name);
358
359/* Return entry from protocol data base which number is PROTO.
360
361 This function is a possible cancellation point and therefore not
362 marked with __THROW. */
363extern struct protoent *getprotobynumber (int __proto);
364
365
366#ifdef __USE_MISC
367/* Reentrant versions of the functions above. The additional
368 arguments specify a buffer of BUFLEN starting at BUF.
369
370 These functions are not part of POSIX and therefore no official
371 cancellation point. But due to similarity with an POSIX interface
372 or due to the implementation they are cancellation points and
373 therefore not marked with __THROW. */
374extern int getprotoent_r (struct protoent *__restrict __result_buf,
375 char *__restrict __buf, size_t __buflen,
376 struct protoent **__restrict __result);
377
378extern int getprotobyname_r (const char *__restrict __name,
379 struct protoent *__restrict __result_buf,
380 char *__restrict __buf, size_t __buflen,
381 struct protoent **__restrict __result);
382
383extern int getprotobynumber_r (int __proto,
384 struct protoent *__restrict __result_buf,
385 char *__restrict __buf, size_t __buflen,
386 struct protoent **__restrict __result);
387
388
389/* Establish network group NETGROUP for enumeration.
390
391 This function is not part of POSIX and therefore no official
392 cancellation point. But due to similarity with an POSIX interface
393 or due to the implementation it is a cancellation point and
394 therefore not marked with __THROW. */
395extern int setnetgrent (const char *__netgroup);
396
397/* Free all space allocated by previous `setnetgrent' call.
398
399 This function is not part of POSIX and therefore no official
400 cancellation point. But due to similarity with an POSIX interface
401 or due to the implementation it is a cancellation point and
402 therefore not marked with __THROW. */
403extern void endnetgrent (void);
404
405/* Get next member of netgroup established by last `setnetgrent' call
406 and return pointers to elements in HOSTP, USERP, and DOMAINP.
407
408 This function is not part of POSIX and therefore no official
409 cancellation point. But due to similarity with an POSIX interface
410 or due to the implementation it is a cancellation point and
411 therefore not marked with __THROW. */
412extern int getnetgrent (char **__restrict __hostp,
413 char **__restrict __userp,
414 char **__restrict __domainp);
415
416
417/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
418
419 This function is not part of POSIX and therefore no official
420 cancellation point. But due to similarity with an POSIX interface
421 or due to the implementation it is a cancellation point and
422 therefore not marked with __THROW. */
423extern int innetgr (const char *__netgroup, const char *__host,
424 const char *__user, const char *__domain);
425
426/* Reentrant version of `getnetgrent' where result is placed in BUFFER.
427
428 This function is not part of POSIX and therefore no official
429 cancellation point. But due to similarity with an POSIX interface
430 or due to the implementation it is a cancellation point and
431 therefore not marked with __THROW. */
432extern int getnetgrent_r (char **__restrict __hostp,
433 char **__restrict __userp,
434 char **__restrict __domainp,
435 char *__restrict __buffer, size_t __buflen);
436#endif /* misc */
437
438
439#ifdef __USE_BSD
440/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
441 The local user is LOCUSER, on the remote machine the command is
442 executed as REMUSER. In *FD2P the descriptor to the socket for the
443 connection is returned. The caller must have the right to use a
444 reserved port. When the function returns *AHOST contains the
445 official host name.
446
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. */
451extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
452 const char *__restrict __locuser,
453 const char *__restrict __remuser,
454 const char *__restrict __cmd, int *__restrict __fd2p);
455
456/* This is the equivalent function where the protocol can be selected
457 and which therefore can be used for IPv6.
458
459 This function is not part of POSIX and therefore no official
460 cancellation point. But due to similarity with an POSIX interface
461 or due to the implementation it is a cancellation point and
462 therefore not marked with __THROW. */
463extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
464 const char *__restrict __locuser,
465 const char *__restrict __remuser,
466 const char *__restrict __cmd, int *__restrict __fd2p,
467 sa_family_t __af);
468
469/* Call `rexecd' at port RPORT on remote machine *AHOST to execute
470 CMD. The process runs at the remote machine using the ID of user
471 NAME whose cleartext password is PASSWD. In *FD2P the descriptor
472 to the socket for the connection is returned. When the function
473 returns *AHOST contains the official host name.
474
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. */
479extern int rexec (char **__restrict __ahost, int __rport,
480 const char *__restrict __name,
481 const char *__restrict __pass,
482 const char *__restrict __cmd, int *__restrict __fd2p);
483
484/* This is the equivalent function where the protocol can be selected
485 and which therefore can be used for IPv6.
486
487 This function is not part of POSIX and therefore no official
488 cancellation point. But due to similarity with an POSIX interface
489 or due to the implementation it is a cancellation point and
490 therefore not marked with __THROW. */
491extern int rexec_af (char **__restrict __ahost, int __rport,
492 const char *__restrict __name,
493 const char *__restrict __pass,
494 const char *__restrict __cmd, int *__restrict __fd2p,
495 sa_family_t __af);
496
497/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
498 If SUSER is not zero the user tries to become superuser. Return 0 if
499 it is possible.
500
501 This function is not part of POSIX and therefore no official
502 cancellation point. But due to similarity with an POSIX interface
503 or due to the implementation it is a cancellation point and
504 therefore not marked with __THROW. */
505extern int ruserok (const char *__rhost, int __suser,
506 const char *__remuser, const char *__locuser);
507
508/* This is the equivalent function where the protocol can be selected
509 and which therefore can be used for IPv6.
510
511 This function is not part of POSIX and therefore no official
512 cancellation point. But due to similarity with an POSIX interface
513 or due to the implementation it is a cancellation point and
514 therefore not marked with __THROW. */
515extern int ruserok_af (const char *__rhost, int __suser,
516 const char *__remuser, const char *__locuser,
517 sa_family_t __af);
518
519/* Check whether user REMUSER on system indicated by IPv4 address
520 RADDR is allowed to login as LOCUSER. Non-IPv4 (e.g., IPv6) are
521 not supported. If SUSER is not zero the user tries to become
522 superuser. Return 0 if it is possible.
523
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. */
528extern int iruserok (uint32_t __raddr, int __suser,
529 const char *__remuser, const char *__locuser);
530
531/* This is the equivalent function where the pfamiliy if the address
532 pointed to by RADDR is determined by the value of AF. It therefore
533 can be used for IPv6
534
535 This function is not part of POSIX and therefore no official
536 cancellation point. But due to similarity with an POSIX interface
537 or due to the implementation it is a cancellation point and
538 therefore not marked with __THROW. */
539extern int iruserok_af (const void *__raddr, int __suser,
540 const char *__remuser, const char *__locuser,
541 sa_family_t __af);
542
543/* Try to allocate reserved port, returning a descriptor for a socket opened
544 at this port or -1 if unsuccessful. The search for an available port
545 will start at ALPORT and continues with lower numbers.
546
547 This function is not part of POSIX and therefore no official
548 cancellation point. But due to similarity with an POSIX interface
549 or due to the implementation it is a cancellation point and
550 therefore not marked with __THROW. */
551extern int rresvport (int *__alport);
552
553/* This is the equivalent function where the protocol can be selected
554 and which therefore can be used for IPv6.
555
556 This function is not part of POSIX and therefore no official
557 cancellation point. But due to similarity with an POSIX interface
558 or due to the implementation it is a cancellation point and
559 therefore not marked with __THROW. */
560extern int rresvport_af (int *__alport, sa_family_t __af);
561#endif
562
563
564/* Extension from POSIX.1g. */
565#ifdef __USE_POSIX
566/* Structure to contain information about address of a service provider. */
567struct addrinfo
568{
569 int ai_flags; /* Input flags. */
570 int ai_family; /* Protocol family for socket. */
571 int ai_socktype; /* Socket type. */
572 int ai_protocol; /* Protocol for socket. */
573 socklen_t ai_addrlen; /* Length of socket address. */
574 struct sockaddr *ai_addr; /* Socket address for socket. */
575 char *ai_canonname; /* Canonical name for service location. */
576 struct addrinfo *ai_next; /* Pointer to next in list. */
577};
578
579# ifdef __USE_GNU
580/* Structure used as control block for asynchronous lookup. */
581struct gaicb
582{
583 const char *ar_name; /* Name to look up. */
584 const char *ar_service; /* Service name. */
585 const struct addrinfo *ar_request; /* Additional request specification. */
586 struct addrinfo *ar_result; /* Pointer to result. */
587 /* The following are internal elements. */
588 int __return;
589 int __glibc_reserved[5];
590};
591
592/* Lookup mode. */
593# define GAI_WAIT 0
594# define GAI_NOWAIT 1
595# endif
596
597/* Possible values for `ai_flags' field in `addrinfo' structure. */
598# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
599# define AI_CANONNAME 0x0002 /* Request for canonical name. */
600# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
601# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
602# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
603# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
604 returned address type.. */
605# ifdef __USE_GNU
606# define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded
607 in the current locale's character set)
608 before looking it up. */
609# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */
610# define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode
611 code points. */
612# define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to
613 STD3 rules. */
614# endif
615# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
616
617/* Error values for `getaddrinfo' function. */
618# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
619# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
620# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
621# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
622# define EAI_FAMILY -6 /* `ai_family' not supported. */
623# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
624# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
625# define EAI_MEMORY -10 /* Memory allocation failure. */
626# define EAI_SYSTEM -11 /* System error returned in `errno'. */
627# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
628# ifdef __USE_GNU
629# define EAI_NODATA -5 /* No address associated with NAME. */
630# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
631# define EAI_INPROGRESS -100 /* Processing request in progress. */
632# define EAI_CANCELED -101 /* Request canceled. */
633# define EAI_NOTCANCELED -102 /* Request not canceled. */
634# define EAI_ALLDONE -103 /* All requests done. */
635# define EAI_INTR -104 /* Interrupted by a signal. */
636# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
637# endif
638
639# ifdef __USE_MISC
640# define NI_MAXHOST 1025
641# define NI_MAXSERV 32
642# endif
643
644# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */
645# define NI_NUMERICSERV 2 /* Don't convert port number to name. */
646# define NI_NOFQDN 4 /* Only return nodename portion. */
647# define NI_NAMEREQD 8 /* Don't return numeric addresses. */
648# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */
649# ifdef __USE_GNU
650# define NI_IDN 32 /* Convert name from IDN format. */
651# define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
652 code points. */
653# define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to
654 STD3 rules. */
655# endif
656
657/* Translate name of a service location and/or a service name to set of
658 socket addresses.
659
660 This function is a possible cancellation point and therefore not
661 marked with __THROW. */
662extern int getaddrinfo (const char *__restrict __name,
663 const char *__restrict __service,
664 const struct addrinfo *__restrict __req,
665 struct addrinfo **__restrict __pai);
666
667/* Free `addrinfo' structure AI including associated storage. */
668extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
669
670/* Convert error return from getaddrinfo() to a string. */
671extern const char *gai_strerror (int __ecode) __THROW;
672
673/* Translate a socket address to a location and service name.
674
675 This function is a possible cancellation point and therefore not
676 marked with __THROW. */
677extern int getnameinfo (const struct sockaddr *__restrict __sa,
678 socklen_t __salen, char *__restrict __host,
679 socklen_t __hostlen, char *__restrict __serv,
680 socklen_t __servlen, int __flags);
681#endif /* POSIX */
682
683#ifdef __USE_GNU
684/* Enqueue ENT requests from the LIST. If MODE is GAI_WAIT wait until all
685 requests are handled. If WAIT is GAI_NOWAIT return immediately after
686 queueing the requests and signal completion according to SIG.
687
688 This function is not part of POSIX and therefore no official
689 cancellation point. But due to similarity with an POSIX interface
690 or due to the implementation it is a cancellation point and
691 therefore not marked with __THROW. */
692extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict_arr],
693 int __ent, struct sigevent *__restrict __sig);
694
695/* Suspend execution of the thread until at least one of the ENT requests
696 in LIST is handled. If TIMEOUT is not a null pointer it specifies the
697 longest time the function keeps waiting before returning with an error.
698
699 This function is not part of POSIX and therefore no official
700 cancellation point. But due to similarity with an POSIX interface
701 or due to the implementation it is a cancellation point and
702 therefore not marked with __THROW. */
703extern int gai_suspend (const struct gaicb *const __list[], int __ent,
704 const struct timespec *__timeout);
705
706/* Get the error status of the request REQ. */
707extern int gai_error (struct gaicb *__req) __THROW;
708
709/* Cancel the requests associated with GAICBP. */
710extern int gai_cancel (struct gaicb *__gaicbp) __THROW;
711#endif /* GNU */
712
713__END_DECLS
714
715#endif /* netdb.h */
716