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

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

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