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

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

1.16    ! millert     1: /*     $OpenBSD: netdb.h,v 1.15 2002/02/16 21:27:17 millert Exp $      */
1.3       downsj      2:
1.2       dm          3: /*
                      4:  * ++Copyright++ 1980, 1983, 1988, 1993
                      5:  * -
                      6:  * Copyright (c) 1980, 1983, 1988, 1993
                      7:  *     The Regents of the University of California.  All rights reserved.
1.1       deraadt     8:  *
                      9:  * Redistribution and use in source and binary forms, with or without
                     10:  * modification, are permitted provided that the following conditions
                     11:  * are met:
                     12:  * 1. Redistributions of source code must retain the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer.
                     14:  * 2. Redistributions in binary form must reproduce the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer in the
                     16:  *    documentation and/or other materials provided with the distribution.
                     17:  * 3. All advertising materials mentioning features or use of this software
                     18:  *    must display the following acknowledgement:
                     19:  *     This product includes software developed by the University of
                     20:  *     California, Berkeley and its contributors.
                     21:  * 4. Neither the name of the University nor the names of its contributors
                     22:  *    may be used to endorse or promote products derived from this software
                     23:  *    without specific prior written permission.
                     24:  *
                     25:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     26:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     27:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     28:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     29:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     30:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     31:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     32:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     33:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     34:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     35:  * SUCH DAMAGE.
1.2       dm         36:  * -
                     37:  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
1.1       deraadt    38:  *
1.2       dm         39:  * Permission to use, copy, modify, and distribute this software for any
                     40:  * purpose with or without fee is hereby granted, provided that the above
                     41:  * copyright notice and this permission notice appear in all copies, and that
                     42:  * the name of Digital Equipment Corporation not be used in advertising or
                     43:  * publicity pertaining to distribution of the document or software without
                     44:  * specific, written prior permission.
                     45:  *
                     46:  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
                     47:  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
                     48:  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
                     49:  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
                     50:  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
                     51:  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
                     52:  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
                     53:  * SOFTWARE.
                     54:  * -
                     55:  * --Copyright--
                     56:  */
                     57:
                     58: /*
1.13      deraadt    59:  * Copyright (c) 1995, 1996, 1997, 1998, 1999 Craig Metz. All rights reserved.
                     60:  *
                     61:  * Redistribution and use in source and binary forms, with or without
                     62:  * modification, are permitted provided that the following conditions
                     63:  * are met:
                     64:  * 1. Redistributions of source code must retain the above copyright
                     65:  *    notice, this list of conditions and the following disclaimer.
                     66:  * 2. Redistributions in binary form must reproduce the above copyright
                     67:  *    notice, this list of conditions and the following disclaimer in the
                     68:  *    documentation and/or other materials provided with the distribution.
                     69:  * 3. Neither the name of the author nor the names of any contributors
                     70:  *    may be used to endorse or promote products derived from this software
                     71:  *    without specific prior written permission.
                     72:  *
                     73:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     74:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     75:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     76:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     77:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     78:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     79:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     80:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     81:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     82:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     83:  * SUCH DAMAGE.
1.5       deraadt    84:  */
                     85:
                     86: /*
1.2       dm         87:  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
1.3       downsj     88:  *     $From: netdb.h,v 8.7 1996/05/09 05:59:09 vixie Exp $
1.1       deraadt    89:  */
                     90:
                     91: #ifndef _NETDB_H_
                     92: #define _NETDB_H_
                     93:
1.2       dm         94: #include <sys/param.h>
                     95: #if (!defined(BSD)) || (BSD < 199306)
                     96: # include <sys/bitypes.h>
                     97: #endif
                     98: #include <sys/cdefs.h>
                     99:
1.1       deraadt   100: #define        _PATH_HEQUIV    "/etc/hosts.equiv"
                    101: #define        _PATH_HOSTS     "/etc/hosts"
                    102: #define        _PATH_NETWORKS  "/etc/networks"
                    103: #define        _PATH_PROTOCOLS "/etc/protocols"
                    104: #define        _PATH_SERVICES  "/etc/services"
                    105:
1.2       dm        106: extern int h_errno;
                    107:
1.1       deraadt   108: /*
                    109:  * Structures returned by network data base library.  All addresses are
                    110:  * supplied in host order, and returned in network order (suitable for
                    111:  * use in system calls).
                    112:  */
                    113: struct hostent {
                    114:        char    *h_name;        /* official name of host */
                    115:        char    **h_aliases;    /* alias list */
                    116:        int     h_addrtype;     /* host address type */
                    117:        int     h_length;       /* length of address */
                    118:        char    **h_addr_list;  /* list of addresses from name server */
                    119: #define        h_addr  h_addr_list[0]  /* address, for backward compatiblity */
                    120: };
                    121:
                    122: /*
                    123:  * Assumption here is that a network number
1.4       millert   124:  * fits in an in_addr_t -- probably a poor one.
1.1       deraadt   125:  */
                    126: struct netent {
                    127:        char            *n_name;        /* official name of net */
                    128:        char            **n_aliases;    /* alias list */
                    129:        int             n_addrtype;     /* net address type */
1.4       millert   130:        in_addr_t       n_net;          /* network # */
1.1       deraadt   131: };
                    132:
                    133: struct servent {
                    134:        char    *s_name;        /* official service name */
                    135:        char    **s_aliases;    /* alias list */
                    136:        int     s_port;         /* port # */
                    137:        char    *s_proto;       /* protocol to use */
                    138: };
                    139:
                    140: struct protoent {
                    141:        char    *p_name;        /* official protocol name */
                    142:        char    **p_aliases;    /* alias list */
                    143:        int     p_proto;        /* protocol # */
                    144: };
                    145:
                    146: /*
                    147:  * Error return codes from gethostbyname() and gethostbyaddr()
                    148:  * (left in extern int h_errno).
                    149:  */
                    150:
1.2       dm        151: #define        NETDB_INTERNAL  -1      /* see errno */
                    152: #define        NETDB_SUCCESS   0       /* no problem */
1.1       deraadt   153: #define        HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
                    154: #define        TRY_AGAIN       2 /* Non-Authoritive Host not found, or SERVERFAIL */
                    155: #define        NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
                    156: #define        NO_DATA         4 /* Valid name, no data record of requested type */
                    157: #define        NO_ADDRESS      NO_DATA         /* no address, look for MX record */
                    158:
1.5       deraadt   159: /* Values for getaddrinfo() and getnameinfo() */
                    160: #define AI_PASSIVE     1       /* socket address is intended for bind() */
                    161: #define AI_CANONNAME   2       /* request for canonical name */
                    162: #define AI_NUMERICHOST 4       /* don't ever try nameservice */
1.6       cmetz     163: #define AI_EXT         8       /* enable non-portable extensions */
1.9       itojun    164: /* valid flags for addrinfo */
                    165: #define AI_MASK                (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
1.5       deraadt   166:
                    167: #define NI_NUMERICHOST 1       /* return the host address, not the name */
                    168: #define NI_NUMERICSERV 2       /* return the service address, not the name */
                    169: #define NI_NOFQDN      4       /* return a short name if in the local domain */
                    170: #define NI_NAMEREQD    8       /* fail if either host or service name is unknown */
                    171: #define NI_DGRAM       16      /* look up datagram service instead of stream */
1.8       itojun    172: #define NI_WITHSCOPEID 32      /* KAME hack: attach scopeid to host portion */
1.5       deraadt   173:
1.7       deraadt   174: #define NI_MAXHOST     MAXHOSTNAMELEN  /* max host name returned by getnameinfo */
1.5       deraadt   175: #define NI_MAXSERV     32      /* max serv. name length returned by getnameinfo */
                    176:
1.8       itojun    177: /*
                    178:  * Scope delimit character (KAME hack)
                    179:  */
1.9       itojun    180: #define SCOPE_DELIMITER '%'
1.8       itojun    181:
1.5       deraadt   182: #define EAI_BADFLAGS   -1      /* invalid value for ai_flags */
                    183: #define EAI_NONAME     -2      /* name or service is not known */
                    184: #define EAI_AGAIN      -3      /* temporary failure in name resolution */
                    185: #define EAI_FAIL       -4      /* non-recoverable failure in name resolution */
                    186: #define EAI_NODATA     -5      /* no address associated with name */
                    187: #define EAI_FAMILY     -6      /* ai_family not supported */
                    188: #define EAI_SOCKTYPE   -7      /* ai_socktype not supported */
                    189: #define EAI_SERVICE    -8      /* service not supported for ai_socktype */
                    190: #define EAI_ADDRFAMILY -9      /* address family for name not supported */
                    191: #define EAI_MEMORY     -10     /* memory allocation failure */
                    192: #define EAI_SYSTEM     -11     /* system error (code indicated in errno) */
1.8       itojun    193: #define EAI_BADHINTS   -12     /* invalid value for hints */
                    194: #define EAI_PROTOCOL   -13     /* resolved protocol is unknown */
1.5       deraadt   195:
                    196: struct addrinfo {
                    197:        int ai_flags;           /* input flags */
                    198:        int ai_family;          /* protocol family for socket */
                    199:        int ai_socktype;        /* socket type */
                    200:        int ai_protocol;        /* protocol for socket */
1.12      itojun    201:        socklen_t ai_addrlen;   /* length of socket-address */
1.5       deraadt   202:        struct sockaddr *ai_addr; /* socket-address for socket */
                    203:        char *ai_canonname;     /* canonical name for service location (iff req) */
                    204:        struct addrinfo *ai_next; /* pointer to next in list */
                    205: };
                    206:
1.14      jakob     207: /*
                    208:  * Flags for getrrsetbyname()
                    209:  */
                    210: #define RRSET_VALIDATED                1
                    211:
                    212: /*
                    213:  * Return codes for getrrsetbyname()
                    214:  */
                    215: #define ERRSET_SUCCESS         0
                    216: #define ERRSET_NOMEMORY                1
                    217: #define ERRSET_FAIL            2
                    218: #define ERRSET_INVAL           3
                    219: #define ERRSET_NONAME          4
                    220: #define ERRSET_NODATA          5
                    221:
                    222: /*
                    223:  * Structures used by getrrsetbyname() and freerrset()
                    224:  */
                    225: struct rdatainfo {
                    226:        unsigned int            rdi_length;     /* length of data */
                    227:        unsigned char           *rdi_data;      /* record data */
                    228: };
                    229:
                    230: struct rrsetinfo {
                    231:        unsigned int            rri_flags;      /* RRSET_VALIDATED ... */
                    232:        unsigned int            rri_rdclass;    /* class number */
                    233:        unsigned int            rri_rdtype;     /* RR type number */
                    234:        unsigned int            rri_ttl;        /* time to live */
                    235:        unsigned int            rri_nrdatas;    /* size of rdatas array */
                    236:        unsigned int            rri_nsigs;      /* size of sigs array */
                    237:        char                    *rri_name;      /* canonical name */
                    238:        struct rdatainfo        *rri_rdatas;    /* individual records */
                    239:        struct rdatainfo        *rri_sigs;      /* individual signatures */
                    240: };
                    241:
1.1       deraadt   242: __BEGIN_DECLS
1.15      millert   243: void           endhostent(void);
                    244: void           endnetent(void);
                    245: void           endprotoent(void);
                    246: void           endservent(void);
                    247: struct hostent *gethostbyaddr(const char *, int, int);
                    248: struct hostent *gethostbyname(const char *);
                    249: struct hostent *gethostbyname2(const char *, int);
                    250: struct hostent *gethostent(void);
                    251: struct netent  *getnetbyaddr(in_addr_t, int);
                    252: struct netent  *getnetbyname(const char *);
                    253: struct netent  *getnetent(void);
                    254: struct protoent        *getprotobyname(const char *);
                    255: struct protoent        *getprotobynumber(int);
                    256: struct protoent        *getprotoent(void);
                    257: struct servent *getservbyname(const char *, const char *);
                    258: struct servent *getservbyport(int, const char *);
                    259: struct servent *getservent(void);
                    260: void           herror(const char *);
                    261: const char     *hstrerror(int);
                    262: void           sethostent(int);
                    263: /* void                sethostfile(const char *); */
                    264: void           setnetent(int);
                    265: void           setprotoent(int);
                    266: void           setservent(int);
1.5       deraadt   267:
1.16    ! millert   268: int            getaddrinfo(const char *, const char *,
        !           269:                    const struct addrinfo *, struct addrinfo **);
1.15      millert   270: void           freeaddrinfo(struct addrinfo *);
1.16    ! millert   271: int            getnameinfo(const struct sockaddr *, socklen_t,
        !           272:                    char *, size_t, char *, size_t, int);
1.15      millert   273: char           *gai_strerror(int);
                    274: int            net_addrcmp(struct sockaddr *, struct sockaddr *);
1.14      jakob     275: int            getrrsetbyname(const char *, unsigned int, unsigned int, unsigned int, struct rrsetinfo **);
                    276: void           freerrset(struct rrsetinfo *);
1.1       deraadt   277: __END_DECLS
1.2       dm        278:
                    279: /* This is nec'y to make this include file properly replace the sun version. */
                    280: #ifdef sun
                    281: #ifdef __GNU_LIBRARY__
                    282: #include <rpc/netdb.h>
                    283: #else
                    284: struct rpcent {
                    285:        char    *r_name;        /* name of server for this rpc program */
                    286:        char    **r_aliases;    /* alias list */
                    287:        int     r_number;       /* rpc program number */
                    288: };
                    289: struct rpcent  *getrpcbyname(), *getrpcbynumber(), *getrpcent();
                    290: #endif /* __GNU_LIBRARY__ */
                    291: #endif /* sun */
1.1       deraadt   292:
                    293: #endif /* !_NETDB_H_ */