OSDN Git Service

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