OSDN Git Service

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