2 * rr.h - resource record definitions
4 * a Net::DNS like library for C
6 * (c) NLnet Labs, 2005-2006
8 * See the file LICENSE for the license
14 * Contains the definition of ldns_rr and functions to manipulate those.
21 #include <ldns/common.h>
22 #include <ldns/rdata.h>
23 #include <ldns/buffer.h>
24 #include <ldns/error.h>
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 /* The first fields are 'common' and can be referenced instantly */
36 #define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 51
41 * The different RR classes.
43 enum ldns_enum_rr_class
49 /** Hesiod (Dyer 87) */
51 /** None class, dynamic update */
52 LDNS_RR_CLASS_NONE = 254,
54 LDNS_RR_CLASS_ANY = 255,
56 LDNS_RR_CLASS_FIRST = 0,
57 LDNS_RR_CLASS_LAST = 65535,
58 LDNS_RR_CLASS_COUNT = LDNS_RR_CLASS_LAST - LDNS_RR_CLASS_FIRST + 1
60 typedef enum ldns_enum_rr_class ldns_rr_class;
63 * Used to specify whether compression is allowed.
65 enum ldns_enum_rr_compress
67 /** compression is allowed */
71 typedef enum ldns_enum_rr_compress ldns_rr_compress;
74 * The different RR types.
76 enum ldns_enum_rr_type
80 /** an authoritative name server */
82 /** a mail destination (Obsolete - use MX) */
84 /** a mail forwarder (Obsolete - use MX) */
86 /** the canonical name for an alias */
87 LDNS_RR_TYPE_CNAME = 5,
88 /** marks the start of a zone of authority */
90 /** a mailbox domain name (EXPERIMENTAL) */
92 /** a mail group member (EXPERIMENTAL) */
94 /** a mail rename domain name (EXPERIMENTAL) */
96 /** a null RR (EXPERIMENTAL) */
97 LDNS_RR_TYPE_NULL = 10,
98 /** a well known service description */
99 LDNS_RR_TYPE_WKS = 11,
100 /** a domain name pointer */
101 LDNS_RR_TYPE_PTR = 12,
102 /** host information */
103 LDNS_RR_TYPE_HINFO = 13,
104 /** mailbox or mail list information */
105 LDNS_RR_TYPE_MINFO = 14,
107 LDNS_RR_TYPE_MX = 15,
109 LDNS_RR_TYPE_TXT = 16,
111 LDNS_RR_TYPE_RP = 17,
113 LDNS_RR_TYPE_AFSDB = 18,
115 LDNS_RR_TYPE_X25 = 19,
117 LDNS_RR_TYPE_ISDN = 20,
119 LDNS_RR_TYPE_RT = 21,
121 LDNS_RR_TYPE_NSAP = 22,
123 LDNS_RR_TYPE_NSAP_PTR = 23,
125 LDNS_RR_TYPE_SIG = 24,
127 LDNS_RR_TYPE_KEY = 25,
129 LDNS_RR_TYPE_PX = 26,
131 LDNS_RR_TYPE_GPOS = 27,
133 LDNS_RR_TYPE_AAAA = 28,
134 /** LOC record RFC1876 */
135 LDNS_RR_TYPE_LOC = 29,
137 LDNS_RR_TYPE_NXT = 30,
138 /** draft-ietf-nimrod-dns-01.txt */
139 LDNS_RR_TYPE_EID = 31,
140 /** draft-ietf-nimrod-dns-01.txt */
141 LDNS_RR_TYPE_NIMLOC = 32,
142 /** SRV record RFC2782 */
143 LDNS_RR_TYPE_SRV = 33,
144 /** http://www.jhsoft.com/rfc/af-saa-0069.000.rtf */
145 LDNS_RR_TYPE_ATMA = 34,
147 LDNS_RR_TYPE_NAPTR = 35,
149 LDNS_RR_TYPE_KX = 36,
151 LDNS_RR_TYPE_CERT = 37,
153 LDNS_RR_TYPE_A6 = 38,
155 LDNS_RR_TYPE_DNAME = 39,
156 /** dnsind-kitchen-sink-02.txt */
157 LDNS_RR_TYPE_SINK = 40,
158 /** Pseudo OPT record... */
159 LDNS_RR_TYPE_OPT = 41,
161 LDNS_RR_TYPE_APL = 42,
162 /** draft-ietf-dnsext-delegation */
163 LDNS_RR_TYPE_DS = 43,
164 /** SSH Key Fingerprint */
165 LDNS_RR_TYPE_SSHFP = 44,
166 /** draft-richardson-ipseckey-rr-11.txt */
167 LDNS_RR_TYPE_IPSECKEY = 45,
168 /** draft-ietf-dnsext-dnssec-25 */
169 LDNS_RR_TYPE_RRSIG = 46,
170 LDNS_RR_TYPE_NSEC = 47,
171 LDNS_RR_TYPE_DNSKEY = 48,
172 LDNS_RR_TYPE_DHCID = 49,
174 LDNS_RR_TYPE_NSEC3 = 50,
175 LDNS_RR_TYPE_NSEC3PARAMS = 51,
177 LDNS_RR_TYPE_SPF = 99,
179 LDNS_RR_TYPE_UINFO = 100,
180 LDNS_RR_TYPE_UID = 101,
181 LDNS_RR_TYPE_GID = 102,
182 LDNS_RR_TYPE_UNSPEC = 103,
184 LDNS_RR_TYPE_TSIG = 250,
185 LDNS_RR_TYPE_IXFR = 251,
186 LDNS_RR_TYPE_AXFR = 252,
187 /** A request for mailbox-related records (MB, MG or MR) */
188 LDNS_RR_TYPE_MAILB = 253,
189 /** A request for mail agent RRs (Obsolete - see MX) */
190 LDNS_RR_TYPE_MAILA = 254,
191 /** any type (wildcard) */
192 LDNS_RR_TYPE_ANY = 255,
194 /* RFC 4431, 5074, DNSSEC Lookaside Validation */
195 LDNS_RR_TYPE_DLV = 32769,
197 /* type codes from nsec3 experimental phase
198 LDNS_RR_TYPE_NSEC3 = 65324,
199 LDNS_RR_TYPE_NSEC3PARAMS = 65325, */
200 LDNS_RR_TYPE_FIRST = 0,
201 LDNS_RR_TYPE_LAST = 65535,
202 LDNS_RR_TYPE_COUNT = LDNS_RR_TYPE_LAST - LDNS_RR_TYPE_FIRST + 1
204 typedef enum ldns_enum_rr_type ldns_rr_type;
209 * This is the basic DNS element that contains actual data
215 All RRs have the same top level format shown below:
218 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
219 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
224 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
226 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
228 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
231 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
233 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
236 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
240 NAME an owner name, i.e., the name of the node to which this
241 resource record pertains.
243 TYPE two octets containing one of the RR TYPE codes.
245 CLASS two octets containing one of the RR CLASS codes.
247 TTL a 32 bit signed integer that specifies the time interval
248 that the resource record may be cached before the source
249 of the information should again be consulted. Zero
250 values are interpreted to mean that the RR can only be
251 used for the transaction in progress, and should not be
252 cached. For example, SOA records are always distributed
253 with a zero TTL to prohibit caching. Zero values can
254 also be used for extremely volatile data.
256 RDLENGTH an unsigned 16 bit integer that specifies the length in
257 octets of the RDATA field.
259 RDATA a variable length string of octets that describes the
260 resource. The format of this information varies
261 according to the TYPE and CLASS of the resource record.
264 * The actual amount and type of rdata fields depend on the RR type of the
265 * RR, and can be found by using \ref ldns_rr_descriptor functions.
267 struct ldns_struct_rr
269 /** Owner name, uncompressed */
273 /** Number of data fields */
275 /** the type of the RR. A, MX etc. */
276 ldns_rr_type _rr_type;
277 /** Class of the resource record. */
278 ldns_rr_class _rr_class;
279 /* everything in the rdata is in network order */
280 /** The array of rdata's */
281 ldns_rdf **_rdata_fields;
282 /** question rr [it would be nicer if thous is after _rd_count]
283 ABI change: Fix this in next major release
287 typedef struct ldns_struct_rr ldns_rr;
290 * List or Set of Resource Records
292 * Contains a list of rr's <br>
293 * No official RFC-like checks are made
295 struct ldns_struct_rr_list
301 typedef struct ldns_struct_rr_list ldns_rr_list;
304 * Contains all information about resource record types.
306 * This structure contains, for all rr types, the rdata fields that are defined.
308 struct ldns_struct_rr_descriptor
310 /** Type of the RR that is described here */
312 /** Textual name of the RR type. */
314 /** Minimum number of rdata fields in the RRs of this type. */
316 /** Maximum number of rdata fields in the RRs of this type. */
318 /** Wireformat specification for the rr, i.e. the types of rdata fields in their respective order. */
319 const ldns_rdf_type *_wireformat;
320 /** Special rdf types */
321 ldns_rdf_type _variable;
322 /** Specifies whether compression can be used for dnames in this RR type. */
323 ldns_rr_compress _compress;
324 /** The number of DNAMEs in the _wireformat string, for parsing. */
325 uint8_t _dname_count;
327 typedef struct ldns_struct_rr_descriptor ldns_rr_descriptor;
330 * creates a new rr structure.
333 ldns_rr* ldns_rr_new(void);
336 * creates a new rr structure, based on the given type.
337 * alloc enough space to hold all the rdf's
339 ldns_rr* ldns_rr_new_frm_type(ldns_rr_type t);
342 * frees an RR structure
343 * \param[in] *rr the RR to be freed
346 void ldns_rr_free(ldns_rr *rr);
349 * creates an rr from a string.
350 * The string should be a fully filled-in rr, like
351 * ownername <space> TTL <space> CLASS <space>
352 * TYPE <space> RDATA.
353 * \param[out] n the rr to return
354 * \param[in] str the string to convert
355 * \param[in] default_ttl default ttl value for the rr.
356 * If 0 DEF_TTL will be used
357 * \param[in] origin when the owner is relative add this.
358 * The caller must ldns_rdf_deep_free it.
359 * \param[out] prev the previous ownername. if this value is not NULL,
360 * the function overwrites this with the ownername found in this
361 * string. The caller must then ldns_rdf_deep_free it.
362 * \return a status msg describing an error or LDNS_STATUS_OK
364 ldns_status ldns_rr_new_frm_str(ldns_rr **n, const char *str,
365 uint32_t default_ttl, ldns_rdf *origin,
369 * creates an rr for the question section from a string, i.e.
370 * without RDATA fields
371 * Origin and previous RR functionality are the same as in
372 * ldns_rr_new_frm_str()
373 * \param[out] n the rr to return
374 * \param[in] str the string to convert
375 * \param[in] origin when the owner is relative add this.
376 * The caller must ldns_rdf_deep_free it.
377 * \param prev the previous ownername. the function overwrite this with
378 * the current found ownername. The caller must ldns_rdf_deep_free it.
379 * \return a status msg describing an error or LDNS_STATUS_OK
381 ldns_status ldns_rr_new_question_frm_str(ldns_rr **n, const char *str,
382 ldns_rdf *origin, ldns_rdf **prev);
385 * creates a new rr from a file containing a string.
386 * \param[out] rr the new rr
387 * \param[in] fp the file pointer to use
388 * \param[in] default_ttl pointer to a default ttl for the rr. If NULL DEF_TTL will be used
389 * the pointer will be updated if the file contains a $TTL directive
390 * \param[in] origin when the owner is relative add this
391 * the pointer will be updated if the file contains a $ORIGIN directive
392 * The caller must ldns_rdf_deep_free it.
393 * \param[in] prev when the owner is whitespaces use this as the * ownername
394 * the pointer will be updated after the call
395 * The caller must ldns_rdf_deep_free it.
396 * \return a ldns_status with an error or LDNS_STATUS_OK
398 ldns_status ldns_rr_new_frm_fp(ldns_rr **rr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev);
401 * creates a new rr from a file containing a string.
402 * \param[out] rr the new rr
403 * \param[in] fp the file pointer to use
404 * \param[in] default_ttl a default ttl for the rr. If NULL DEF_TTL will be used
405 * the pointer will be updated if the file contains a $TTL directive
406 * \param[in] origin when the owner is relative add this
407 * the pointer will be updated if the file contains a $ORIGIN directive
408 * The caller must ldns_rdf_deep_free it.
409 * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
410 * \param[in] prev when the owner is whitespaces use this as the * ownername
411 * the pointer will be updated after the call
412 * The caller must ldns_rdf_deep_free it.
413 * \return a ldns_status with an error or LDNS_STATUS_OK
415 ldns_status ldns_rr_new_frm_fp_l(ldns_rr **rr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr);
418 * sets the owner in the rr structure.
419 * \param[in] *rr rr to operate on
420 * \param[in] *owner set to this owner
423 void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner);
426 * sets the question flag in the rr structure.
427 * \param[in] *rr rr to operate on
428 * \param[in] question question flag
431 void ldns_rr_set_question(ldns_rr *rr, bool question);
434 * sets the ttl in the rr structure.
435 * \param[in] *rr rr to operate on
436 * \param[in] ttl set to this ttl
439 void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl);
442 * sets the rd_count in the rr.
443 * \param[in] *rr rr to operate on
444 * \param[in] count set to this count
447 void ldns_rr_set_rd_count(ldns_rr *rr, size_t count);
450 * sets the type in the rr.
451 * \param[in] *rr rr to operate on
452 * \param[in] rr_type set to this type
455 void ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type);
458 * sets the class in the rr.
459 * \param[in] *rr rr to operate on
460 * \param[in] rr_class set to this class
463 void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class);
466 * sets a rdf member, it will be set on the
467 * position given. The old value is returned, like pop.
468 * \param[in] *rr the rr to operate on
469 * \param[in] *f the rdf to set
470 * \param[in] position the position the set the rdf
471 * \return the old value in the rr, NULL on failyre
473 ldns_rdf* ldns_rr_set_rdf(ldns_rr *rr, const ldns_rdf *f, size_t position);
476 * sets rd_field member, it will be
477 * placed in the next available spot.
478 * \param[in] *rr rr to operate on
479 * \param[in] *f the data field member to set
482 bool ldns_rr_push_rdf(ldns_rr *rr, const ldns_rdf *f);
485 * removes a rd_field member, it will be
486 * popped from the last position.
487 * \param[in] *rr rr to operate on
488 * \return rdf which was popped (null if nothing)
490 ldns_rdf* ldns_rr_pop_rdf(ldns_rr *rr);
493 * returns the rdata field member counter.
494 * \param[in] *rr rr to operate on
495 * \param[in] nr the number of the rdf to return
498 ldns_rdf* ldns_rr_rdf(const ldns_rr *rr, size_t nr);
501 * returns the owner name of an rr structure.
502 * \param[in] *rr rr to operate on
505 ldns_rdf* ldns_rr_owner(const ldns_rr *rr);
508 * returns the question flag of an rr structure.
509 * \param[in] *rr rr to operate on
510 * \return bool true if question
512 bool ldns_rr_is_question(const ldns_rr *rr);
515 * returns the ttl of an rr structure.
516 * \param[in] *rr the rr to read from
517 * \return the ttl of the rr
519 uint32_t ldns_rr_ttl(const ldns_rr *rr);
522 * returns the rd_count of an rr structure.
523 * \param[in] *rr the rr to read from
524 * \return the rd count of the rr
526 size_t ldns_rr_rd_count(const ldns_rr *rr);
529 * returns the type of the rr.
530 * \param[in] *rr the rr to read from
531 * \return the type of the rr
533 ldns_rr_type ldns_rr_get_type(const ldns_rr *rr);
536 * returns the class of the rr.
537 * \param[in] *rr the rr to read from
538 * \return the class of the rr
540 ldns_rr_class ldns_rr_get_class(const ldns_rr *rr);
545 * returns the number of rr's in an rr_list.
546 * \param[in] rr_list the rr_list to read from
547 * \return the number of rr's
549 size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list);
552 * sets the number of rr's in an rr_list.
553 * \param[in] rr_list the rr_list to set the count on
554 * \param[in] count the number of rr in this list
557 void ldns_rr_list_set_rr_count(ldns_rr_list *rr_list, size_t count);
560 * set a rr on a specific index in a ldns_rr_list
561 * \param[in] rr_list the rr_list to use
562 * \param[in] r the rr to set
563 * \param[in] count index into the rr_list
564 * \return the old rr which was stored in the rr_list, or
565 * NULL is the index was too large
566 * set a specific rr */
567 ldns_rr * ldns_rr_list_set_rr(ldns_rr_list *rr_list, const ldns_rr *r, size_t count);
570 * returns a specific rr of an rrlist.
571 * \param[in] rr_list the rr_list to read from
572 * \param[in] nr return this rr
573 * \return the rr at position nr
575 ldns_rr* ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr);
578 * creates a new rr_list structure.
579 * \return a new rr_list structure
581 ldns_rr_list* ldns_rr_list_new();
584 * frees an rr_list structure.
585 * \param[in] rr_list the list to free
587 void ldns_rr_list_free(ldns_rr_list *rr_list);
590 * frees an rr_list structure and all rrs contained therein.
591 * \param[in] rr_list the list to free
593 void ldns_rr_list_deep_free(ldns_rr_list *rr_list);
596 * concatenates two ldns_rr_lists together. This modifies
597 * *left (to extend it and add the pointers from *right).
598 * \param[in] left the leftside
599 * \param[in] right the rightside
600 * \return a left with right concatenated to it
602 bool ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right);
605 * concatenates two ldns_rr_lists together, but makes clones of the rr's
606 * (instead of pointer copying).
607 * \param[in] left the leftside
608 * \param[in] right the rightside
609 * \return a new rr_list with leftside/rightside concatenated
611 ldns_rr_list* ldns_rr_list_cat_clone(ldns_rr_list *left, ldns_rr_list *right);
614 * pushes an rr to an rrlist.
615 * \param[in] rr_list the rr_list to push to
616 * \param[in] rr the rr to push
617 * \return false on error, otherwise true
619 bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr);
622 * pushes an rr_list to an rrlist.
623 * \param[in] rr_list the rr_list to push to
624 * \param[in] push_list the rr_list to push
625 * \return false on error, otherwise true
627 bool ldns_rr_list_push_rr_list(ldns_rr_list *rr_list, const ldns_rr_list *push_list);
630 * pops the last rr from an rrlist.
631 * \param[in] rr_list the rr_list to pop from
632 * \return NULL if nothing to pop. Otherwise the popped RR
634 ldns_rr* ldns_rr_list_pop_rr(ldns_rr_list *rr_list);
637 * pops an rr_list of size s from an rrlist.
638 * \param[in] rr_list the rr_list to pop from
639 * \param[in] size the number of rr's to pop
640 * \return NULL if nothing to pop. Otherwise the popped rr_list
642 ldns_rr_list* ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t size);
645 * returns true if the given rr is one of the rrs in the
646 * list, or if it is equal to one
647 * \param[in] rr_list the rr_list to check
648 * \param[in] rr the rr to check
649 * \return true if rr_list contains rr, false otherwise
651 bool ldns_rr_list_contains_rr(const ldns_rr_list *rr_list, ldns_rr *rr);
654 * checks if an rr_list is a rrset.
655 * \param[in] rr_list the rr_list to check
656 * \return true if it is an rrset otherwise false
658 bool ldns_is_rrset(ldns_rr_list *rr_list);
661 * pushes an rr to an rrset (which really are rr_list's).
662 * \param[in] *rr_list the rrset to push the rr to
663 * \param[in] *rr the rr to push
664 * \return true if the push succeeded otherwise false
666 bool ldns_rr_set_push_rr(ldns_rr_list *rr_list, ldns_rr *rr);
669 * pops the last rr from an rrset. This function is there only
671 * \param[in] rr_list the rr_list to pop from
672 * \return NULL if nothing to pop. Otherwise the popped RR
675 ldns_rr* ldns_rr_set_pop_rr(ldns_rr_list *rr_list);
678 * pops the first rrset from the list,
679 * the list must be sorted, so that all rr's from each rrset
680 * are next to each other
682 ldns_rr_list *ldns_rr_list_pop_rrset(ldns_rr_list *rr_list);
686 * retrieves a rrtype by looking up its name.
687 * \param[in] name a string with the name
688 * \return the type which corresponds with the name
690 ldns_rr_type ldns_get_rr_type_by_name(const char *name);
693 * retrieves a class by looking up its name.
694 * \param[in] name string with the name
695 * \return the cass which corresponds with the name
697 ldns_rr_class ldns_get_rr_class_by_name(const char *name);
700 * clones a rr and all its data
701 * \param[in] rr the rr to clone
702 * \return the new rr or NULL on failure
704 ldns_rr* ldns_rr_clone(const ldns_rr *rr);
708 * \param[in] rrlist the rrlist to clone
709 * \return the cloned rr list
711 ldns_rr_list* ldns_rr_list_clone(const ldns_rr_list *rrlist);
714 * sorts an rr_list (canonical wire format). the sorting is done inband.
715 * \param[in] unsorted the rr_list to be sorted
718 void ldns_rr_list_sort(ldns_rr_list *unsorted);
721 * compares two rrs. The TTL is not looked at.
722 * \param[in] rr1 the first one
723 * \param[in] rr2 the second one
725 * -1 if rr1 comes before rr2
726 * +1 if rr2 comes before rr1
728 int ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2);
731 * compares two rrs, up to the rdata.
732 * \param[in] rr1 the first one
733 * \param[in] rr2 the second one
735 * -1 if rr1 comes before rr2
736 * +1 if rr2 comes before rr1
738 int ldns_rr_compare_no_rdata(const ldns_rr *rr1, const ldns_rr *rr2);
741 * compares the wireformat of two rrs, contained in the given buffers.
742 * \param[in] rr1_buf the first one
743 * \param[in] rr2_buf the second one
745 * -1 if rr1_buf comes before rr2_buf
746 * +1 if rr2_buf comes before rr1_buf
748 int ldns_rr_compare_wire(ldns_buffer *rr1_buf, ldns_buffer *rr2_buf);
751 * returns true of the given rr's are equal.
752 * Also returns true if one record is a DS that represents the
753 * same DNSKEY record as the other record
754 * \param[in] rr1 the first rr
755 * \param[in] rr2 the second rr
756 * \return true if equal otherwise false
758 bool ldns_rr_compare_ds(const ldns_rr *rr1, const ldns_rr *rr2);
761 * compares two rr listss.
762 * \param[in] rrl1 the first one
763 * \param[in] rrl2 the second one
765 * -1 if rrl1 comes before rrl2
766 * +1 if rrl2 comes before rrl1
768 int ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2);
771 * calculates the uncompressed size of an RR.
772 * \param[in] r the rr to operate on
773 * \return size of the rr
775 size_t ldns_rr_uncompressed_size(const ldns_rr *r);
778 * converts each dname in a rr to its canonical form.
779 * \param[in] rr the rr to work on
782 void ldns_rr2canonical(ldns_rr *rr);
785 * converts each dname in each rr in a rr_list to its canonical form.
786 * \param[in] rr_list the rr_list to work on
789 void ldns_rr_list2canonical(ldns_rr_list *rr_list);
792 * counts the number of labels of the ownername.
793 * \param[in] rr count the labels of this rr
794 * \return the number of labels
796 uint8_t ldns_rr_label_count(ldns_rr *rr);
799 * returns the resource record descriptor for the given rr type.
801 * \param[in] type the type value of the rr type
802 *\return the ldns_rr_descriptor for this type
804 const ldns_rr_descriptor *ldns_rr_descript(uint16_t type);
807 * returns the minimum number of rdata fields of the rr type this descriptor describes.
809 * \param[in] descriptor for an rr type
810 * \return the minimum number of rdata fields
812 size_t ldns_rr_descriptor_minimum(const ldns_rr_descriptor *descriptor);
815 * returns the maximum number of rdata fields of the rr type this descriptor describes.
817 * \param[in] descriptor for an rr type
818 * \return the maximum number of rdata fields
820 size_t ldns_rr_descriptor_maximum(const ldns_rr_descriptor *descriptor);
823 * returns the rdf type for the given rdata field number of the rr type for the given descriptor.
825 * \param[in] descriptor for an rr type
826 * \param[in] field the field number
827 * \return the rdf type for the field
829 ldns_rdf_type ldns_rr_descriptor_field_type(const ldns_rr_descriptor *descriptor, size_t field);
832 * Return the rr_list which matches the rdf at position field. Think
833 * type-covered stuff for RRSIG
835 * \param[in] l the rr_list to look in
836 * \param[in] r the rdf to use for the comparison
837 * \param[in] pos at which position can we find the rdf
839 * \return a new rr list with only the RRs that match
842 ldns_rr_list *ldns_rr_list_subtype_by_rdf(ldns_rr_list *l, ldns_rdf *r, size_t pos);
845 * convert an rdf of type LDNS_RDF_TYPE_TYPE to an actual
846 * LDNS_RR_TYPE. This is usefull in the case when inspecting
847 * the rrtype covered field of an RRSIG.
848 * \param[in] rd the rdf to look at
849 * \return a ldns_rr_type with equivalent LDNS_RR_TYPE
852 ldns_rr_type ldns_rdf2rr_type(const ldns_rdf *rd);
855 * Returns the type of the first element of the RR
856 * If there are no elements present, 0 is returned
858 * \param[in] rr_list The rr list
859 * \return rr_type of the first element, or 0 if the list is empty
862 ldns_rr_list_type(const ldns_rr_list *rr_list);
865 * Returns the owner domain name rdf of the first element of the RR
866 * If there are no elements present, NULL is returned
868 * \param[in] rr_list The rr list
869 * \return dname of the first element, or NULL if the list is empty
872 ldns_rr_list_owner(const ldns_rr_list *rr_list);
874 #endif /* LDNS_RR_H */