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

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

1.7     ! deraadt     1: /*     $OpenBSD: netdb.h,v 1.6 1999/06/23 21:55:29 cmetz 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.5       deraadt    59:  * %%% portions-copyright-cmetz-96
                     60:  * Portions of this software are Copyright 1996-1998 by Craig Metz, All Rights
                     61:  * Reserved. The Inner Net License Version 2 applies to these portions of
                     62:  * the software.
                     63:  * You should have received a copy of the license with this software. If
                     64:  * you didn't get a copy, you may request one from <license@inner.net>.
                     65:  */
                     66:
                     67: /*
1.2       dm         68:  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
1.3       downsj     69:  *     $From: netdb.h,v 8.7 1996/05/09 05:59:09 vixie Exp $
1.1       deraadt    70:  */
                     71:
                     72: #ifndef _NETDB_H_
                     73: #define _NETDB_H_
                     74:
1.2       dm         75: #include <sys/param.h>
                     76: #if (!defined(BSD)) || (BSD < 199306)
                     77: # include <sys/bitypes.h>
                     78: #endif
                     79: #include <sys/cdefs.h>
                     80:
1.1       deraadt    81: #define        _PATH_HEQUIV    "/etc/hosts.equiv"
                     82: #define        _PATH_HOSTS     "/etc/hosts"
                     83: #define        _PATH_NETWORKS  "/etc/networks"
                     84: #define        _PATH_PROTOCOLS "/etc/protocols"
                     85: #define        _PATH_SERVICES  "/etc/services"
                     86:
1.2       dm         87: extern int h_errno;
                     88:
1.1       deraadt    89: /*
                     90:  * Structures returned by network data base library.  All addresses are
                     91:  * supplied in host order, and returned in network order (suitable for
                     92:  * use in system calls).
                     93:  */
                     94: struct hostent {
                     95:        char    *h_name;        /* official name of host */
                     96:        char    **h_aliases;    /* alias list */
                     97:        int     h_addrtype;     /* host address type */
                     98:        int     h_length;       /* length of address */
                     99:        char    **h_addr_list;  /* list of addresses from name server */
                    100: #define        h_addr  h_addr_list[0]  /* address, for backward compatiblity */
                    101: };
                    102:
                    103: /*
                    104:  * Assumption here is that a network number
1.4       millert   105:  * fits in an in_addr_t -- probably a poor one.
1.1       deraadt   106:  */
                    107: struct netent {
                    108:        char            *n_name;        /* official name of net */
                    109:        char            **n_aliases;    /* alias list */
                    110:        int             n_addrtype;     /* net address type */
1.4       millert   111:        in_addr_t       n_net;          /* network # */
1.1       deraadt   112: };
                    113:
                    114: struct servent {
                    115:        char    *s_name;        /* official service name */
                    116:        char    **s_aliases;    /* alias list */
                    117:        int     s_port;         /* port # */
                    118:        char    *s_proto;       /* protocol to use */
                    119: };
                    120:
                    121: struct protoent {
                    122:        char    *p_name;        /* official protocol name */
                    123:        char    **p_aliases;    /* alias list */
                    124:        int     p_proto;        /* protocol # */
                    125: };
                    126:
                    127: /*
                    128:  * Error return codes from gethostbyname() and gethostbyaddr()
                    129:  * (left in extern int h_errno).
                    130:  */
                    131:
1.2       dm        132: #define        NETDB_INTERNAL  -1      /* see errno */
                    133: #define        NETDB_SUCCESS   0       /* no problem */
1.1       deraadt   134: #define        HOST_NOT_FOUND  1 /* Authoritative Answer Host not found */
                    135: #define        TRY_AGAIN       2 /* Non-Authoritive Host not found, or SERVERFAIL */
                    136: #define        NO_RECOVERY     3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
                    137: #define        NO_DATA         4 /* Valid name, no data record of requested type */
                    138: #define        NO_ADDRESS      NO_DATA         /* no address, look for MX record */
                    139:
1.5       deraadt   140: /* Values for getaddrinfo() and getnameinfo() */
                    141: #define AI_PASSIVE     1       /* socket address is intended for bind() */
                    142: #define AI_CANONNAME   2       /* request for canonical name */
                    143: #define AI_NUMERICHOST 4       /* don't ever try nameservice */
1.6       cmetz     144: #define AI_EXT         8       /* enable non-portable extensions */
1.5       deraadt   145:
                    146: #define NI_NUMERICHOST 1       /* return the host address, not the name */
                    147: #define NI_NUMERICSERV 2       /* return the service address, not the name */
                    148: #define NI_NOFQDN      4       /* return a short name if in the local domain */
                    149: #define NI_NAMEREQD    8       /* fail if either host or service name is unknown */
                    150: #define NI_DGRAM       16      /* look up datagram service instead of stream */
                    151:
1.7     ! deraadt   152: #define NI_MAXHOST     MAXHOSTNAMELEN  /* max host name returned by getnameinfo */
1.5       deraadt   153: #define NI_MAXSERV     32      /* max serv. name length returned by getnameinfo */
                    154:
                    155: #define EAI_BADFLAGS   -1      /* invalid value for ai_flags */
                    156: #define EAI_NONAME     -2      /* name or service is not known */
                    157: #define EAI_AGAIN      -3      /* temporary failure in name resolution */
                    158: #define EAI_FAIL       -4      /* non-recoverable failure in name resolution */
                    159: #define EAI_NODATA     -5      /* no address associated with name */
                    160: #define EAI_FAMILY     -6      /* ai_family not supported */
                    161: #define EAI_SOCKTYPE   -7      /* ai_socktype not supported */
                    162: #define EAI_SERVICE    -8      /* service not supported for ai_socktype */
                    163: #define EAI_ADDRFAMILY -9      /* address family for name not supported */
                    164: #define EAI_MEMORY     -10     /* memory allocation failure */
                    165: #define EAI_SYSTEM     -11     /* system error (code indicated in errno) */
                    166:
                    167: struct addrinfo {
                    168:        int ai_flags;           /* input flags */
                    169:        int ai_family;          /* protocol family for socket */
                    170:        int ai_socktype;        /* socket type */
                    171:        int ai_protocol;        /* protocol for socket */
                    172:        int ai_addrlen;         /* length of socket-address */
                    173:        struct sockaddr *ai_addr; /* socket-address for socket */
                    174:        char *ai_canonname;     /* canonical name for service location (iff req) */
                    175:        struct addrinfo *ai_next; /* pointer to next in list */
                    176: };
                    177:
1.1       deraadt   178: __BEGIN_DECLS
                    179: void           endhostent __P((void));
                    180: void           endnetent __P((void));
                    181: void           endprotoent __P((void));
                    182: void           endservent __P((void));
                    183: struct hostent *gethostbyaddr __P((const char *, int, int));
                    184: struct hostent *gethostbyname __P((const char *));
1.2       dm        185: struct hostent *gethostbyname2 __P((const char *, int));
1.1       deraadt   186: struct hostent *gethostent __P((void));
1.4       millert   187: struct netent  *getnetbyaddr __P((in_addr_t, int));
1.1       deraadt   188: struct netent  *getnetbyname __P((const char *));
                    189: struct netent  *getnetent __P((void));
                    190: struct protoent        *getprotobyname __P((const char *));
                    191: struct protoent        *getprotobynumber __P((int));
                    192: struct protoent        *getprotoent __P((void));
                    193: struct servent *getservbyname __P((const char *, const char *));
                    194: struct servent *getservbyport __P((int, const char *));
                    195: struct servent *getservent __P((void));
                    196: void           herror __P((const char *));
1.2       dm        197: const char     *hstrerror __P((int));
1.1       deraadt   198: void           sethostent __P((int));
                    199: /* void                sethostfile __P((const char *)); */
                    200: void           setnetent __P((int));
                    201: void           setprotoent __P((int));
                    202: void           setservent __P((int));
1.5       deraadt   203:
                    204: int            getaddrinfo __P((const char *name, const char *service,
                    205:                    const struct addrinfo *req, struct addrinfo **pai));
                    206: void           freeaddrinfo __P((struct addrinfo *ai));
                    207: int            getnameinfo __P((const struct sockaddr *sa, size_t addrlen,
                    208:                    char *host, size_t hostlen, char *serv, size_t servlen,
                    209:                    int flags));
                    210: char           *gai_strerror __P((int ecode));
1.7     ! deraadt   211: int            net_addrcmp __P((struct sockaddr *, struct sockaddr *));
1.1       deraadt   212: __END_DECLS
1.2       dm        213:
                    214: /* This is nec'y to make this include file properly replace the sun version. */
                    215: #ifdef sun
                    216: #ifdef __GNU_LIBRARY__
                    217: #include <rpc/netdb.h>
                    218: #else
                    219: struct rpcent {
                    220:        char    *r_name;        /* name of server for this rpc program */
                    221:        char    **r_aliases;    /* alias list */
                    222:        int     r_number;       /* rpc program number */
                    223: };
                    224: struct rpcent  *getrpcbyname(), *getrpcbynumber(), *getrpcent();
                    225: #endif /* __GNU_LIBRARY__ */
                    226: #endif /* sun */
1.1       deraadt   227:
                    228: #endif /* !_NETDB_H_ */