OSDN Git Service

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