xref: /original-bsd/include/netdb.h (revision f66f3413)
1 /*-
2  * Copyright (c) 1980, 1983, 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)netdb.h	5.16 (Berkeley) 03/29/92
8  */
9 
10 #ifndef _NETDB_H_
11 #define _NETDB_H_
12 
13 #define	_PATH_HEQUIV	"/etc/hosts.equiv"
14 #define	_PATH_HOSTS	"/etc/hosts"
15 #define	_PATH_NETWORKS	"/etc/networks"
16 #define	_PATH_PROTOCOLS	"/etc/protocols"
17 #define	_PATH_SERVICES	"/etc/services"
18 
19 /*
20  * Structures returned by network data base library.  All addresses are
21  * supplied in host order, and returned in network order (suitable for
22  * use in system calls).
23  */
24 struct	hostent {
25 	char	*h_name;	/* official name of host */
26 	char	**h_aliases;	/* alias list */
27 	int	h_addrtype;	/* host address type */
28 	int	h_length;	/* length of address */
29 	char	**h_addr_list;	/* list of addresses from name server */
30 #define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
31 };
32 
33 /*
34  * Assumption here is that a network number
35  * fits in 32 bits -- probably a poor one.
36  */
37 struct	netent {
38 	char		*n_name;	/* official name of net */
39 	char		**n_aliases;	/* alias list */
40 	int		n_addrtype;	/* net address type */
41 	unsigned long	n_net;		/* network # */
42 };
43 
44 struct	servent {
45 	char	*s_name;	/* official service name */
46 	char	**s_aliases;	/* alias list */
47 	int	s_port;		/* port # */
48 	char	*s_proto;	/* protocol to use */
49 };
50 
51 struct	protoent {
52 	char	*p_name;	/* official protocol name */
53 	char	**p_aliases;	/* alias list */
54 	int	p_proto;	/* protocol # */
55 };
56 
57 /*
58  * Error return codes from gethostbyname() and gethostbyaddr()
59  * (left in extern int h_errno).
60  */
61 
62 #define	HOST_NOT_FOUND	1 /* Authoritative Answer Host not found */
63 #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
64 #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
65 #define	NO_DATA		4 /* Valid name, no data record of requested type */
66 #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
67 
68 #include <sys/cdefs.h>
69 
70 __BEGIN_DECLS
71 void		endhostent __P((void));
72 void		endnetent __P((void));
73 void		endprotoent __P((void));
74 void		endservent __P((void));
75 struct hostent	*gethostbyaddr __P((const char *, int, int));
76 struct hostent	*gethostbyname __P((const char *));
77 struct hostent *gethostent __P((void));
78 struct netent	*getnetbyaddr __P((long, int)); /* u_long? */
79 struct netent	*getnetbyname __P((const char *));
80 struct netent	*getnetent __P((void));
81 struct protoent	*getprotobyname __P((const char *));
82 struct protoent	*getprotobynumber __P((int));
83 struct protoent	*getprotoent __P((void));
84 struct servent	*getservbyname __P((const char *, const char *));
85 struct servent	*getservbyport __P((int, const char *));
86 struct servent	*getservent __P((void));
87 void		herror __P((const char *));
88 void		sethostent __P((int));
89 /* void		sethostfile __P((const char *)); */
90 void		setnetent __P((int));
91 void		setprotoent __P((int));
92 void		setservent __P((int));
93 __END_DECLS
94 
95 #endif /* !_NETDB_H_ */
96