6 * a Net::DNS like library for C
8 * (c) NLnet Labs, 2005-2006
10 * See the file LICENSE for the license
16 * Defines resource record types and constants.
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
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 */
40 /* The first fields are contiguous and can be referenced instantly */
41 #define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 259
43 /** lookuptable for rr classes */
44 extern struct sldns_struct_lookup_table* sldns_rr_classes;
47 * The different RR classes.
49 enum sldns_enum_rr_class
55 /** Hesiod (Dyer 87) */
57 /** None class, dynamic update */
58 LDNS_RR_CLASS_NONE = 254,
60 LDNS_RR_CLASS_ANY = 255,
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
66 typedef enum sldns_enum_rr_class sldns_rr_class;
69 * Used to specify whether compression is allowed.
71 enum sldns_enum_rr_compress
73 /** compression is allowed */
77 typedef enum sldns_enum_rr_compress sldns_rr_compress;
80 * The different RR types.
82 enum sldns_enum_rr_type
86 /** an authoritative name server */
88 /** a mail destination (Obsolete - use MX) */
90 /** a mail forwarder (Obsolete - use MX) */
92 /** the canonical name for an alias */
93 LDNS_RR_TYPE_CNAME = 5,
94 /** marks the start of a zone of authority */
96 /** a mailbox domain name (EXPERIMENTAL) */
98 /** a mail group member (EXPERIMENTAL) */
100 /** a mail rename domain name (EXPERIMENTAL) */
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,
113 LDNS_RR_TYPE_MX = 15,
115 LDNS_RR_TYPE_TXT = 16,
117 LDNS_RR_TYPE_RP = 17,
119 LDNS_RR_TYPE_AFSDB = 18,
121 LDNS_RR_TYPE_X25 = 19,
123 LDNS_RR_TYPE_ISDN = 20,
125 LDNS_RR_TYPE_RT = 21,
127 LDNS_RR_TYPE_NSAP = 22,
129 LDNS_RR_TYPE_NSAP_PTR = 23,
131 LDNS_RR_TYPE_SIG = 24,
133 LDNS_RR_TYPE_KEY = 25,
135 LDNS_RR_TYPE_PX = 26,
137 LDNS_RR_TYPE_GPOS = 27,
139 LDNS_RR_TYPE_AAAA = 28,
140 /** LOC record RFC1876 */
141 LDNS_RR_TYPE_LOC = 29,
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,
153 LDNS_RR_TYPE_NAPTR = 35,
155 LDNS_RR_TYPE_KX = 36,
157 LDNS_RR_TYPE_CERT = 37,
159 LDNS_RR_TYPE_A6 = 38,
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,
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 */
173 LDNS_RR_TYPE_IPSECKEY = 45, /* RFC 4025 */
175 LDNS_RR_TYPE_RRSIG = 46, /* RFC 4034 */
176 LDNS_RR_TYPE_NSEC = 47, /* RFC 4034 */
177 LDNS_RR_TYPE_DNSKEY = 48, /* RFC 4034 */
179 LDNS_RR_TYPE_DHCID = 49, /* RFC 4701 */
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 LDNS_RR_TYPE_SMIMEA = 53, /* RFC 8162 */
186 LDNS_RR_TYPE_HIP = 55, /* RFC 5205 */
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 LDNS_RR_TYPE_CDS = 59, /** RFC 7344 */
195 LDNS_RR_TYPE_CDNSKEY = 60, /** RFC 7344 */
196 LDNS_RR_TYPE_OPENPGPKEY = 61, /* RFC 7929 */
197 LDNS_RR_TYPE_CSYNC = 62, /* RFC 7477 */
199 LDNS_RR_TYPE_SPF = 99, /* RFC 4408 */
201 LDNS_RR_TYPE_UINFO = 100,
202 LDNS_RR_TYPE_UID = 101,
203 LDNS_RR_TYPE_GID = 102,
204 LDNS_RR_TYPE_UNSPEC = 103,
206 LDNS_RR_TYPE_NID = 104, /* RFC 6742 */
207 LDNS_RR_TYPE_L32 = 105, /* RFC 6742 */
208 LDNS_RR_TYPE_L64 = 106, /* RFC 6742 */
209 LDNS_RR_TYPE_LP = 107, /* RFC 6742 */
211 /** draft-jabley-dnsext-eui48-eui64-rrtypes */
212 LDNS_RR_TYPE_EUI48 = 108,
213 LDNS_RR_TYPE_EUI64 = 109,
215 LDNS_RR_TYPE_TKEY = 249, /* RFC 2930 */
216 LDNS_RR_TYPE_TSIG = 250,
217 LDNS_RR_TYPE_IXFR = 251,
218 LDNS_RR_TYPE_AXFR = 252,
219 /** A request for mailbox-related records (MB, MG or MR) */
220 LDNS_RR_TYPE_MAILB = 253,
221 /** A request for mail agent RRs (Obsolete - see MX) */
222 LDNS_RR_TYPE_MAILA = 254,
223 /** any type (wildcard) */
224 LDNS_RR_TYPE_ANY = 255,
225 LDNS_RR_TYPE_URI = 256, /* RFC 7553 */
226 LDNS_RR_TYPE_CAA = 257, /* RFC 6844 */
227 LDNS_RR_TYPE_AVC = 258,
229 /** DNSSEC Trust Authorities */
230 LDNS_RR_TYPE_TA = 32768,
231 /* RFC 4431, 5074, DNSSEC Lookaside Validation */
232 LDNS_RR_TYPE_DLV = 32769,
234 /* type codes from nsec3 experimental phase
235 LDNS_RR_TYPE_NSEC3 = 65324,
236 LDNS_RR_TYPE_NSEC3PARAMS = 65325, */
237 LDNS_RR_TYPE_FIRST = 0,
238 LDNS_RR_TYPE_LAST = 65535,
239 LDNS_RR_TYPE_COUNT = LDNS_RR_TYPE_LAST - LDNS_RR_TYPE_FIRST + 1
241 typedef enum sldns_enum_rr_type sldns_rr_type;
244 #define LDNS_MAX_RDFLEN 65535
246 #define LDNS_RDF_SIZE_BYTE 1
247 #define LDNS_RDF_SIZE_WORD 2
248 #define LDNS_RDF_SIZE_DOUBLEWORD 4
249 #define LDNS_RDF_SIZE_6BYTES 6
250 #define LDNS_RDF_SIZE_8BYTES 8
251 #define LDNS_RDF_SIZE_16BYTES 16
253 #define LDNS_NSEC3_VARS_OPTOUT_MASK 0x01
255 #define LDNS_APL_IP4 1
256 #define LDNS_APL_IP6 2
257 #define LDNS_APL_MASK 0x7f
258 #define LDNS_APL_NEGATION 0x80
261 * The different types of RDATA fields.
263 enum sldns_enum_rdf_type
284 LDNS_RDF_TYPE_B32_EXT,
289 /** nsec type codes */
295 /** certificate algorithm */
296 LDNS_RDF_TYPE_CERT_ALG,
297 /** a key algorithm */
300 LDNS_RDF_TYPE_UNKNOWN,
301 /** time (32 bits) */
304 LDNS_RDF_TYPE_PERIOD,
305 /** tsig time 48 bits */
306 LDNS_RDF_TYPE_TSIGTIME,
307 /** Represents the Public Key Algorithm, HIT and Public Key fields
308 for the HIP RR types. A HIP specific rdf type is used because of
309 the unusual layout in wireformat (see RFC 5205 Section 5) */
311 /** variable length any type rdata where the length
312 is specified by the first 2 bytes */
313 LDNS_RDF_TYPE_INT16_DATA,
314 /** protocol and port bitmaps */
315 LDNS_RDF_TYPE_SERVICE,
318 /** well known services */
325 LDNS_RDF_TYPE_IPSECKEY,
326 /** nsec3 hash salt */
327 LDNS_RDF_TYPE_NSEC3_SALT,
328 /** nsec3 base32 string (with length byte on wire */
329 LDNS_RDF_TYPE_NSEC3_NEXT_OWNER,
331 /** 4 shorts represented as 4 * 16 bit hex numbers
332 * separated by colons. For NID and L64.
334 LDNS_RDF_TYPE_ILNP64,
336 /** 6 * 8 bit hex numbers separated by dashes. For EUI48. */
338 /** 8 * 8 bit hex numbers separated by dashes. For EUI64. */
341 /** A non-zero sequence of US-ASCII letters and numbers in lower case.
346 /** A <character-string> encoding of the value field as specified
347 * [RFC1035], Section 5.1., encoded as remaining rdata.
350 LDNS_RDF_TYPE_LONG_STR,
352 /** TSIG extended 16bit error value */
353 LDNS_RDF_TYPE_TSIGERROR,
356 LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC
358 typedef enum sldns_enum_rdf_type sldns_rdf_type;
361 * Algorithms used in dns
363 enum sldns_enum_algorithm
365 LDNS_RSAMD5 = 1, /* RFC 4034,4035 */
371 LDNS_RSASHA1_NSEC3 = 7,
372 LDNS_RSASHA256 = 8, /* RFC 5702 */
373 LDNS_RSASHA512 = 10, /* RFC 5702 */
374 LDNS_ECC_GOST = 12, /* RFC 5933 */
375 LDNS_ECDSAP256SHA256 = 13, /* RFC 6605 */
376 LDNS_ECDSAP384SHA384 = 14, /* RFC 6605 */
377 LDNS_ED25519 = 15, /* RFC 8080 */
378 LDNS_ED448 = 16, /* RFC 8080 */
380 LDNS_PRIVATEDNS = 253,
381 LDNS_PRIVATEOID = 254
383 typedef enum sldns_enum_algorithm sldns_algorithm;
386 * Hashing algorithms used in the DS record
390 LDNS_SHA1 = 1, /* RFC 4034 */
391 LDNS_SHA256 = 2, /* RFC 4509 */
392 LDNS_HASH_GOST = 3, /* RFC 5933 */
393 LDNS_SHA384 = 4 /* RFC 6605 */
395 typedef enum sldns_enum_hash sldns_hash;
398 * algorithms used in CERT rrs
400 enum sldns_enum_cert_algorithm
408 LDNS_CERT_ACPKIX = 7,
409 LDNS_CERT_IACPKIX = 8,
413 typedef enum sldns_enum_cert_algorithm sldns_cert_algorithm;
418 enum sldns_enum_edns_option
420 LDNS_EDNS_LLQ = 1, /* http://files.dns-sd.org/draft-sekar-dns-llq.txt */
421 LDNS_EDNS_UL = 2, /* http://files.dns-sd.org/draft-sekar-dns-ul.txt */
422 LDNS_EDNS_NSID = 3, /* RFC5001 */
423 /* 4 draft-cheshire-edns0-owner-option */
424 LDNS_EDNS_DAU = 5, /* RFC6975 */
425 LDNS_EDNS_DHU = 6, /* RFC6975 */
426 LDNS_EDNS_N3U = 7, /* RFC6975 */
427 LDNS_EDNS_CLIENT_SUBNET = 8, /* RFC7871 */
428 LDNS_EDNS_KEEPALIVE = 11, /* draft-ietf-dnsop-edns-tcp-keepalive*/
429 LDNS_EDNS_PADDING = 12, /* RFC7830 */
430 LDNS_EDNS_CLIENT_TAG = 16 /* draft-bellis-dnsop-edns-tags-01 */
432 typedef enum sldns_enum_edns_option sldns_edns_option;
434 #define LDNS_EDNS_MASK_DO_BIT 0x8000
436 /** TSIG and TKEY extended rcodes (16bit), 0-15 are the normal rcodes. */
437 #define LDNS_TSIG_ERROR_NOERROR 0
438 #define LDNS_TSIG_ERROR_BADSIG 16
439 #define LDNS_TSIG_ERROR_BADKEY 17
440 #define LDNS_TSIG_ERROR_BADTIME 18
441 #define LDNS_TSIG_ERROR_BADMODE 19
442 #define LDNS_TSIG_ERROR_BADNAME 20
443 #define LDNS_TSIG_ERROR_BADALG 21
446 * Contains all information about resource record types.
448 * This structure contains, for all rr types, the rdata fields that are defined.
450 struct sldns_struct_rr_descriptor
452 /** Type of the RR that is described here */
454 /** Textual name of the RR type. */
456 /** Minimum number of rdata fields in the RRs of this type. */
458 /** Maximum number of rdata fields in the RRs of this type. */
460 /** Wireformat specification for the rr, i.e. the types of rdata fields in their respective order. */
461 const sldns_rdf_type *_wireformat;
462 /** Special rdf types */
463 sldns_rdf_type _variable;
464 /** Specifies whether compression can be used for dnames in this RR type. */
465 sldns_rr_compress _compress;
466 /** The number of DNAMEs in the _wireformat string, for parsing. */
467 uint8_t _dname_count;
469 typedef struct sldns_struct_rr_descriptor sldns_rr_descriptor;
472 * returns the resource record descriptor for the given rr type.
474 * \param[in] type the type value of the rr type
475 *\return the sldns_rr_descriptor for this type
477 const sldns_rr_descriptor *sldns_rr_descript(uint16_t type);
480 * returns the minimum number of rdata fields of the rr type this descriptor describes.
482 * \param[in] descriptor for an rr type
483 * \return the minimum number of rdata fields
485 size_t sldns_rr_descriptor_minimum(const sldns_rr_descriptor *descriptor);
488 * returns the maximum number of rdata fields of the rr type this descriptor describes.
490 * \param[in] descriptor for an rr type
491 * \return the maximum number of rdata fields
493 size_t sldns_rr_descriptor_maximum(const sldns_rr_descriptor *descriptor);
496 * returns the rdf type for the given rdata field number of the rr type for the given descriptor.
498 * \param[in] descriptor for an rr type
499 * \param[in] field the field number
500 * \return the rdf type for the field
502 sldns_rdf_type sldns_rr_descriptor_field_type(const sldns_rr_descriptor *descriptor, size_t field);
505 * retrieves a rrtype by looking up its name.
506 * \param[in] name a string with the name
507 * \return the type which corresponds with the name
509 sldns_rr_type sldns_get_rr_type_by_name(const char *name);
512 * retrieves a class by looking up its name.
513 * \param[in] name string with the name
514 * \return the cass which corresponds with the name
516 sldns_rr_class sldns_get_rr_class_by_name(const char *name);
522 #endif /* LDNS_RRDEF_H */