xref: /illumos-gate/usr/src/head/resolv.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  *
5*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T
6*7c478bd9Sstevel@tonic-gate  * All Rights Reserved
7*7c478bd9Sstevel@tonic-gate  *
8*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley
9*7c478bd9Sstevel@tonic-gate  * 4.3 BSD under license from the regents of the University of
10*7c478bd9Sstevel@tonic-gate  * California.
11*7c478bd9Sstevel@tonic-gate  */
12*7c478bd9Sstevel@tonic-gate 
13*7c478bd9Sstevel@tonic-gate /*
14*7c478bd9Sstevel@tonic-gate  * BIND 4.9.4:
15*7c478bd9Sstevel@tonic-gate  */
16*7c478bd9Sstevel@tonic-gate 
17*7c478bd9Sstevel@tonic-gate /*
18*7c478bd9Sstevel@tonic-gate  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software for any
21*7c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
22*7c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies, and that
23*7c478bd9Sstevel@tonic-gate  * the name of Digital Equipment Corporation not be used in advertising or
24*7c478bd9Sstevel@tonic-gate  * publicity pertaining to distribution of the document or software without
25*7c478bd9Sstevel@tonic-gate  * specific, written prior permission.
26*7c478bd9Sstevel@tonic-gate  *
27*7c478bd9Sstevel@tonic-gate  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
28*7c478bd9Sstevel@tonic-gate  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
29*7c478bd9Sstevel@tonic-gate  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
30*7c478bd9Sstevel@tonic-gate  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
31*7c478bd9Sstevel@tonic-gate  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
32*7c478bd9Sstevel@tonic-gate  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
33*7c478bd9Sstevel@tonic-gate  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
34*7c478bd9Sstevel@tonic-gate  * SOFTWARE.
35*7c478bd9Sstevel@tonic-gate  * --Copyright--
36*7c478bd9Sstevel@tonic-gate  *
37*7c478bd9Sstevel@tonic-gate  * End BIND 4.9.4
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate /*
41*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1983, 1987, 1989
42*7c478bd9Sstevel@tonic-gate  *    The Regents of the University of California.  All rights reserved.
43*7c478bd9Sstevel@tonic-gate  *
44*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
45*7c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
46*7c478bd9Sstevel@tonic-gate  * are met:
47*7c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
48*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
49*7c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
50*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
51*7c478bd9Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
52*7c478bd9Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
53*7c478bd9Sstevel@tonic-gate  *    must display the following acknowledgement:
54*7c478bd9Sstevel@tonic-gate  * 	This product includes software developed by the University of
55*7c478bd9Sstevel@tonic-gate  * 	California, Berkeley and its contributors.
56*7c478bd9Sstevel@tonic-gate  * 4. Neither the name of the University nor the names of its contributors
57*7c478bd9Sstevel@tonic-gate  *    may be used to endorse or promote products derived from this software
58*7c478bd9Sstevel@tonic-gate  *    without specific prior written permission.
59*7c478bd9Sstevel@tonic-gate  *
60*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61*7c478bd9Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62*7c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63*7c478bd9Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64*7c478bd9Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65*7c478bd9Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66*7c478bd9Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67*7c478bd9Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68*7c478bd9Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69*7c478bd9Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70*7c478bd9Sstevel@tonic-gate  * SUCH DAMAGE.
71*7c478bd9Sstevel@tonic-gate  */
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /*
74*7c478bd9Sstevel@tonic-gate  * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
75*7c478bd9Sstevel@tonic-gate  *
76*7c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software for any
77*7c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
78*7c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies.
79*7c478bd9Sstevel@tonic-gate  *
80*7c478bd9Sstevel@tonic-gate  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
81*7c478bd9Sstevel@tonic-gate  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
82*7c478bd9Sstevel@tonic-gate  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
83*7c478bd9Sstevel@tonic-gate  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
84*7c478bd9Sstevel@tonic-gate  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
85*7c478bd9Sstevel@tonic-gate  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
86*7c478bd9Sstevel@tonic-gate  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
87*7c478bd9Sstevel@tonic-gate  * SOFTWARE.
88*7c478bd9Sstevel@tonic-gate  */
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate /*
91*7c478bd9Sstevel@tonic-gate  *	@(#)resolv.h	8.1 (Berkeley) 6/2/93
92*7c478bd9Sstevel@tonic-gate  *	$Id: resolv.h,v 8.52 2003/04/29 02:27:03 marka Exp $
93*7c478bd9Sstevel@tonic-gate  */
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate #ifndef _RESOLV_H_
96*7c478bd9Sstevel@tonic-gate #define	_RESOLV_H_
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #include <stdio.h>
103*7c478bd9Sstevel@tonic-gate #include <arpa/nameser.h>
104*7c478bd9Sstevel@tonic-gate #include <sys/socket.h>
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
107*7c478bd9Sstevel@tonic-gate extern "C" {
108*7c478bd9Sstevel@tonic-gate #endif
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /*
111*7c478bd9Sstevel@tonic-gate  * Revision information.  This is the release date in YYYYMMDD format.
112*7c478bd9Sstevel@tonic-gate  * It can change every day so the right thing to do with it is use it
113*7c478bd9Sstevel@tonic-gate  * in preprocessor commands such as "#if (__RES > 19931104)".  Do not
114*7c478bd9Sstevel@tonic-gate  * compare for equality; rather, use it to determine whether your resolver
115*7c478bd9Sstevel@tonic-gate  * is new enough to contain a certain feature.
116*7c478bd9Sstevel@tonic-gate  */
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate #define	__RES	20030124
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #define	RES_SET_H_ERRNO(r, x)	__h_errno_set(r, x)
121*7c478bd9Sstevel@tonic-gate struct __res_state;					/* forward */
122*7c478bd9Sstevel@tonic-gate 
123*7c478bd9Sstevel@tonic-gate void __h_errno_set(struct __res_state *res, int err);
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate /*
126*7c478bd9Sstevel@tonic-gate  * Resolver configuration file.
127*7c478bd9Sstevel@tonic-gate  * Normally not present, but may contain the address of the
128*7c478bd9Sstevel@tonic-gate  * initial name server(s) to query and the domain search list.
129*7c478bd9Sstevel@tonic-gate  */
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate #ifndef _PATH_RESCONF
132*7c478bd9Sstevel@tonic-gate #define	_PATH_RESCONF		"/etc/resolv.conf"
133*7c478bd9Sstevel@tonic-gate #endif
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate #ifdef __STDC__
136*7c478bd9Sstevel@tonic-gate #ifndef __P
137*7c478bd9Sstevel@tonic-gate #define	__P(x)	x
138*7c478bd9Sstevel@tonic-gate #endif
139*7c478bd9Sstevel@tonic-gate #else
140*7c478bd9Sstevel@tonic-gate #ifndef __P
141*7c478bd9Sstevel@tonic-gate #define	__P(x)	()
142*7c478bd9Sstevel@tonic-gate #endif
143*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
146*7c478bd9Sstevel@tonic-gate 	res_sendhookact;
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *ns,
149*7c478bd9Sstevel@tonic-gate 						const uchar_t **query,
150*7c478bd9Sstevel@tonic-gate 						int *querylen,
151*7c478bd9Sstevel@tonic-gate 						uchar_t *ans,
152*7c478bd9Sstevel@tonic-gate 						int anssiz,
153*7c478bd9Sstevel@tonic-gate 						int *resplen));
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *ns,
156*7c478bd9Sstevel@tonic-gate 						const uchar_t *query,
157*7c478bd9Sstevel@tonic-gate 						int querylen,
158*7c478bd9Sstevel@tonic-gate 						uchar_t *ans,
159*7c478bd9Sstevel@tonic-gate 						int anssiz,
160*7c478bd9Sstevel@tonic-gate 						int *resplen));
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate struct res_sym {
163*7c478bd9Sstevel@tonic-gate 	int		number;	   /* Identifying number, like T_MX */
164*7c478bd9Sstevel@tonic-gate 	const char 	*name;	   /* Its symbolic name, like "MX" */
165*7c478bd9Sstevel@tonic-gate 	const char 	*humanname; /* Its fun name, like "mail exchanger" */
166*7c478bd9Sstevel@tonic-gate };
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate /*
169*7c478bd9Sstevel@tonic-gate  * Global defines and variables for resolver stub.
170*7c478bd9Sstevel@tonic-gate  */
171*7c478bd9Sstevel@tonic-gate /* ADDRSORT and MAXADDR retained for compatibility; not used */
172*7c478bd9Sstevel@tonic-gate #define	ADDRSORT	1	/* enable the address-sorting option */
173*7c478bd9Sstevel@tonic-gate #define	MAXADDR		10	/* max # addresses to sort by */
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate #define	MAXNS			3	/* max # name servers we'll track */
176*7c478bd9Sstevel@tonic-gate #define	MAXDFLSRCH		3	/* # default domain levels to try */
177*7c478bd9Sstevel@tonic-gate #define	MAXDNSRCH		6	/* max # domains in search path */
178*7c478bd9Sstevel@tonic-gate #define	LOCALDOMAINPARTS	2	/* min levels in name that is "local" */
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate #define	RES_TIMEOUT		5	/* min. seconds between retries */
181*7c478bd9Sstevel@tonic-gate #define	MAXRESOLVSORT		10	/* number of net to sort on */
182*7c478bd9Sstevel@tonic-gate #define	RES_MAXNDOTS		15	/* should reflect bit field size */
183*7c478bd9Sstevel@tonic-gate #define	RES_MAXRETRANS		30	/* only for resolv.conf/RES_OPTIONS */
184*7c478bd9Sstevel@tonic-gate #define	RES_MAXRETRY		5	/* only for resolv.conf/RES_OPTIONS */
185*7c478bd9Sstevel@tonic-gate #define	RES_DFLRETRY		2	/* Default #/tries. */
186*7c478bd9Sstevel@tonic-gate #define	RES_MAXTIME		65535	/* Infinity, in milliseconds. */
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate struct __res_state_ext;
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate struct __res_state {
191*7c478bd9Sstevel@tonic-gate 	int	retrans;		/* retransmission time interval */
192*7c478bd9Sstevel@tonic-gate 	int	retry;			/* number of times to retransmit */
193*7c478bd9Sstevel@tonic-gate #ifdef __sun
194*7c478bd9Sstevel@tonic-gate 	uint_t	options;		/* option flags - see below. */
195*7c478bd9Sstevel@tonic-gate #else
196*7c478bd9Sstevel@tonic-gate 	ulong_t	options;		/* option flags - see below. */
197*7c478bd9Sstevel@tonic-gate #endif
198*7c478bd9Sstevel@tonic-gate 	int	nscount;		/* number of name servers */
199*7c478bd9Sstevel@tonic-gate 	struct sockaddr_in
200*7c478bd9Sstevel@tonic-gate 		nsaddr_list[MAXNS];	/* address of name server */
201*7c478bd9Sstevel@tonic-gate #define	nsaddr	nsaddr_list[0]		/* for backward compatibility */
202*7c478bd9Sstevel@tonic-gate 	ushort_t id;			/* current packet id */
203*7c478bd9Sstevel@tonic-gate 	char	*dnsrch[MAXDNSRCH+1];	/* components of domain to search */
204*7c478bd9Sstevel@tonic-gate 	char	defdname[256];		/* default domain (deprecated) */
205*7c478bd9Sstevel@tonic-gate #ifdef __sun
206*7c478bd9Sstevel@tonic-gate 	uint_t	pfcode;			/* RES_PRF_ flags - see below. */
207*7c478bd9Sstevel@tonic-gate #else
208*7c478bd9Sstevel@tonic-gate 	ulong_t	pfcode;			/* RES_PRF_ flags - see below. */
209*7c478bd9Sstevel@tonic-gate #endif
210*7c478bd9Sstevel@tonic-gate 	unsigned ndots:4;		/* threshold for initial abs. query */
211*7c478bd9Sstevel@tonic-gate 	unsigned nsort:4;		/* number of elements in sort_list[] */
212*7c478bd9Sstevel@tonic-gate 	char	unused[3];
213*7c478bd9Sstevel@tonic-gate 	struct {
214*7c478bd9Sstevel@tonic-gate 		struct in_addr	addr;
215*7c478bd9Sstevel@tonic-gate 		unsigned int	mask;
216*7c478bd9Sstevel@tonic-gate 	} sort_list[MAXRESOLVSORT];
217*7c478bd9Sstevel@tonic-gate 	res_send_qhook qhook;		/* query hook */
218*7c478bd9Sstevel@tonic-gate 	res_send_rhook rhook;		/* response hook */
219*7c478bd9Sstevel@tonic-gate 	int		res_h_errno;	/* last one set for this context */
220*7c478bd9Sstevel@tonic-gate 	int		_vcsock;	/* PRIVATE: for res_send VC i/o */
221*7c478bd9Sstevel@tonic-gate 	uint_t	_flags;		/* PRIVATE: see below */
222*7c478bd9Sstevel@tonic-gate 	uint_t	_pad;			/* make _u 64 bit aligned */
223*7c478bd9Sstevel@tonic-gate 	union {
224*7c478bd9Sstevel@tonic-gate 		/* On an 32-bit arch this means 512b total. */
225*7c478bd9Sstevel@tonic-gate 		char	pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
226*7c478bd9Sstevel@tonic-gate 		struct {
227*7c478bd9Sstevel@tonic-gate 			uint16_t		nscount;
228*7c478bd9Sstevel@tonic-gate 			uint16_t		nstimes[MAXNS];	/* ms. */
229*7c478bd9Sstevel@tonic-gate 			int			nssocks[MAXNS];
230*7c478bd9Sstevel@tonic-gate 			struct __res_state_ext *ext;	/* extention for IPv6 */
231*7c478bd9Sstevel@tonic-gate 		} _ext;
232*7c478bd9Sstevel@tonic-gate 	} _u;
233*7c478bd9Sstevel@tonic-gate };
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate typedef	struct __res_state	*res_state;
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate union res_sockaddr_union {
238*7c478bd9Sstevel@tonic-gate 	struct sockaddr_in	sin;
239*7c478bd9Sstevel@tonic-gate #ifdef IN6ADDR_ANY_INIT
240*7c478bd9Sstevel@tonic-gate 	struct sockaddr_in6	sin6;
241*7c478bd9Sstevel@tonic-gate #endif
242*7c478bd9Sstevel@tonic-gate #ifdef ISC_ALIGN64
243*7c478bd9Sstevel@tonic-gate 	int64_t			__align64;	/* 64bit alignment */
244*7c478bd9Sstevel@tonic-gate #else
245*7c478bd9Sstevel@tonic-gate 	int32_t			__align32;	/* 32bit alignment */
246*7c478bd9Sstevel@tonic-gate #endif
247*7c478bd9Sstevel@tonic-gate 	char			__space[128];   /* max size */
248*7c478bd9Sstevel@tonic-gate };
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate /*
251*7c478bd9Sstevel@tonic-gate  * Resolver flags (used to be discrete per-module statics ints).
252*7c478bd9Sstevel@tonic-gate  */
253*7c478bd9Sstevel@tonic-gate #define	RES_F_VC	0x00000001	/* socket is TCP */
254*7c478bd9Sstevel@tonic-gate #define	RES_F_CONN	0x00000002	/* socket is connected */
255*7c478bd9Sstevel@tonic-gate #define	RES_F_EDNS0ERR	0x00000004	/* EDNS0 caused errors */
256*7c478bd9Sstevel@tonic-gate #define	RES_F__UNUSED	0x00000008	/* (unused) */
257*7c478bd9Sstevel@tonic-gate #define	RES_F_LASTMASK	0x000000F0	/* ordinal server of last res_nsend */
258*7c478bd9Sstevel@tonic-gate #define	RES_F_LASTSHIFT	4		/* bit position of LASTMASK "flag" */
259*7c478bd9Sstevel@tonic-gate #define	RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate /* res_findzonecut2() options */
262*7c478bd9Sstevel@tonic-gate #define	RES_EXHAUSTIVE	0x00000001	/* always do all queries */
263*7c478bd9Sstevel@tonic-gate #define	RES_IPV4ONLY	0x00000002	/* IPv4 only */
264*7c478bd9Sstevel@tonic-gate #define	RES_IPV6ONLY	0x00000004	/* IPv6 only */
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate /*
267*7c478bd9Sstevel@tonic-gate  * Resolver options (keep these in synch with res_debug.c, please)
268*7c478bd9Sstevel@tonic-gate  */
269*7c478bd9Sstevel@tonic-gate #define	RES_INIT	0x00000001	/* address initialized */
270*7c478bd9Sstevel@tonic-gate #define	RES_DEBUG	0x00000002	/* print debug messages */
271*7c478bd9Sstevel@tonic-gate #define	RES_AAONLY	0x00000004	/* authoritative answers only (!IMPL) */
272*7c478bd9Sstevel@tonic-gate #define	RES_USEVC	0x00000008	/* use virtual circuit */
273*7c478bd9Sstevel@tonic-gate #define	RES_PRIMARY	0x00000010	/* query primary server only (!IMPL) */
274*7c478bd9Sstevel@tonic-gate #define	RES_IGNTC	0x00000020	/* ignore trucation errors */
275*7c478bd9Sstevel@tonic-gate #define	RES_RECURSE	0x00000040	/* recursion desired */
276*7c478bd9Sstevel@tonic-gate #define	RES_DEFNAMES	0x00000080	/* use default domain name */
277*7c478bd9Sstevel@tonic-gate #define	RES_STAYOPEN	0x00000100	/* Keep TCP socket open */
278*7c478bd9Sstevel@tonic-gate #define	RES_DNSRCH	0x00000200	/* search up local domain tree */
279*7c478bd9Sstevel@tonic-gate #define	RES_INSECURE1	0x00000400	/* type 1 security disabled */
280*7c478bd9Sstevel@tonic-gate #define	RES_INSECURE2	0x00000800	/* type 2 security disabled */
281*7c478bd9Sstevel@tonic-gate #define	RES_NOALIASES	0x00001000	/* shuts off HOSTALIASES feature */
282*7c478bd9Sstevel@tonic-gate #define	RES_USE_INET6	0x00002000	/* use/map IPv6 in gethostbyname() */
283*7c478bd9Sstevel@tonic-gate #define	RES_ROTATE	0x00004000	/* rotate ns list after each query */
284*7c478bd9Sstevel@tonic-gate #define	RES_NOCHECKNAME	0x00008000	/* do not check names for sanity. */
285*7c478bd9Sstevel@tonic-gate #define	RES_KEEPTSIG	0x00010000	/* do not strip TSIG records */
286*7c478bd9Sstevel@tonic-gate #define	RES_BLAST	0x00020000	/* blast all recursive servers */
287*7c478bd9Sstevel@tonic-gate #define	RES_NO_NIBBLE	0x00040000	/* disable IPv6 nibble mode reverse */
288*7c478bd9Sstevel@tonic-gate #define	RES_NO_BITSTRING 0x00080000	/* disable IPv6 bitstring mode revrse */
289*7c478bd9Sstevel@tonic-gate #define	RES_NOTLDQUERY	0x00100000	/* don't unqualified name as a tld */
290*7c478bd9Sstevel@tonic-gate #define	RES_USE_DNSSEC	0x00200000	/* use DNSSEC using OK bit in OPT */
291*7c478bd9Sstevel@tonic-gate /* KAME extensions: use higher bit to avoid conflict with ISC use */
292*7c478bd9Sstevel@tonic-gate #define	RES_USE_DNAME	0x10000000	/* use DNAME */
293*7c478bd9Sstevel@tonic-gate #define	RES_USE_EDNS0	0x40000000	/* use EDNS0 if configured */
294*7c478bd9Sstevel@tonic-gate #define	RES_NO_NIBBLE2	0x80000000	/* disable alternate nibble lookup */
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate #define	RES_DEFAULT	(RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
297*7c478bd9Sstevel@tonic-gate 
298*7c478bd9Sstevel@tonic-gate /*
299*7c478bd9Sstevel@tonic-gate  * Resolver "pfcode" values.  Used by dig.
300*7c478bd9Sstevel@tonic-gate  */
301*7c478bd9Sstevel@tonic-gate #define	RES_PRF_STATS	0x00000001
302*7c478bd9Sstevel@tonic-gate #define	RES_PRF_UPDATE	0x00000002
303*7c478bd9Sstevel@tonic-gate #define	RES_PRF_CLASS   0x00000004
304*7c478bd9Sstevel@tonic-gate #define	RES_PRF_CMD		0x00000008
305*7c478bd9Sstevel@tonic-gate #define	RES_PRF_QUES	0x00000010
306*7c478bd9Sstevel@tonic-gate #define	RES_PRF_ANS		0x00000020
307*7c478bd9Sstevel@tonic-gate #define	RES_PRF_AUTH	0x00000040
308*7c478bd9Sstevel@tonic-gate #define	RES_PRF_ADD		0x00000080
309*7c478bd9Sstevel@tonic-gate #define	RES_PRF_HEAD1	0x00000100
310*7c478bd9Sstevel@tonic-gate #define	RES_PRF_HEAD2	0x00000200
311*7c478bd9Sstevel@tonic-gate #define	RES_PRF_TTLID	0x00000400
312*7c478bd9Sstevel@tonic-gate #define	RES_PRF_HEADX	0x00000800
313*7c478bd9Sstevel@tonic-gate #define	RES_PRF_QUERY	0x00001000
314*7c478bd9Sstevel@tonic-gate #define	RES_PRF_REPLY	0x00002000
315*7c478bd9Sstevel@tonic-gate #define	RES_PRF_INIT	0x00004000
316*7c478bd9Sstevel@tonic-gate #define	RES_PRF_TRUNC	0x00008000
317*7c478bd9Sstevel@tonic-gate /*			0x00010000	*/
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate /* Things involving an internal (static) resolver context. */
320*7c478bd9Sstevel@tonic-gate #ifdef _REENTRANT
321*7c478bd9Sstevel@tonic-gate extern struct __res_state *__res_state(void);
322*7c478bd9Sstevel@tonic-gate #define	_res (*__res_state())
323*7c478bd9Sstevel@tonic-gate #else
324*7c478bd9Sstevel@tonic-gate #ifndef __BIND_NOSTATIC
325*7c478bd9Sstevel@tonic-gate extern struct __res_state _res;
326*7c478bd9Sstevel@tonic-gate #endif
327*7c478bd9Sstevel@tonic-gate #endif
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate #ifndef __BIND_NOSTATIC
330*7c478bd9Sstevel@tonic-gate void		fp_nquery __P((const uchar_t *, int, FILE *));
331*7c478bd9Sstevel@tonic-gate void		fp_query __P((const uchar_t *, FILE *));
332*7c478bd9Sstevel@tonic-gate const char *hostalias __P((const char *));
333*7c478bd9Sstevel@tonic-gate void		p_query __P((const uchar_t *));
334*7c478bd9Sstevel@tonic-gate void		res_close __P((void));
335*7c478bd9Sstevel@tonic-gate int		res_init __P((void));
336*7c478bd9Sstevel@tonic-gate int		res_isourserver __P((const struct sockaddr_in *));
337*7c478bd9Sstevel@tonic-gate int		res_mkquery __P((int, const char *, int, int, const uchar_t *,
338*7c478bd9Sstevel@tonic-gate 				int, const uchar_t *, uchar_t *, int));
339*7c478bd9Sstevel@tonic-gate int		res_query	__P((const char *, int, int, uchar_t *, int));
340*7c478bd9Sstevel@tonic-gate int		res_querydomain __P((const char *, const char *, int, int,
341*7c478bd9Sstevel@tonic-gate 				uchar_t *, int));
342*7c478bd9Sstevel@tonic-gate int		res_search __P((const char *, int, int, uchar_t *, int));
343*7c478bd9Sstevel@tonic-gate int		res_send __P((const uchar_t *, int, uchar_t *, int));
344*7c478bd9Sstevel@tonic-gate int		res_sendsigned __P((const uchar_t *, int, ns_tsig_key *,
345*7c478bd9Sstevel@tonic-gate 				    uchar_t *, int));
346*7c478bd9Sstevel@tonic-gate #endif	/* __BIND_NOSTATIC */
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate extern const struct res_sym __p_key_syms[];
349*7c478bd9Sstevel@tonic-gate extern const struct res_sym __p_cert_syms[];
350*7c478bd9Sstevel@tonic-gate extern const struct res_sym __p_class_syms[];
351*7c478bd9Sstevel@tonic-gate extern const struct res_sym __p_type_syms[];
352*7c478bd9Sstevel@tonic-gate extern const struct res_sym __p_rcode_syms[];
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate int		res_hnok __P((const char *));
355*7c478bd9Sstevel@tonic-gate int		res_ownok __P((const char *));
356*7c478bd9Sstevel@tonic-gate int		res_mailok __P((const char *));
357*7c478bd9Sstevel@tonic-gate int		res_dnok __P((const char *));
358*7c478bd9Sstevel@tonic-gate int		sym_ston __P((const struct res_sym *, const char *, int *));
359*7c478bd9Sstevel@tonic-gate const char	*sym_ntos __P((const struct res_sym *, int, int *));
360*7c478bd9Sstevel@tonic-gate const char	*sym_ntop __P((const struct res_sym *, int, int *));
361*7c478bd9Sstevel@tonic-gate int		b64_ntop __P((uchar_t const *, size_t, char *, size_t));
362*7c478bd9Sstevel@tonic-gate int		b64_pton __P((char const *, uchar_t *, size_t));
363*7c478bd9Sstevel@tonic-gate int		loc_aton __P((const char *ascii, uchar_t *binary));
364*7c478bd9Sstevel@tonic-gate const char	*loc_ntoa __P((const uchar_t *binary, char *ascii));
365*7c478bd9Sstevel@tonic-gate int		dn_skipname __P((const uchar_t *, const uchar_t *));
366*7c478bd9Sstevel@tonic-gate void		putlong __P((unsigned int, uchar_t *));
367*7c478bd9Sstevel@tonic-gate void		putshort __P((unsigned short, uchar_t *));
368*7c478bd9Sstevel@tonic-gate const char	*p_class __P((int));
369*7c478bd9Sstevel@tonic-gate const char	*p_time __P((unsigned int));
370*7c478bd9Sstevel@tonic-gate const char	*p_type __P((int));
371*7c478bd9Sstevel@tonic-gate const char	*p_rcode __P((int));
372*7c478bd9Sstevel@tonic-gate const char	*p_sockun __P((union res_sockaddr_union, char *, size_t));
373*7c478bd9Sstevel@tonic-gate const uchar_t	*p_cdnname __P((const uchar_t *, const uchar_t *, int,
374*7c478bd9Sstevel@tonic-gate 			FILE *));
375*7c478bd9Sstevel@tonic-gate const uchar_t	*p_cdname __P((const uchar_t *, const uchar_t *, FILE *));
376*7c478bd9Sstevel@tonic-gate const uchar_t	*p_fqnname __P((const uchar_t *cp, const uchar_t *msg,
377*7c478bd9Sstevel@tonic-gate 			int, char *, int));
378*7c478bd9Sstevel@tonic-gate const uchar_t	*p_fqname __P((const uchar_t *, const uchar_t *, FILE *));
379*7c478bd9Sstevel@tonic-gate const char	*p_option __P((uint_t option));
380*7c478bd9Sstevel@tonic-gate char		*p_secstodate __P((uint_t));
381*7c478bd9Sstevel@tonic-gate int		dn_count_labels __P((const char *));
382*7c478bd9Sstevel@tonic-gate int		dn_comp __P((const char *, uchar_t *, int,
383*7c478bd9Sstevel@tonic-gate 				uchar_t **, uchar_t **));
384*7c478bd9Sstevel@tonic-gate int		dn_expand __P((const uchar_t *, const uchar_t *,
385*7c478bd9Sstevel@tonic-gate 			const uchar_t *, char *, int));
386*7c478bd9Sstevel@tonic-gate uint_t		res_randomid __P((void));
387*7c478bd9Sstevel@tonic-gate int		res_nameinquery __P((const char *, int, int,
388*7c478bd9Sstevel@tonic-gate 				const uchar_t *, const uchar_t *));
389*7c478bd9Sstevel@tonic-gate int		res_queriesmatch __P((const uchar_t *, const uchar_t *,
390*7c478bd9Sstevel@tonic-gate 				const uchar_t *, const uchar_t *));
391*7c478bd9Sstevel@tonic-gate const char	*p_section __P((int section, int opcode));
392*7c478bd9Sstevel@tonic-gate 
393*7c478bd9Sstevel@tonic-gate 
394*7c478bd9Sstevel@tonic-gate /* Things involving a resolver context. */
395*7c478bd9Sstevel@tonic-gate int		res_ninit __P((res_state));
396*7c478bd9Sstevel@tonic-gate int		res_nisourserver __P((const res_state,
397*7c478bd9Sstevel@tonic-gate 				const struct sockaddr_in *));
398*7c478bd9Sstevel@tonic-gate void	fp_resstat __P((const res_state, FILE *));
399*7c478bd9Sstevel@tonic-gate void	res_pquery	__P((const res_state, const uchar_t *, int, FILE *));
400*7c478bd9Sstevel@tonic-gate const char	*res_hostalias __P((const res_state, const char *,
401*7c478bd9Sstevel@tonic-gate 				char *, size_t));
402*7c478bd9Sstevel@tonic-gate int		res_nquery __P((res_state,
403*7c478bd9Sstevel@tonic-gate 				const char *, int, int, uchar_t *, int));
404*7c478bd9Sstevel@tonic-gate int		res_nsearch __P((res_state, const char *, int,
405*7c478bd9Sstevel@tonic-gate 				int, uchar_t *, int));
406*7c478bd9Sstevel@tonic-gate int		res_nquerydomain __P((res_state,
407*7c478bd9Sstevel@tonic-gate 				const char *, const char *, int, int,
408*7c478bd9Sstevel@tonic-gate 				uchar_t *, int));
409*7c478bd9Sstevel@tonic-gate int		res_nmkquery __P((res_state,
410*7c478bd9Sstevel@tonic-gate 				int, const char *, int, int, const uchar_t *,
411*7c478bd9Sstevel@tonic-gate 				int, const uchar_t *, uchar_t *, int));
412*7c478bd9Sstevel@tonic-gate int		res_nsend __P((res_state, const uchar_t *, int, uchar_t *,
413*7c478bd9Sstevel@tonic-gate 				int));
414*7c478bd9Sstevel@tonic-gate int		res_nsendsigned __P((res_state, const uchar_t *, int,
415*7c478bd9Sstevel@tonic-gate 				ns_tsig_key *, uchar_t *, int));
416*7c478bd9Sstevel@tonic-gate int		res_findzonecut __P((res_state, const char *, ns_class, int,
417*7c478bd9Sstevel@tonic-gate 				char *, size_t, struct in_addr *, int));
418*7c478bd9Sstevel@tonic-gate int		res_findzonecut2 __P((res_state, const char *, ns_class, int,
419*7c478bd9Sstevel@tonic-gate 				char *, size_t, union res_sockaddr_union *,
420*7c478bd9Sstevel@tonic-gate 				int));
421*7c478bd9Sstevel@tonic-gate void		res_nclose __P((res_state));
422*7c478bd9Sstevel@tonic-gate int		res_nopt __P((res_state, int, uchar_t *, int, int));
423*7c478bd9Sstevel@tonic-gate void		res_send_setqhook __P((res_send_qhook hook));
424*7c478bd9Sstevel@tonic-gate void		res_send_setrhook __P((res_send_rhook hook));
425*7c478bd9Sstevel@tonic-gate int		__res_vinit __P((res_state, int));
426*7c478bd9Sstevel@tonic-gate void		res_destroyservicelist __P((void));
427*7c478bd9Sstevel@tonic-gate const char 	*res_servicename __P((uint16_t port, const char *proto));
428*7c478bd9Sstevel@tonic-gate const char 	*res_protocolname __P((int num));
429*7c478bd9Sstevel@tonic-gate void		res_destroyprotolist __P((void));
430*7c478bd9Sstevel@tonic-gate void		res_buildprotolist __P((void));
431*7c478bd9Sstevel@tonic-gate const char 	*res_get_nibblesuffix __P((res_state));
432*7c478bd9Sstevel@tonic-gate const char 	*res_get_nibblesuffix2 __P((res_state));
433*7c478bd9Sstevel@tonic-gate void		res_ndestroy __P((res_state));
434*7c478bd9Sstevel@tonic-gate uint16_t	res_nametoclass __P((const char *buf, int *success));
435*7c478bd9Sstevel@tonic-gate uint16_t	res_nametotype __P((const char *buf, int *success));
436*7c478bd9Sstevel@tonic-gate void		res_setservers __P((res_state,
437*7c478bd9Sstevel@tonic-gate 				    const union res_sockaddr_union *, int));
438*7c478bd9Sstevel@tonic-gate int		res_getservers __P((res_state,
439*7c478bd9Sstevel@tonic-gate 				    union res_sockaddr_union *, int));
440*7c478bd9Sstevel@tonic-gate 
441*7c478bd9Sstevel@tonic-gate 
442*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
443*7c478bd9Sstevel@tonic-gate }
444*7c478bd9Sstevel@tonic-gate #endif
445*7c478bd9Sstevel@tonic-gate 
446*7c478bd9Sstevel@tonic-gate #endif /* !_RESOLV_H_ */
447