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