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