(linenum→info "unix/slp.c:2238")

glibc/2.7/resolv/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: #ifdef __USE_MISC
   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: 
   63: 
   64: /* Possible values left in `h_errno'.  */
   65: #define NETDB_INTERNAL  -1       /* See errno.  */
   66: #define NETDB_SUCCESS   0 /* No problem.  */
   67: #define HOST_NOT_FOUND  1        /* Authoritative Answer Host not found.  */
   68: #define TRY_AGAIN       2     /* Non-Authoritative Host not found,
   69:                                    or SERVERFAIL.  */
   70: #define NO_RECOVERY     3   /* Non recoverable errors, FORMERR, REFUSED,
   71:                                    NOTIMP.  */
   72: #define NO_DATA         4      /* Valid name, no data record of requested
   73:                                    type.  */
   74: #define NO_ADDRESS      NO_DATA      /* No address, look for MX record.  */
   75: 
   76: #ifdef __USE_XOPEN2K
   77: /* Highest reserved Internet port number.  */
   78: # define IPPORT_RESERVED        1024
   79: #endif
   80: 
   81: #ifdef __USE_GNU
   82: /* Scope delimiter for getaddrinfo(), getnameinfo().  */
   83: # define SCOPE_DELIMITER        '%'
   84: #endif
   85: 
   86: /* Print error indicated by `h_errno' variable on standard error.  STR
   87:    if non-null is printed before the error string.  */
   88: extern void herror (__const char *__str) __THROW;
   89: 
   90: /* Return string associated with error ERR_NUM.  */
   91: extern __const char *hstrerror (int __err_num) __THROW;
   92: 
   93: 
   94: 
   95: /* Description of data base entry for a single host.  */
   96: struct hostent
   97: {
   98:   char *h_name;                 /* Official name of host.  */
   99:   char **h_aliases;             /* Alias list.  */
  100:   int h_addrtype;               /* Host address type.  */
  101:   int h_length;                 /* Length of address.  */
  102:   char **h_addr_list;           /* List of addresses from name server.  */
  103: #define h_addr  h_addr_list[0]   /* Address, for backward compatibility.  */
  104: };
  105: 
  106: /* Open host data base files and mark them as staying open even after
  107:    a later search if STAY_OPEN is non-zero.
  108: 
  109:    This function is a possible cancellation point and therefore not
  110:    marked with __THROW.  */
  111: extern void sethostent (int __stay_open);
  112: 
  113: /* Close host data base files and clear `stay open' flag.
  114: 
  115:    This function is a possible cancellation point and therefore not
  116:    marked with __THROW.  */
  117: extern void endhostent (void);
  118: 
  119: /* Get next entry from host data base file.  Open data base if
  120:    necessary.
  121: 
  122:    This function is a possible cancellation point and therefore not
  123:    marked with __THROW.  */
  124: extern struct hostent *gethostent (void);
  125: 
  126: /* Return entry from host data base which address match ADDR with
  127:    length LEN and type TYPE.
  128: 
  129:    This function is a possible cancellation point and therefore not
  130:    marked with __THROW.  */
  131: extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len,
  132:                                       int __type);
  133: 
  134: /* Return entry from host data base for host with NAME.
  135: 
  136:    This function is a possible cancellation point and therefore not
  137:    marked with __THROW.  */
  138: extern struct hostent *gethostbyname (__const char *__name);
  139: 
  140: #ifdef __USE_MISC
  141: /* Return entry from host data base for host with NAME.  AF must be
  142:    set to the address type which is `AF_INET' for IPv4 or `AF_INET6'
  143:    for IPv6.
  144: 
  145:    This function is not part of POSIX and therefore no official
  146:    cancellation point.  But due to similarity with an POSIX interface
  147:    or due to the implementation it is a cancellation point and
  148:    therefore not marked with __THROW.  */
  149: extern struct hostent *gethostbyname2 (__const char *__name, int __af);
  150: 
  151: /* Reentrant versions of the functions above.  The additional
  152:    arguments specify a buffer of BUFLEN starting at BUF.  The last
  153:    argument is a pointer to a variable which gets the value which
  154:    would be stored in the global variable `herrno' by the
  155:    non-reentrant functions.
  156: 
  157:    These functions are not part of POSIX and therefore no official
  158:    cancellation point.  But due to similarity with an POSIX interface
  159:    or due to the implementation they are cancellation points and
  160:    therefore not marked with __THROW.  */
  161: extern int gethostent_r (struct hostent *__restrict __result_buf,
  162:                          char *__restrict __buf, size_t __buflen,
  163:                          struct hostent **__restrict __result,
  164:                          int *__restrict __h_errnop);
  165: 
  166: extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len,
  167:                             int __type,
  168:                             struct hostent *__restrict __result_buf,
  169:                             char *__restrict __buf, size_t __buflen,
  170:                             struct hostent **__restrict __result,
  171:                             int *__restrict __h_errnop);
  172: 
  173: extern int gethostbyname_r (__const char *__restrict __name,
  174:                             struct hostent *__restrict __result_buf,
  175:                             char *__restrict __buf, size_t __buflen,
  176:                             struct hostent **__restrict __result,
  177:                             int *__restrict __h_errnop);
  178: 
  179: extern int gethostbyname2_r (__const char *__restrict __name, int __af,
  180:                              struct hostent *__restrict __result_buf,
  181:                              char *__restrict __buf, size_t __buflen,
  182:                              struct hostent **__restrict __result,
  183:                              int *__restrict __h_errnop);
  184: #endif  /* misc */
  185: 
  186: 
  187: /* Open network data base files and mark them as staying open even
  188:    after a later search if STAY_OPEN is non-zero.
  189: 
  190:    This function is a possible cancellation point and therefore not
  191:    marked with __THROW.  */
  192: extern void setnetent (int __stay_open);
  193: 
  194: /* Close network data base files and clear `stay open' flag.
  195: 
  196:    This function is a possible cancellation point and therefore not
  197:    marked with __THROW.  */
  198: extern void endnetent (void);
  199: 
  200: /* Get next entry from network data base file.  Open data base if
  201:    necessary.
  202: 
  203:    This function is a possible cancellation point and therefore not
  204:    marked with __THROW.  */
  205: extern struct netent *getnetent (void);
  206: 
  207: /* Return entry from network data base which address match NET and
  208:    type TYPE.
  209: 
  210:    This function is a possible cancellation point and therefore not
  211:    marked with __THROW.  */
  212: extern struct netent *getnetbyaddr (uint32_t __net, int __type);
  213: 
  214: /* Return entry from network data base for network with NAME.
  215: 
  216:    This function is a possible cancellation point and therefore not
  217:    marked with __THROW.  */
  218: extern struct netent *getnetbyname (__const char *__name);
  219: 
  220: #ifdef  __USE_MISC
  221: /* Reentrant versions of the functions above.  The additional
  222:    arguments specify a buffer of BUFLEN starting at BUF.  The last
  223:    argument is a pointer to a variable which gets the value which
  224:    would be stored in the global variable `herrno' by the
  225:    non-reentrant functions.
  226: 
  227:    These functions are not part of POSIX and therefore no official
  228:    cancellation point.  But due to similarity with an POSIX interface
  229:    or due to the implementation they are cancellation points and
  230:    therefore not marked with __THROW.  */
  231: extern int getnetent_r (struct netent *__restrict __result_buf,
  232:                         char *__restrict __buf, size_t __buflen,
  233:                         struct netent **__restrict __result,
  234:                         int *__restrict __h_errnop);
  235: 
  236: extern int getnetbyaddr_r (uint32_t __net, int __type,
  237:                            struct netent *__restrict __result_buf,
  238:                            char *__restrict __buf, size_t __buflen,
  239:                            struct netent **__restrict __result,
  240:                            int *__restrict __h_errnop);
  241: 
  242: extern int getnetbyname_r (__const char *__restrict __name,
  243:                            struct netent *__restrict __result_buf,
  244:                            char *__restrict __buf, size_t __buflen,
  245:                            struct netent **__restrict __result,
  246:                            int *__restrict __h_errnop);
  247: #endif  /* misc */
  248: 
  249: 
  250: /* Description of data base entry for a single service.  */
  251: struct servent
  252: {
  253:   char *s_name;                 /* Official service name.  */
  254:   char **s_aliases;             /* Alias list.  */
  255:   int s_port;                   /* Port number.  */
  256:   char *s_proto;                /* Protocol to use.  */
  257: };
  258: 
  259: /* Open service data base files and mark them as staying open even
  260:    after a later search if STAY_OPEN is non-zero.
  261: 
  262:    This function is a possible cancellation point and therefore not
  263:    marked with __THROW.  */
  264: extern void setservent (int __stay_open);
  265: 
  266: /* Close service data base files and clear `stay open' flag.
  267: 
  268:    This function is a possible cancellation point and therefore not
  269:    marked with __THROW.  */
  270: extern void endservent (void);
  271: 
  272: /* Get next entry from service data base file.  Open data base if
  273:    necessary.
  274: 
  275:    This function is a possible cancellation point and therefore not
  276:    marked with __THROW.  */
  277: extern struct servent *getservent (void);
  278: 
  279: /* Return entry from network data base for network with NAME and
  280:    protocol PROTO.
  281: 
  282:    This function is a possible cancellation point and therefore not
  283:    marked with __THROW.  */
  284: extern struct servent *getservbyname (__const char *__name,
  285:                                       __const char *__proto);
  286: 
  287: /* Return entry from service data base which matches port PORT and
  288:    protocol PROTO.
  289: 
  290:    This function is a possible cancellation point and therefore not
  291:    marked with __THROW.  */
  292: extern struct servent *getservbyport (int __port, __const char *__proto);
  293: 
  294: 
  295: #ifdef  __USE_MISC
  296: /* Reentrant versions of the functions above.  The additional
  297:    arguments specify a buffer of BUFLEN starting at BUF.
  298: 
  299:    These functions are not part of POSIX and therefore no official
  300:    cancellation point.  But due to similarity with an POSIX interface
  301:    or due to the implementation they are cancellation points and
  302:    therefore not marked with __THROW.  */
  303: extern int getservent_r (struct servent *__restrict __result_buf,
  304:                          char *__restrict __buf, size_t __buflen,
  305:                          struct servent **__restrict __result);
  306: 
  307: extern int getservbyname_r (__const char *__restrict __name,
  308:                             __const char *__restrict __proto,
  309:                             struct servent *__restrict __result_buf,
  310:                             char *__restrict __buf, size_t __buflen,
  311:                             struct servent **__restrict __result);
  312: 
  313: extern int getservbyport_r (int __port, __const char *__restrict __proto,
  314:                             struct servent *__restrict __result_buf,
  315:                             char *__restrict __buf, size_t __buflen,
  316:                             struct servent **__restrict __result);
  317: #endif  /* misc */
  318: 
  319: 
  320: /* Description of data base entry for a single service.  */
  321: struct protoent
  322: {
  323:   char *p_name;                 /* Official protocol name.  */
  324:   char **p_aliases;             /* Alias list.  */
  325:   int p_proto;                  /* Protocol number.  */
  326: };
  327: 
  328: /* Open protocol data base files and mark them as staying open even
  329:    after a later search if STAY_OPEN is non-zero.
  330: 
  331:    This function is a possible cancellation point and therefore not
  332:    marked with __THROW.  */
  333: extern void setprotoent (int __stay_open);
  334: 
  335: /* Close protocol data base files and clear `stay open' flag.
  336: 
  337:    This function is a possible cancellation point and therefore not
  338:    marked with __THROW.  */
  339: extern void endprotoent (void);
  340: 
  341: /* Get next entry from protocol data base file.  Open data base if
  342:    necessary.
  343: 
  344:    This function is a possible cancellation point and therefore not
  345:    marked with __THROW.  */
  346: extern struct protoent *getprotoent (void);
  347: 
  348: /* Return entry from protocol data base for network with NAME.
  349: 
  350:    This function is a possible cancellation point and therefore not
  351:    marked with __THROW.  */
  352: extern struct protoent *getprotobyname (__const char *__name);
  353: 
  354: /* Return entry from protocol data base which number is PROTO.
  355: 
  356:    This function is a possible cancellation point and therefore not
  357:    marked with __THROW.  */
  358: extern struct protoent *getprotobynumber (int __proto);
  359: 
  360: 
  361: #ifdef  __USE_MISC
  362: /* Reentrant versions of the functions above.  The additional
  363:    arguments specify a buffer of BUFLEN starting at BUF.
  364: 
  365:    These functions are not part of POSIX and therefore no official
  366:    cancellation point.  But due to similarity with an POSIX interface
  367:    or due to the implementation they are cancellation points and
  368:    therefore not marked with __THROW.  */
  369: extern int getprotoent_r (struct protoent *__restrict __result_buf,
  370:                           char *__restrict __buf, size_t __buflen,
  371:                           struct protoent **__restrict __result);
  372: 
  373: extern int getprotobyname_r (__const char *__restrict __name,
  374:                              struct protoent *__restrict __result_buf,
  375:                              char *__restrict __buf, size_t __buflen,
  376:                              struct protoent **__restrict __result);
  377: 
  378: extern int getprotobynumber_r (int __proto,
  379:                                struct protoent *__restrict __result_buf,
  380:                                char *__restrict __buf, size_t __buflen,
  381:                                struct protoent **__restrict __result);
  382: 
  383: 
  384: /* Establish network group NETGROUP for enumeration.
  385: 
  386:    This function is not part of POSIX and therefore no official
  387:    cancellation point.  But due to similarity with an POSIX interface
  388:    or due to the implementation it is a cancellation point and
  389:    therefore not marked with __THROW.  */
  390: extern int setnetgrent (__const char *__netgroup);
  391: 
  392: /* Free all space allocated by previous `setnetgrent' call.
  393: 
  394:    This function is not part of POSIX and therefore no official
  395:    cancellation point.  But due to similarity with an POSIX interface
  396:    or due to the implementation it is a cancellation point and
  397:    therefore not marked with __THROW.  */
  398: extern void endnetgrent (void);
  399: 
  400: /* Get next member of netgroup established by last `setnetgrent' call
  401:    and return pointers to elements in HOSTP, USERP, and DOMAINP.
  402: 
  403:    This function is not part of POSIX and therefore no official
  404:    cancellation point.  But due to similarity with an POSIX interface
  405:    or due to the implementation it is a cancellation point and
  406:    therefore not marked with __THROW.  */
  407: extern int getnetgrent (char **__restrict __hostp,
  408:                         char **__restrict __userp,
  409:                         char **__restrict __domainp);
  410: 
  411: 
  412: /* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN).
  413: 
  414:    This function is not part of POSIX and therefore no official
  415:    cancellation point.  But due to similarity with an POSIX interface
  416:    or due to the implementation it is a cancellation point and
  417:    therefore not marked with __THROW.  */
  418: extern int innetgr (__const char *__netgroup, __const char *__host,
  419:                     __const char *__user, __const char *domain);
  420: 
  421: /* Reentrant version of `getnetgrent' where result is placed in BUFFER.
  422: 
  423:    This function is not part of POSIX and therefore no official
  424:    cancellation point.  But due to similarity with an POSIX interface
  425:    or due to the implementation it is a cancellation point and
  426:    therefore not marked with __THROW.  */
  427: extern int getnetgrent_r (char **__restrict __hostp,
  428:                           char **__restrict __userp,
  429:                           char **__restrict __domainp,
  430:                           char *__restrict __buffer, size_t __buflen);
  431: #endif  /* misc */
  432: 
  433: 
  434: #ifdef __USE_BSD
  435: /* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD.
  436:    The local user is LOCUSER, on the remote machine the command is
  437:    executed as REMUSER.  In *FD2P the descriptor to the socket for the
  438:    connection is returned.  The caller must have the right to use a
  439:    reserved port.  When the function returns *AHOST contains the
  440:    official host name.
  441: 
  442:    This function is not part of POSIX and therefore no official
  443:    cancellation point.  But due to similarity with an POSIX interface
  444:    or due to the implementation it is a cancellation point and
  445:    therefore not marked with __THROW.  */
  446: extern int rcmd (char **__restrict __ahost, unsigned short int __rport,
  447:                  __const char *__restrict __locuser,
  448:                  __const char *__restrict __remuser,
  449:                  __const char *__restrict __cmd, int *__restrict __fd2p);
  450: 
  451: /* This is the equivalent function where the protocol can be selected
  452:    and which therefore can be used for IPv6.
  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 rcmd_af (char **__restrict __ahost, unsigned short int __rport,
  459:                     __const char *__restrict __locuser,
  460:                     __const char *__restrict __remuser,
  461:                     __const char *__restrict __cmd, int *__restrict __fd2p,
  462:                     sa_family_t __af);
  463: 
  464: /* Call `rexecd' at port RPORT on remote machine *AHOST to execute
  465:    CMD.  The process runs at the remote machine using the ID of user
  466:    NAME whose cleartext password is PASSWD.  In *FD2P the descriptor
  467:    to the socket for the connection is returned.  When the function
  468:    returns *AHOST contains the official host name.
  469: 
  470:    This function is not part of POSIX and therefore no official
  471:    cancellation point.  But due to similarity with an POSIX interface
  472:    or due to the implementation it is a cancellation point and
  473:    therefore not marked with __THROW.  */
  474: extern int rexec (char **__restrict __ahost, int __rport,
  475:                   __const char *__restrict __name,
  476:                   __const char *__restrict __pass,
  477:                   __const char *__restrict __cmd, int *__restrict __fd2p);
  478: 
  479: /* This is the equivalent function where the protocol can be selected
  480:    and which therefore can be used for IPv6.
  481: 
  482:    This function is not part of POSIX and therefore no official
  483:    cancellation point.  But due to similarity with an POSIX interface
  484:    or due to the implementation it is a cancellation point and
  485:    therefore not marked with __THROW.  */
  486: extern int rexec_af (char **__restrict __ahost, int __rport,
  487:                      __const char *__restrict __name,
  488:                      __const char *__restrict __pass,
  489:                      __const char *__restrict __cmd, int *__restrict __fd2p,
  490:                      sa_family_t __af);
  491: 
  492: /* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER.
  493:    If SUSER is not zero the user tries to become superuser.  Return 0 if
  494:    it is possible.
  495: 
  496:    This function is not part of POSIX and therefore no official
  497:    cancellation point.  But due to similarity with an POSIX interface
  498:    or due to the implementation it is a cancellation point and
  499:    therefore not marked with __THROW.  */
  500: extern int ruserok (__const char *__rhost, int __suser,
  501:                     __const char *__remuser, __const char *__locuser);
  502: 
  503: /* This is the equivalent function where the protocol can be selected
  504:    and which therefore can be used for IPv6.
  505: 
  506:    This function is not part of POSIX and therefore no official
  507:    cancellation point.  But due to similarity with an POSIX interface
  508:    or due to the implementation it is a cancellation point and
  509:    therefore not marked with __THROW.  */
  510: extern int ruserok_af (__const char *__rhost, int __suser,
  511:                        __const char *__remuser, __const char *__locuser,
  512:                        sa_family_t __af);
  513: 
  514: /* Try to allocate reserved port, returning a descriptor for a socket opened
  515:    at this port or -1 if unsuccessful.  The search for an available port
  516:    will start at ALPORT and continues with lower numbers.
  517: 
  518:    This function is not part of POSIX and therefore no official
  519:    cancellation point.  But due to similarity with an POSIX interface
  520:    or due to the implementation it is a cancellation point and
  521:    therefore not marked with __THROW.  */
  522: extern int rresvport (int *__alport);
  523: 
  524: /* This is the equivalent function where the protocol can be selected
  525:    and which therefore can be used for IPv6.
  526: 
  527:    This function is not part of POSIX and therefore no official
  528:    cancellation point.  But due to similarity with an POSIX interface
  529:    or due to the implementation it is a cancellation point and
  530:    therefore not marked with __THROW.  */
  531: extern int rresvport_af (int *__alport, sa_family_t __af);
  532: #endif
  533: 
  534: 
  535: /* Extension from POSIX.1g.  */
  536: #ifdef  __USE_POSIX
  537: /* Structure to contain information about address of a service provider.  */
  538: struct addrinfo
  539: {
  540:   int ai_flags;                 /* Input flags.  */
  541:   int ai_family;                /* Protocol family for socket.  */
  542:   int ai_socktype;              /* Socket type.  */
  543:   int ai_protocol;              /* Protocol for socket.  */
  544:   socklen_t ai_addrlen;         /* Length of socket address.  */
  545:   struct sockaddr *ai_addr;     /* Socket address for socket.  */
  546:   char *ai_canonname;           /* Canonical name for service location.  */
  547:   struct addrinfo *ai_next;     /* Pointer to next in list.  */
  548: };
  549: 
  550: # ifdef __USE_GNU
  551: /* Structure used as control block for asynchronous lookup.  */
  552: struct gaicb
  553: {
  554:   const char *ar_name;          /* Name to look up.  */
  555:   const char *ar_service;       /* Service name.  */
  556: