Home | History | Annotate | Line # | Download | only in dist
nameser.h revision 1.6.2.1
      1      1.1  christos /*
      2      1.1  christos  * Copyright (c) 1983, 1989, 1993
      3      1.1  christos  *	The Regents of the University of California.  All rights reserved.
      4      1.1  christos  *
      5      1.1  christos  * Redistribution and use in source and binary forms, with or without
      6      1.1  christos  * modification, are permitted provided that the following conditions
      7      1.1  christos  * are met:
      8      1.1  christos  * 1. Redistributions of source code must retain the above copyright
      9      1.1  christos  *    notice, this list of conditions and the following disclaimer.
     10      1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     11      1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     12      1.1  christos  *    documentation and/or other materials provided with the distribution.
     13      1.2  christos  * 3. Neither the name of the University nor the names of its contributors
     14      1.1  christos  *    may be used to endorse or promote products derived from this software
     15      1.1  christos  *    without specific prior written permission.
     16      1.1  christos  *
     17      1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     18      1.1  christos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19      1.1  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20      1.1  christos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     21      1.1  christos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22      1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23      1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24      1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25      1.1  christos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26      1.1  christos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27      1.1  christos  * SUCH DAMAGE.
     28      1.1  christos  *
     29      1.1  christos  *      @(#)nameser.h	8.2 (Berkeley) 2/16/94
     30      1.1  christos  * -
     31      1.1  christos  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
     32      1.1  christos  *
     33      1.1  christos  * Permission to use, copy, modify, and distribute this software for any
     34      1.1  christos  * purpose with or without fee is hereby granted, provided that the above
     35      1.1  christos  * copyright notice and this permission notice appear in all copies, and that
     36      1.1  christos  * the name of Digital Equipment Corporation not be used in advertising or
     37      1.1  christos  * publicity pertaining to distribution of the document or software without
     38      1.1  christos  * specific, written prior permission.
     39      1.1  christos  *
     40      1.1  christos  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
     41      1.1  christos  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
     42      1.1  christos  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
     43      1.1  christos  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
     44      1.1  christos  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
     45      1.1  christos  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     46      1.1  christos  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     47      1.1  christos  * SOFTWARE.
     48      1.1  christos  * -
     49      1.1  christos  * --Copyright--
     50      1.1  christos  */
     51      1.1  christos 
     52      1.1  christos #ifndef _NAMESER_H_
     53      1.1  christos #define	_NAMESER_H_
     54      1.1  christos 
     55      1.1  christos #include <sys/types.h>
     56      1.1  christos 
     57      1.1  christos /*
     58      1.1  christos  * Define constants based on rfc883
     59      1.1  christos  */
     60      1.1  christos #define PACKETSZ	512		/* maximum packet size */
     61      1.1  christos #define MAXDNAME	256		/* maximum domain name */
     62      1.1  christos #define MAXCDNAME	255		/* maximum compressed domain name */
     63      1.1  christos #define MAXLABEL	63		/* maximum length of domain label */
     64      1.1  christos 	/* Number of bytes of fixed size data in query structure */
     65      1.1  christos #define QFIXEDSZ	4
     66      1.1  christos 	/* number of bytes of fixed size data in resource record */
     67      1.1  christos #define RRFIXEDSZ	10
     68      1.1  christos 
     69      1.1  christos /*
     70      1.1  christos  * Currently defined opcodes
     71      1.1  christos  */
     72      1.1  christos #define QUERY		0x0		/* standard query */
     73      1.1  christos #define IQUERY		0x1		/* inverse query */
     74      1.1  christos #define STATUS		0x2		/* nameserver status query */
     75      1.1  christos #if 0
     76      1.1  christos #define xxx		0x3		/* 0x3 reserved */
     77      1.1  christos #endif
     78      1.1  christos 	/* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
     79      1.1  christos #define UPDATEA		0x9		/* add resource record */
     80      1.1  christos #define UPDATED		0xa		/* delete a specific resource record */
     81      1.1  christos #define UPDATEDA	0xb		/* delete all named resource record */
     82      1.1  christos #define UPDATEM		0xc		/* modify a specific resource record */
     83      1.1  christos #define UPDATEMA	0xd		/* modify all named resource record */
     84      1.1  christos 
     85      1.1  christos #define ZONEINIT	0xe		/* initial zone transfer */
     86  1.6.2.1  perseant #define ZONEREF		0xf		/* incremental zone refresh */
     87      1.1  christos 
     88      1.1  christos /*
     89      1.1  christos  * Undefine various #defines from various System V-flavored OSes (Solaris,
     90      1.1  christos  * SINIX, HP-UX) so the compiler doesn't whine that we redefine them.
     91      1.1  christos  */
     92      1.1  christos #ifdef T_NULL
     93      1.1  christos #undef T_NULL
     94      1.1  christos #endif
     95      1.1  christos #ifdef T_OPT
     96      1.1  christos #undef T_OPT
     97      1.1  christos #endif
     98      1.1  christos #ifdef T_UNSPEC
     99      1.1  christos #undef T_UNSPEC
    100      1.1  christos #endif
    101      1.1  christos #ifdef NOERROR
    102      1.1  christos #undef NOERROR
    103      1.1  christos #endif
    104      1.1  christos 
    105      1.1  christos /*
    106      1.1  christos  * Currently defined response codes
    107      1.1  christos  */
    108      1.1  christos #define NOERROR		0		/* no error */
    109      1.1  christos #define FORMERR		1		/* format error */
    110      1.1  christos #define SERVFAIL	2		/* server failure */
    111  1.6.2.1  perseant #define NXDOMAIN	3		/* nonexistent domain */
    112      1.1  christos #define NOTIMP		4		/* not implemented */
    113      1.1  christos #define REFUSED		5		/* query refused */
    114      1.1  christos 	/* non standard */
    115      1.1  christos #define NOCHANGE	0xf		/* update failed to change db */
    116      1.1  christos 
    117      1.1  christos /*
    118      1.1  christos  * Type values for resources and queries
    119      1.1  christos  */
    120      1.1  christos #define T_A		1		/* host address */
    121      1.1  christos #define T_NS		2		/* authoritative server */
    122      1.1  christos #define T_MD		3		/* mail destination */
    123      1.1  christos #define T_MF		4		/* mail forwarder */
    124  1.6.2.1  perseant #define T_CNAME		5		/* canonical name */
    125      1.1  christos #define T_SOA		6		/* start of authority zone */
    126      1.1  christos #define T_MB		7		/* mailbox domain name */
    127      1.1  christos #define T_MG		8		/* mail group member */
    128      1.1  christos #define T_MR		9		/* mail rename name */
    129      1.1  christos #define T_NULL		10		/* null resource record */
    130      1.1  christos #define T_WKS		11		/* well known service */
    131      1.1  christos #define T_PTR		12		/* domain name pointer */
    132      1.1  christos #define T_HINFO		13		/* host information */
    133      1.1  christos #define T_MINFO		14		/* mailbox information */
    134      1.1  christos #define T_MX		15		/* mail routing information */
    135      1.1  christos #define T_TXT		16		/* text strings */
    136      1.1  christos #define	T_RP		17		/* responsible person */
    137      1.1  christos #define	T_AFSDB		18		/* AFS cell database */
    138      1.1  christos #define T_X25		19		/* X_25 calling address */
    139      1.1  christos #define T_ISDN		20		/* ISDN calling address */
    140      1.1  christos #define T_RT		21		/* router */
    141      1.1  christos #define	T_NSAP		22		/* NSAP address */
    142      1.1  christos #define	T_NSAP_PTR	23		/* reverse lookup for NSAP */
    143      1.1  christos #define T_SIG		24		/* security signature */
    144      1.1  christos #define T_KEY		25		/* security key */
    145      1.1  christos #define T_PX		26		/* X.400 mail mapping */
    146      1.1  christos #define T_GPOS		27		/* geographical position (withdrawn) */
    147      1.1  christos #define T_AAAA		28		/* IP6 Address */
    148      1.1  christos #define T_LOC		29		/* Location Information */
    149      1.1  christos #define T_NXT		30		/* Next Valid Name in Zone */
    150      1.1  christos #define T_EID		31		/* Endpoint identifier */
    151      1.1  christos #define T_NIMLOC	32		/* Nimrod locator */
    152      1.1  christos #define T_SRV		33		/* Server selection */
    153      1.1  christos #define T_ATMA		34		/* ATM Address */
    154      1.1  christos #define T_NAPTR		35		/* Naming Authority PoinTeR */
    155      1.1  christos #define T_KX		36		/* Key Exchanger */
    156      1.1  christos #define T_CERT		37		/* Certificates in the DNS */
    157      1.1  christos #define T_A6		38		/* IP6 address */
    158      1.1  christos #define T_DNAME		39		/* non-terminal redirection */
    159      1.1  christos #define T_SINK		40		/* unknown */
    160      1.1  christos #define T_OPT		41		/* EDNS0 option (meta-RR) */
    161      1.1  christos #define T_APL		42		/* lists of address prefixes */
    162      1.1  christos #define T_DS		43		/* Delegation Signer */
    163      1.1  christos #define T_SSHFP		44		/* SSH Fingerprint */
    164      1.1  christos #define T_IPSECKEY	45		/* IPsec keying material */
    165      1.1  christos #define T_RRSIG		46		/* new security signature */
    166      1.1  christos #define T_NSEC		47		/* provable insecure information */
    167      1.1  christos #define T_DNSKEY	48		/* new security key */
    168      1.6  christos #define T_DHCID		49		/* DHCP IDentifier */
    169      1.6  christos #define T_NSEC3		50		/* Next SECure record v3 */
    170      1.6  christos #define T_NSEC3PARAM	51		/* NSEC3 PARAMeter */
    171      1.6  christos #define T_TLSA		52		/* TLS Authentication */
    172      1.6  christos #define T_SMIMEA	53		/* S/MIME Authentication */
    173      1.6  christos /* Unassigned */
    174      1.6  christos #define T_HIP		55		/* Host Identity Protocol */
    175      1.6  christos #define T_NINFO		56		/* zone status information */
    176      1.6  christos #define T_RKEY		57		/* Record encryption KEY */
    177      1.6  christos #define T_TALINK	58		/* Trust Anchor LINK */
    178      1.6  christos #define T_CDS		59		/* Child Delegation Signer */
    179      1.6  christos #define T_CDNSKEY	60		/* Child DNSKEY */
    180      1.6  christos #define T_OPENPGPKEY	61		/* OpenPGP KEY */
    181  1.6.2.1  perseant #define T_CSYNC		62		/* Child to parent SYNChronization */
    182      1.6  christos #define T_ZONEMD	63		/* ZONE data Message Digest */
    183      1.6  christos #define T_SVCB		64		/* SerViCe Binding */
    184      1.6  christos #define T_HTTPS		65		/* HTTPS binding */
    185      1.1  christos 	/* non standard */
    186      1.1  christos #define T_SPF		99		/* sender policy framework */
    187      1.1  christos #define T_UINFO		100		/* user (finger) information */
    188      1.1  christos #define T_UID		101		/* user ID */
    189      1.1  christos #define T_GID		102		/* group ID */
    190      1.1  christos #define T_UNSPEC	103		/* Unspecified format (binary data) */
    191      1.6  christos #define T_NID		104		/* Node IDentifier */
    192      1.6  christos #define T_L32		105		/* Locator 32-bit */
    193      1.6  christos #define T_L64		106		/* Locator 64-bit */
    194      1.6  christos #define T_LP		107		/* Locator Pointer */
    195      1.6  christos #define T_EUI48		108		/* an EUI-48 address */
    196      1.6  christos #define T_EUI64		109		/* an EUI-64 address */
    197      1.1  christos 	/* Query type values which do not appear in resource records */
    198      1.1  christos #define T_TKEY		249		/* Transaction Key [RFC2930] */
    199      1.1  christos #define T_TSIG		250		/* Transaction Signature [RFC2845] */
    200      1.1  christos #define T_IXFR		251		/* incremental transfer [RFC1995] */
    201      1.1  christos #define T_AXFR		252		/* transfer zone of authority */
    202      1.1  christos #define T_MAILB		253		/* transfer mailbox records */
    203      1.1  christos #define T_MAILA		254		/* transfer mail agent records */
    204      1.1  christos #define T_ANY		255		/* wildcard match */
    205      1.6  christos #define T_URI		256		/* uri records [RFC7553] */
    206      1.6  christos #define T_CAA		257		/* Certification Authority Authorization */
    207      1.6  christos #define T_AVC		258		/* Application Visibility and Control */
    208      1.6  christos #define T_DOA		259		/* Digital Object Architecture */
    209      1.6  christos #define T_AMTRELAY	260		/* Automatic Multicast Tunneling RELAY */
    210      1.6  christos #define T_TA		32768		/* DNSSEC Trust Authorities */
    211      1.6  christos #define T_DLV		32769		/* DNSSEC Lookaside Validation */
    212      1.1  christos 
    213      1.1  christos /*
    214      1.1  christos  * Values for class field
    215      1.1  christos  */
    216      1.1  christos 
    217      1.1  christos #define C_IN		1		/* the arpa internet */
    218      1.1  christos #define C_CHAOS		3		/* for chaos net (MIT) */
    219      1.1  christos #define C_HS		4		/* for Hesiod name server (MIT) (XXX) */
    220      1.1  christos 	/* Query class values which do not appear in resource records */
    221      1.1  christos #define C_ANY		255		/* wildcard match */
    222      1.1  christos #define C_QU		0x8000		/* mDNS QU flag in queries */
    223      1.1  christos #define C_CACHE_FLUSH	0x8000		/* mDNS cache flush flag in replies */
    224      1.1  christos 
    225      1.1  christos /*
    226      1.6  christos  * Values for EDNS option types
    227      1.6  christos  */
    228      1.6  christos #define E_LLQ           1       /* long lived queries protocol */
    229      1.6  christos #define E_UL            2       /* dynamic dns update leases */
    230      1.6  christos #define E_NSID          3       /* name server identifier */
    231      1.6  christos #define E_DAU           5       /* signal DNSSEC algorithm understood */
    232      1.6  christos #define E_DHU           6       /* signal DS hash understood */
    233      1.6  christos #define E_N3U           7       /* signal NSEC3 hash understood */
    234      1.6  christos #define E_ECS           8       /* EDNS client subnet */
    235      1.6  christos #define E_EXPIRE        9       /* zone expiration */
    236      1.6  christos #define E_COOKIE        10      /* DNS cookies */
    237      1.6  christos #define E_KEEPALIVE     11      /* TCP keepalive */
    238      1.6  christos #define E_PADDING       12      /* pad DNS messages */
    239      1.6  christos #define E_CHAIN         13      /* chain DNS queries */
    240      1.6  christos #define E_KEYTAG        14      /* EDNS key tag */
    241      1.6  christos #define E_CLIENTTAG     16      /* EDNS client tag */
    242      1.6  christos #define E_SERVERTAG     17      /* EDNS server tag */
    243      1.6  christos 
    244      1.6  christos /*
    245      1.6  christos  * Values for DNSSEC Algorithms
    246      1.6  christos  * https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml
    247      1.6  christos  */
    248      1.6  christos 
    249      1.6  christos #define A_DELETE                0
    250      1.6  christos #define A_RSAMD5                1
    251      1.6  christos #define A_DH                    2
    252      1.6  christos #define A_DSA                   3
    253      1.6  christos #define A_RSASHA1               5
    254      1.6  christos #define A_DSA_NSEC3_SHA1        6
    255      1.6  christos #define A_RSASHA1_NSEC3_SHA1    7
    256      1.6  christos #define A_RSASHA256             8
    257      1.6  christos #define A_RSASHA512             10
    258      1.6  christos #define A_ECC_GOST              12
    259      1.6  christos #define A_ECDSAP256SHA256       13
    260      1.6  christos #define A_ECDSAP384SHA384       14
    261      1.6  christos #define A_ED25519               15
    262      1.6  christos #define A_ED448                 16
    263      1.6  christos #define A_INDIRECT              252
    264      1.6  christos #define A_PRIVATEDNS            253
    265      1.6  christos #define A_PRIVATEOID            254
    266      1.6  christos 
    267      1.6  christos /*
    268      1.6  christos  * Values for NSEC3 algorithms
    269      1.6  christos  * https://www.iana.org/assignments/dnssec-nsec3-parameters/dnssec-nsec3-parameters.xhtml
    270      1.6  christos  */
    271      1.6  christos #define NSEC_SHA1   1
    272      1.6  christos 
    273      1.6  christos /*
    274      1.6  christos  * Values for delegation signer algorithms
    275      1.6  christos  * https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml
    276      1.6  christos  */
    277      1.6  christos #define DS_SHA1     1
    278      1.6  christos #define DS_SHA256   2
    279      1.6  christos #define DS_GOST     3
    280      1.6  christos #define DS_SHA384   4
    281      1.6  christos 
    282      1.6  christos 
    283      1.6  christos /*
    284      1.1  christos  * Status return codes for T_UNSPEC conversion routines
    285      1.1  christos  */
    286      1.1  christos #define CONV_SUCCESS 0
    287      1.1  christos #define CONV_OVERFLOW -1
    288      1.1  christos #define CONV_BADFMT -2
    289      1.1  christos #define CONV_BADCKSUM -3
    290      1.1  christos #define CONV_BADBUFLEN -4
    291      1.1  christos 
    292      1.1  christos /*
    293      1.1  christos  * Structure for query header.
    294      1.1  christos  */
    295      1.1  christos typedef struct {
    296      1.6  christos 	nd_uint16_t id;		/* query identification number */
    297      1.6  christos 	nd_uint16_t flags;	/* QR, Opcode, AA, TC, RD, RA, RCODE */
    298      1.6  christos 	nd_uint16_t qdcount;	/* number of question entries */
    299      1.6  christos 	nd_uint16_t ancount;	/* number of answer entries */
    300      1.6  christos 	nd_uint16_t nscount;	/* number of authority entries */
    301      1.6  christos 	nd_uint16_t arcount;	/* number of resource entries */
    302      1.6  christos } dns_header_t;
    303      1.1  christos 
    304      1.1  christos /*
    305      1.1  christos  * Macros for subfields of flag fields.
    306      1.1  christos  */
    307      1.6  christos #define DNS_QR(flags)		((flags) & 0x8000)	/* response flag */
    308      1.6  christos #define DNS_OPCODE(flags)	(((flags) >> 11) & 0xF)	/* purpose of message */
    309      1.6  christos #define DNS_AA(flags)		(flags & 0x0400)	/* authoritative answer */
    310      1.6  christos #define DNS_TC(flags)		(flags & 0x0200)	/* truncated message */
    311      1.6  christos #define DNS_RD(flags)		(flags & 0x0100)	/* recursion desired */
    312      1.6  christos #define DNS_RA(flags)		(flags & 0x0080)	/* recursion available */
    313      1.6  christos #define DNS_AD(flags)		(flags & 0x0020)	/* authentic data from named */
    314      1.6  christos #define DNS_CD(flags)		(flags & 0x0010)	/* checking disabled by resolver */
    315      1.6  christos #define DNS_RCODE(flags)	(flags & 0x000F)	/* response code */
    316      1.1  christos 
    317      1.1  christos /*
    318      1.1  christos  * Defines for handling compressed domain names, EDNS0 labels, etc.
    319      1.1  christos  */
    320      1.6  christos #define TYPE_MASK	0xc0	/* mask for the type bits of the item */
    321      1.6  christos #define TYPE_INDIR	0xc0	/* 11.... - pointer */
    322      1.6  christos #define TYPE_RESERVED	0x80	/* 10.... - reserved */
    323      1.6  christos #define TYPE_EDNS0	0x40	/* 01.... - EDNS(0) label */
    324      1.6  christos #define TYPE_LABEL	0x00	/* 00.... - regular label */
    325      1.1  christos #  define EDNS0_ELT_BITLABEL 0x01
    326      1.1  christos 
    327      1.1  christos #endif /* !_NAMESER_H_ */
    328