xref: /illumos-gate/usr/src/head/arpa/nameser_compat.h (revision 66582b606a8194f7f3ba5b3a3a6dca5b0d346361)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Copyright(c)	1983,	1989
29  *    The Regents of the University of California.  All rights reserved.
30  *
31  * Redistribution and use in source and binary forms, with or without
32  * modification, are permitted provided that the following conditions
33  * are met:
34  * 1. Redistributions of source code must retain the above copyright
35  *    notice, this list of conditions and the following disclaimer.
36  * 2. Redistributions in binary form must reproduce the above copyright
37  *    notice, this list of conditions and the following disclaimer in the
38  *    documentation and/or other materials provided with the distribution.
39  * 3. All advertising materials mentioning features or use of this software
40  *    must display the following acknowledgement:
41  *	This product includes software developed by the University of
42  *	California, Berkeley and its contributors.
43  * 4. Neither the name of the University nor the names of its contributors
44  *    may be used to endorse or promote products derived from this software
45  *    without specific prior written permission.
46  *
47  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52  * DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55  * LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57  * SUCH DAMAGE.
58  */
59 
60 /*
61  *      from nameser.h	8.1 (Berkeley) 6/2/93
62  *	$Id: nameser_compat.h,v 8.15 2002/07/17 07:01:02 marka Exp $
63  */
64 
65 #ifndef _ARPA_NAMESER_COMPAT_H
66 #define	_ARPA_NAMESER_COMPAT_H
67 
68 #ifdef	__cplusplus
69 extern "C" {
70 #endif
71 
72 #define	__BIND		19950621	/* (DEAD) interface version stamp. */
73 
74 #ifndef BYTE_ORDER
75 #if (BSD >= 199103)
76 #include <machine/endian.h>
77 #else
78 #ifdef linux
79 #include <endian.h>
80 #else
81 #define	LITTLE_ENDIAN	1234	/* least-significant byte first (vax, pc) */
82 #define	BIG_ENDIAN	4321	/* most-significant byte first (IBM, net) */
83 #define	PDP_ENDIAN	3412	/* LSB first in word, MSW first in long (pdp) */
84 
85 #if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
86 	defined(__i386) || defined(__amd64) || \
87 	defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
88 	defined(__alpha__) || defined(__alpha) || \
89 	(defined(__Lynx__) && defined(__x86__))
90 #define	BYTE_ORDER	LITTLE_ENDIAN
91 #endif
92 
93 #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
94     defined(__sparc) || \
95     defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
96     defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
97     defined(apollo) || defined(__convex__) || defined(_CRAY) || \
98     defined(__hppa) || defined(__hp9000) || \
99     defined(__hp9000s300) || defined(__hp9000s700) || \
100     defined(__hp3000s900) || defined(MPE) || \
101     defined(BIT_ZERO_ON_LEFT) || defined(m68k) || \
102 	(defined(__Lynx__) && \
103 	(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
104 #define	BYTE_ORDER	BIG_ENDIAN
105 #endif
106 #endif /* linux */
107 #endif /* BSD */
108 #endif /* BYTE_ORDER */
109 
110 #if !defined(BYTE_ORDER) || \
111 	((BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN) && \
112 	(BYTE_ORDER != PDP_ENDIAN))
113 /*
114  * you must determine what the correct bit order is for
115  * your compiler - the next line is an intentional error
116  * which will force your compiles to bomb until you fix
117  * the above macros.
118  */
119 #error "Undefined or invalid BYTE_ORDER";
120 #endif
121 
122 /*
123  * Structure for query header.  The order of the fields is machine- and
124  * compiler-dependent, depending on the byte/bit order and the layout
125  * of bit fields.  We use bit fields only in int variables, as this
126  * is all ANSI requires.  This requires a somewhat confusing rearrangement.
127  */
128 
129 typedef struct {
130 	unsigned	id :16;		/* query identification number */
131 #if BYTE_ORDER == BIG_ENDIAN
132 			/* fields in third byte */
133 	unsigned	qr: 1;		/* response flag */
134 	unsigned	opcode: 4;	/* purpose of message */
135 	unsigned	aa: 1;		/* authoritive answer */
136 	unsigned	tc: 1;		/* truncated message */
137 	unsigned	rd: 1;		/* recursion desired */
138 			/* fields in fourth byte */
139 	unsigned	ra: 1;		/* recursion available */
140 	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
141 	unsigned	ad: 1;		/* authentic data from named */
142 	unsigned	cd: 1;		/* checking disabled by resolver */
143 	unsigned	rcode :4;	/* response code */
144 #endif
145 #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
146 			/* fields in third byte */
147 	unsigned	rd :1;		/* recursion desired */
148 	unsigned	tc :1;		/* truncated message */
149 	unsigned	aa :1;		/* authoritive answer */
150 	unsigned	opcode :4;	/* purpose of message */
151 	unsigned	qr :1;		/* response flag */
152 			/* fields in fourth byte */
153 	unsigned	rcode :4;	/* response code */
154 	unsigned	cd: 1;		/* checking disabled by resolver */
155 	unsigned	ad: 1;		/* authentic data from named */
156 	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
157 	unsigned	ra :1;		/* recursion available */
158 #endif
159 			/* remaining bytes */
160 	unsigned	qdcount :16;	/* number of question entries */
161 	unsigned	ancount :16;	/* number of answer entries */
162 	unsigned	nscount :16;	/* number of authority entries */
163 	unsigned	arcount :16;	/* number of resource entries */
164 } HEADER;
165 
166 #define	PACKETSZ	NS_PACKETSZ
167 #define	MAXDNAME	NS_MAXDNAME
168 #define	MAXCDNAME	NS_MAXCDNAME
169 #define	MAXLABEL	NS_MAXLABEL
170 #define	HFIXEDSZ	NS_HFIXEDSZ
171 #define	QFIXEDSZ	NS_QFIXEDSZ
172 #define	RRFIXEDSZ	NS_RRFIXEDSZ
173 #define	INT32SZ		NS_INT32SZ
174 #define	INT16SZ		NS_INT16SZ
175 #define	INT8SZ		NS_INT8SZ
176 #define	INADDRSZ	NS_INADDRSZ
177 #define	IN6ADDRSZ	NS_IN6ADDRSZ
178 #define	INDIR_MASK	NS_CMPRSFLGS
179 #define	NAMESERVER_PORT	NS_DEFAULTPORT
180 
181 #define	S_ZONE		ns_s_zn
182 #define	S_PREREQ	ns_s_pr
183 #define	S_UPDATE	ns_s_ud
184 #define	S_ADDT		ns_s_ar
185 
186 #define	QUERY		ns_o_query
187 #define	IQUERY		ns_o_iquery
188 #define	STATUS		ns_o_status
189 #define	NS_NOTIFY_OP	ns_o_notify
190 #define	NS_UPDATE_OP	ns_o_update
191 
192 #define	NOERROR		ns_r_noerror
193 #define	FORMERR		ns_r_formerr
194 #define	SERVFAIL	ns_r_servfail
195 #define	NXDOMAIN	ns_r_nxdomain
196 #define	NOTIMP		ns_r_notimpl
197 #define	REFUSED		ns_r_refused
198 #define	YXDOMAIN	ns_r_yxdomain
199 #define	YXRRSET		ns_r_yxrrset
200 #define	NXRRSET		ns_r_nxrrset
201 #define	NOTAUTH		ns_r_notauth
202 #define	NOTZONE		ns_r_notzone
203 /* #define	BADSIG		ns_r_badsig */
204 /* #define	BADKEY		ns_r_badkey */
205 /* #define	BADTIME		ns_r_badtime */
206 
207 #define	DELETE		ns_uop_delete
208 #ifndef	ADD
209 #define	ADD		ns_uop_add
210 #endif
211 
212 #define	T_A		ns_t_a
213 #define	T_NS		ns_t_ns
214 #define	T_MD		ns_t_md
215 #define	T_MF		ns_t_mf
216 #define	T_CNAME		ns_t_cname
217 #define	T_SOA		ns_t_soa
218 #define	T_MB		ns_t_mb
219 #define	T_MG		ns_t_mg
220 #define	T_MR		ns_t_mr
221 #define	T_NULL		ns_t_null
222 #define	T_WKS		ns_t_wks
223 #define	T_PTR		ns_t_ptr
224 #define	T_HINFO		ns_t_hinfo
225 #define	T_MINFO		ns_t_minfo
226 #define	T_MX		ns_t_mx
227 #define	T_TXT		ns_t_txt
228 #define	T_RP		ns_t_rp
229 #define	T_AFSDB		ns_t_afsdb
230 #define	T_X25		ns_t_x25
231 #define	T_ISDN		ns_t_isdn
232 #define	T_RT		ns_t_rt
233 #define	T_NSAP		ns_t_nsap
234 #define	T_NSAP_PTR	ns_t_nsap_ptr
235 #define	T_SIG		ns_t_sig
236 #define	T_KEY		ns_t_key
237 #define	T_PX		ns_t_px
238 #define	T_GPOS		ns_t_gpos
239 #define	T_AAAA		ns_t_aaaa
240 #define	T_LOC		ns_t_loc
241 #define	T_NXT		ns_t_nxt
242 #define	T_EID		ns_t_eid
243 #define	T_NIMLOC	ns_t_nimloc
244 #define	T_SRV		ns_t_srv
245 #define	T_ATMA		ns_t_atma
246 #define	T_NAPTR		ns_t_naptr
247 #define	T_A6		ns_t_a6
248 #define	T_TSIG		ns_t_tsig
249 #define	T_IXFR		ns_t_ixfr
250 #define	T_AXFR		ns_t_axfr
251 #define	T_MAILB		ns_t_mailb
252 #define	T_MAILA		ns_t_maila
253 #define	T_ANY		ns_t_any
254 
255 #define	C_IN		ns_c_in
256 #define	C_CHAOS		ns_c_chaos
257 #define	C_HS		ns_c_hs
258 /* BIND_UPDATE */
259 #define	C_NONE		ns_c_none
260 #define	C_ANY		ns_c_any
261 
262 #define	GETSHORT		NS_GET16
263 #define	GETLONG			NS_GET32
264 #define	PUTSHORT		NS_PUT16
265 #define	PUTLONG			NS_PUT32
266 
267 #ifdef	__cplusplus
268 }
269 #endif
270 
271 #endif	/* _ARPA_NAMESER_COMPAT_H */
272