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