xref: /illumos-gate/usr/src/lib/libresolv/netdb.h (revision 1da57d55)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1996 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
32*7c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate /*
36*7c478bd9Sstevel@tonic-gate  * Structures returned by network data base library.
37*7c478bd9Sstevel@tonic-gate  * All addresses are supplied in host order, and
38*7c478bd9Sstevel@tonic-gate  * returned in network order (suitable for use in system calls).
39*7c478bd9Sstevel@tonic-gate  */
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #ifndef _NETDB_H
42*7c478bd9Sstevel@tonic-gate #define	_NETDB_H
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
45*7c478bd9Sstevel@tonic-gate extern "C" {
46*7c478bd9Sstevel@tonic-gate #endif
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate #define	_PATH_HEQUIV	"/etc/hosts.equiv"
49*7c478bd9Sstevel@tonic-gate #define	_PATH_HOSTS	"/etc/hosts"
50*7c478bd9Sstevel@tonic-gate #define	_PATH_NETWORKS	"/etc/networks"
51*7c478bd9Sstevel@tonic-gate #define	_PATH_PROTOCOLS	"/etc/protocols"
52*7c478bd9Sstevel@tonic-gate #define	_PATH_SERVICES	"/etc/services"
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate struct	hostent {
55*7c478bd9Sstevel@tonic-gate 	char	*h_name;	/* official name of host */
56*7c478bd9Sstevel@tonic-gate 	char	**h_aliases;	/* alias list */
57*7c478bd9Sstevel@tonic-gate 	int	h_addrtype;	/* host address type */
58*7c478bd9Sstevel@tonic-gate 	int	h_length;	/* length of address */
59*7c478bd9Sstevel@tonic-gate 	char	**h_addr_list;	/* list of addresses from name server */
60*7c478bd9Sstevel@tonic-gate #define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
61*7c478bd9Sstevel@tonic-gate };
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate /*
64*7c478bd9Sstevel@tonic-gate  * Assumption here is that a network number
65*7c478bd9Sstevel@tonic-gate  * fits in 32 bits -- probably a poor one.
66*7c478bd9Sstevel@tonic-gate  */
67*7c478bd9Sstevel@tonic-gate struct	netent {
68*7c478bd9Sstevel@tonic-gate 	char		*n_name;	/* official name of net */
69*7c478bd9Sstevel@tonic-gate 	char		**n_aliases;	/* alias list */
70*7c478bd9Sstevel@tonic-gate 	int		n_addrtype;	/* net address type */
71*7c478bd9Sstevel@tonic-gate 	unsigned long	n_net;		/* network # */
72*7c478bd9Sstevel@tonic-gate };
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate struct	servent {
75*7c478bd9Sstevel@tonic-gate 	char	*s_name;	/* official service name */
76*7c478bd9Sstevel@tonic-gate 	char	**s_aliases;	/* alias list */
77*7c478bd9Sstevel@tonic-gate 	int	s_port;		/* port # */
78*7c478bd9Sstevel@tonic-gate 	char	*s_proto;	/* protocol to use */
79*7c478bd9Sstevel@tonic-gate };
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate struct	protoent {
82*7c478bd9Sstevel@tonic-gate 	char	*p_name;	/* official protocol name */
83*7c478bd9Sstevel@tonic-gate 	char	**p_aliases;	/* alias list */
84*7c478bd9Sstevel@tonic-gate 	int	p_proto;	/* protocol # */
85*7c478bd9Sstevel@tonic-gate };
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
88*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname_r
89*7c478bd9Sstevel@tonic-gate 	(const char *,		 struct hostent *, char *, int, int *h_errnop);
90*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr_r
91*7c478bd9Sstevel@tonic-gate 	(const char *, int, int, struct hostent *, char *, int, int *h_errnop);
92*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent_r(struct hostent *, char *, int, int *h_errnop);
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname_r
95*7c478bd9Sstevel@tonic-gate 	(const char *name, const char *, struct servent *, char *, int);
96*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport_r
97*7c478bd9Sstevel@tonic-gate 	(int port,	   const char *, struct servent *, char *, int);
98*7c478bd9Sstevel@tonic-gate struct servent	*getservent_r(struct	servent *, char *, int);
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname_r
101*7c478bd9Sstevel@tonic-gate 	(const char *, struct netent *, char *, int);
102*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr_r(long, int, struct netent *, char *, int);
103*7c478bd9Sstevel@tonic-gate struct netent	*getnetent_r(struct netent *, char *, int);
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname_r
106*7c478bd9Sstevel@tonic-gate 	(const char *, struct protoent *, char *, int);
107*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber_r
108*7c478bd9Sstevel@tonic-gate 	(int, struct protoent *, char *, int);
109*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent_r(struct protoent *, char *, int);
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate int getnetgrent_r(char **, char **, char **, char *, int);
112*7c478bd9Sstevel@tonic-gate int innetgr(const char *, const char *, const char *, const char *);
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /* Old interfaces that return a pointer to a static area;  MT-unsafe */
115*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname(const char *);
116*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr(const char *, int, int);
117*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent(void);
118*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname(const char *);
119*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr(long, int);
120*7c478bd9Sstevel@tonic-gate struct netent	*getnetent(void);
121*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname(const char *, const char *);
122*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport(int, const char *);
123*7c478bd9Sstevel@tonic-gate struct servent	*getservent(void);
124*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname(const char *);
125*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber(int);
126*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent(void);
127*7c478bd9Sstevel@tonic-gate int		 getnetgrent(char **, char **, char **);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate int sethostent(int);
130*7c478bd9Sstevel@tonic-gate int endhostent(void);
131*7c478bd9Sstevel@tonic-gate int setnetent(int);
132*7c478bd9Sstevel@tonic-gate int endnetent(void);
133*7c478bd9Sstevel@tonic-gate int setservent(int);
134*7c478bd9Sstevel@tonic-gate int endservent(void);
135*7c478bd9Sstevel@tonic-gate int setprotoent(int);
136*7c478bd9Sstevel@tonic-gate int endprotoent(void);
137*7c478bd9Sstevel@tonic-gate int setnetgrent(const char *);
138*7c478bd9Sstevel@tonic-gate int endnetgrent(void);
139*7c478bd9Sstevel@tonic-gate int rcmd(char **ahost, unsigned short inport,
140*7c478bd9Sstevel@tonic-gate 	const char *luser, const char *ruser, const char *cmd, int *fd2p);
141*7c478bd9Sstevel@tonic-gate int rexec(char **ahost, unsigned short inport,
142*7c478bd9Sstevel@tonic-gate 	const char *user, const char *passwd, const char *cmd, int *fd2p);
143*7c478bd9Sstevel@tonic-gate int rresvport(int *);
144*7c478bd9Sstevel@tonic-gate int ruserok(const char *rhost, int suser, const char *ruser, const char *luser);
145*7c478bd9Sstevel@tonic-gate #else
146*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname_r();
147*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr_r();
148*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent_r();
149*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname_r();
150*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport_r();
151*7c478bd9Sstevel@tonic-gate struct servent	*getservent_r();
152*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname_r();
153*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr_r();
154*7c478bd9Sstevel@tonic-gate struct netent	*getnetent_r();
155*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname_r();
156*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber_r();
157*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent_r();
158*7c478bd9Sstevel@tonic-gate int		 getnetgrent_r();
159*7c478bd9Sstevel@tonic-gate int		 innetgr();
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate /* Old interfaces that return a pointer to a static area;  MT-unsafe */
162*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname();
163*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr();
164*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent();
165*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname();
166*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr();
167*7c478bd9Sstevel@tonic-gate struct netent	*getnetent();
168*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname();
169*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport();
170*7c478bd9Sstevel@tonic-gate struct servent	*getservent();
171*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname();
172*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber();
173*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent();
174*7c478bd9Sstevel@tonic-gate int		 getnetgrent();
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate int sethostent();
177*7c478bd9Sstevel@tonic-gate int endhostent();
178*7c478bd9Sstevel@tonic-gate int setnetent();
179*7c478bd9Sstevel@tonic-gate int endnetent();
180*7c478bd9Sstevel@tonic-gate int setservent();
181*7c478bd9Sstevel@tonic-gate int endservent();
182*7c478bd9Sstevel@tonic-gate int setprotoent();
183*7c478bd9Sstevel@tonic-gate int endprotoent();
184*7c478bd9Sstevel@tonic-gate int setnetgrent();
185*7c478bd9Sstevel@tonic-gate int endnetgrent();
186*7c478bd9Sstevel@tonic-gate int rcmd();
187*7c478bd9Sstevel@tonic-gate int rexec();
188*7c478bd9Sstevel@tonic-gate int rresvport();
189*7c478bd9Sstevel@tonic-gate int ruserok();
190*7c478bd9Sstevel@tonic-gate #endif
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate /*
193*7c478bd9Sstevel@tonic-gate  * Error return codes from gethostbyname() and gethostbyaddr()
194*7c478bd9Sstevel@tonic-gate  * (when using the resolver)
195*7c478bd9Sstevel@tonic-gate  */
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate extern  int h_errno;
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate #define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
200*7c478bd9Sstevel@tonic-gate #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
201*7c478bd9Sstevel@tonic-gate #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
202*7c478bd9Sstevel@tonic-gate #define	NO_DATA		4 /* Valid name, no data record of requested type */
203*7c478bd9Sstevel@tonic-gate #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate #define	MAXHOSTNAMELEN	256
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate #define	MAXALIASES	35
208*7c478bd9Sstevel@tonic-gate #define	MAXADDRS	35
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
211*7c478bd9Sstevel@tonic-gate }
212*7c478bd9Sstevel@tonic-gate #endif
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate #endif	/* _NETDB_H */
215