OSDN Git Service

- trim any trailing whitespace
[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 #ifdef __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 #ifdef __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 /* ruserpass - remote password check.
448    This function also exists in glibc but is undocumented */
449 extern int ruserpass(const char *host, const char **aname, const char **apass);
450
451
452 #ifdef __USE_BSD
453 /* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
454    The local user is LOCUSER, on the remote machine the command is
455    executed as REMUSER.  In *FD2P the descriptor to the socket for the
456    connection is returned.  The caller must have the right to use a
457    reserved port.  When the function returns *AHOST contains the
458    official host name.
459
460    This function is not part of POSIX and therefore no official
461    cancellation point.  But due to similarity with an POSIX interface
462    or due to the implementation it is a cancellation point and
463    therefore not marked with __THROW.  */
464 extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
465                  __const char *__restrict __locuser,
466                  __const char *__restrict __remuser,
467                  __const char *__restrict __cmd, int *__restrict __fd2p);
468
469 #if 0
470 /* FIXME */
471 /* This is the equivalent function where the protocol can be selected
472    and which therefore can be used for IPv6.
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.  */
478 extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
479                     __const char *__restrict __locuser,
480                     __const char *__restrict __remuser,
481                     __const char *__restrict __cmd, int *__restrict __fd2p,
482                     sa_family_t __af);
483 #endif
484
485 /* Call `rexecd' at port RPORT on remote machine *AHOST to execute
486    CMD.  The process runs at the remote machine using the ID of user
487    NAME whose cleartext password is PASSWD.  In *FD2P the descriptor
488    to the socket for the connection is returned.  When the function
489    returns *AHOST contains the official host name.
490
491    This function is not part of POSIX and therefore no official
492    cancellation point.  But due to similarity with an POSIX interface
493    or due to the implementation it is a cancellation point and
494    therefore not marked with __THROW.  */
495 extern int rexec (char **__restrict __ahost, int __rport,
496                   __const char *__restrict __name,
497                   __const char *__restrict __pass,
498                   __const char *__restrict __cmd, int *__restrict __fd2p);
499
500 /* This is the equivalent function where the protocol can be selected
501    and which therefore can be used for IPv6.
502
503    This function is not part of POSIX and therefore no official
504    cancellation point.  But due to similarity with an POSIX interface
505    or due to the implementation it is a cancellation point and
506    therefore not marked with __THROW.  */
507 extern int rexec_af (char **__restrict __ahost, int __rport,
508                      __const char *__restrict __name,
509                      __const char *__restrict __pass,
510                      __const char *__restrict __cmd, int *__restrict __fd2p,
511                      sa_family_t __af);
512
513 /* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
514    If SUSER is not zero the user tries to become superuser.  Return 0 if
515    it is possible.
516
517    This function is not part of POSIX and therefore no official
518    cancellation point.  But due to similarity with an POSIX interface
519    or due to the implementation it is a cancellation point and
520    therefore not marked with __THROW.  */
521 extern int ruserok (__const char *__rhost, int __suser,
522                     __const char *__remuser, __const char *__locuser);
523
524 #if 0
525 /* FIXME */
526 /* This is the equivalent function where the protocol can be selected
527    and which therefore can be used for IPv6.
528
529    This function is not part of POSIX and therefore no official
530    cancellation point.  But due to similarity with an POSIX interface
531    or due to the implementation it is a cancellation point and
532    therefore not marked with __THROW.  */
533 extern int ruserok_af (__const char *__rhost, int __suser,
534                        __const char *__remuser, __const char *__locuser,
535                        sa_family_t __af);
536 #endif
537
538 /* Try to allocate reserved port, returning a descriptor for a socket opened
539    at this port or -1 if unsuccessful.  The search for an available port
540    will start at ALPORT and continues with lower numbers.
541
542    This function is not part of POSIX and therefore no official
543    cancellation point.  But due to similarity with an POSIX interface
544    or due to the implementation it is a cancellation point and
545    therefore not marked with __THROW.  */
546 extern int rresvport (int *__alport);
547
548 #if 0
549 /* FIXME */
550 /* This is the equivalent function where the protocol can be selected
551    and which therefore can be used for IPv6.
552
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 rresvport_af (int *__alport, sa_family_t __af);
558 #endif
559 #endif
560
561
562 /* Extension from POSIX.1g.  */
563 #ifdef  __USE_POSIX
564 /* Structure to contain information about address of a service provider.  */
565 struct addrinfo
566 {
567   int ai_flags;                 /* Input flags.  */
568   int ai_family;                /* Protocol family for socket.  */
569   int ai_socktype;              /* Socket type.  */
570   int ai_protocol;              /* Protocol for socket.  */
571   socklen_t ai_addrlen;         /* Length of socket address.  */
572   struct sockaddr *ai_addr;     /* Socket address for socket.  */
573   char *ai_canonname;           /* Canonical name for service location.  */
574   struct addrinfo *ai_next;     /* Pointer to next in list.  */
575 };
576
577 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
578 # define AI_PASSIVE     0x0001  /* Socket address is intended for `bind'.  */
579 # define AI_CANONNAME   0x0002  /* Request for canonical name.  */
580 # define AI_NUMERICHOST 0x0004  /* Don't use name resolution.  */
581 # define AI_V4MAPPED    0x0008  /* IPv4 mapped addresses are acceptable.  */
582 # define AI_ALL         0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
583 # define AI_ADDRCONFIG  0x0020  /* Use configuration of this host to choose
584                                    returned address type..  */
585 # ifdef __USE_GNU
586 #  define AI_IDN        0x0040  /* IDN encode input (assuming it is encoded
587                                    in the current locale's character set)
588                                    before looking it up. */
589 #  define AI_CANONIDN   0x0080  /* Translate canonical name from IDN format. */
590 #  define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode
591                                             code points.  */
592 #  define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to
593                                                 STD3 rules.  */
594 # endif
595 # define AI_NUMERICSERV 0x0400  /* Don't use name resolution.  */
596
597 /* Error values for `getaddrinfo' function.  */
598 # define EAI_BADFLAGS     -1    /* Invalid value for `ai_flags' field.  */
599 # define EAI_NONAME       -2    /* NAME or SERVICE is unknown.  */
600 # define EAI_AGAIN        -3    /* Temporary failure in name resolution.  */
601 # define EAI_FAIL         -4    /* Non-recoverable failure in name res.  */
602 # define EAI_NODATA       -5    /* No address associated with NAME.  */
603 # define EAI_FAMILY       -6    /* `ai_family' not supported.  */
604 # define EAI_SOCKTYPE     -7    /* `ai_socktype' not supported.  */
605 # define EAI_SERVICE      -8    /* SERVICE not supported for `ai_socktype'.  */
606 # define EAI_ADDRFAMILY   -9    /* Address family for NAME not supported.  */
607 # define EAI_MEMORY       -10   /* Memory allocation failure.  */
608 # define EAI_SYSTEM       -11   /* System error returned in `errno'.  */
609 # define EAI_OVERFLOW     -12   /* Argument buffer overflow.  */
610 # ifdef __USE_GNU
611 #  define EAI_INPROGRESS  -100  /* Processing request in progress.  */
612 #  define EAI_CANCELED    -101  /* Request canceled.  */
613 #  define EAI_NOTCANCELED -102  /* Request not canceled.  */
614 #  define EAI_ALLDONE     -103  /* All requests done.  */
615 #  define EAI_INTR        -104  /* Interrupted by a signal.  */
616 #  define EAI_IDN_ENCODE  -105  /* IDN encoding failed.  */
617 # endif
618
619 # define NI_MAXHOST      1025
620 # define NI_MAXSERV      32
621
622 # define NI_NUMERICHOST 1       /* Don't try to look up hostname.  */
623 # define NI_NUMERICSERV 2       /* Don't convert port number to name.  */
624 # define NI_NOFQDN      4       /* Only return nodename portion.  */
625 # define NI_NAMEREQD    8       /* Don't return numeric addresses.  */
626 # define NI_DGRAM       16      /* Look up UDP service rather than TCP.  */
627 # ifdef __USE_GNU
628 #  define NI_IDN        32      /* Convert name from IDN format.  */
629 #  define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
630                                         code points.  */
631 #  define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to
632                                              STD3 rules.  */
633 # endif
634
635 /* Translate name of a service location and/or a service name to set of
636    socket addresses.
637
638    This function is a possible cancellation point and therefore not
639    marked with __THROW.  */
640 extern int getaddrinfo (__const char *__restrict __name,
641                         __const char *__restrict __service,
642                         __const struct addrinfo *__restrict __req,
643                         struct addrinfo **__restrict __pai);
644
645 /* Free `addrinfo' structure AI including associated storage.  */
646 extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
647
648 /* Convert error return from getaddrinfo() to a string.  */
649 extern __const char *gai_strerror (int __ecode) __THROW;
650
651 /* Translate a socket address to a location and service name.
652
653    This function is a possible cancellation point and therefore not
654    marked with __THROW.  */
655 extern int getnameinfo (__const struct sockaddr *__restrict __sa,
656                         socklen_t __salen, char *__restrict __host,
657                         socklen_t __hostlen, char *__restrict __serv,
658                         socklen_t __servlen, unsigned int __flags);
659 #endif  /* POSIX */
660
661 __END_DECLS
662
663 #endif  /* netdb.h */