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