3 * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
13 * Copyright (c) 1983, 1989, 1993
14 * The Regents of the University of California. All rights reserved.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by the University of
27 * California, Berkeley and its contributors.
28 * 4. Neither the name of the University nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * Portions Copyright (c) 1993 by Digital Equipment Corporation.
47 * Permission to use, copy, modify, and distribute this software for any
48 * purpose with or without fee is hereby granted, provided that the above
49 * copyright notice and this permission notice appear in all copies, and that
50 * the name of Digital Equipment Corporation not be used in advertising or
51 * publicity pertaining to distribution of the document or software without
52 * specific, written prior permission.
54 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
55 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
56 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
57 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
58 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
59 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
60 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
63 * Portions Copyright (c) 1995 by International Business Machines, Inc.
65 * International Business Machines, Inc. (hereinafter called IBM) grants
66 * permission under its copyrights to use, copy, modify, and distribute this
67 * Software with or without fee, provided that the above copyright notice and
68 * all paragraphs of this notice appear in all copies, and that the name of IBM
69 * not be used in connection with the marketing of any product incorporating
70 * the Software or modifications thereof, without specific, written prior
73 * To the extent it has a right to do so, IBM grants an immunity from suit
74 * under its patents, if any, for the use, sale or manufacture of products to
75 * the extent that such products are used for performing Domain Name System
76 * dynamic updates in TCP/IP networks by means of the Software. No immunity is
77 * granted for any product per se or for any other function of any product.
78 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
79 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
80 * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
81 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
82 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
83 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
85 * @(#)nameser.h 8.2 (Berkeley) 2/16/94
86 * From Id: nameser.h,v 8.11 1996/10/08 04:51:02 vixie Exp
87 * $Id: nameser.h,v 1.11 1997/02/23 09:17:20 peter Exp $
90 #ifndef _ARPA_NAMESER_H_
91 #define _ARPA_NAMESER_H_
97 #include <sys/param.h>
98 #include <sys/types.h>
101 revision information. this is the release date in YYYYMMDD format.
102 it can change every day so the right thing to do with it is use it
103 in preprocessor commands such as "#if (__BIND > 19931104)". do not
104 compare for equality; rather, use it to determine whether your resolver
105 is new enough to contain a certain feature.
108 #define __BIND 19960801 /* interface version stamp */
111 Define constants based on rfc883
114 /** maximum packet size */
117 /** maximum presentation domain name */
118 #define MAXDNAME 1025
120 /** maximum compressed domain name */
121 #define MAXCDNAME 255
123 /** maximum length of domain label */
126 /** #/bytes of fixed data in header */
129 /** #/bytes of fixed data in query */
132 /** #/bytes of fixed data in r record */
135 /** for systems without 32-bit ints */
138 /** for systems without 16-bit ints */
148 Internet nameserver port number
150 #define NAMESERVER_PORT 53
154 Currently defined opcodes
157 /** standard query */
163 /** nameserver status query */
168 #define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
172 Currently defined response codes
181 /** server failure */
184 /** non existent domain */
187 /** not implemented */
196 Type values for resources and queries
202 /** authoritative server */
205 /** mail destination */
208 /** mail forwarder */
211 /** canonical name */
214 /** start of authority zone */
217 /** mailbox domain name */
220 /** mail group member */
223 /** mail rename name */
226 /** null resource record */
229 /** well known service */
232 /** domain name pointer */
235 /** host information */
238 /** mailbox information */
241 /** mail routing information */
247 /** responsible person */
250 /** AFS cell database */
253 /** X_25 calling address */
256 /** ISDN calling address */
265 /** reverse NSAP lookup (deprecated) */
266 #define T_NSAP_PTR 23
268 /** security signature */
274 /** X.400 mail mapping */
277 /** geographical position (withdrawn) */
283 /** Location Information */
286 /** Next Valid Name in Zone */
289 /** Endpoint identifier */
292 /** Nimrod locator */
295 /** Server selection */
301 /** Naming Authority PoinTeR */
304 /** user (finger) information
315 /** Unspecified format (binary data) */
318 /** Query type values which do not appear in resource records
319 incremental zone transfer */
322 /** transfer zone of authority */
325 /** transfer mailbox records */
328 /** transfer mail agent records */
331 /** wildcard match */
335 Values for class field
337 #define C_IN 1 /* the arpa internet */
338 #define C_CHAOS 3 /* for chaos net (MIT) */
339 #define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
340 /* Query class values which do not appear in resource records */
341 #define C_ANY 255 /* wildcard match */
344 Flags field of the KEY RR rdata
346 #define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */
347 #define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */
348 #define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */
349 #define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */
350 #define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */
351 /** The type bits can also be interpreted independently, as single bits: */
352 #define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */
353 #define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */
355 #define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */
356 #define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */
357 #define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */
358 #define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */
359 #define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */
360 #define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */
361 #define KEYFLAG_IPSEC 0x0080 /* key is for IPSEC use (host or user)*/
362 #define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */
363 #define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */
364 #define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */
365 #define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */
367 #define KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \
368 KEYFLAG_RESERVED4 | \
369 KEYFLAG_RESERVED10| KEYFLAG_RESERVED11)
372 The Algorithm field of the KEY and SIG RR's is an integer, {1..254}
374 #define ALGORITHM_MD5RSA 1 /* MD5 with RSA */
375 #define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */
376 #define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */
381 /** Size of a mod or exp in bits */
382 #define MIN_MD5RSA_KEY_PART_BITS 512
383 #define MAX_MD5RSA_KEY_PART_BITS 2552
384 /** Total of binary mod and exp, bytes */
385 #define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3)
386 /** Max length of text sig block */
387 #define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4)
390 Status return codes for T_UNSPEC conversion routines
392 #define CONV_SUCCESS 0
393 #define CONV_OVERFLOW (-1)
394 #define CONV_BADFMT (-2)
395 #define CONV_BADCKSUM (-3)
396 #define CONV_BADBUFLEN (-4)
399 Structure for query header. The order of the fields is machine- and
400 compiler-dependent, depending on the byte/bit order and the layout
401 of bit fields. We use bit fields only in int variables, as this
402 is all ANSI requires. This requires a somewhat confusing rearrangement.
403 EPOC32 is little-endian
406 unsigned id :16; /* query identification number */
407 /* fields in third byte */
408 unsigned rd :1; /* recursion desired */
409 unsigned tc :1; /* truncated message */
410 unsigned aa :1; /* authoritative answer */
411 unsigned opcode :4; /* purpose of message */
412 unsigned qr :1; /* response flag */
413 /* fields in fourth byte */
414 unsigned rcode :4; /* response code */
415 unsigned cd: 1; /* checking disabled by resolver */
416 unsigned ad: 1; /* authentic data from named */
417 unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */
418 unsigned ra :1; /* recursion available */
419 /* remaining bytes */
420 unsigned qdcount :16; /* number of question entries */
421 unsigned ancount :16; /* number of answer entries */
422 unsigned nscount :16; /* number of authority entries */
423 unsigned arcount :16; /* number of resource entries */
427 Defines for handling compressed domain names
429 #define INDIR_MASK 0xc0
431 extern u_int16_t _getshort (const u_char *);
432 extern u_int32_t _getlong (const u_char *);
435 Inline versions of get/put short/long. Pointer is advanced.
437 These macros demonstrate the property of C whereby it can be
438 portable or it can be elegant but rarely both.
440 #define GETSHORT(s, cp) { \
441 register u_char *t_cp = (u_char *)(cp); \
442 (s) = ((u_int16_t)t_cp[0] << 8) \
443 | ((u_int16_t)t_cp[1]) \
448 #define GETLONG(l, cp) { \
449 register u_char *t_cp = (u_char *)(cp); \
450 (l) = ((u_int32_t)t_cp[0] << 24) \
451 | ((u_int32_t)t_cp[1] << 16) \
452 | ((u_int32_t)t_cp[2] << 8) \
453 | ((u_int32_t)t_cp[3]) \
458 #define PUTSHORT(s, cp) { \
459 register u_int16_t t_s = (u_int16_t)(s); \
460 register u_char *t_cp = (u_char *)(cp); \
461 *t_cp++ = t_s >> 8; \
466 #define PUTLONG(l, cp) { \
467 register u_int32_t t_l = (u_int32_t)(l); \
468 register u_char *t_cp = (u_char *)(cp); \
469 *t_cp++ = t_l >> 24; \
470 *t_cp++ = t_l >> 16; \
471 *t_cp++ = t_l >> 8; \
479 #endif /* !_ARPA_NAMESER_H_ */