OSDN Git Service

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