netdb.h revision 1.10
1/*	$NetBSD: netdb.h,v 1.10 1998/02/03 04:20:36 perry Exp $	*/
2
3/*-
4 * Copyright (c) 1980, 1983, 1988, 1993
5 *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
16 *    must display the following acknowledgement:
17 *	This product includes software developed by the University of
18 *	California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 *    may be used to endorse or promote products derived from this software
21 *    without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 *      @(#)netdb.h	8.1 (Berkeley) 6/2/93
36 *	Id: netdb.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp
37 * -
38 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
39 *
40 * Permission to use, copy, modify, and distribute this software for any
41 * purpose with or without fee is hereby granted, provided that the above
42 * copyright notice and this permission notice appear in all copies, and that
43 * the name of Digital Equipment Corporation not be used in advertising or
44 * publicity pertaining to distribution of the document or software without
45 * specific, written prior permission.
46 *
47 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
48 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
50 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
51 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
52 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
53 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
54 * SOFTWARE.
55 * -
56 * --Copyright--
57 */
58
59#ifndef _NETDB_H_
60#define _NETDB_H_
61
62#include <sys/param.h>
63#include <sys/cdefs.h>
64
65#define	_PATH_HEQUIV	"/etc/hosts.equiv"
66#define	_PATH_HOSTS	"/etc/hosts"
67#define	_PATH_NETWORKS	"/etc/networks"
68#define	_PATH_PROTOCOLS	"/etc/protocols"
69#define	_PATH_SERVICES	"/etc/services"
70
71extern int h_errno;
72
73/*
74 * Structures returned by network data base library.  All addresses are
75 * supplied in host order, and returned in network order (suitable for
76 * use in system calls).
77 */
78struct	hostent {
79	char	*h_name;	/* official name of host */
80	char	**h_aliases;	/* alias list */
81	int	h_addrtype;	/* host address type */
82	int	h_length;	/* length of address */
83	char	**h_addr_list;	/* list of addresses from name server */
84#define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
85};
86
87/*
88 * Assumption here is that a network number
89 * fits in an unsigned long -- probably a poor one.
90 */
91struct	netent {
92	char		*n_name;	/* official name of net */
93	char		**n_aliases;	/* alias list */
94	int		n_addrtype;	/* net address type */
95	unsigned long	n_net;		/* network # */
96};
97
98struct	servent {
99	char	*s_name;	/* official service name */
100	char	**s_aliases;	/* alias list */
101	int	s_port;		/* port # */
102	char	*s_proto;	/* protocol to use */
103};
104
105struct	protoent {
106	char	*p_name;	/* official protocol name */
107	char	**p_aliases;	/* alias list */
108	int	p_proto;	/* protocol # */
109};
110
111/*
112 * Error return codes from gethostbyname() and gethostbyaddr()
113 * (left in extern int h_errno).
114 */
115
116#define	NETDB_INTERNAL	-1	/* see errno */
117#define	NETDB_SUCCESS	0	/* no problem */
118#define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
119#define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
120#define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
121#define	NO_DATA		4 /* Valid name, no data record of requested type */
122#define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
123
124__BEGIN_DECLS
125void		endhostent __P((void));
126void		endnetent __P((void));
127void		endprotoent __P((void));
128void		endservent __P((void));
129struct hostent	*gethostbyaddr __P((const char *, int, int));
130struct hostent	*gethostbyname __P((const char *));
131struct hostent	*gethostbyname2 __P((const char *, int));
132struct hostent	*gethostent __P((void));
133struct netent	*getnetbyaddr __P((unsigned long, int));
134struct netent	*getnetbyname __P((const char *));
135struct netent	*getnetent __P((void));
136struct protoent	*getprotobyname __P((const char *));
137struct protoent	*getprotobynumber __P((int));
138struct protoent	*getprotoent __P((void));
139struct servent	*getservbyname __P((const char *, const char *));
140struct servent	*getservbyport __P((int, const char *));
141struct servent	*getservent __P((void));
142void		herror __P((const char *));
143const char	*hstrerror __P((int));
144void		sethostent __P((int));
145/* void		sethostfile __P((const char *)); */
146void		setnetent __P((int));
147void		setprotoent __P((int));
148void		setservent __P((int));
149__END_DECLS
150
151#endif /* !_NETDB_H_ */
152