[BACK]Return to netdb.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / include

Annotation of src/include/netdb.h, Revision 1.38

1.38    ! kleink      1: /*     $NetBSD: netdb.h,v 1.37 2004/05/08 18:52:15 kleink Exp $        */
1.12      itojun      2:
                      3: /*
                      4:  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
                      5:  * All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  * 3. Neither the name of the project nor the names of its contributors
                     16:  *    may be used to endorse or promote products derived from this software
                     17:  *    without specific prior written permission.
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
                     20:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     21:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     22:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
                     23:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     24:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     25:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     26:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     27:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     28:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     29:  * SUCH DAMAGE.
                     30:  */
1.9       perry      31:
                     32: /*-
1.6       mrg        33:  * Copyright (c) 1980, 1983, 1988, 1993
                     34:  *     The Regents of the University of California.  All rights reserved.
1.1       cgd        35:  *
                     36:  * Redistribution and use in source and binary forms, with or without
                     37:  * modification, are permitted provided that the following conditions
                     38:  * are met:
                     39:  * 1. Redistributions of source code must retain the above copyright
                     40:  *    notice, this list of conditions and the following disclaimer.
                     41:  * 2. Redistributions in binary form must reproduce the above copyright
                     42:  *    notice, this list of conditions and the following disclaimer in the
                     43:  *    documentation and/or other materials provided with the distribution.
1.31      agc        44:  * 3. Neither the name of the University nor the names of its contributors
1.1       cgd        45:  *    may be used to endorse or promote products derived from this software
                     46:  *    without specific prior written permission.
                     47:  *
                     48:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     49:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     50:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     51:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     52:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     53:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     54:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     55:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     56:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     57:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     58:  * SUCH DAMAGE.
1.9       perry      59:  *
                     60:  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
1.10      perry      61:  *     Id: netdb.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp
1.6       mrg        62:  * -
                     63:  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
1.9       perry      64:  *
1.6       mrg        65:  * Permission to use, copy, modify, and distribute this software for any
                     66:  * purpose with or without fee is hereby granted, provided that the above
                     67:  * copyright notice and this permission notice appear in all copies, and that
                     68:  * the name of Digital Equipment Corporation not be used in advertising or
                     69:  * publicity pertaining to distribution of the document or software without
                     70:  * specific, written prior permission.
1.9       perry      71:  *
1.6       mrg        72:  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
                     73:  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
                     74:  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
                     75:  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
                     76:  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
                     77:  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
                     78:  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
                     79:  * SOFTWARE.
                     80:  * -
                     81:  * --Copyright--
                     82:  */
                     83:
1.1       cgd        84: #ifndef _NETDB_H_
                     85: #define _NETDB_H_
                     86:
1.13      kleink     87: #include <machine/ansi.h>
1.37      kleink     88: #include <machine/endian_machdep.h>
1.23      kleink     89: #include <sys/ansi.h>
1.6       mrg        90: #include <sys/cdefs.h>
1.29      bjh21      91: #include <sys/featuretest.h>
1.13      kleink     92: #include <inttypes.h>
1.6       mrg        93:
1.23      kleink     94: /*
                     95:  * Data types
                     96:  */
                     97: #ifndef socklen_t
                     98: typedef __socklen_t    socklen_t;
                     99: #define socklen_t      __socklen_t
                    100: #endif
                    101:
1.13      kleink    102: #ifdef  _BSD_SIZE_T_
                    103: typedef _BSD_SIZE_T_   size_t;
                    104: #undef  _BSD_SIZE_T_
                    105: #endif
1.11      kleink    106:
1.29      bjh21     107: #if defined(_NETBSD_SOURCE)
1.1       cgd       108: #define        _PATH_HEQUIV    "/etc/hosts.equiv"
                    109: #define        _PATH_HOSTS     "/etc/hosts"
                    110: #define        _PATH_NETWORKS  "/etc/networks"
                    111: #define        _PATH_PROTOCOLS "/etc/protocols"
                    112: #define        _PATH_SERVICES  "/etc/services"
1.11      kleink    113: #endif
1.1       cgd       114:
1.6       mrg       115: extern int h_errno;
                    116:
1.1       cgd       117: /*
                    118:  * Structures returned by network data base library.  All addresses are
                    119:  * supplied in host order, and returned in network order (suitable for
                    120:  * use in system calls).
                    121:  */
                    122: struct hostent {
                    123:        char    *h_name;        /* official name of host */
                    124:        char    **h_aliases;    /* alias list */
                    125:        int     h_addrtype;     /* host address type */
                    126:        int     h_length;       /* length of address */
                    127:        char    **h_addr_list;  /* list of addresses from name server */
1.28      wiz       128: #define        h_addr  h_addr_list[0]  /* address, for backward compatibility */
1.1       cgd       129: };
                    130:
                    131: /*
                    132:  * Assumption here is that a network number
1.6       mrg       133:  * fits in an unsigned long -- probably a poor one.
1.1       cgd       134:  */
                    135: struct netent {
                    136:        char            *n_name;        /* official name of net */
                    137:        char            **n_aliases;    /* alias list */
                    138:        int             n_addrtype;     /* net address type */
1.37      kleink    139: #if (defined(__sparc__) && defined(_LP64)) || \
                    140:     (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _BIG_ENDIAN))
                    141:        int             __n_pad0;       /* ABI compatibility */
                    142: #endif
                    143:        uint32_t        n_net;          /* network # */
                    144: #if defined(__alpha__) || (defined(__i386__) && defined(_LP64)) || \
                    145:     (defined(__sh__) && defined(_LP64) && (_BYTE_ORDER == _LITTLE_ENDIAN))
                    146:        int             __n_pad0;       /* ABI compatibility */
                    147: #endif
1.1       cgd       148: };
                    149:
                    150: struct servent {
                    151:        char    *s_name;        /* official service name */
                    152:        char    **s_aliases;    /* alias list */
                    153:        int     s_port;         /* port # */
                    154:        char    *s_proto;       /* protocol to use */
                    155: };
                    156:
                    157: struct protoent {
                    158:        char    *p_name;        /* official protocol name */
                    159:        char    **p_aliases;    /* alias list */
                    160:        int     p_proto;        /* protocol # */
                    161: };
                    162:
1.23      kleink    163: /*
                    164:  * Note: ai_addrlen used to be a size_t, per RFC 2553.
                    165:  * In XNS5.2, and subsequently in POSIX-2001 and
                    166:  * draft-ietf-ipngwg-rfc2553bis-02.txt it was changed to a socklen_t.
                    167:  * To accomodate for this while preserving binary compatibility with the
                    168:  * old interface, we prepend or append 32 bits of padding, depending on
                    169:  * the (LP64) architecture's endianness.
                    170:  *
                    171:  * This should be deleted the next time the libc major number is
                    172:  * incremented.
                    173:  */
1.30      bjh21     174: #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
                    175:     defined(_NETBSD_SOURCE)
1.12      itojun    176: struct addrinfo {
1.36      itojun    177:        int     ai_flags;       /* AI_xxx */
1.12      itojun    178:        int     ai_family;      /* PF_xxx */
                    179:        int     ai_socktype;    /* SOCK_xxx */
                    180:        int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
1.38    ! kleink    181: #if defined(__sparc__) && defined(_LP64)
        !           182:        int     __ai_pad0;      /* ABI compatibility */
1.23      kleink    183: #endif
                    184:        socklen_t ai_addrlen;   /* length of ai_addr */
                    185: #if defined(__alpha__) || (defined(__i386__) && defined(_LP64))
1.38    ! kleink    186:        int     __ai_pad0;      /* ABI compatbility */
1.23      kleink    187: #endif
1.12      itojun    188:        char    *ai_canonname;  /* canonical name for hostname */
                    189:        struct sockaddr *ai_addr;       /* binary address */
                    190:        struct addrinfo *ai_next;       /* next structure in linked list */
                    191: };
1.13      kleink    192: #endif
1.12      itojun    193:
1.1       cgd       194: /*
                    195:  * Error return codes from gethostbyname() and gethostbyaddr()
                    196:  * (left in extern int h_errno).
                    197:  */
1.5       jtc       198:
1.29      bjh21     199: #if defined(_NETBSD_SOURCE)
1.6       mrg       200: #define        NETDB_INTERNAL  -1      /* see errno */
                    201: #define        NETDB_SUCCESS   0       /* no problem */
1.11      kleink    202: #endif
1.1       cgd       203: #define        HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
1.16      mjl       204: #define        TRY_AGAIN       2 /* Non-Authoritative Host not found, or SERVERFAIL */
1.1       cgd       205: #define        NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
                    206: #define        NO_DATA         4 /* Valid name, no data record of requested type */
1.29      bjh21     207: #if defined(_NETBSD_SOURCE)
1.1       cgd       208: #define        NO_ADDRESS      NO_DATA         /* no address, look for MX record */
1.11      kleink    209: #endif
1.1       cgd       210:
1.12      itojun    211: /*
                    212:  * Error return codes from getaddrinfo()
                    213:  */
1.30      bjh21     214: #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
                    215:     defined(_NETBSD_SOURCE)
1.12      itojun    216: #define        EAI_ADDRFAMILY   1      /* address family for hostname not supported */
                    217: #define        EAI_AGAIN        2      /* temporary failure in name resolution */
                    218: #define        EAI_BADFLAGS     3      /* invalid value for ai_flags */
                    219: #define        EAI_FAIL         4      /* non-recoverable failure in name resolution */
                    220: #define        EAI_FAMILY       5      /* ai_family not supported */
                    221: #define        EAI_MEMORY       6      /* memory allocation failure */
                    222: #define        EAI_NODATA       7      /* no address associated with hostname */
                    223: #define        EAI_NONAME       8      /* hostname nor servname provided, or not known */
                    224: #define        EAI_SERVICE      9      /* servname not supported for ai_socktype */
                    225: #define        EAI_SOCKTYPE    10      /* ai_socktype not supported */
                    226: #define        EAI_SYSTEM      11      /* system error returned in errno */
1.20      lukem     227: #define        EAI_BADHINTS    12
                    228: #define        EAI_PROTOCOL    13
                    229: #define        EAI_MAX         14
1.30      bjh21     230: #endif /* _POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE >= 520 || _NETBSD_SOURCE */
1.12      itojun    231:
                    232: /*
                    233:  * Flag values for getaddrinfo()
                    234:  */
1.30      bjh21     235: #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
                    236:     defined(_NETBSD_SOURCE)
1.12      itojun    237: #define        AI_PASSIVE      0x00000001 /* get address to use bind() */
                    238: #define        AI_CANONNAME    0x00000002 /* fill ai_canonname */
1.35      itojun    239: #define        AI_NUMERICHOST  0x00000004 /* prevent host name resolution */
                    240: #define        AI_NUMERICSERV  0x00000008 /* prevent service name resolution */
                    241: /* valid flags for addrinfo (not a standard def, apps should not use it) */
                    242: #define        AI_MASK \
                    243:     (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
1.13      kleink    244: #endif
1.12      itojun    245:
1.30      bjh21     246: #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
                    247:     defined(_NETBSD_SOURCE)
1.12      itojun    248: /*
                    249:  * Constants for getnameinfo()
                    250:  */
1.29      bjh21     251: #if defined(_NETBSD_SOURCE)
1.12      itojun    252: #define        NI_MAXHOST      1025
                    253: #define        NI_MAXSERV      32
1.22      kleink    254: #endif
1.12      itojun    255:
                    256: /*
                    257:  * Flag values for getnameinfo()
                    258:  */
                    259: #define        NI_NOFQDN       0x00000001
                    260: #define        NI_NUMERICHOST  0x00000002
                    261: #define        NI_NAMEREQD     0x00000004
                    262: #define        NI_NUMERICSERV  0x00000008
                    263: #define        NI_DGRAM        0x00000010
1.29      bjh21     264: #if defined(_NETBSD_SOURCE)
1.20      lukem     265: #define        NI_WITHSCOPEID  0x00000020      /*KAME extension*/
1.22      kleink    266: #endif
1.14      itojun    267:
                    268: /*
                    269:  * Scope delimit character
                    270:  */
1.29      bjh21     271: #if defined(_NETBSD_SOURCE)
1.20      lukem     272: #define        SCOPE_DELIMITER '%'             /*KAME extension*/
1.22      kleink    273: #endif
1.30      bjh21     274: #endif /* (_POSIX_C_SOURCE - 0) >= 200112L || ... */
1.18      itojun    275:
1.1       cgd       276: __BEGIN_DECLS
                    277: void           endhostent __P((void));
                    278: void           endnetent __P((void));
                    279: void           endprotoent __P((void));
                    280: void           endservent __P((void));
1.30      bjh21     281: #if (_XOPEN_SOURCE - 0) >= 500 && (_XOPEN_SOURCE - 0) < 600 || \
                    282:     defined(_NETBSD_SOURCE)
1.12      itojun    283: void           freehostent __P((struct hostent *));
1.13      kleink    284: #endif
1.21      kleink    285: struct hostent *gethostbyaddr __P((const char *, socklen_t, int));
1.3       deraadt   286: struct hostent *gethostbyname __P((const char *));
1.29      bjh21     287: #if defined(_NETBSD_SOURCE)
1.6       mrg       288: struct hostent *gethostbyname2 __P((const char *, int));
1.11      kleink    289: #endif
1.3       deraadt   290: struct hostent *gethostent __P((void));
1.30      bjh21     291: #if (_XOPEN_SOURCE - 0) >= 520 && (_XOPEN_SOURCE - 0) < 600 || \
                    292:     defined(_NETBSD_SOURCE)
1.15      itojun    293: #if 0 /* we do not ship these */
1.12      itojun    294: struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
                    295: struct hostent *getipnodebyname __P((const char *, int, int, int *));
1.15      itojun    296: #endif
1.13      kleink    297: #endif
1.37      kleink    298: struct netent  *getnetbyaddr __P((uint32_t, int));
1.1       cgd       299: struct netent  *getnetbyname __P((const char *));
                    300: struct netent  *getnetent __P((void));
                    301: struct protoent        *getprotobyname __P((const char *));
                    302: struct protoent        *getprotobynumber __P((int));
                    303: struct protoent        *getprotoent __P((void));
                    304: struct servent *getservbyname __P((const char *, const char *));
                    305: struct servent *getservbyport __P((int, const char *));
                    306: struct servent *getservent __P((void));
1.29      bjh21     307: #if defined(_NETBSD_SOURCE)
1.1       cgd       308: void           herror __P((const char *));
1.6       mrg       309: const char     *hstrerror __P((int));
1.11      kleink    310: #endif
1.1       cgd       311: void           sethostent __P((int));
1.29      bjh21     312: #if defined(_NETBSD_SOURCE)
1.1       cgd       313: /* void                sethostfile __P((const char *)); */
1.11      kleink    314: #endif
1.1       cgd       315: void           setnetent __P((int));
                    316: void           setprotoent __P((int));
1.30      bjh21     317: #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 520 || \
                    318:     defined(_NETBSD_SOURCE)
1.12      itojun    319: int            getaddrinfo __P((const char *, const char *,
                    320:                                 const struct addrinfo *, struct addrinfo **));
1.18      itojun    321: int            getnameinfo __P((const struct sockaddr *, socklen_t, char *,
1.26      kleink    322:                                 socklen_t, char *, socklen_t, int));
1.12      itojun    323: void           freeaddrinfo __P((struct addrinfo *));
                    324: char           *gai_strerror __P((int));
1.13      kleink    325: #endif
1.1       cgd       326: void           setservent __P((int));
1.32      christos  327:
1.34      christos  328: #if defined(_NETBSD_SOURCE) && defined(_LIBC)
1.32      christos  329:
                    330: struct protoent_data {
                    331:         FILE *fp;
                    332:        struct protoent proto;
                    333:        char **aliases;
                    334:        size_t maxaliases;
                    335:        int stayopen;
1.33      christos  336:        char *line;
                    337:        void *dummy;
1.32      christos  338: };
                    339:
                    340: struct protoent        *getprotoent_r __P((struct protoent *, struct protoent_data *));
                    341: struct protoent        *getprotobyname_r __P((const char *,
                    342:     struct protoent *, struct protoent_data *));
                    343: struct protoent        *getprotobynumber_r __P((int,
                    344:     struct protoent *, struct protoent_data *));
                    345: struct protoent        *getprotoent_r __P((struct protoent *, struct protoent_data *));
                    346: void setprotoent_r __P((int, struct protoent_data *));
                    347: void endprotoent_r __P((struct protoent_data *));
                    348:
                    349: struct servent_data {
                    350:         FILE *fp;
                    351:        struct servent serv;
                    352:        char **aliases;
                    353:        size_t maxaliases;
                    354:        int stayopen;
1.33      christos  355:        char *line;
                    356:        void *dummy;
1.32      christos  357: };
                    358:
                    359: struct servent *getservent_r __P((struct servent *, struct servent_data *));
                    360: struct servent *getservbyname_r __P((const char *, const char *,
                    361:     struct servent *, struct servent_data *));
                    362: struct servent *getservbyport_r __P((int, const char *,
                    363:     struct servent *, struct servent_data *));
                    364: void setservent_r __P((int, struct servent_data *));
                    365: void endservent_r __P((struct servent_data *));
                    366:
1.34      christos  367: #endif /* _NETBSD_SOURCE && _LIBC */
1.1       cgd       368: __END_DECLS
                    369:
                    370: #endif /* !_NETDB_H_ */

CVSweb <webmaster@jp.NetBSD.org>