rrdef.h revision 266140
1/* 2 * rrdef.h 3 * 4 * RR definitions 5 * 6 * a Net::DNS like library for C 7 * 8 * (c) NLnet Labs, 2005-2006 9 * 10 * See the file LICENSE for the license 11 */ 12 13/** 14 * \file 15 * 16 * Defines resource record types and constants. 17 */ 18 19#ifndef LDNS_RRDEF_H 20#define LDNS_RRDEF_H 21 22#ifdef __cplusplus 23extern "C" { 24#endif 25 26/** Maximum length of a dname label */ 27#define LDNS_MAX_LABELLEN 63 28/** Maximum length of a complete dname */ 29#define LDNS_MAX_DOMAINLEN 255 30/** Maximum number of pointers in 1 dname */ 31#define LDNS_MAX_POINTERS 65535 32/** The bytes TTL, CLASS and length use up in an rr */ 33#define LDNS_RR_OVERHEAD 10 34 35#define LDNS_DNSSEC_KEYPROTO 3 36#define LDNS_KEY_ZONE_KEY 0x0100 /* set for ZSK&KSK, rfc 4034 */ 37#define LDNS_KEY_SEP_KEY 0x0001 /* set for KSK, rfc 4034 */ 38#define LDNS_KEY_REVOKE_KEY 0x0080 /* used to revoke KSK, rfc 5011 */ 39 40/* The first fields are contiguous and can be referenced instantly */ 41#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 258 42 43/** lookuptable for rr classes */ 44extern struct sldns_struct_lookup_table* sldns_rr_classes; 45 46/** 47 * The different RR classes. 48 */ 49enum sldns_enum_rr_class 50{ 51 /** the Internet */ 52 LDNS_RR_CLASS_IN = 1, 53 /** Chaos class */ 54 LDNS_RR_CLASS_CH = 3, 55 /** Hesiod (Dyer 87) */ 56 LDNS_RR_CLASS_HS = 4, 57 /** None class, dynamic update */ 58 LDNS_RR_CLASS_NONE = 254, 59 /** Any class */ 60 LDNS_RR_CLASS_ANY = 255, 61 62 LDNS_RR_CLASS_FIRST = 0, 63 LDNS_RR_CLASS_LAST = 65535, 64 LDNS_RR_CLASS_COUNT = LDNS_RR_CLASS_LAST - LDNS_RR_CLASS_FIRST + 1 65}; 66typedef enum sldns_enum_rr_class sldns_rr_class; 67 68/** 69 * Used to specify whether compression is allowed. 70 */ 71enum sldns_enum_rr_compress 72{ 73 /** compression is allowed */ 74 LDNS_RR_COMPRESS, 75 LDNS_RR_NO_COMPRESS 76}; 77typedef enum sldns_enum_rr_compress sldns_rr_compress; 78 79/** 80 * The different RR types. 81 */ 82enum sldns_enum_rr_type 83{ 84 /** a host address */ 85 LDNS_RR_TYPE_A = 1, 86 /** an authoritative name server */ 87 LDNS_RR_TYPE_NS = 2, 88 /** a mail destination (Obsolete - use MX) */ 89 LDNS_RR_TYPE_MD = 3, 90 /** a mail forwarder (Obsolete - use MX) */ 91 LDNS_RR_TYPE_MF = 4, 92 /** the canonical name for an alias */ 93 LDNS_RR_TYPE_CNAME = 5, 94 /** marks the start of a zone of authority */ 95 LDNS_RR_TYPE_SOA = 6, 96 /** a mailbox domain name (EXPERIMENTAL) */ 97 LDNS_RR_TYPE_MB = 7, 98 /** a mail group member (EXPERIMENTAL) */ 99 LDNS_RR_TYPE_MG = 8, 100 /** a mail rename domain name (EXPERIMENTAL) */ 101 LDNS_RR_TYPE_MR = 9, 102 /** a null RR (EXPERIMENTAL) */ 103 LDNS_RR_TYPE_NULL = 10, 104 /** a well known service description */ 105 LDNS_RR_TYPE_WKS = 11, 106 /** a domain name pointer */ 107 LDNS_RR_TYPE_PTR = 12, 108 /** host information */ 109 LDNS_RR_TYPE_HINFO = 13, 110 /** mailbox or mail list information */ 111 LDNS_RR_TYPE_MINFO = 14, 112 /** mail exchange */ 113 LDNS_RR_TYPE_MX = 15, 114 /** text strings */ 115 LDNS_RR_TYPE_TXT = 16, 116 /** RFC1183 */ 117 LDNS_RR_TYPE_RP = 17, 118 /** RFC1183 */ 119 LDNS_RR_TYPE_AFSDB = 18, 120 /** RFC1183 */ 121 LDNS_RR_TYPE_X25 = 19, 122 /** RFC1183 */ 123 LDNS_RR_TYPE_ISDN = 20, 124 /** RFC1183 */ 125 LDNS_RR_TYPE_RT = 21, 126 /** RFC1706 */ 127 LDNS_RR_TYPE_NSAP = 22, 128 /** RFC1348 */ 129 LDNS_RR_TYPE_NSAP_PTR = 23, 130 /** 2535typecode */ 131 LDNS_RR_TYPE_SIG = 24, 132 /** 2535typecode */ 133 LDNS_RR_TYPE_KEY = 25, 134 /** RFC2163 */ 135 LDNS_RR_TYPE_PX = 26, 136 /** RFC1712 */ 137 LDNS_RR_TYPE_GPOS = 27, 138 /** ipv6 address */ 139 LDNS_RR_TYPE_AAAA = 28, 140 /** LOC record RFC1876 */ 141 LDNS_RR_TYPE_LOC = 29, 142 /** 2535typecode */ 143 LDNS_RR_TYPE_NXT = 30, 144 /** draft-ietf-nimrod-dns-01.txt */ 145 LDNS_RR_TYPE_EID = 31, 146 /** draft-ietf-nimrod-dns-01.txt */ 147 LDNS_RR_TYPE_NIMLOC = 32, 148 /** SRV record RFC2782 */ 149 LDNS_RR_TYPE_SRV = 33, 150 /** http://www.jhsoft.com/rfc/af-saa-0069.000.rtf */ 151 LDNS_RR_TYPE_ATMA = 34, 152 /** RFC2915 */ 153 LDNS_RR_TYPE_NAPTR = 35, 154 /** RFC2230 */ 155 LDNS_RR_TYPE_KX = 36, 156 /** RFC2538 */ 157 LDNS_RR_TYPE_CERT = 37, 158 /** RFC2874 */ 159 LDNS_RR_TYPE_A6 = 38, 160 /** RFC2672 */ 161 LDNS_RR_TYPE_DNAME = 39, 162 /** dnsind-kitchen-sink-02.txt */ 163 LDNS_RR_TYPE_SINK = 40, 164 /** Pseudo OPT record... */ 165 LDNS_RR_TYPE_OPT = 41, 166 /** RFC3123 */ 167 LDNS_RR_TYPE_APL = 42, 168 /** RFC4034, RFC3658 */ 169 LDNS_RR_TYPE_DS = 43, 170 /** SSH Key Fingerprint */ 171 LDNS_RR_TYPE_SSHFP = 44, /* RFC 4255 */ 172 /** IPsec Key */ 173 LDNS_RR_TYPE_IPSECKEY = 45, /* RFC 4025 */ 174 /** DNSSEC */ 175 LDNS_RR_TYPE_RRSIG = 46, /* RFC 4034 */ 176 LDNS_RR_TYPE_NSEC = 47, /* RFC 4034 */ 177 LDNS_RR_TYPE_DNSKEY = 48, /* RFC 4034 */ 178 179 LDNS_RR_TYPE_DHCID = 49, /* RFC 4701 */ 180 /* NSEC3 */ 181 LDNS_RR_TYPE_NSEC3 = 50, /* RFC 5155 */ 182 LDNS_RR_TYPE_NSEC3PARAM = 51, /* RFC 5155 */ 183 LDNS_RR_TYPE_NSEC3PARAMS = 51, 184 LDNS_RR_TYPE_TLSA = 52, /* RFC 6698 */ 185 186 LDNS_RR_TYPE_HIP = 55, /* RFC 5205 */ 187 188 /** draft-reid-dnsext-zs */ 189 LDNS_RR_TYPE_NINFO = 56, 190 /** draft-reid-dnsext-rkey */ 191 LDNS_RR_TYPE_RKEY = 57, 192 /** draft-ietf-dnsop-trust-history */ 193 LDNS_RR_TYPE_TALINK = 58, 194 /** draft-barwood-dnsop-ds-publis */ 195 LDNS_RR_TYPE_CDS = 59, 196 197 LDNS_RR_TYPE_SPF = 99, /* RFC 4408 */ 198 199 LDNS_RR_TYPE_UINFO = 100, 200 LDNS_RR_TYPE_UID = 101, 201 LDNS_RR_TYPE_GID = 102, 202 LDNS_RR_TYPE_UNSPEC = 103, 203 204 LDNS_RR_TYPE_NID = 104, /* RFC 6742 */ 205 LDNS_RR_TYPE_L32 = 105, /* RFC 6742 */ 206 LDNS_RR_TYPE_L64 = 106, /* RFC 6742 */ 207 LDNS_RR_TYPE_LP = 107, /* RFC 6742 */ 208 209 /** draft-jabley-dnsext-eui48-eui64-rrtypes */ 210 LDNS_RR_TYPE_EUI48 = 108, 211 LDNS_RR_TYPE_EUI64 = 109, 212 213 LDNS_RR_TYPE_TKEY = 249, /* RFC 2930 */ 214 LDNS_RR_TYPE_TSIG = 250, 215 LDNS_RR_TYPE_IXFR = 251, 216 LDNS_RR_TYPE_AXFR = 252, 217 /** A request for mailbox-related records (MB, MG or MR) */ 218 LDNS_RR_TYPE_MAILB = 253, 219 /** A request for mail agent RRs (Obsolete - see MX) */ 220 LDNS_RR_TYPE_MAILA = 254, 221 /** any type (wildcard) */ 222 LDNS_RR_TYPE_ANY = 255, 223 /** draft-faltstrom-uri-06 */ 224 LDNS_RR_TYPE_URI = 256, 225 LDNS_RR_TYPE_CAA = 257, /* RFC 6844 */ 226 227 /** DNSSEC Trust Authorities */ 228 LDNS_RR_TYPE_TA = 32768, 229 /* RFC 4431, 5074, DNSSEC Lookaside Validation */ 230 LDNS_RR_TYPE_DLV = 32769, 231 232 /* type codes from nsec3 experimental phase 233 LDNS_RR_TYPE_NSEC3 = 65324, 234 LDNS_RR_TYPE_NSEC3PARAMS = 65325, */ 235 LDNS_RR_TYPE_FIRST = 0, 236 LDNS_RR_TYPE_LAST = 65535, 237 LDNS_RR_TYPE_COUNT = LDNS_RR_TYPE_LAST - LDNS_RR_TYPE_FIRST + 1 238}; 239typedef enum sldns_enum_rr_type sldns_rr_type; 240 241/* RDATA */ 242#define LDNS_MAX_RDFLEN 65535 243 244#define LDNS_RDF_SIZE_BYTE 1 245#define LDNS_RDF_SIZE_WORD 2 246#define LDNS_RDF_SIZE_DOUBLEWORD 4 247#define LDNS_RDF_SIZE_6BYTES 6 248#define LDNS_RDF_SIZE_8BYTES 8 249#define LDNS_RDF_SIZE_16BYTES 16 250 251#define LDNS_NSEC3_VARS_OPTOUT_MASK 0x01 252 253#define LDNS_APL_IP4 1 254#define LDNS_APL_IP6 2 255#define LDNS_APL_MASK 0x7f 256#define LDNS_APL_NEGATION 0x80 257 258/** 259 * The different types of RDATA fields. 260 */ 261enum sldns_enum_rdf_type 262{ 263 /** none */ 264 LDNS_RDF_TYPE_NONE, 265 /** domain name */ 266 LDNS_RDF_TYPE_DNAME, 267 /** 8 bits */ 268 LDNS_RDF_TYPE_INT8, 269 /** 16 bits */ 270 LDNS_RDF_TYPE_INT16, 271 /** 32 bits */ 272 LDNS_RDF_TYPE_INT32, 273 /** A record */ 274 LDNS_RDF_TYPE_A, 275 /** AAAA record */ 276 LDNS_RDF_TYPE_AAAA, 277 /** txt string */ 278 LDNS_RDF_TYPE_STR, 279 /** apl data */ 280 LDNS_RDF_TYPE_APL, 281 /** b32 string */ 282 LDNS_RDF_TYPE_B32_EXT, 283 /** b64 string */ 284 LDNS_RDF_TYPE_B64, 285 /** hex string */ 286 LDNS_RDF_TYPE_HEX, 287 /** nsec type codes */ 288 LDNS_RDF_TYPE_NSEC, 289 /** a RR type */ 290 LDNS_RDF_TYPE_TYPE, 291 /** a class */ 292 LDNS_RDF_TYPE_CLASS, 293 /** certificate algorithm */ 294 LDNS_RDF_TYPE_CERT_ALG, 295 /** a key algorithm */ 296 LDNS_RDF_TYPE_ALG, 297 /** unknown types */ 298 LDNS_RDF_TYPE_UNKNOWN, 299 /** time (32 bits) */ 300 LDNS_RDF_TYPE_TIME, 301 /** period */ 302 LDNS_RDF_TYPE_PERIOD, 303 /** tsig time 48 bits */ 304 LDNS_RDF_TYPE_TSIGTIME, 305 /** Represents the Public Key Algorithm, HIT and Public Key fields 306 for the HIP RR types. A HIP specific rdf type is used because of 307 the unusual layout in wireformat (see RFC 5205 Section 5) */ 308 LDNS_RDF_TYPE_HIP, 309 /** variable length any type rdata where the length 310 is specified by the first 2 bytes */ 311 LDNS_RDF_TYPE_INT16_DATA, 312 /** protocol and port bitmaps */ 313 LDNS_RDF_TYPE_SERVICE, 314 /** location data */ 315 LDNS_RDF_TYPE_LOC, 316 /** well known services */ 317 LDNS_RDF_TYPE_WKS, 318 /** NSAP */ 319 LDNS_RDF_TYPE_NSAP, 320 /** ATMA */ 321 LDNS_RDF_TYPE_ATMA, 322 /** IPSECKEY */ 323 LDNS_RDF_TYPE_IPSECKEY, 324 /** nsec3 hash salt */ 325 LDNS_RDF_TYPE_NSEC3_SALT, 326 /** nsec3 base32 string (with length byte on wire */ 327 LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, 328 329 /** 4 shorts represented as 4 * 16 bit hex numbers 330 * seperated by colons. For NID and L64. 331 */ 332 LDNS_RDF_TYPE_ILNP64, 333 334 /** 6 * 8 bit hex numbers seperated by dashes. For EUI48. */ 335 LDNS_RDF_TYPE_EUI48, 336 /** 8 * 8 bit hex numbers seperated by dashes. For EUI64. */ 337 LDNS_RDF_TYPE_EUI64, 338 339 /** A non-zero sequence of US-ASCII letters and numbers in lower case. 340 * For CAA. 341 */ 342 LDNS_RDF_TYPE_TAG, 343 344 /** A <character-string> encoding of the value field as specified 345 * [RFC1035], Section 5.1., encoded as remaining rdata. 346 * For CAA. 347 */ 348 LDNS_RDF_TYPE_LONG_STR, 349 350 /* Aliases */ 351 LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC 352}; 353typedef enum sldns_enum_rdf_type sldns_rdf_type; 354 355/** 356 * Algorithms used in dns 357 */ 358enum sldns_enum_algorithm 359{ 360 LDNS_RSAMD5 = 1, /* RFC 4034,4035 */ 361 LDNS_DH = 2, 362 LDNS_DSA = 3, 363 LDNS_ECC = 4, 364 LDNS_RSASHA1 = 5, 365 LDNS_DSA_NSEC3 = 6, 366 LDNS_RSASHA1_NSEC3 = 7, 367 LDNS_RSASHA256 = 8, /* RFC 5702 */ 368 LDNS_RSASHA512 = 10, /* RFC 5702 */ 369 LDNS_ECC_GOST = 12, /* RFC 5933 */ 370 LDNS_ECDSAP256SHA256 = 13, /* RFC 6605 */ 371 LDNS_ECDSAP384SHA384 = 14, /* RFC 6605 */ 372 LDNS_INDIRECT = 252, 373 LDNS_PRIVATEDNS = 253, 374 LDNS_PRIVATEOID = 254 375}; 376typedef enum sldns_enum_algorithm sldns_algorithm; 377 378/** 379 * Hashing algorithms used in the DS record 380 */ 381enum sldns_enum_hash 382{ 383 LDNS_SHA1 = 1, /* RFC 4034 */ 384 LDNS_SHA256 = 2, /* RFC 4509 */ 385 LDNS_HASH_GOST = 3, /* RFC 5933 */ 386 LDNS_SHA384 = 4 /* RFC 6605 */ 387}; 388typedef enum sldns_enum_hash sldns_hash; 389 390/** 391 * algorithms used in CERT rrs 392 */ 393enum sldns_enum_cert_algorithm 394{ 395 LDNS_CERT_PKIX = 1, 396 LDNS_CERT_SPKI = 2, 397 LDNS_CERT_PGP = 3, 398 LDNS_CERT_IPKIX = 4, 399 LDNS_CERT_ISPKI = 5, 400 LDNS_CERT_IPGP = 6, 401 LDNS_CERT_ACPKIX = 7, 402 LDNS_CERT_IACPKIX = 8, 403 LDNS_CERT_URI = 253, 404 LDNS_CERT_OID = 254 405}; 406typedef enum sldns_enum_cert_algorithm sldns_cert_algorithm; 407 408/** 409 * EDNS option codes 410 */ 411enum sldns_enum_edns_option 412{ 413 LDNS_EDNS_LLQ = 1, /* http://files.dns-sd.org/draft-sekar-dns-llq.txt */ 414 LDNS_EDNS_UL = 2, /* http://files.dns-sd.org/draft-sekar-dns-ul.txt */ 415 LDNS_EDNS_NSID = 3, /* RFC5001 */ 416 /* 4 draft-cheshire-edns0-owner-option */ 417 LDNS_EDNS_DAU = 5, /* RFC6975 */ 418 LDNS_EDNS_DHU = 6, /* RFC6975 */ 419 LDNS_EDNS_N3U = 7, /* RFC6975 */ 420 LDNS_EDNS_CLIENT_SUBNET = 8 /* draft-vandergaast-edns-client-subnet */ 421}; 422typedef enum sldns_edns_option sldns_edns_option; 423 424#define LDNS_EDNS_MASK_DO_BIT 0x8000 425 426/** 427 * Contains all information about resource record types. 428 * 429 * This structure contains, for all rr types, the rdata fields that are defined. 430 */ 431struct sldns_struct_rr_descriptor 432{ 433 /** Type of the RR that is described here */ 434 sldns_rr_type _type; 435 /** Textual name of the RR type. */ 436 const char *_name; 437 /** Minimum number of rdata fields in the RRs of this type. */ 438 uint8_t _minimum; 439 /** Maximum number of rdata fields in the RRs of this type. */ 440 uint8_t _maximum; 441 /** Wireformat specification for the rr, i.e. the types of rdata fields in their respective order. */ 442 const sldns_rdf_type *_wireformat; 443 /** Special rdf types */ 444 sldns_rdf_type _variable; 445 /** Specifies whether compression can be used for dnames in this RR type. */ 446 sldns_rr_compress _compress; 447 /** The number of DNAMEs in the _wireformat string, for parsing. */ 448 uint8_t _dname_count; 449}; 450typedef struct sldns_struct_rr_descriptor sldns_rr_descriptor; 451 452/** 453 * returns the resource record descriptor for the given rr type. 454 * 455 * \param[in] type the type value of the rr type 456 *\return the sldns_rr_descriptor for this type 457 */ 458const sldns_rr_descriptor *sldns_rr_descript(uint16_t type); 459 460/** 461 * returns the minimum number of rdata fields of the rr type this descriptor describes. 462 * 463 * \param[in] descriptor for an rr type 464 * \return the minimum number of rdata fields 465 */ 466size_t sldns_rr_descriptor_minimum(const sldns_rr_descriptor *descriptor); 467 468/** 469 * returns the maximum number of rdata fields of the rr type this descriptor describes. 470 * 471 * \param[in] descriptor for an rr type 472 * \return the maximum number of rdata fields 473 */ 474size_t sldns_rr_descriptor_maximum(const sldns_rr_descriptor *descriptor); 475 476/** 477 * returns the rdf type for the given rdata field number of the rr type for the given descriptor. 478 * 479 * \param[in] descriptor for an rr type 480 * \param[in] field the field number 481 * \return the rdf type for the field 482 */ 483sldns_rdf_type sldns_rr_descriptor_field_type(const sldns_rr_descriptor *descriptor, size_t field); 484 485/** 486 * retrieves a rrtype by looking up its name. 487 * \param[in] name a string with the name 488 * \return the type which corresponds with the name 489 */ 490sldns_rr_type sldns_get_rr_type_by_name(const char *name); 491 492/** 493 * retrieves a class by looking up its name. 494 * \param[in] name string with the name 495 * \return the cass which corresponds with the name 496 */ 497sldns_rr_class sldns_get_rr_class_by_name(const char *name); 498 499#ifdef __cplusplus 500} 501#endif 502 503#endif /* LDNS_RRDEF_H */ 504