sl@0: /* NAMESER.H sl@0: * sl@0: * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: /** @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: /* sl@0: * Copyright (c) 1983, 1989, 1993 sl@0: * The Regents of the University of California. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in the sl@0: * documentation and/or other materials provided with the distribution. sl@0: * 3. All advertising materials mentioning features or use of this software sl@0: * must display the following acknowledgement: sl@0: * This product includes software developed by the University of sl@0: * California, Berkeley and its contributors. sl@0: * 4. Neither the name of the University nor the names of its contributors sl@0: * may be used to endorse or promote products derived from this software sl@0: * without specific prior written permission. sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND sl@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE sl@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE sl@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL sl@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS sl@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT sl@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY sl@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF sl@0: * SUCH DAMAGE. sl@0: * sl@0: * - sl@0: * Portions Copyright (c) 1993 by Digital Equipment Corporation. sl@0: * sl@0: * Permission to use, copy, modify, and distribute this software for any sl@0: * purpose with or without fee is hereby granted, provided that the above sl@0: * copyright notice and this permission notice appear in all copies, and that sl@0: * the name of Digital Equipment Corporation not be used in advertising or sl@0: * publicity pertaining to distribution of the document or software without sl@0: * specific, written prior permission. sl@0: * sl@0: * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL sl@0: * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES sl@0: * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT sl@0: * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL sl@0: * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR sl@0: * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS sl@0: * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS sl@0: * SOFTWARE. sl@0: * - sl@0: * Portions Copyright (c) 1995 by International Business Machines, Inc. sl@0: * sl@0: * International Business Machines, Inc. (hereinafter called IBM) grants sl@0: * permission under its copyrights to use, copy, modify, and distribute this sl@0: * Software with or without fee, provided that the above copyright notice and sl@0: * all paragraphs of this notice appear in all copies, and that the name of IBM sl@0: * not be used in connection with the marketing of any product incorporating sl@0: * the Software or modifications thereof, without specific, written prior sl@0: * permission. sl@0: * sl@0: * To the extent it has a right to do so, IBM grants an immunity from suit sl@0: * under its patents, if any, for the use, sale or manufacture of products to sl@0: * the extent that such products are used for performing Domain Name System sl@0: * dynamic updates in TCP/IP networks by means of the Software. No immunity is sl@0: * granted for any product per se or for any other function of any product. sl@0: * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, sl@0: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A sl@0: * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, sl@0: * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING sl@0: * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN sl@0: * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. sl@0: * sl@0: * @(#)nameser.h 8.2 (Berkeley) 2/16/94 sl@0: * From Id: nameser.h,v 8.11 1996/10/08 04:51:02 vixie Exp sl@0: * $Id: nameser.h,v 1.11 1997/02/23 09:17:20 peter Exp $ sl@0: */ sl@0: sl@0: #ifndef _ARPA_NAMESER_H_ sl@0: #define _ARPA_NAMESER_H_ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: revision information. this is the release date in YYYYMMDD format. sl@0: it can change every day so the right thing to do with it is use it sl@0: in preprocessor commands such as "#if (__BIND > 19931104)". do not sl@0: compare for equality; rather, use it to determine whether your resolver sl@0: is new enough to contain a certain feature. sl@0: */ sl@0: sl@0: #define __BIND 19960801 /* interface version stamp */ sl@0: sl@0: /** sl@0: Define constants based on rfc883 sl@0: */ sl@0: sl@0: /** maximum packet size */ sl@0: #define PACKETSZ 512 sl@0: sl@0: /** maximum presentation domain name */ sl@0: #define MAXDNAME 1025 sl@0: sl@0: /** maximum compressed domain name */ sl@0: #define MAXCDNAME 255 sl@0: sl@0: /** maximum length of domain label */ sl@0: #define MAXLABEL 63 sl@0: sl@0: /** #/bytes of fixed data in header */ sl@0: #define HFIXEDSZ 12 sl@0: sl@0: /** #/bytes of fixed data in query */ sl@0: #define QFIXEDSZ 4 sl@0: sl@0: /** #/bytes of fixed data in r record */ sl@0: #define RRFIXEDSZ 10 sl@0: sl@0: /** for systems without 32-bit ints */ sl@0: #define INT32SZ 4 sl@0: sl@0: /** for systems without 16-bit ints */ sl@0: #define INT16SZ 2 sl@0: sl@0: /** IPv4 T_A */ sl@0: #define INADDRSZ 4 sl@0: sl@0: /** IPv6 T_AAAA */ sl@0: #define IN6ADDRSZ 16 sl@0: sl@0: /** sl@0: Internet nameserver port number sl@0: */ sl@0: #define NAMESERVER_PORT 53 sl@0: sl@0: sl@0: /** sl@0: Currently defined opcodes sl@0: */ sl@0: sl@0: /** standard query */ sl@0: #define QUERY 0x0 sl@0: sl@0: /** inverse query */ sl@0: #define IQUERY 0x1 sl@0: sl@0: /** nameserver status query */ sl@0: #define STATUS 0x2 sl@0: sl@0: /* 0x3 reserved */ sl@0: /*#define xxx 0x3 */ sl@0: #define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */ sl@0: sl@0: sl@0: /** sl@0: Currently defined response codes sl@0: */ sl@0: sl@0: /** no error */ sl@0: #define NOERROR 0 sl@0: sl@0: /** format error */ sl@0: #define FORMERR 1 sl@0: sl@0: /** server failure */ sl@0: #define SERVFAIL 2 sl@0: sl@0: /** non existent domain */ sl@0: #define NXDOMAIN 3 sl@0: sl@0: /** not implemented */ sl@0: #define NOTIMP 4 sl@0: sl@0: /** query refused */ sl@0: #define REFUSED 5 sl@0: sl@0: sl@0: sl@0: /** sl@0: Type values for resources and queries sl@0: */ sl@0: sl@0: /** host address */ sl@0: #define T_A 1 sl@0: sl@0: /** authoritative server */ sl@0: #define T_NS 2 sl@0: sl@0: /** mail destination */ sl@0: #define T_MD 3 sl@0: sl@0: /** mail forwarder */ sl@0: #define T_MF 4 sl@0: sl@0: /** canonical name */ sl@0: #define T_CNAME 5 sl@0: sl@0: /** start of authority zone */ sl@0: #define T_SOA 6 sl@0: sl@0: /** mailbox domain name */ sl@0: #define T_MB 7 sl@0: sl@0: /** mail group member */ sl@0: #define T_MG 8 sl@0: sl@0: /** mail rename name */ sl@0: #define T_MR 9 sl@0: sl@0: /** null resource record */ sl@0: #define T_NULL 10 sl@0: sl@0: /** well known service */ sl@0: #define T_WKS 11 sl@0: sl@0: /** domain name pointer */ sl@0: #define T_PTR 12 sl@0: sl@0: /** host information */ sl@0: #define T_HINFO 13 sl@0: sl@0: /** mailbox information */ sl@0: #define T_MINFO 14 sl@0: sl@0: /** mail routing information */ sl@0: #define T_MX 15 sl@0: sl@0: /** text strings */ sl@0: #define T_TXT 16 sl@0: sl@0: /** responsible person */ sl@0: #define T_RP 17 sl@0: sl@0: /** AFS cell database */ sl@0: #define T_AFSDB 18 sl@0: sl@0: /** X_25 calling address */ sl@0: #define T_X25 19 sl@0: sl@0: /** ISDN calling address */ sl@0: #define T_ISDN 20 sl@0: sl@0: /** router */ sl@0: #define T_RT 21 sl@0: sl@0: /** NSAP address */ sl@0: #define T_NSAP 22 sl@0: sl@0: /** reverse NSAP lookup (deprecated) */ sl@0: #define T_NSAP_PTR 23 sl@0: sl@0: /** security signature */ sl@0: #define T_SIG 24 sl@0: sl@0: /** security key */ sl@0: #define T_KEY 25 sl@0: sl@0: /** X.400 mail mapping */ sl@0: #define T_PX 26 sl@0: sl@0: /** geographical position (withdrawn) */ sl@0: #define T_GPOS 27 sl@0: sl@0: /** IP6 Address */ sl@0: #define T_AAAA 28 sl@0: sl@0: /** Location Information */ sl@0: #define T_LOC 29 sl@0: sl@0: /** Next Valid Name in Zone */ sl@0: #define T_NXT 30 sl@0: sl@0: /** Endpoint identifier */ sl@0: #define T_EID 31 sl@0: sl@0: /** Nimrod locator */ sl@0: #define T_NIMLOC 32 sl@0: sl@0: /** Server selection */ sl@0: #define T_SRV 33 sl@0: sl@0: /** ATM Address */ sl@0: #define T_ATMA 34 sl@0: sl@0: /** Naming Authority PoinTeR */ sl@0: #define T_NAPTR 35 sl@0: sl@0: /** user (finger) information sl@0: non standard sl@0: */ sl@0: #define T_UINFO 100 sl@0: sl@0: /** user ID */ sl@0: #define T_UID 101 sl@0: sl@0: /** group ID */ sl@0: #define T_GID 102 sl@0: sl@0: /** Unspecified format (binary data) */ sl@0: #define T_UNSPEC 103 sl@0: sl@0: /** Query type values which do not appear in resource records sl@0: incremental zone transfer */ sl@0: #define T_IXFR 251 sl@0: sl@0: /** transfer zone of authority */ sl@0: #define T_AXFR 252 sl@0: sl@0: /** transfer mailbox records */ sl@0: #define T_MAILB 253 sl@0: sl@0: /** transfer mail agent records */ sl@0: #define T_MAILA 254 sl@0: sl@0: /** wildcard match */ sl@0: #define T_ANY 255 sl@0: sl@0: /** sl@0: Values for class field sl@0: */ sl@0: #define C_IN 1 /* the arpa internet */ sl@0: #define C_CHAOS 3 /* for chaos net (MIT) */ sl@0: #define C_HS 4 /* for Hesiod name server (MIT) (XXX) */ sl@0: /* Query class values which do not appear in resource records */ sl@0: #define C_ANY 255 /* wildcard match */ sl@0: sl@0: /** sl@0: Flags field of the KEY RR rdata sl@0: */ sl@0: #define KEYFLAG_TYPEMASK 0xC000 /* Mask for "type" bits */ sl@0: #define KEYFLAG_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ sl@0: #define KEYFLAG_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ sl@0: #define KEYFLAG_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ sl@0: #define KEYFLAG_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ sl@0: /** The type bits can also be interpreted independently, as single bits: */ sl@0: #define KEYFLAG_NO_AUTH 0x8000 /* Key not usable for authentication */ sl@0: #define KEYFLAG_NO_CONF 0x4000 /* Key not usable for confidentiality */ sl@0: sl@0: #define KEYFLAG_EXPERIMENTAL 0x2000 /* Security is *mandatory* if bit=0 */ sl@0: #define KEYFLAG_RESERVED3 0x1000 /* reserved - must be zero */ sl@0: #define KEYFLAG_RESERVED4 0x0800 /* reserved - must be zero */ sl@0: #define KEYFLAG_USERACCOUNT 0x0400 /* key is assoc. with a user acct */ sl@0: #define KEYFLAG_ENTITY 0x0200 /* key is assoc. with entity eg host */ sl@0: #define KEYFLAG_ZONEKEY 0x0100 /* key is zone key for the zone named */ sl@0: #define KEYFLAG_IPSEC 0x0080 /* key is for IPSEC use (host or user)*/ sl@0: #define KEYFLAG_EMAIL 0x0040 /* key is for email (MIME security) */ sl@0: #define KEYFLAG_RESERVED10 0x0020 /* reserved - must be zero */ sl@0: #define KEYFLAG_RESERVED11 0x0010 /* reserved - must be zero */ sl@0: #define KEYFLAG_SIGNATORYMASK 0x000F /* key can sign DNS RR's of same name */ sl@0: sl@0: #define KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \ sl@0: KEYFLAG_RESERVED4 | \ sl@0: KEYFLAG_RESERVED10| KEYFLAG_RESERVED11) sl@0: sl@0: /** sl@0: The Algorithm field of the KEY and SIG RR's is an integer, {1..254} sl@0: */ sl@0: #define ALGORITHM_MD5RSA 1 /* MD5 with RSA */ sl@0: #define ALGORITHM_EXPIRE_ONLY 253 /* No alg, no security */ sl@0: #define ALGORITHM_PRIVATE_OID 254 /* Key begins with OID indicating alg */ sl@0: sl@0: /** sl@0: Signatures sl@0: */ sl@0: /** Size of a mod or exp in bits */ sl@0: #define MIN_MD5RSA_KEY_PART_BITS 512 sl@0: #define MAX_MD5RSA_KEY_PART_BITS 2552 sl@0: /** Total of binary mod and exp, bytes */ sl@0: #define MAX_MD5RSA_KEY_BYTES ((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3) sl@0: /** Max length of text sig block */ sl@0: #define MAX_KEY_BASE64 (((MAX_MD5RSA_KEY_BYTES+2)/3)*4) sl@0: sl@0: /** sl@0: Status return codes for T_UNSPEC conversion routines sl@0: */ sl@0: #define CONV_SUCCESS 0 sl@0: #define CONV_OVERFLOW (-1) sl@0: #define CONV_BADFMT (-2) sl@0: #define CONV_BADCKSUM (-3) sl@0: #define CONV_BADBUFLEN (-4) sl@0: sl@0: /** sl@0: Structure for query header. The order of the fields is machine- and sl@0: compiler-dependent, depending on the byte/bit order and the layout sl@0: of bit fields. We use bit fields only in int variables, as this sl@0: is all ANSI requires. This requires a somewhat confusing rearrangement. sl@0: EPOC32 is little-endian sl@0: */ sl@0: typedef struct { sl@0: unsigned id :16; /* query identification number */ sl@0: /* fields in third byte */ sl@0: unsigned rd :1; /* recursion desired */ sl@0: unsigned tc :1; /* truncated message */ sl@0: unsigned aa :1; /* authoritative answer */ sl@0: unsigned opcode :4; /* purpose of message */ sl@0: unsigned qr :1; /* response flag */ sl@0: /* fields in fourth byte */ sl@0: unsigned rcode :4; /* response code */ sl@0: unsigned cd: 1; /* checking disabled by resolver */ sl@0: unsigned ad: 1; /* authentic data from named */ sl@0: unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ sl@0: unsigned ra :1; /* recursion available */ sl@0: /* remaining bytes */ sl@0: unsigned qdcount :16; /* number of question entries */ sl@0: unsigned ancount :16; /* number of answer entries */ sl@0: unsigned nscount :16; /* number of authority entries */ sl@0: unsigned arcount :16; /* number of resource entries */ sl@0: } HEADER; sl@0: sl@0: /** sl@0: Defines for handling compressed domain names sl@0: */ sl@0: #define INDIR_MASK 0xc0 sl@0: sl@0: extern u_int16_t _getshort (const u_char *); sl@0: extern u_int32_t _getlong (const u_char *); sl@0: sl@0: /** sl@0: Inline versions of get/put short/long. Pointer is advanced. sl@0: sl@0: These macros demonstrate the property of C whereby it can be sl@0: portable or it can be elegant but rarely both. sl@0: */ sl@0: #define GETSHORT(s, cp) { \ sl@0: register u_char *t_cp = (u_char *)(cp); \ sl@0: (s) = ((u_int16_t)t_cp[0] << 8) \ sl@0: | ((u_int16_t)t_cp[1]) \ sl@0: ; \ sl@0: (cp) += INT16SZ; \ sl@0: } sl@0: sl@0: #define GETLONG(l, cp) { \ sl@0: register u_char *t_cp = (u_char *)(cp); \ sl@0: (l) = ((u_int32_t)t_cp[0] << 24) \ sl@0: | ((u_int32_t)t_cp[1] << 16) \ sl@0: | ((u_int32_t)t_cp[2] << 8) \ sl@0: | ((u_int32_t)t_cp[3]) \ sl@0: ; \ sl@0: (cp) += INT32SZ; \ sl@0: } sl@0: sl@0: #define PUTSHORT(s, cp) { \ sl@0: register u_int16_t t_s = (u_int16_t)(s); \ sl@0: register u_char *t_cp = (u_char *)(cp); \ sl@0: *t_cp++ = t_s >> 8; \ sl@0: *t_cp = t_s; \ sl@0: (cp) += INT16SZ; \ sl@0: } sl@0: sl@0: #define PUTLONG(l, cp) { \ sl@0: register u_int32_t t_l = (u_int32_t)(l); \ sl@0: register u_char *t_cp = (u_char *)(cp); \ sl@0: *t_cp++ = t_l >> 24; \ sl@0: *t_cp++ = t_l >> 16; \ sl@0: *t_cp++ = t_l >> 8; \ sl@0: *t_cp = t_l; \ sl@0: (cp) += INT32SZ; \ sl@0: } sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: #endif /* !_ARPA_NAMESER_H_ */