OSDN Git Service

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