OSDN Git Service

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