xref: /illumos-gate/usr/src/head/netdb.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate /*
10*7c478bd9Sstevel@tonic-gate  * BIND 4.9.3:
11*7c478bd9Sstevel@tonic-gate  *
12*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1980, 1983, 1988, 1993
13*7c478bd9Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
14*7c478bd9Sstevel@tonic-gate  *
15*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
16*7c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
17*7c478bd9Sstevel@tonic-gate  * are met:
18*7c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
19*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
20*7c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
21*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
22*7c478bd9Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
23*7c478bd9Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
24*7c478bd9Sstevel@tonic-gate  *    must display the following acknowledgement:
25*7c478bd9Sstevel@tonic-gate  *	This product includes software developed by the University of
26*7c478bd9Sstevel@tonic-gate  *	California, Berkeley and its contributors.
27*7c478bd9Sstevel@tonic-gate  * 4. Neither the name of the University nor the names of its contributors
28*7c478bd9Sstevel@tonic-gate  *    may be used to endorse or promote products derived from this software
29*7c478bd9Sstevel@tonic-gate  *    without specific prior written permission.
30*7c478bd9Sstevel@tonic-gate  *
31*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
32*7c478bd9Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33*7c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34*7c478bd9Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35*7c478bd9Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*7c478bd9Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*7c478bd9Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*7c478bd9Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39*7c478bd9Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40*7c478bd9Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41*7c478bd9Sstevel@tonic-gate  * SUCH DAMAGE.
42*7c478bd9Sstevel@tonic-gate  * -
43*7c478bd9Sstevel@tonic-gate  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
44*7c478bd9Sstevel@tonic-gate  *
45*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software for any
46*7c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
47*7c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies, and that
48*7c478bd9Sstevel@tonic-gate  * the name of Digital Equipment Corporation not be used in advertising or
49*7c478bd9Sstevel@tonic-gate  * publicity pertaining to distribution of the document or software without
50*7c478bd9Sstevel@tonic-gate  * specific, written prior permission.
51*7c478bd9Sstevel@tonic-gate  *
52*7c478bd9Sstevel@tonic-gate  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
53*7c478bd9Sstevel@tonic-gate  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
54*7c478bd9Sstevel@tonic-gate  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
55*7c478bd9Sstevel@tonic-gate  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
56*7c478bd9Sstevel@tonic-gate  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
57*7c478bd9Sstevel@tonic-gate  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
58*7c478bd9Sstevel@tonic-gate  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
59*7c478bd9Sstevel@tonic-gate  * SOFTWARE.
60*7c478bd9Sstevel@tonic-gate  * --Copyright--
61*7c478bd9Sstevel@tonic-gate  *
62*7c478bd9Sstevel@tonic-gate  * End BIND 4.9.3
63*7c478bd9Sstevel@tonic-gate  */
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /*
66*7c478bd9Sstevel@tonic-gate  * Structures returned by network data base library.
67*7c478bd9Sstevel@tonic-gate  * All addresses are supplied in host order, and
68*7c478bd9Sstevel@tonic-gate  * returned in network order (suitable for use in system calls).
69*7c478bd9Sstevel@tonic-gate  */
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate #ifndef _NETDB_H
72*7c478bd9Sstevel@tonic-gate #define	_NETDB_H
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
75*7c478bd9Sstevel@tonic-gate 
76*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
77*7c478bd9Sstevel@tonic-gate #include <netinet/in.h>
78*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
79*7c478bd9Sstevel@tonic-gate #include <sys/socket.h>
80*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
81*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
84*7c478bd9Sstevel@tonic-gate extern "C" {
85*7c478bd9Sstevel@tonic-gate #endif
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate #define	_PATH_HEQUIV	"/etc/hosts.equiv"
88*7c478bd9Sstevel@tonic-gate #define	_PATH_HOSTS	"/etc/hosts"
89*7c478bd9Sstevel@tonic-gate #define	_PATH_IPNODES	"/etc/inet/ipnodes"
90*7c478bd9Sstevel@tonic-gate #define	_PATH_IPSECALGS	"/etc/inet/ipsecalgs"
91*7c478bd9Sstevel@tonic-gate #define	_PATH_NETMASKS	"/etc/netmasks"
92*7c478bd9Sstevel@tonic-gate #define	_PATH_NETWORKS	"/etc/networks"
93*7c478bd9Sstevel@tonic-gate #define	_PATH_PROTOCOLS	"/etc/protocols"
94*7c478bd9Sstevel@tonic-gate #define	_PATH_SERVICES	"/etc/services"
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate struct	hostent {
97*7c478bd9Sstevel@tonic-gate 	char	*h_name;	/* official name of host */
98*7c478bd9Sstevel@tonic-gate 	char	**h_aliases;	/* alias list */
99*7c478bd9Sstevel@tonic-gate 	int	h_addrtype;	/* host address type */
100*7c478bd9Sstevel@tonic-gate 	int	h_length;	/* length of address */
101*7c478bd9Sstevel@tonic-gate 	char	**h_addr_list;	/* list of addresses from name server */
102*7c478bd9Sstevel@tonic-gate #define	h_addr	h_addr_list[0]	/* address, for backward compatiblity */
103*7c478bd9Sstevel@tonic-gate };
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /*
107*7c478bd9Sstevel@tonic-gate  * addrinfo introduced with IPv6 for Protocol-Independent Hostname
108*7c478bd9Sstevel@tonic-gate  * and Service Name Translation.
109*7c478bd9Sstevel@tonic-gate  */
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
112*7c478bd9Sstevel@tonic-gate struct addrinfo {
113*7c478bd9Sstevel@tonic-gate 	int ai_flags;		/* AI_PASSIVE, AI_CANONNAME, ... */
114*7c478bd9Sstevel@tonic-gate 	int ai_family;		/* PF_xxx */
115*7c478bd9Sstevel@tonic-gate 	int ai_socktype;	/* SOCK_xxx */
116*7c478bd9Sstevel@tonic-gate 	int ai_protocol;	/* 0 or IPPROTO_xxx for IPv4 and IPv6 */
117*7c478bd9Sstevel@tonic-gate #ifdef __sparcv9
118*7c478bd9Sstevel@tonic-gate 	int _ai_pad;		/* for backwards compat with old size_t */
119*7c478bd9Sstevel@tonic-gate #endif /* __sparcv9 */
120*7c478bd9Sstevel@tonic-gate 	socklen_t ai_addrlen;
121*7c478bd9Sstevel@tonic-gate 	char *ai_canonname;	/* canonical name for hostname */
122*7c478bd9Sstevel@tonic-gate 	struct sockaddr *ai_addr;	/* binary address */
123*7c478bd9Sstevel@tonic-gate 	struct addrinfo *ai_next;	/* next structure in linked list */
124*7c478bd9Sstevel@tonic-gate };
125*7c478bd9Sstevel@tonic-gate /* addrinfo flags */
126*7c478bd9Sstevel@tonic-gate #define	AI_PASSIVE	0x0008	/* intended for bind() + listen() */
127*7c478bd9Sstevel@tonic-gate #define	AI_CANONNAME	0x0010	/* return canonical version of host */
128*7c478bd9Sstevel@tonic-gate #define	AI_NUMERICHOST	0x0020	/* use numeric node address string */
129*7c478bd9Sstevel@tonic-gate #define	AI_NUMERICSERV	0x0040	/* servname is assumed numeric */
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate /* getipnodebyname() flags */
132*7c478bd9Sstevel@tonic-gate #define	AI_V4MAPPED	0x0001	/* IPv4 mapped addresses if no IPv6 */
133*7c478bd9Sstevel@tonic-gate #define	AI_ALL		0x0002	/* IPv6 and IPv4 mapped addresses */
134*7c478bd9Sstevel@tonic-gate #define	AI_ADDRCONFIG	0x0004	/* AAAA or A records only if IPv6/IPv4 cnfg'd */
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate /*
137*7c478bd9Sstevel@tonic-gate  * These were defined in RFC 2553 but not SUSv3
138*7c478bd9Sstevel@tonic-gate  * or RFC 3493 which obsoleted 2553.
139*7c478bd9Sstevel@tonic-gate  */
140*7c478bd9Sstevel@tonic-gate #if !defined(_XPG6) || defined(__EXTENSIONS__)
141*7c478bd9Sstevel@tonic-gate #define	AI_DEFAULT	(AI_V4MAPPED | AI_ADDRCONFIG)
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate /* addrinfo errors */
144*7c478bd9Sstevel@tonic-gate #define	EAI_ADDRFAMILY	1	/* address family not supported */
145*7c478bd9Sstevel@tonic-gate #define	EAI_NODATA	7	/* no address */
146*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
147*7c478bd9Sstevel@tonic-gate #define	EAI_AGAIN	2	/* DNS temporary failure */
148*7c478bd9Sstevel@tonic-gate #define	EAI_BADFLAGS	3	/* invalid ai_flags */
149*7c478bd9Sstevel@tonic-gate #define	EAI_FAIL	4	/* DNS non-recoverable failure */
150*7c478bd9Sstevel@tonic-gate #define	EAI_FAMILY	5	/* ai_family not supported */
151*7c478bd9Sstevel@tonic-gate #define	EAI_MEMORY	6	/* memory allocation failure */
152*7c478bd9Sstevel@tonic-gate #define	EAI_NONAME	8	/* host/servname not known */
153*7c478bd9Sstevel@tonic-gate #define	EAI_SERVICE	9	/* servname not supported for ai_socktype */
154*7c478bd9Sstevel@tonic-gate #define	EAI_SOCKTYPE	10	/* ai_socktype not supported */
155*7c478bd9Sstevel@tonic-gate #define	EAI_SYSTEM	11	/* system error in errno */
156*7c478bd9Sstevel@tonic-gate #define	EAI_OVERFLOW	12	/* argument buffer overflow */
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate /* getnameinfo flags */
159*7c478bd9Sstevel@tonic-gate #define	NI_NOFQDN	0x0001
160*7c478bd9Sstevel@tonic-gate #define	NI_NUMERICHOST	0x0002	/* return numeric form of address */
161*7c478bd9Sstevel@tonic-gate #define	NI_NAMEREQD	0x0004	/* request DNS name */
162*7c478bd9Sstevel@tonic-gate #define	NI_NUMERICSERV	0x0008
163*7c478bd9Sstevel@tonic-gate #define	NI_DGRAM	0x0010
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate #if !defined(_XPG6) || defined(__EXTENSIONS__)
166*7c478bd9Sstevel@tonic-gate /* Not listed in any standards document */
167*7c478bd9Sstevel@tonic-gate #define	NI_WITHSCOPEID  0x0020
168*7c478bd9Sstevel@tonic-gate #define	NI_NUMERICSCOPE 0x0040
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate /* getnameinfo max sizes as defined in RFC 2553 obsoleted in RFC 3493 */
171*7c478bd9Sstevel@tonic-gate #define	NI_MAXHOST	1025
172*7c478bd9Sstevel@tonic-gate #define	NI_MAXSERV	32
173*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
174*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate /*
177*7c478bd9Sstevel@tonic-gate  * Algorithm entry for /etc/inet/ipsecalgs which defines IPsec protocols
178*7c478bd9Sstevel@tonic-gate  * and algorithms.
179*7c478bd9Sstevel@tonic-gate  */
180*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
181*7c478bd9Sstevel@tonic-gate typedef struct ipsecalgent {
182*7c478bd9Sstevel@tonic-gate 	char **a_names;		/* algorithm names */
183*7c478bd9Sstevel@tonic-gate 	int a_proto_num;	/* protocol number */
184*7c478bd9Sstevel@tonic-gate 	int a_alg_num;		/* algorithm number */
185*7c478bd9Sstevel@tonic-gate 	char *a_mech_name;	/* encryption framework mechanism name */
186*7c478bd9Sstevel@tonic-gate 	int *a_block_sizes;	/* supported block sizes */
187*7c478bd9Sstevel@tonic-gate 	int *a_key_sizes;	/* supported key sizes */
188*7c478bd9Sstevel@tonic-gate 	int a_key_increment;	/* key size increment */
189*7c478bd9Sstevel@tonic-gate } ipsecalgent_t;
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate /* well-known IPsec protocol numbers */
192*7c478bd9Sstevel@tonic-gate 
193*7c478bd9Sstevel@tonic-gate #define	IPSEC_PROTO_AH		2
194*7c478bd9Sstevel@tonic-gate #define	IPSEC_PROTO_ESP		3
195*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate /*
198*7c478bd9Sstevel@tonic-gate  * Assumption here is that a network number
199*7c478bd9Sstevel@tonic-gate  * fits in 32 bits -- probably a poor one.
200*7c478bd9Sstevel@tonic-gate  */
201*7c478bd9Sstevel@tonic-gate struct	netent {
202*7c478bd9Sstevel@tonic-gate 	char		*n_name;	/* official name of net */
203*7c478bd9Sstevel@tonic-gate 	char		**n_aliases;	/* alias list */
204*7c478bd9Sstevel@tonic-gate 	int		n_addrtype;	/* net address type */
205*7c478bd9Sstevel@tonic-gate 	in_addr_t	n_net;		/* network # */
206*7c478bd9Sstevel@tonic-gate };
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate struct	protoent {
209*7c478bd9Sstevel@tonic-gate 	char	*p_name;	/* official protocol name */
210*7c478bd9Sstevel@tonic-gate 	char	**p_aliases;	/* alias list */
211*7c478bd9Sstevel@tonic-gate 	int	p_proto;	/* protocol # */
212*7c478bd9Sstevel@tonic-gate };
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate struct	servent {
215*7c478bd9Sstevel@tonic-gate 	char	*s_name;	/* official service name */
216*7c478bd9Sstevel@tonic-gate 	char	**s_aliases;	/* alias list */
217*7c478bd9Sstevel@tonic-gate 	int	s_port;		/* port # */
218*7c478bd9Sstevel@tonic-gate 	char	*s_proto;	/* protocol to use */
219*7c478bd9Sstevel@tonic-gate };
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
222*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
223*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname_r
224*7c478bd9Sstevel@tonic-gate 	(const char *, struct hostent *, char *, int, int *h_errnop);
225*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr_r
226*7c478bd9Sstevel@tonic-gate 	(const char *, int, int, struct hostent *, char *, int, int *h_errnop);
227*7c478bd9Sstevel@tonic-gate struct hostent	*getipnodebyname(const char *, int, int, int *);
228*7c478bd9Sstevel@tonic-gate struct hostent	*getipnodebyaddr(const void *, size_t, int, int *);
229*7c478bd9Sstevel@tonic-gate void		freehostent(struct hostent *);
230*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent_r(struct hostent *, char *, int, int *h_errnop);
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname_r
233*7c478bd9Sstevel@tonic-gate 	(const char *name, const char *, struct servent *, char *, int);
234*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport_r
235*7c478bd9Sstevel@tonic-gate 	(int port, const char *, struct servent *, char *, int);
236*7c478bd9Sstevel@tonic-gate struct servent	*getservent_r(struct	servent *, char *, int);
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname_r
239*7c478bd9Sstevel@tonic-gate 	(const char *, struct netent *, char *, int);
240*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr_r(long, int, struct netent *, char *, int);
241*7c478bd9Sstevel@tonic-gate struct netent	*getnetent_r(struct netent *, char *, int);
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname_r
244*7c478bd9Sstevel@tonic-gate 	(const char *, struct protoent *, char *, int);
245*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber_r
246*7c478bd9Sstevel@tonic-gate 	(int, struct protoent *, char *, int);
247*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent_r(struct protoent *, char *, int);
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate int getnetgrent_r(char **, char **, char **, char *, int);
250*7c478bd9Sstevel@tonic-gate int innetgr(const char *, const char *, const char *, const char *);
251*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate /* Old interfaces that return a pointer to a static area;  MT-unsafe */
254*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname(const char *);
255*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent(void);
256*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr(in_addr_t, int);
257*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname(const char *);
258*7c478bd9Sstevel@tonic-gate struct netent	*getnetent(void);
259*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname(const char *);
260*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber(int);
261*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent(void);
262*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname(const char *, const char *);
263*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport(int, const char *);
264*7c478bd9Sstevel@tonic-gate struct servent	*getservent(void);
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate /* gethostbyaddr() second argument is a size_t only in unix95/unix98 */
267*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
268*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr(const void *, socklen_t, int);
269*7c478bd9Sstevel@tonic-gate #else
270*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr(const void *, size_t, int);
271*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
274*7c478bd9Sstevel@tonic-gate int endhostent(void);
275*7c478bd9Sstevel@tonic-gate int endnetent(void);
276*7c478bd9Sstevel@tonic-gate int endprotoent(void);
277*7c478bd9Sstevel@tonic-gate int endservent(void);
278*7c478bd9Sstevel@tonic-gate int sethostent(int);
279*7c478bd9Sstevel@tonic-gate int setnetent(int);
280*7c478bd9Sstevel@tonic-gate int setprotoent(int);
281*7c478bd9Sstevel@tonic-gate int setservent(int);
282*7c478bd9Sstevel@tonic-gate #else
283*7c478bd9Sstevel@tonic-gate void endhostent(void);
284*7c478bd9Sstevel@tonic-gate void endnetent(void);
285*7c478bd9Sstevel@tonic-gate void endprotoent(void);
286*7c478bd9Sstevel@tonic-gate void endservent(void);
287*7c478bd9Sstevel@tonic-gate void sethostent(int);
288*7c478bd9Sstevel@tonic-gate void setnetent(int);
289*7c478bd9Sstevel@tonic-gate void setprotoent(int);
290*7c478bd9Sstevel@tonic-gate void setservent(int);
291*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
294*7c478bd9Sstevel@tonic-gate 
295*7c478bd9Sstevel@tonic-gate #ifdef	_XPG6
296*7c478bd9Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
297*7c478bd9Sstevel@tonic-gate #pragma redefine_extname getaddrinfo __xnet_getaddrinfo
298*7c478bd9Sstevel@tonic-gate #else	/* __PRAGMA_REDEFINE_EXTNAME */
299*7c478bd9Sstevel@tonic-gate #define	getaddrinfo __xnet_getaddrinfo
300*7c478bd9Sstevel@tonic-gate #endif	/* __PRAGMA_REDEFINE_EXTNAME */
301*7c478bd9Sstevel@tonic-gate #endif	/* _XPG6 */
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate int		getaddrinfo(const char *_RESTRICT_KYWD,
304*7c478bd9Sstevel@tonic-gate 			const char *_RESTRICT_KYWD,
305*7c478bd9Sstevel@tonic-gate 			const struct addrinfo *_RESTRICT_KYWD,
306*7c478bd9Sstevel@tonic-gate 			struct addrinfo **_RESTRICT_KYWD);
307*7c478bd9Sstevel@tonic-gate void		freeaddrinfo(struct addrinfo *);
308*7c478bd9Sstevel@tonic-gate const char	*gai_strerror(int);
309*7c478bd9Sstevel@tonic-gate int		getnameinfo(const struct sockaddr *_RESTRICT_KYWD,
310*7c478bd9Sstevel@tonic-gate 			socklen_t, char *_RESTRICT_KYWD, socklen_t,
311*7c478bd9Sstevel@tonic-gate 			char *_RESTRICT_KYWD, socklen_t, int);
312*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
313*7c478bd9Sstevel@tonic-gate 
314*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
315*7c478bd9Sstevel@tonic-gate int getnetgrent(char **, char **, char **);
316*7c478bd9Sstevel@tonic-gate int setnetgrent(const char *);
317*7c478bd9Sstevel@tonic-gate int endnetgrent(void);
318*7c478bd9Sstevel@tonic-gate int rcmd(char **, unsigned short,
319*7c478bd9Sstevel@tonic-gate 	const char *, const char *, const char *, int *);
320*7c478bd9Sstevel@tonic-gate int rcmd_af(char **, unsigned short,
321*7c478bd9Sstevel@tonic-gate 	const char *, const char *, const char *, int *, int);
322*7c478bd9Sstevel@tonic-gate int rresvport_af(int *, int);
323*7c478bd9Sstevel@tonic-gate int rresvport_addr(int *, struct sockaddr_storage *);
324*7c478bd9Sstevel@tonic-gate int rexec(char **, unsigned short,
325*7c478bd9Sstevel@tonic-gate 	const char *, const char *, const char *, int *);
326*7c478bd9Sstevel@tonic-gate int rexec_af(char **, unsigned short,
327*7c478bd9Sstevel@tonic-gate 	const char *, const char *, const char *, int *, int);
328*7c478bd9Sstevel@tonic-gate int rresvport(int *);
329*7c478bd9Sstevel@tonic-gate int ruserok(const char *, int, const char *, const char *);
330*7c478bd9Sstevel@tonic-gate /* BIND */
331*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname2(const char *, int);
332*7c478bd9Sstevel@tonic-gate void		herror(const char *);
333*7c478bd9Sstevel@tonic-gate const char	*hstrerror(int);
334*7c478bd9Sstevel@tonic-gate /* End BIND */
335*7c478bd9Sstevel@tonic-gate 
336*7c478bd9Sstevel@tonic-gate /* IPsec algorithm prototype definitions */
337*7c478bd9Sstevel@tonic-gate struct ipsecalgent *getipsecalgbyname(const char *, int, int *);
338*7c478bd9Sstevel@tonic-gate struct ipsecalgent *getipsecalgbynum(int, int, int *);
339*7c478bd9Sstevel@tonic-gate int getipsecprotobyname(const char *doi_name);
340*7c478bd9Sstevel@tonic-gate char *getipsecprotobynum(int doi_domain);
341*7c478bd9Sstevel@tonic-gate void freeipsecalgent(struct ipsecalgent *ptr);
342*7c478bd9Sstevel@tonic-gate /* END IPsec algorithm prototype definitions */
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
345*7c478bd9Sstevel@tonic-gate #else	/* __STDC__ */
346*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname_r();
347*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr_r();
348*7c478bd9Sstevel@tonic-gate struct hostent	*getipnodebyname();
349*7c478bd9Sstevel@tonic-gate struct hostent	*getipnodebyaddr();
350*7c478bd9Sstevel@tonic-gate void		 freehostent();
351*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent_r();
352*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname_r();
353*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport_r();
354*7c478bd9Sstevel@tonic-gate struct servent	*getservent_r();
355*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname_r();
356*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr_r();
357*7c478bd9Sstevel@tonic-gate struct netent	*getnetent_r();
358*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname_r();
359*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber_r();
360*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent_r();
361*7c478bd9Sstevel@tonic-gate int		 getnetgrent_r();
362*7c478bd9Sstevel@tonic-gate int		 innetgr();
363*7c478bd9Sstevel@tonic-gate 
364*7c478bd9Sstevel@tonic-gate /* Old interfaces that return a pointer to a static area;  MT-unsafe */
365*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname();
366*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyaddr();
367*7c478bd9Sstevel@tonic-gate struct hostent	*gethostent();
368*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyname();
369*7c478bd9Sstevel@tonic-gate struct netent	*getnetbyaddr();
370*7c478bd9Sstevel@tonic-gate struct netent	*getnetent();
371*7c478bd9Sstevel@tonic-gate struct servent	*getservbyname();
372*7c478bd9Sstevel@tonic-gate struct servent	*getservbyport();
373*7c478bd9Sstevel@tonic-gate struct servent	*getservent();
374*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobyname();
375*7c478bd9Sstevel@tonic-gate struct protoent	*getprotobynumber();
376*7c478bd9Sstevel@tonic-gate struct protoent	*getprotoent();
377*7c478bd9Sstevel@tonic-gate int		 getnetgrent();
378*7c478bd9Sstevel@tonic-gate 
379*7c478bd9Sstevel@tonic-gate int sethostent();
380*7c478bd9Sstevel@tonic-gate int endhostent();
381*7c478bd9Sstevel@tonic-gate int setnetent();
382*7c478bd9Sstevel@tonic-gate int endnetent();
383*7c478bd9Sstevel@tonic-gate int setservent();
384*7c478bd9Sstevel@tonic-gate int endservent();
385*7c478bd9Sstevel@tonic-gate int setprotoent();
386*7c478bd9Sstevel@tonic-gate int endprotoent();
387*7c478bd9Sstevel@tonic-gate int setnetgrent();
388*7c478bd9Sstevel@tonic-gate int endnetgrent();
389*7c478bd9Sstevel@tonic-gate int rcmd();
390*7c478bd9Sstevel@tonic-gate int rcmd_af();
391*7c478bd9Sstevel@tonic-gate int rexec();
392*7c478bd9Sstevel@tonic-gate int rexec_af();
393*7c478bd9Sstevel@tonic-gate int rresvport();
394*7c478bd9Sstevel@tonic-gate int rresvport_af();
395*7c478bd9Sstevel@tonic-gate int rresvport_addr();
396*7c478bd9Sstevel@tonic-gate int ruserok();
397*7c478bd9Sstevel@tonic-gate /* BIND */
398*7c478bd9Sstevel@tonic-gate struct hostent	*gethostbyname2();
399*7c478bd9Sstevel@tonic-gate void		herror();
400*7c478bd9Sstevel@tonic-gate char		*hstrerror();
401*7c478bd9Sstevel@tonic-gate /* IPv6 prototype definitons */
402*7c478bd9Sstevel@tonic-gate int		getaddrinfo();
403*7c478bd9Sstevel@tonic-gate void		freeaddrinfo();
404*7c478bd9Sstevel@tonic-gate const char	*gai_strerror();
405*7c478bd9Sstevel@tonic-gate int		getnameinfo();
406*7c478bd9Sstevel@tonic-gate /* END IPv6 prototype definitions */
407*7c478bd9Sstevel@tonic-gate /* End BIND */
408*7c478bd9Sstevel@tonic-gate 
409*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
410*7c478bd9Sstevel@tonic-gate /* IPsec algorithm prototype definitions */
411*7c478bd9Sstevel@tonic-gate struct ipsecalgent *getalgbyname();
412*7c478bd9Sstevel@tonic-gate struct ipsecalgent *getalgbydoi();
413*7c478bd9Sstevel@tonic-gate int getdoidomainbyname();
414*7c478bd9Sstevel@tonic-gate const char *getdoidomainbynum();
415*7c478bd9Sstevel@tonic-gate void freealgent();
416*7c478bd9Sstevel@tonic-gate /* END IPsec algorithm prototype definitions */
417*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
418*7c478bd9Sstevel@tonic-gate 
419*7c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate /*
422*7c478bd9Sstevel@tonic-gate  * Error return codes from gethostbyname() and gethostbyaddr()
423*7c478bd9Sstevel@tonic-gate  * (when using the resolver)
424*7c478bd9Sstevel@tonic-gate  */
425*7c478bd9Sstevel@tonic-gate 
426*7c478bd9Sstevel@tonic-gate extern  int h_errno;
427*7c478bd9Sstevel@tonic-gate 
428*7c478bd9Sstevel@tonic-gate #ifdef	_REENTRANT
429*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
430*7c478bd9Sstevel@tonic-gate extern int	*__h_errno(void);
431*7c478bd9Sstevel@tonic-gate #else
432*7c478bd9Sstevel@tonic-gate extern int	*__h_errno();
433*7c478bd9Sstevel@tonic-gate #endif	/* __STDC__ */
434*7c478bd9Sstevel@tonic-gate 
435*7c478bd9Sstevel@tonic-gate /* Only #define h_errno if there is no conflict with other use */
436*7c478bd9Sstevel@tonic-gate #ifdef	H_ERRNO_IS_FUNCTION
437*7c478bd9Sstevel@tonic-gate #define	h_errno	(*__h_errno())
438*7c478bd9Sstevel@tonic-gate #endif	/* NO_H_ERRNO_DEFINE */
439*7c478bd9Sstevel@tonic-gate #endif	/* _REENTRANT */
440*7c478bd9Sstevel@tonic-gate 
441*7c478bd9Sstevel@tonic-gate #define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
442*7c478bd9Sstevel@tonic-gate #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
443*7c478bd9Sstevel@tonic-gate #define	NO_RECOVERY	3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
444*7c478bd9Sstevel@tonic-gate #define	NO_DATA		4 /* Valid name, no data record of requested type */
445*7c478bd9Sstevel@tonic-gate 
446*7c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
447*7c478bd9Sstevel@tonic-gate #define	NO_ADDRESS	NO_DATA		/* no address, look for MX record */
448*7c478bd9Sstevel@tonic-gate 
449*7c478bd9Sstevel@tonic-gate /* BIND */
450*7c478bd9Sstevel@tonic-gate #define	NETDB_INTERNAL	-1	/* see errno */
451*7c478bd9Sstevel@tonic-gate #define	NETDB_SUCCESS	0	/* no problem */
452*7c478bd9Sstevel@tonic-gate /* End BIND */
453*7c478bd9Sstevel@tonic-gate 
454*7c478bd9Sstevel@tonic-gate #define	MAXHOSTNAMELEN	256
455*7c478bd9Sstevel@tonic-gate 
456*7c478bd9Sstevel@tonic-gate #define	MAXALIASES	35
457*7c478bd9Sstevel@tonic-gate #define	MAXADDRS	35
458*7c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
459*7c478bd9Sstevel@tonic-gate 
460*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
461*7c478bd9Sstevel@tonic-gate }
462*7c478bd9Sstevel@tonic-gate #endif
463*7c478bd9Sstevel@tonic-gate 
464*7c478bd9Sstevel@tonic-gate #endif	/* _NETDB_H */
465