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