nameser.h revision 1.9 1 1.1 cgd /*
2 1.8 mrg * ++Copyright++ 1983, 1989, 1993
3 1.8 mrg * -
4 1.8 mrg * Copyright (c) 1983, 1989, 1993
5 1.8 mrg * The Regents of the University of California. All rights reserved.
6 1.8 mrg *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.8 mrg * This product includes software developed by the University of
18 1.8 mrg * California, Berkeley and its contributors.
19 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
20 1.1 cgd * may be used to endorse or promote products derived from this software
21 1.1 cgd * without specific prior written permission.
22 1.8 mrg *
23 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 cgd * SUCH DAMAGE.
34 1.8 mrg * -
35 1.8 mrg * Portions Copyright (c) 1993 by Digital Equipment Corporation.
36 1.8 mrg *
37 1.8 mrg * Permission to use, copy, modify, and distribute this software for any
38 1.8 mrg * purpose with or without fee is hereby granted, provided that the above
39 1.8 mrg * copyright notice and this permission notice appear in all copies, and that
40 1.8 mrg * the name of Digital Equipment Corporation not be used in advertising or
41 1.8 mrg * publicity pertaining to distribution of the document or software without
42 1.8 mrg * specific, written prior permission.
43 1.8 mrg *
44 1.8 mrg * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
45 1.8 mrg * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
46 1.8 mrg * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
47 1.8 mrg * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
48 1.8 mrg * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
49 1.8 mrg * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
50 1.8 mrg * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
51 1.8 mrg * SOFTWARE.
52 1.8 mrg * -
53 1.9 mrg * Portions Copyright (c) 1995 by International Business Machines, Inc.
54 1.9 mrg *
55 1.9 mrg * International Business Machines, Inc. (hereinafter called IBM) grants
56 1.9 mrg * permission under its copyrights to use, copy, modify, and distribute this
57 1.9 mrg * Software with or without fee, provided that the above copyright notice and
58 1.9 mrg * all paragraphs of this notice appear in all copies, and that the name of IBM
59 1.9 mrg * not be used in connection with the marketing of any product incorporating
60 1.9 mrg * the Software or modifications thereof, without specific, written prior
61 1.9 mrg * permission.
62 1.9 mrg *
63 1.9 mrg * To the extent it has a right to do so, IBM grants an immunity from suit
64 1.9 mrg * under its patents, if any, for the use, sale or manufacture of products to
65 1.9 mrg * the extent that such products are used for performing Domain Name System
66 1.9 mrg * dynamic updates in TCP/IP networks by means of the Software. No immunity is
67 1.9 mrg * granted for any product per se or for any other function of any product.
68 1.9 mrg *
69 1.9 mrg * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
70 1.9 mrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
71 1.9 mrg * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
72 1.9 mrg * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
73 1.9 mrg * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
74 1.9 mrg * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
75 1.8 mrg * --Copyright--
76 1.8 mrg */
77 1.8 mrg
78 1.8 mrg /*
79 1.8 mrg * @(#)nameser.h 8.1 (Berkeley) 6/2/93
80 1.9 mrg * $Id: nameser.h,v 1.9 1997/04/13 09:26:24 mrg Exp $
81 1.1 cgd */
82 1.1 cgd
83 1.1 cgd #ifndef _NAMESER_H_
84 1.9 mrg #define _NAMESER_H_
85 1.1 cgd
86 1.8 mrg #include <sys/param.h>
87 1.8 mrg #if (!defined(BSD)) || (BSD < 199306)
88 1.8 mrg # include <sys/bitypes.h>
89 1.8 mrg #else
90 1.8 mrg # include <sys/types.h>
91 1.8 mrg #endif
92 1.5 deraadt #include <sys/cdefs.h>
93 1.4 mycroft
94 1.8 mrg #ifdef _AUX_SOURCE
95 1.9 mrg # include <sys/types.h>
96 1.9 mrg #endif
97 1.8 mrg
98 1.8 mrg /*
99 1.8 mrg * revision information. this is the release date in YYYYMMDD format.
100 1.8 mrg * it can change every day so the right thing to do with it is use it
101 1.8 mrg * in preprocessor commands such as "#if (__BIND > 19931104)". do not
102 1.8 mrg * compare for equality; rather, use it to determine whether your resolver
103 1.8 mrg * is new enough to contain a certain feature.
104 1.8 mrg */
105 1.8 mrg
106 1.9 mrg #define __BIND 19960801 /* interface version stamp */
107 1.8 mrg
108 1.1 cgd /*
109 1.1 cgd * Define constants based on rfc883
110 1.1 cgd */
111 1.1 cgd #define PACKETSZ 512 /* maximum packet size */
112 1.9 mrg #define MAXDNAME 1025 /* maximum presentation domain name */
113 1.1 cgd #define MAXCDNAME 255 /* maximum compressed domain name */
114 1.1 cgd #define MAXLABEL 63 /* maximum length of domain label */
115 1.9 mrg #define HFIXEDSZ 12 /* #/bytes of fixed data in header */
116 1.8 mrg #define QFIXEDSZ 4 /* #/bytes of fixed data in query */
117 1.8 mrg #define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
118 1.9 mrg #define INT32SZ 4 /* for systems without 32-bit ints */
119 1.9 mrg #define INT16SZ 2 /* for systems without 16-bit ints */
120 1.9 mrg #define INADDRSZ 4 /* IPv4 T_A */
121 1.9 mrg #define IN6ADDRSZ 16 /* IPv6 T_AAAA */
122 1.1 cgd
123 1.1 cgd /*
124 1.1 cgd * Internet nameserver port number
125 1.1 cgd */
126 1.1 cgd #define NAMESERVER_PORT 53
127 1.1 cgd
128 1.1 cgd /*
129 1.1 cgd * Currently defined opcodes
130 1.1 cgd */
131 1.1 cgd #define QUERY 0x0 /* standard query */
132 1.1 cgd #define IQUERY 0x1 /* inverse query */
133 1.1 cgd #define STATUS 0x2 /* nameserver status query */
134 1.8 mrg /*#define xxx 0x3*/ /* 0x3 reserved */
135 1.9 mrg #define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
136 1.1 cgd /*
137 1.1 cgd * Currently defined response codes
138 1.1 cgd */
139 1.1 cgd #define NOERROR 0 /* no error */
140 1.1 cgd #define FORMERR 1 /* format error */
141 1.1 cgd #define SERVFAIL 2 /* server failure */
142 1.1 cgd #define NXDOMAIN 3 /* non existent domain */
143 1.1 cgd #define NOTIMP 4 /* not implemented */
144 1.1 cgd #define REFUSED 5 /* query refused */
145 1.1 cgd
146 1.1 cgd /*
147 1.1 cgd * Type values for resources and queries
148 1.1 cgd */
149 1.1 cgd #define T_A 1 /* host address */
150 1.1 cgd #define T_NS 2 /* authoritative server */
151 1.1 cgd #define T_MD 3 /* mail destination */
152 1.1 cgd #define T_MF 4 /* mail forwarder */
153 1.8 mrg #define T_CNAME 5 /* canonical name */
154 1.1 cgd #define T_SOA 6 /* start of authority zone */
155 1.1 cgd #define T_MB 7 /* mailbox domain name */
156 1.1 cgd #define T_MG 8 /* mail group member */
157 1.1 cgd #define T_MR 9 /* mail rename name */
158 1.1 cgd #define T_NULL 10 /* null resource record */
159 1.1 cgd #define T_WKS 11 /* well known service */
160 1.1 cgd #define T_PTR 12 /* domain name pointer */
161 1.1 cgd #define T_HINFO 13 /* host information */
162 1.1 cgd #define T_MINFO 14 /* mailbox information */
163 1.1 cgd #define T_MX 15 /* mail routing information */
164 1.1 cgd #define T_TXT 16 /* text strings */
165 1.9 mrg #define T_RP 17 /* responsible person */
166 1.5 deraadt #define T_AFSDB 18 /* AFS cell database */
167 1.8 mrg #define T_X25 19 /* X_25 calling address */
168 1.8 mrg #define T_ISDN 20 /* ISDN calling address */
169 1.8 mrg #define T_RT 21 /* router */
170 1.5 deraadt #define T_NSAP 22 /* NSAP address */
171 1.8 mrg #define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
172 1.9 mrg #define T_SIG 24 /* security signature */
173 1.9 mrg #define T_KEY 25 /* security key */
174 1.9 mrg #define T_PX 26 /* X.400 mail mapping */
175 1.9 mrg #define T_GPOS 27 /* geographical position (withdrawn) */
176 1.9 mrg #define T_AAAA 28 /* IP6 Address */
177 1.9 mrg #define T_LOC 29 /* Location Information */
178 1.9 mrg #define T_NXT 30 /* Next Valid Name in Zone */
179 1.9 mrg #define T_EID 31 /* Endpoint identifier */
180 1.9 mrg #define T_NIMLOC 32 /* Nimrod locator */
181 1.9 mrg #define T_SRV 33 /* Server selection */
182 1.9 mrg #define T_ATMA 34 /* ATM Address */
183 1.9 mrg #define T_NAPTR 35 /* Naming Authority PoinTeR */
184 1.1 cgd /* non standard */
185 1.1 cgd #define T_UINFO 100 /* user (finger) information */
186 1.1 cgd #define T_UID 101 /* user ID */
187 1.1 cgd #define T_GID 102 /* group ID */
188 1.1 cgd #define T_UNSPEC 103 /* Unspecified format (binary data) */
189 1.1 cgd /* Query type values which do not appear in resource records */
190 1.9 mrg #define T_IXFR 251 /* incremental zone transfer */
191 1.1 cgd #define T_AXFR 252 /* transfer zone of authority */
192 1.1 cgd #define T_MAILB 253 /* transfer mailbox records */
193 1.1 cgd #define T_MAILA 254 /* transfer mail agent records */
194 1.1 cgd #define T_ANY 255 /* wildcard match */
195 1.1 cgd
196 1.1 cgd /*
197 1.1 cgd * Values for class field
198 1.1 cgd */
199 1.8 mrg
200 1.1 cgd #define C_IN 1 /* the arpa internet */
201 1.8 mrg #define C_CHAOS 3 /* for chaos net (MIT) */
202 1.8 mrg #define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
203 1.1 cgd /* Query class values which do not appear in resource records */
204 1.1 cgd #define C_ANY 255 /* wildcard match */
205 1.1 cgd
206 1.1 cgd /*
207 1.9 mrg * Flags field of the KEY RR rdata
208 1.9 mrg */
209 1.9 mrg #define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */
210 1.9 mrg #define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
211 1.9 mrg #define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
212 1.9 mrg #define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
213 1.9 mrg #define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
214 1.9 mrg /* The type bits can also be interpreted independently, as single bits: */
215 1.9 mrg #define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */
216 1.9 mrg #define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */
217 1.9 mrg
218 1.9 mrg #define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */
219 1.9 mrg #define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */
220 1.9 mrg #define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */
221 1.9 mrg #define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */
222 1.9 mrg #define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */
223 1.9 mrg #define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */
224 1.9 mrg #define KEYFLAG_IPSEC 0x0080 /* key is for IPSEC use (host or user)*/
225 1.9 mrg #define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */
226 1.9 mrg #define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */
227 1.9 mrg #define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */
228 1.9 mrg #define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */
229 1.9 mrg
230 1.9 mrg #define KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \
231 1.9 mrg KEYFLAG_RESERVED4 | \
232 1.9 mrg KEYFLAG_RESERVED10| KEYFLAG_RESERVED11)
233 1.9 mrg
234 1.9 mrg /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
235 1.9 mrg #define ALGORITHM_MD5RSA 1 /* MD5 with RSA */
236 1.9 mrg #define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */
237 1.9 mrg #define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */
238 1.9 mrg
239 1.9 mrg /* Signatures */
240 1.9 mrg /* Size of a mod or exp in bits */
241 1.9 mrg #define MIN_MD5RSA_KEY_PART_BITS 512
242 1.9 mrg #define MAX_MD5RSA_KEY_PART_BITS 2552
243 1.9 mrg /* Total of binary mod and exp, bytes */
244 1.9 mrg #define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3)
245 1.9 mrg /* Max length of text sig block */
246 1.9 mrg #define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4)
247 1.9 mrg
248 1.9 mrg /*
249 1.1 cgd * Status return codes for T_UNSPEC conversion routines
250 1.1 cgd */
251 1.8 mrg #define CONV_SUCCESS 0
252 1.8 mrg #define CONV_OVERFLOW (-1)
253 1.8 mrg #define CONV_BADFMT (-2)
254 1.8 mrg #define CONV_BADCKSUM (-3)
255 1.8 mrg #define CONV_BADBUFLEN (-4)
256 1.8 mrg
257 1.8 mrg #ifndef BYTE_ORDER
258 1.8 mrg #if (BSD >= 199103)
259 1.8 mrg # include <machine/endian.h>
260 1.8 mrg #else
261 1.8 mrg #ifdef linux
262 1.8 mrg # include <endian.h>
263 1.8 mrg #else
264 1.9 mrg #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
265 1.9 mrg #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
266 1.9 mrg #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
267 1.8 mrg
268 1.8 mrg #if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
269 1.8 mrg defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
270 1.8 mrg defined(__alpha__) || defined(__alpha)
271 1.8 mrg #define BYTE_ORDER LITTLE_ENDIAN
272 1.8 mrg #endif
273 1.8 mrg
274 1.8 mrg #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
275 1.8 mrg defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
276 1.8 mrg defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
277 1.8 mrg defined(apollo) || defined(__convex__) || defined(_CRAY) || \
278 1.8 mrg defined(__hppa) || defined(__hp9000) || \
279 1.8 mrg defined(__hp9000s300) || defined(__hp9000s700) || \
280 1.8 mrg defined (BIT_ZERO_ON_LEFT) || defined(m68k)
281 1.8 mrg #define BYTE_ORDER BIG_ENDIAN
282 1.8 mrg #endif
283 1.8 mrg #endif /* linux */
284 1.8 mrg #endif /* BSD */
285 1.8 mrg #endif /* BYTE_ORDER */
286 1.8 mrg
287 1.8 mrg #if !defined(BYTE_ORDER) || \
288 1.8 mrg (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
289 1.8 mrg BYTE_ORDER != PDP_ENDIAN)
290 1.8 mrg /* you must determine what the correct bit order is for
291 1.8 mrg * your compiler - the next line is an intentional error
292 1.8 mrg * which will force your compiles to bomb until you fix
293 1.8 mrg * the above macros.
294 1.8 mrg */
295 1.8 mrg error "Undefined or invalid BYTE_ORDER";
296 1.8 mrg #endif
297 1.1 cgd
298 1.1 cgd /*
299 1.8 mrg * Structure for query header. The order of the fields is machine- and
300 1.8 mrg * compiler-dependent, depending on the byte/bit order and the layout
301 1.8 mrg * of bit fields. We use bit fields only in int variables, as this
302 1.8 mrg * is all ANSI requires. This requires a somewhat confusing rearrangement.
303 1.1 cgd */
304 1.8 mrg
305 1.1 cgd typedef struct {
306 1.8 mrg unsigned id :16; /* query identification number */
307 1.1 cgd #if BYTE_ORDER == BIG_ENDIAN
308 1.1 cgd /* fields in third byte */
309 1.8 mrg unsigned qr: 1; /* response flag */
310 1.8 mrg unsigned opcode: 4; /* purpose of message */
311 1.8 mrg unsigned aa: 1; /* authoritive answer */
312 1.8 mrg unsigned tc: 1; /* truncated message */
313 1.8 mrg unsigned rd: 1; /* recursion desired */
314 1.1 cgd /* fields in fourth byte */
315 1.8 mrg unsigned ra: 1; /* recursion available */
316 1.9 mrg unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
317 1.9 mrg unsigned ad: 1; /* authentic data from named */
318 1.9 mrg unsigned cd: 1; /* checking disabled by resolver */
319 1.8 mrg unsigned rcode :4; /* response code */
320 1.1 cgd #endif
321 1.1 cgd #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
322 1.1 cgd /* fields in third byte */
323 1.8 mrg unsigned rd :1; /* recursion desired */
324 1.8 mrg unsigned tc :1; /* truncated message */
325 1.8 mrg unsigned aa :1; /* authoritive answer */
326 1.8 mrg unsigned opcode :4; /* purpose of message */
327 1.8 mrg unsigned qr :1; /* response flag */
328 1.1 cgd /* fields in fourth byte */
329 1.8 mrg unsigned rcode :4; /* response code */
330 1.9 mrg unsigned cd: 1; /* checking disabled by resolver */
331 1.9 mrg unsigned ad: 1; /* authentic data from named */
332 1.9 mrg unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
333 1.8 mrg unsigned ra :1; /* recursion available */
334 1.1 cgd #endif
335 1.1 cgd /* remaining bytes */
336 1.8 mrg unsigned qdcount :16; /* number of question entries */
337 1.8 mrg unsigned ancount :16; /* number of answer entries */
338 1.8 mrg unsigned nscount :16; /* number of authority entries */
339 1.8 mrg unsigned arcount :16; /* number of resource entries */
340 1.1 cgd } HEADER;
341 1.1 cgd
342 1.1 cgd /*
343 1.1 cgd * Defines for handling compressed domain names
344 1.1 cgd */
345 1.1 cgd #define INDIR_MASK 0xc0
346 1.1 cgd
347 1.8 mrg extern u_int16_t _getshort __P((const u_char *));
348 1.8 mrg extern u_int32_t _getlong __P((const u_char *));
349 1.1 cgd
350 1.1 cgd /*
351 1.8 mrg * Inline versions of get/put short/long. Pointer is advanced.
352 1.8 mrg *
353 1.8 mrg * These macros demonstrate the property of C whereby it can be
354 1.8 mrg * portable or it can be elegant but rarely both.
355 1.1 cgd */
356 1.1 cgd #define GETSHORT(s, cp) { \
357 1.5 deraadt register u_char *t_cp = (u_char *)(cp); \
358 1.6 deraadt (s) = ((u_int16_t)t_cp[0] << 8) \
359 1.8 mrg | ((u_int16_t)t_cp[1]) \
360 1.8 mrg ; \
361 1.8 mrg (cp) += INT16SZ; \
362 1.1 cgd }
363 1.1 cgd
364 1.1 cgd #define GETLONG(l, cp) { \
365 1.5 deraadt register u_char *t_cp = (u_char *)(cp); \
366 1.6 deraadt (l) = ((u_int32_t)t_cp[0] << 24) \
367 1.6 deraadt | ((u_int32_t)t_cp[1] << 16) \
368 1.6 deraadt | ((u_int32_t)t_cp[2] << 8) \
369 1.8 mrg | ((u_int32_t)t_cp[3]) \
370 1.8 mrg ; \
371 1.8 mrg (cp) += INT32SZ; \
372 1.1 cgd }
373 1.1 cgd
374 1.1 cgd #define PUTSHORT(s, cp) { \
375 1.6 deraadt register u_int16_t t_s = (u_int16_t)(s); \
376 1.5 deraadt register u_char *t_cp = (u_char *)(cp); \
377 1.5 deraadt *t_cp++ = t_s >> 8; \
378 1.5 deraadt *t_cp = t_s; \
379 1.8 mrg (cp) += INT16SZ; \
380 1.1 cgd }
381 1.1 cgd
382 1.1 cgd #define PUTLONG(l, cp) { \
383 1.6 deraadt register u_int32_t t_l = (u_int32_t)(l); \
384 1.5 deraadt register u_char *t_cp = (u_char *)(cp); \
385 1.5 deraadt *t_cp++ = t_l >> 24; \
386 1.5 deraadt *t_cp++ = t_l >> 16; \
387 1.5 deraadt *t_cp++ = t_l >> 8; \
388 1.5 deraadt *t_cp = t_l; \
389 1.8 mrg (cp) += INT32SZ; \
390 1.1 cgd }
391 1.1 cgd
392 1.1 cgd #endif /* !_NAMESER_H_ */
393