xref: /original-bsd/include/netdb.h (revision 3cd9f84a)
1 /*-
2  * Copyright (c) 1980, 1983, 1988, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *      @(#)netdb.h	8.1 (Berkeley) 06/02/93
8  *	$Id: netdb.h,v 4.9.1.2 1993/05/17 09:59:01 vixie Exp $
9  * -
10  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
11  *
12  * Permission to use, copy, modify, and distribute this software for any
13  * purpose with or without fee is hereby granted, provided that the above
14  * copyright notice and this permission notice appear in all copies, and that
15  * the name of Digital Equipment Corporation not be used in advertising or
16  * publicity pertaining to distribution of the document or software without
17  * specific, written prior permission.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
20  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
21  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
22  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
23  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
24  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
25  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
26  * SOFTWARE.
27  * -
28  * --Copyright--
29  */
30 
31 #ifndef _NETDB_H_
32 #define _NETDB_H_
33 
34 #define	_PATH_HEQUIV	"/etc/hosts.equiv"
35 #define	_PATH_HOSTS	"/etc/hosts"
36 #define	_PATH_NETWORKS	"/etc/networks"
37 #define	_PATH_PROTOCOLS	"/etc/protocols"
38 #define	_PATH_SERVICES	"/etc/services"
39 
40 /*
41  * Structures returned by network data base library.  All addresses are
42  * supplied in host order, and returned in network order (suitable for
43  * use in system calls).
44  */
45 struct	hostent {
46 	char	*h_name;	/* official name of host */
47 	char	**h_aliases;	/* alias list */
48 	int	h_addrtype;	/* host address type */
49 	int	h_length;	/* length of address */
50 	char	**h_addr_list;	/* list of addresses from name server */
51 #define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
52 };
53 
54 /*
55  * Assumption here is that a network number
56  * fits in an unsigned long -- probably a poor one.
57  */
58 struct	netent {
59 	char		*n_name;	/* official name of net */
60 	char		**n_aliases;	/* alias list */
61 	int		n_addrtype;	/* net address type */
62 	unsigned long	n_net;		/* network # */
63 };
64 
65 struct	servent {
66 	char	*s_name;	/* official service name */
67 	char	**s_aliases;	/* alias list */
68 	int	s_port;		/* port # */
69 	char	*s_proto;	/* protocol to use */
70 };
71 
72 struct	protoent {
73 	char	*p_name;	/* official protocol name */
74 	char	**p_aliases;	/* alias list */
75 	int	p_proto;	/* protocol # */
76 };
77 
78 /*
79  * Error return codes from gethostbyname() and gethostbyaddr()
80  * (left in extern int h_errno).
81  */
82 
83 #define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
84 #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
85 #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
86 #define	NO_DATA		4 /* Valid name, no data record of requested type */
87 #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
88 
89 #include <sys/cdefs.h>
90 
91 __BEGIN_DECLS
92 void		endhostent __P((void));
93 void		endnetent __P((void));
94 void		endprotoent __P((void));
95 void		endservent __P((void));
96 struct hostent	*gethostbyaddr __P((const char *, int, int));
97 struct hostent	*gethostbyname __P((const char *));
98 struct hostent	*gethostent __P((void));
99 struct netent	*getnetbyaddr __P((long, int)); /* u_long? */
100 struct netent	*getnetbyname __P((const char *));
101 struct netent	*getnetent __P((void));
102 struct protoent	*getprotobyname __P((const char *));
103 struct protoent	*getprotobynumber __P((int));
104 struct protoent	*getprotoent __P((void));
105 struct servent	*getservbyname __P((const char *, const char *));
106 struct servent	*getservbyport __P((int, const char *));
107 struct servent	*getservent __P((void));
108 void		herror __P((const char *));
109 char		*hstrerror __P((int));
110 void		sethostent __P((int));
111 /* void		sethostfile __P((const char *)); */
112 void		setnetent __P((int));
113 void		setprotoent __P((int));
114 void		setservent __P((int));
115 __END_DECLS
116 
117 #endif /* !_NETDB_H_ */
118