Back to index

glibc  2.9
netdb.h
Go to the documentation of this file.
00001   /* Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /* All data returned by the network data base library are supplied in
00020    host order and returned in network order (suitable for use in
00021    system calls).  */
00022 
00023 #ifndef       _NETDB_H
00024 #define       _NETDB_H      1
00025 
00026 #include <features.h>
00027 
00028 #include <netinet/in.h>
00029 #include <stdint.h>
00030 #ifdef __USE_MISC
00031 /* This is necessary to make this include file properly replace the
00032    Sun version.  */
00033 # include <rpc/netdb.h>
00034 #endif
00035 
00036 #ifdef __USE_GNU
00037 # define __need_sigevent_t
00038 # include <bits/siginfo.h>
00039 # define __need_timespec
00040 # include <time.h>
00041 #endif
00042 
00043 #include <bits/netdb.h>
00044 
00045 /* Absolute file name for network data base files.  */
00046 #define       _PATH_HEQUIV         "/etc/hosts.equiv"
00047 #define       _PATH_HOSTS          "/etc/hosts"
00048 #define       _PATH_NETWORKS              "/etc/networks"
00049 #define       _PATH_NSSWITCH_CONF  "/etc/nsswitch.conf"
00050 #define       _PATH_PROTOCOLS             "/etc/protocols"
00051 #define       _PATH_SERVICES              "/etc/services"
00052 
00053 
00054 __BEGIN_DECLS
00055 
00056 /* Error status for non-reentrant lookup functions.
00057    We use a macro to access always the thread-specific `h_errno' variable.  */
00058 #define h_errno (*__h_errno_location ())
00059 
00060 /* Function to get address of global `h_errno' variable.  */
00061 extern int *__h_errno_location (void) __THROW __attribute__ ((__const__));
00062 
00063 
00064 /* Possible values left in `h_errno'.  */
00065 #define       HOST_NOT_FOUND       1      /* Authoritative Answer Host not found.  */
00066 #define       TRY_AGAIN     2      /* Non-Authoritative Host not found,
00067                                or SERVERFAIL.  */
00068 #define       NO_RECOVERY   3      /* Non recoverable errors, FORMERR, REFUSED,
00069                                NOTIMP.  */
00070 #define       NO_DATA              4      /* Valid name, no data record of requested
00071                                type.  */
00072 #if defined __USE_MISC || defined __USE_GNU
00073 # define NETDB_INTERNAL     -1     /* See errno.  */
00074 # define NETDB_SUCCESS      0      /* No problem.  */
00075 # define NO_ADDRESS  NO_DATA       /* No address, look for MX record.  */
00076 #endif
00077 
00078 #ifdef __USE_XOPEN2K
00079 /* Highest reserved Internet port number.  */
00080 # define IPPORT_RESERVED    1024
00081 #endif
00082 
00083 #ifdef __USE_GNU
00084 /* Scope delimiter for getaddrinfo(), getnameinfo().  */
00085 # define SCOPE_DELIMITER    '%'
00086 #endif
00087 
00088 #if defined __USE_MISC || defined __USE_GNU
00089 /* Print error indicated by `h_errno' variable on standard error.  STR
00090    if non-null is printed before the error string.  */
00091 extern void herror (__const char *__str) __THROW;
00092 
00093 /* Return string associated with error ERR_NUM.  */
00094 extern __const char *hstrerror (int __err_num) __THROW;
00095 #endif
00096 
00097 
00098 /* Description of data base entry for a single host.  */
00099 struct hostent
00100 {
00101   char *h_name;                    /* Official name of host.  */
00102   char **h_aliases;         /* Alias list.  */
00103   int h_addrtype;           /* Host address type.  */
00104   int h_length;                    /* Length of address.  */
00105   char **h_addr_list;              /* List of addresses from name server.  */
00106 #if defined __USE_MISC || defined __USE_GNU
00107 # define      h_addr h_addr_list[0] /* Address, for backward compatibility.*/
00108 #endif
00109 };
00110 
00111 /* Open host data base files and mark them as staying open even after
00112    a later search if STAY_OPEN is non-zero.
00113 
00114    This function is a possible cancellation point and therefore not
00115    marked with __THROW.  */
00116 extern void sethostent (int __stay_open);
00117 
00118 /* Close host data base files and clear `stay open' flag.
00119 
00120    This function is a possible cancellation point and therefore not
00121    marked with __THROW.  */
00122 extern void endhostent (void);
00123 
00124 /* Get next entry from host data base file.  Open data base if
00125    necessary.
00126 
00127    This function is a possible cancellation point and therefore not
00128    marked with __THROW.  */
00129 extern struct hostent *gethostent (void);
00130 
00131 /* Return entry from host data base which address match ADDR with
00132    length LEN and type TYPE.
00133 
00134    This function is a possible cancellation point and therefore not
00135    marked with __THROW.  */
00136 extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
00137                                   int __type);
00138 
00139 /* Return entry from host data base for host with NAME.
00140 
00141    This function is a possible cancellation point and therefore not
00142    marked with __THROW.  */
00143 extern struct hostent *gethostbyname (__const char *__name);
00144 
00145 #ifdef __USE_MISC
00146 /* Return entry from host data base for host with NAME.  AF must be
00147    set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
00148    for IPv6.
00149 
00150    This function is not part of POSIX and therefore no official
00151    cancellation point.  But due to similarity with an POSIX interface
00152    or due to the implementation it is a cancellation point and
00153    therefore not marked with __THROW.  */
00154 extern struct hostent *gethostbyname2 (__const char *__name, int __af);
00155 
00156 /* Reentrant versions of the functions above.  The additional
00157    arguments specify a buffer of BUFLEN starting at BUF.  The last
00158    argument is a pointer to a variable which gets the value which
00159    would be stored in the global variable `herrno' by the
00160    non-reentrant functions.
00161 
00162    These functions are not part of POSIX and therefore no official
00163    cancellation point.  But due to similarity with an POSIX interface
00164    or due to the implementation they are cancellation points and
00165    therefore not marked with __THROW.  */
00166 extern int gethostent_r (struct hostent *__restrict __result_buf,
00167                       char *__restrict __buf, size_t __buflen,
00168                       struct hostent **__restrict __result,
00169                       int *__restrict __h_errnop);
00170 
00171 extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
00172                          int __type,
00173                          struct hostent *__restrict __result_buf,
00174                          char *__restrict __buf, size_t __buflen,
00175                          struct hostent **__restrict __result,
00176                          int *__restrict __h_errnop);
00177 
00178 extern int gethostbyname_r (__const char *__restrict __name,
00179                          struct hostent *__restrict __result_buf,
00180                          char *__restrict __buf, size_t __buflen,
00181                          struct hostent **__restrict __result,
00182                          int *__restrict __h_errnop);
00183 
00184 extern int gethostbyname2_r (__const char *__restrict __name, int __af,
00185                           struct hostent *__restrict __result_buf,
00186                           char *__restrict __buf, size_t __buflen,
00187                           struct hostent **__restrict __result,
00188                           int *__restrict __h_errnop);
00189 #endif /* misc */
00190 
00191 
00192 /* Open network data base files and mark them as staying open even
00193    after a later search if STAY_OPEN is non-zero.
00194 
00195    This function is a possible cancellation point and therefore not
00196    marked with __THROW.  */
00197 extern void setnetent (int __stay_open);
00198 
00199 /* Close network data base files and clear `stay open' flag.
00200 
00201    This function is a possible cancellation point and therefore not
00202    marked with __THROW.  */
00203 extern void endnetent (void);
00204 
00205 /* Get next entry from network data base file.  Open data base if
00206    necessary.
00207 
00208    This function is a possible cancellation point and therefore not
00209    marked with __THROW.  */
00210 extern struct netent *getnetent (void);
00211 
00212 /* Return entry from network data base which address match NET and
00213    type TYPE.
00214 
00215    This function is a possible cancellation point and therefore not
00216    marked with __THROW.  */
00217 extern struct netent *getnetbyaddr (uint32_t __net, int __type);
00218 
00219 /* Return entry from network data base for network with NAME.
00220 
00221    This function is a possible cancellation point and therefore not
00222    marked with __THROW.  */
00223 extern struct netent *getnetbyname (__const char *__name);
00224 
00225 #ifdef __USE_MISC
00226 /* Reentrant versions of the functions above.  The additional
00227    arguments specify a buffer of BUFLEN starting at BUF.  The last
00228    argument is a pointer to a variable which gets the value which
00229    would be stored in the global variable `herrno' by the
00230    non-reentrant functions.
00231 
00232    These functions are not part of POSIX and therefore no official
00233    cancellation point.  But due to similarity with an POSIX interface
00234    or due to the implementation they are cancellation points and
00235    therefore not marked with __THROW.  */
00236 extern int getnetent_r (struct netent *__restrict __result_buf,
00237                      char *__restrict __buf, size_t __buflen,
00238                      struct netent **__restrict __result,
00239                      int *__restrict __h_errnop);
00240 
00241 extern int getnetbyaddr_r (uint32_t __net, int __type,
00242                         struct netent *__restrict __result_buf,
00243                         char *__restrict __buf, size_t __buflen,
00244                         struct netent **__restrict __result,
00245                         int *__restrict __h_errnop);
00246 
00247 extern int getnetbyname_r (__const char *__restrict __name,
00248                         struct netent *__restrict __result_buf,
00249                         char *__restrict __buf, size_t __buflen,
00250                         struct netent **__restrict __result,
00251                         int *__restrict __h_errnop);
00252 #endif /* misc */
00253 
00254 
00255 /* Description of data base entry for a single service.  */
00256 struct servent
00257 {
00258   char *s_name;                    /* Official service name.  */
00259   char **s_aliases;         /* Alias list.  */
00260   int s_port;               /* Port number.  */
00261   char *s_proto;            /* Protocol to use.  */
00262 };
00263 
00264 /* Open service data base files and mark them as staying open even
00265    after a later search if STAY_OPEN is non-zero.
00266 
00267    This function is a possible cancellation point and therefore not
00268    marked with __THROW.  */
00269 extern void setservent (int __stay_open);
00270 
00271 /* Close service data base files and clear `stay open' flag.
00272 
00273    This function is a possible cancellation point and therefore not
00274    marked with __THROW.  */
00275 extern void endservent (void);
00276 
00277 /* Get next entry from service data base file.  Open data base if
00278    necessary.
00279 
00280    This function is a possible cancellation point and therefore not
00281    marked with __THROW.  */
00282 extern struct servent *getservent (void);
00283 
00284 /* Return entry from network data base for network with NAME and
00285    protocol PROTO.
00286 
00287    This function is a possible cancellation point and therefore not
00288    marked with __THROW.  */
00289 extern struct servent *getservbyname (__const char *__name,
00290                                   __const char *__proto);
00291 
00292 /* Return entry from service data base which matches port PORT and
00293    protocol PROTO.
00294 
00295    This function is a possible cancellation point and therefore not
00296    marked with __THROW.  */
00297 extern struct servent *getservbyport (int __port, __const char *__proto);
00298 
00299 
00300 #ifdef __USE_MISC
00301 /* Reentrant versions of the functions above.  The additional
00302    arguments specify a buffer of BUFLEN starting at BUF.
00303 
00304    These functions are not part of POSIX and therefore no official
00305    cancellation point.  But due to similarity with an POSIX interface
00306    or due to the implementation they are cancellation points and
00307    therefore not marked with __THROW.  */
00308 extern int getservent_r (struct servent *__restrict __result_buf,
00309                       char *__restrict __buf, size_t __buflen,
00310                       struct servent **__restrict __result);
00311 
00312 extern int getservbyname_r (__const char *__restrict __name,
00313                          __const char *__restrict __proto,
00314                          struct servent *__restrict __result_buf,
00315                          char *__restrict __buf, size_t __buflen,
00316                          struct servent **__restrict __result);
00317 
00318 extern int getservbyport_r (int __port, __const char *__restrict __proto,
00319                          struct servent *__restrict __result_buf,
00320                          char *__restrict __buf, size_t __buflen,
00321                          struct servent **__restrict __result);
00322 #endif /* misc */
00323 
00324 
00325 /* Description of data base entry for a single service.  */
00326 struct protoent
00327 {
00328   char *p_name;                    /* Official protocol name.  */
00329   char **p_aliases;         /* Alias list.  */
00330   int p_proto;                     /* Protocol number.  */
00331 };
00332 
00333 /* Open protocol data base files and mark them as staying open even
00334    after a later search if STAY_OPEN is non-zero.
00335 
00336    This function is a possible cancellation point and therefore not
00337    marked with __THROW.  */
00338 extern void setprotoent (int __stay_open);
00339 
00340 /* Close protocol data base files and clear `stay open' flag.
00341 
00342    This function is a possible cancellation point and therefore not
00343    marked with __THROW.  */
00344 extern void endprotoent (void);
00345 
00346 /* Get next entry from protocol data base file.  Open data base if
00347    necessary.
00348 
00349    This function is a possible cancellation point and therefore not
00350    marked with __THROW.  */
00351 extern struct protoent *getprotoent (void);
00352 
00353 /* Return entry from protocol data base for network with NAME.
00354 
00355    This function is a possible cancellation point and therefore not
00356    marked with __THROW.  */
00357 extern struct protoent *getprotobyname (__const char *__name);
00358 
00359 /* Return entry from protocol data base which number is PROTO.
00360 
00361    This function is a possible cancellation point and therefore not
00362    marked with __THROW.  */
00363 extern struct protoent *getprotobynumber (int __proto);
00364 
00365 
00366 #ifdef __USE_MISC
00367 /* Reentrant versions of the functions above.  The additional
00368    arguments specify a buffer of BUFLEN starting at BUF.
00369 
00370    These functions are not part of POSIX and therefore no official
00371    cancellation point.  But due to similarity with an POSIX interface
00372    or due to the implementation they are cancellation points and
00373    therefore not marked with __THROW.  */
00374 extern int getprotoent_r (struct protoent *__restrict __result_buf,
00375                        char *__restrict __buf, size_t __buflen,
00376                        struct protoent **__restrict __result);
00377 
00378 extern int getprotobyname_r (__const char *__restrict __name,
00379                           struct protoent *__restrict __result_buf,
00380                           char *__restrict __buf, size_t __buflen,
00381                           struct protoent **__restrict __result);
00382 
00383 extern int getprotobynumber_r (int __proto,
00384                             struct protoent *__restrict __result_buf,
00385                             char *__restrict __buf, size_t __buflen,
00386                             struct protoent **__restrict __result);
00387 
00388 
00389 /* Establish network group NETGROUP for enumeration.
00390 
00391    This function is not part of POSIX and therefore no official
00392    cancellation point.  But due to similarity with an POSIX interface
00393    or due to the implementation it is a cancellation point and
00394    therefore not marked with __THROW.  */
00395 extern int setnetgrent (__const char *__netgroup);
00396 
00397 /* Free all space allocated by previous `setnetgrent' call.
00398 
00399    This function is not part of POSIX and therefore no official
00400    cancellation point.  But due to similarity with an POSIX interface
00401    or due to the implementation it is a cancellation point and
00402    therefore not marked with __THROW.  */
00403 extern void endnetgrent (void);
00404 
00405 /* Get next member of netgroup established by last `setnetgrent' call
00406    and return pointers to elements in HOSTP, USERP, and DOMAINP.
00407 
00408    This function is not part of POSIX and therefore no official
00409    cancellation point.  But due to similarity with an POSIX interface
00410    or due to the implementation it is a cancellation point and
00411    therefore not marked with __THROW.  */
00412 extern int getnetgrent (char **__restrict __hostp,
00413                      char **__restrict __userp,
00414                      char **__restrict __domainp);
00415 
00416 
00417 /* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
00418 
00419    This function is not part of POSIX and therefore no official
00420    cancellation point.  But due to similarity with an POSIX interface
00421    or due to the implementation it is a cancellation point and
00422    therefore not marked with __THROW.  */
00423 extern int innetgr (__const char *__netgroup, __const char *__host,
00424                   __const char *__user, __const char *domain);
00425 
00426 /* Reentrant version of `getnetgrent' where result is placed in BUFFER.
00427 
00428    This function is not part of POSIX and therefore no official
00429    cancellation point.  But due to similarity with an POSIX interface
00430    or due to the implementation it is a cancellation point and
00431    therefore not marked with __THROW.  */
00432 extern int getnetgrent_r (char **__restrict __hostp,
00433                        char **__restrict __userp,
00434                        char **__restrict __domainp,
00435                        char *__restrict __buffer, size_t __buflen);
00436 #endif /* misc */
00437 
00438 
00439 #ifdef __USE_BSD
00440 /* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
00441    The local user is LOCUSER, on the remote machine the command is
00442    executed as REMUSER.  In *FD2P the descriptor to the socket for the
00443    connection is returned.  The caller must have the right to use a
00444    reserved port.  When the function returns *AHOST contains the
00445    official host name.
00446 
00447    This function is not part of POSIX and therefore no official
00448    cancellation point.  But due to similarity with an POSIX interface
00449    or due to the implementation it is a cancellation point and
00450    therefore not marked with __THROW.  */
00451 extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
00452                __const char *__restrict __locuser,
00453                __const char *__restrict __remuser,
00454                __const char *__restrict __cmd, int *__restrict __fd2p);
00455 
00456 /* This is the equivalent function where the protocol can be selected
00457    and which therefore can be used for IPv6.
00458 
00459    This function is not part of POSIX and therefore no official
00460    cancellation point.  But due to similarity with an POSIX interface
00461    or due to the implementation it is a cancellation point and
00462    therefore not marked with __THROW.  */
00463 extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport,
00464                   __const char *__restrict __locuser,
00465                   __const char *__restrict __remuser,
00466                   __const char *__restrict __cmd, int *__restrict __fd2p,
00467                   sa_family_t __af);
00468 
00469 /* Call `rexecd' at port RPORT on remote machine *AHOST to execute
00470    CMD.  The process runs at the remote machine using the ID of user
00471    NAME whose cleartext password is PASSWD.  In *FD2P the descriptor
00472    to the socket for the connection is returned.  When the function
00473    returns *AHOST contains the official host name.
00474 
00475    This function is not part of POSIX and therefore no official
00476    cancellation point.  But due to similarity with an POSIX interface
00477    or due to the implementation it is a cancellation point and
00478    therefore not marked with __THROW.  */
00479 extern int rexec (char **__restrict __ahost, int __rport,
00480                 __const char *__restrict __name,
00481                 __const char *__restrict __pass,
00482                 __const char *__restrict __cmd, int *__restrict __fd2p);
00483 
00484 /* This is the equivalent function where the protocol can be selected
00485    and which therefore can be used for IPv6.
00486 
00487    This function is not part of POSIX and therefore no official
00488    cancellation point.  But due to similarity with an POSIX interface
00489    or due to the implementation it is a cancellation point and
00490    therefore not marked with __THROW.  */
00491 extern int rexec_af (char **__restrict __ahost, int __rport,
00492                    __const char *__restrict __name,
00493                    __const char *__restrict __pass,
00494                    __const char *__restrict __cmd, int *__restrict __fd2p,
00495                    sa_family_t __af);
00496 
00497 /* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
00498    If SUSER is not zero the user tries to become superuser.  Return 0 if
00499    it is possible.
00500 
00501    This function is not part of POSIX and therefore no official
00502    cancellation point.  But due to similarity with an POSIX interface
00503    or due to the implementation it is a cancellation point and
00504    therefore not marked with __THROW.  */
00505 extern int ruserok (__const char *__rhost, int __suser,
00506                   __const char *__remuser, __const char *__locuser);
00507 
00508 /* This is the equivalent function where the protocol can be selected
00509    and which therefore can be used for IPv6.
00510 
00511    This function is not part of POSIX and therefore no official
00512    cancellation point.  But due to similarity with an POSIX interface
00513    or due to the implementation it is a cancellation point and
00514    therefore not marked with __THROW.  */
00515 extern int ruserok_af (__const char *__rhost, int __suser,
00516                      __const char *__remuser, __const char *__locuser,
00517                      sa_family_t __af);
00518 
00519 /* Try to allocate reserved port, returning a descriptor for a socket opened
00520    at this port or -1 if unsuccessful.  The search for an available port
00521    will start at ALPORT and continues with lower numbers.
00522 
00523    This function is not part of POSIX and therefore no official
00524    cancellation point.  But due to similarity with an POSIX interface
00525    or due to the implementation it is a cancellation point and
00526    therefore not marked with __THROW.  */
00527 extern int rresvport (int *__alport);
00528 
00529 /* This is the equivalent function where the protocol can be selected
00530    and which therefore can be used for IPv6.
00531 
00532    This function is not part of POSIX and therefore no official
00533    cancellation point.  But due to similarity with an POSIX interface
00534    or due to the implementation it is a cancellation point and
00535    therefore not marked with __THROW.  */
00536 extern int rresvport_af (int *__alport, sa_family_t __af);
00537 #endif
00538 
00539 
00540 /* Extension from POSIX.1g.  */
00541 #ifdef __USE_POSIX
00542 /* Structure to contain information about address of a service provider.  */
00543 struct addrinfo
00544 {
00545   int ai_flags;                    /* Input flags.  */
00546   int ai_family;            /* Protocol family for socket.  */
00547   int ai_socktype;          /* Socket type.  */
00548   int ai_protocol;          /* Protocol for socket.  */
00549   socklen_t ai_addrlen;            /* Length of socket address.  */
00550   struct sockaddr *ai_addr; /* Socket address for socket.  */
00551   char *ai_canonname;              /* Canonical name for service location.  */
00552   struct addrinfo *ai_next; /* Pointer to next in list.  */
00553 };
00554 
00555 # ifdef __USE_GNU
00556 /* Structure used as control block for asynchronous lookup.  */
00557 struct gaicb
00558 {
00559   const char *ar_name;             /* Name to look up.  */
00560   const char *ar_service;   /* Service name.  */
00561   const struct addrinfo *ar_request; /* Additional request specification.  */
00562   struct addrinfo *ar_result;      /* Pointer to result.  */
00563   /* The following are internal elements.  */
00564   int __return;
00565   int __unused[5];
00566 };
00567 
00568 /* Lookup mode.  */
00569 #  define GAI_WAIT   0
00570 #  define GAI_NOWAIT 1
00571 # endif
00572 
00573 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
00574 # define AI_PASSIVE  0x0001 /* Socket address is intended for `bind'.  */
00575 # define AI_CANONNAME       0x0002 /* Request for canonical name.  */
00576 # define AI_NUMERICHOST     0x0004 /* Don't use name resolution.  */
00577 # define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable.  */
00578 # define AI_ALL             0x0010 /* Return IPv4 mapped and IPv6 addresses.  */
00579 # define AI_ADDRCONFIG      0x0020 /* Use configuration of this host to choose
00580                                returned address type..  */
00581 # ifdef __USE_GNU
00582 #  define AI_IDN     0x0040 /* IDN encode input (assuming it is encoded
00583                                in the current locale's character set)
00584                                before looking it up. */
00585 #  define AI_CANONIDN       0x0080 /* Translate canonical name from IDN format. */
00586 #  define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode
00587                                        code points.  */
00588 #  define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to
00589                                           STD3 rules.  */
00590 # endif
00591 # define AI_NUMERICSERV     0x0400 /* Don't use name resolution.  */
00592 
00593 /* Error values for `getaddrinfo' function.  */
00594 # define EAI_BADFLAGS         -1   /* Invalid value for `ai_flags' field.  */
00595 # define EAI_NONAME    -2   /* NAME or SERVICE is unknown.  */
00596 # define EAI_AGAIN     -3   /* Temporary failure in name resolution.  */
00597 # define EAI_FAIL      -4   /* Non-recoverable failure in name res.  */
00598 # define EAI_FAMILY    -6   /* `ai_family' not supported.  */
00599 # define EAI_SOCKTYPE         -7   /* `ai_socktype' not supported.  */
00600 # define EAI_SERVICE   -8   /* SERVICE not supported for `ai_socktype'.  */
00601 # define EAI_MEMORY    -10  /* Memory allocation failure.  */
00602 # define EAI_SYSTEM    -11  /* System error returned in `errno'.  */
00603 # define EAI_OVERFLOW         -12  /* Argument buffer overflow.  */
00604 # ifdef __USE_GNU
00605 #  define EAI_NODATA   -5   /* No address associated with NAME.  */
00606 #  define EAI_ADDRFAMILY  -9       /* Address family for NAME not supported.  */
00607 #  define EAI_INPROGRESS  -100     /* Processing request in progress.  */
00608 #  define EAI_CANCELED        -101 /* Request canceled.  */
00609 #  define EAI_NOTCANCELED -102     /* Request not canceled.  */
00610 #  define EAI_ALLDONE         -103 /* All requests done.  */
00611 #  define EAI_INTR     -104 /* Interrupted by a signal.  */
00612 #  define EAI_IDN_ENCODE  -105     /* IDN encoding failed.  */
00613 # endif
00614 
00615 # ifdef __USE_MISC
00616 #  define NI_MAXHOST      1025
00617 #  define NI_MAXSERV      32
00618 # endif
00619 
00620 # define NI_NUMERICHOST     1      /* Don't try to look up hostname.  */
00621 # define NI_NUMERICSERV 2   /* Don't convert port number to name.  */
00622 # define NI_NOFQDN   4      /* Only return nodename portion.  */
00623 # define NI_NAMEREQD 8      /* Don't return numeric addresses.  */
00624 # define NI_DGRAM    16     /* Look up UDP service rather than TCP.  */
00625 # ifdef __USE_GNU
00626 #  define NI_IDN     32     /* Convert name from IDN format.  */
00627 #  define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode
00628                                    code points.  */
00629 #  define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to
00630                                         STD3 rules.  */
00631 # endif
00632 
00633 /* Translate name of a service location and/or a service name to set of
00634    socket addresses.
00635 
00636    This function is a possible cancellation point and therefore not
00637    marked with __THROW.  */
00638 extern int getaddrinfo (__const char *__restrict __name,
00639                      __const char *__restrict __service,
00640                      __const struct addrinfo *__restrict __req,
00641                      struct addrinfo **__restrict __pai);
00642 
00643 /* Free `addrinfo' structure AI including associated storage.  */
00644 extern void freeaddrinfo (struct addrinfo *__ai) __THROW;
00645 
00646 /* Convert error return from getaddrinfo() to a string.  */
00647 extern __const char *gai_strerror (int __ecode) __THROW;
00648 
00649 /* Translate a socket address to a location and service name.
00650 
00651    This function is a possible cancellation point and therefore not
00652    marked with __THROW.  */
00653 extern int getnameinfo (__const struct sockaddr *__restrict __sa,
00654                      socklen_t __salen, char *__restrict __host,
00655                      socklen_t __hostlen, char *__restrict __serv,
00656                      socklen_t __servlen, unsigned int __flags);
00657 #endif /* POSIX */
00658 
00659 #ifdef __USE_GNU
00660 /* Enqueue ENT requests from the LIST.  If MODE is GAI_WAIT wait until all
00661    requests are handled.  If WAIT is GAI_NOWAIT return immediately after
00662    queueing the requests and signal completion according to SIG.
00663 
00664    This function is not part of POSIX and therefore no official
00665    cancellation point.  But due to similarity with an POSIX interface
00666    or due to the implementation it is a cancellation point and
00667    therefore not marked with __THROW.  */
00668 extern int getaddrinfo_a (int __mode, struct gaicb *__list[__restrict_arr],
00669                        int __ent, struct sigevent *__restrict __sig);
00670 
00671 /* Suspend execution of the thread until at least one of the ENT requests
00672    in LIST is handled.  If TIMEOUT is not a null pointer it specifies the
00673    longest time the function keeps waiting before returning with an error.
00674 
00675    This function is not part of POSIX and therefore no official
00676    cancellation point.  But due to similarity with an POSIX interface
00677    or due to the implementation it is a cancellation point and
00678    therefore not marked with __THROW.  */
00679 extern int gai_suspend (__const struct gaicb *__const __list[], int __ent,
00680                      __const struct timespec *__timeout);
00681 
00682 /* Get the error status of the request REQ.  */
00683 extern int gai_error (struct gaicb *__req) __THROW;
00684 
00685 /* Cancel the requests associated with GAICBP.  */
00686 extern int gai_cancel (struct gaicb *__gaicbp) __THROW;
00687 #endif /* GNU */
00688 
00689 __END_DECLS
00690 
00691 #endif /* netdb.h */