mkinitrd.sh: Fix comment typo.
[dragonfly.git] / contrib / ldns / rr.c
blob72076d40c58d972adf480d0fe42e0d0d6435950e
1 /* rr.c
3 * access functions for ldns_rr -
4 * a Net::DNS like library for C
5 * LibDNS Team @ NLnet Labs
7 * (c) NLnet Labs, 2004-2006
8 * See the file LICENSE for the license
9 */
10 #include <ldns/config.h>
12 #include <ldns/ldns.h>
14 #include <strings.h>
15 #include <limits.h>
17 #include <errno.h>
19 #define LDNS_SYNTAX_DATALEN 16
20 #define LDNS_TTL_DATALEN 21
21 #define LDNS_RRLIST_INIT 8
23 ldns_rr *
24 ldns_rr_new(void)
26 ldns_rr *rr;
27 rr = LDNS_MALLOC(ldns_rr);
28 if (!rr) {
29 return NULL;
32 ldns_rr_set_owner(rr, NULL);
33 ldns_rr_set_question(rr, false);
34 ldns_rr_set_rd_count(rr, 0);
35 rr->_rdata_fields = NULL;
36 ldns_rr_set_class(rr, LDNS_RR_CLASS_IN);
37 ldns_rr_set_ttl(rr, LDNS_DEFAULT_TTL);
38 return rr;
41 ldns_rr *
42 ldns_rr_new_frm_type(ldns_rr_type t)
44 ldns_rr *rr;
45 const ldns_rr_descriptor *desc;
46 size_t i;
48 rr = LDNS_MALLOC(ldns_rr);
49 if (!rr) {
50 return NULL;
53 desc = ldns_rr_descript(t);
55 rr->_rdata_fields = LDNS_XMALLOC(ldns_rdf *, ldns_rr_descriptor_minimum(desc));
56 if(!rr->_rdata_fields) {
57 LDNS_FREE(rr);
58 return NULL;
60 for (i = 0; i < ldns_rr_descriptor_minimum(desc); i++) {
61 rr->_rdata_fields[i] = NULL;
64 ldns_rr_set_owner(rr, NULL);
65 ldns_rr_set_question(rr, false);
66 /* set the count to minimum */
67 ldns_rr_set_rd_count(rr, ldns_rr_descriptor_minimum(desc));
68 ldns_rr_set_class(rr, LDNS_RR_CLASS_IN);
69 ldns_rr_set_ttl(rr, LDNS_DEFAULT_TTL);
70 ldns_rr_set_type(rr, t);
71 return rr;
74 void
75 ldns_rr_free(ldns_rr *rr)
77 size_t i;
78 if (rr) {
79 if (ldns_rr_owner(rr)) {
80 ldns_rdf_deep_free(ldns_rr_owner(rr));
82 for (i = 0; i < ldns_rr_rd_count(rr); i++) {
83 ldns_rdf_deep_free(ldns_rr_rdf(rr, i));
85 LDNS_FREE(rr->_rdata_fields);
86 LDNS_FREE(rr);
91 * trailing spaces are allowed
92 * leading spaces are not allowed
93 * allow ttl to be optional
94 * class is optional too
95 * if ttl is missing, and default_ttl is 0, use DEF_TTL
96 * allow ttl to be written as 1d3h
97 * So the RR should look like. e.g.
98 * miek.nl. 3600 IN MX 10 elektron.atoom.net
99 * or
100 * miek.nl. 1h IN MX 10 elektron.atoom.net
101 * or
102 * miek.nl. IN MX 10 elektron.atoom.net
104 static ldns_status
105 ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str,
106 uint32_t default_ttl, ldns_rdf *origin,
107 ldns_rdf **prev, bool question)
109 ldns_rr *new;
110 const ldns_rr_descriptor *desc;
111 ldns_rr_type rr_type;
112 ldns_buffer *rr_buf = NULL;
113 ldns_buffer *rd_buf = NULL;
114 uint32_t ttl_val;
115 char *owner = NULL;
116 char *ttl = NULL;
117 ldns_rr_class clas_val;
118 char *clas = NULL;
119 char *type = NULL;
120 char *rdata = NULL;
121 char *rd = NULL;
122 char * b64 = NULL;
123 size_t rd_strlen;
124 const char *delimiters;
125 ssize_t c;
126 ldns_rdf *owner_dname;
127 const char* endptr;
128 int was_unknown_rr_format = 0;
129 ldns_status status = LDNS_STATUS_OK;
131 /* used for types with unknown number of rdatas */
132 bool done;
133 bool quoted;
135 ldns_rdf *r = NULL;
136 uint16_t r_cnt;
137 uint16_t r_min;
138 uint16_t r_max;
139 size_t pre_data_pos;
141 new = ldns_rr_new();
143 owner = LDNS_XMALLOC(char, LDNS_MAX_DOMAINLEN + 1);
144 ttl = LDNS_XMALLOC(char, LDNS_TTL_DATALEN);
145 clas = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
146 rdata = LDNS_XMALLOC(char, LDNS_MAX_PACKETLEN + 1);
147 rr_buf = LDNS_MALLOC(ldns_buffer);
148 rd_buf = LDNS_MALLOC(ldns_buffer);
149 rd = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
150 b64 = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
151 if (!new || !owner || !ttl || !clas || !rdata || !rr_buf || !rd_buf || !rd || !b64 ) {
152 status = LDNS_STATUS_MEM_ERR;
153 LDNS_FREE(rr_buf);
154 goto ldnserror;
157 ldns_buffer_new_frm_data(rr_buf, (char*)str, strlen(str));
159 /* split the rr in its parts -1 signals trouble */
160 if (ldns_bget_token(rr_buf, owner, "\t\n ", LDNS_MAX_DOMAINLEN) == -1) {
161 status = LDNS_STATUS_SYNTAX_ERR;
162 ldns_buffer_free(rr_buf);
163 goto ldnserror;
166 if (ldns_bget_token(rr_buf, ttl, "\t\n ", LDNS_TTL_DATALEN) == -1) {
167 status = LDNS_STATUS_SYNTAX_TTL_ERR;
168 ldns_buffer_free(rr_buf);
169 goto ldnserror;
171 ttl_val = (uint32_t) ldns_str2period(ttl, &endptr);
173 if (strlen(ttl) > 0 && !isdigit((int) ttl[0])) {
174 /* ah, it's not there or something */
175 if (default_ttl == 0) {
176 ttl_val = LDNS_DEFAULT_TTL;
177 } else {
178 ttl_val = default_ttl;
180 /* we not ASSUMING the TTL is missing and that
181 * the rest of the RR is still there. That is
182 * CLASS TYPE RDATA
183 * so ttl value we read is actually the class
185 clas_val = ldns_get_rr_class_by_name(ttl);
186 /* class can be left out too, assume IN, current
187 * token must be type
189 if (clas_val == 0) {
190 clas_val = LDNS_RR_CLASS_IN;
191 type = LDNS_XMALLOC(char, strlen(ttl) + 1);
192 if(!type) {
193 status = LDNS_STATUS_MEM_ERR;
194 ldns_buffer_free(rr_buf);
195 goto ldnserror;
197 strncpy(type, ttl, strlen(ttl) + 1);
199 } else {
200 if (ldns_bget_token(rr_buf, clas, "\t\n ", LDNS_SYNTAX_DATALEN) == -1) {
201 status = LDNS_STATUS_SYNTAX_CLASS_ERR;
202 ldns_buffer_free(rr_buf);
203 goto ldnserror;
205 clas_val = ldns_get_rr_class_by_name(clas);
206 /* class can be left out too, assume IN, current
207 * token must be type
209 if (clas_val == 0) {
210 clas_val = LDNS_RR_CLASS_IN;
211 type = LDNS_XMALLOC(char, strlen(clas) + 1);
212 if(!type) {
213 status = LDNS_STATUS_MEM_ERR;
214 ldns_buffer_free(rr_buf);
215 goto ldnserror;
217 strncpy(type, clas, strlen(clas) + 1);
220 /* the rest should still be waiting for us */
222 if (!type) {
223 type = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
224 if(!type) {
225 status = LDNS_STATUS_MEM_ERR;
226 ldns_buffer_free(rr_buf);
227 goto ldnserror;
229 if (ldns_bget_token(rr_buf, type, "\t\n ", LDNS_SYNTAX_DATALEN) == -1) {
230 status = LDNS_STATUS_SYNTAX_TYPE_ERR;
231 ldns_buffer_free(rr_buf);
232 goto ldnserror;
236 if (ldns_bget_token(rr_buf, rdata, "\0", LDNS_MAX_PACKETLEN) == -1) {
237 /* apparently we are done, and it's only a question RR
238 * so do not set status and go to ldnserror here
242 ldns_buffer_new_frm_data(rd_buf, rdata, strlen(rdata));
244 if (strlen(owner) <= 1 && strncmp(owner, "@", 1) == 0) {
245 if (origin) {
246 ldns_rr_set_owner(new, ldns_rdf_clone(origin));
247 } else if (prev && *prev) {
248 ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
249 } else {
250 /* default to root */
251 ldns_rr_set_owner(new, ldns_dname_new_frm_str("."));
254 /* @ also overrides prev */
255 if (prev) {
256 ldns_rdf_deep_free(*prev);
257 *prev = ldns_rdf_clone(ldns_rr_owner(new));
258 if (!*prev) {
259 status = LDNS_STATUS_MEM_ERR;
260 ldns_buffer_free(rr_buf);
261 goto ldnserror;
264 } else {
265 if (strlen(owner) == 0) {
266 /* no ownername was given, try prev, if that fails
267 * origin, else default to root */
268 if (prev && *prev) {
269 ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
270 } else if (origin) {
271 ldns_rr_set_owner(new, ldns_rdf_clone(origin));
272 } else {
273 ldns_rr_set_owner(new, ldns_dname_new_frm_str("."));
275 if(!ldns_rr_owner(new)) {
276 status = LDNS_STATUS_MEM_ERR;
277 ldns_buffer_free(rr_buf);
278 goto ldnserror;
280 } else {
281 owner_dname = ldns_dname_new_frm_str(owner);
282 if (!owner_dname) {
283 status = LDNS_STATUS_SYNTAX_ERR;
284 ldns_buffer_free(rr_buf);
285 goto ldnserror;
288 ldns_rr_set_owner(new, owner_dname);
289 if (!ldns_dname_str_absolute(owner) && origin) {
290 if(ldns_dname_cat(ldns_rr_owner(new),
291 origin) != LDNS_STATUS_OK) {
292 status = LDNS_STATUS_SYNTAX_ERR;
293 ldns_buffer_free(rr_buf);
294 goto ldnserror;
297 if (prev) {
298 ldns_rdf_deep_free(*prev);
299 *prev = ldns_rdf_clone(ldns_rr_owner(new));
300 if(!*prev) {
301 status = LDNS_STATUS_MEM_ERR;
302 ldns_buffer_free(rr_buf);
303 goto ldnserror;
308 LDNS_FREE(owner);
309 owner = NULL;
311 ldns_rr_set_question(new, question);
313 ldns_rr_set_ttl(new, ttl_val);
314 LDNS_FREE(ttl);
315 ttl = NULL;
317 ldns_rr_set_class(new, clas_val);
318 LDNS_FREE(clas);
319 clas = NULL;
321 rr_type = ldns_get_rr_type_by_name(type);
322 LDNS_FREE(type);
323 type = NULL;
325 desc = ldns_rr_descript((uint16_t)rr_type);
326 ldns_rr_set_type(new, rr_type);
327 if (desc) {
328 /* only the rdata remains */
329 r_max = ldns_rr_descriptor_maximum(desc);
330 r_min = ldns_rr_descriptor_minimum(desc);
331 } else {
332 r_min = 0;
333 r_max = 1;
336 /* depending on the rr_type we need to extract
337 * the rdata differently, e.g. NSEC/NSEC3 */
338 switch(rr_type) {
339 default:
340 done = false;
342 for (r_cnt = 0; !done && r_cnt < r_max; r_cnt++) {
343 quoted = false;
344 /* if type = B64, the field may contain spaces */
345 if (ldns_rr_descriptor_field_type(desc,
346 r_cnt) == LDNS_RDF_TYPE_B64 ||
347 ldns_rr_descriptor_field_type(desc,
348 r_cnt) == LDNS_RDF_TYPE_HEX ||
349 ldns_rr_descriptor_field_type(desc,
350 r_cnt) == LDNS_RDF_TYPE_LOC ||
351 ldns_rr_descriptor_field_type(desc,
352 r_cnt) == LDNS_RDF_TYPE_WKS ||
353 ldns_rr_descriptor_field_type(desc,
354 r_cnt) == LDNS_RDF_TYPE_IPSECKEY ||
355 ldns_rr_descriptor_field_type(desc,
356 r_cnt) == LDNS_RDF_TYPE_NSEC) {
357 delimiters = "\n\t";
358 } else {
359 delimiters = "\n\t ";
362 if (ldns_rr_descriptor_field_type(desc,
363 r_cnt) == LDNS_RDF_TYPE_STR &&
364 ldns_buffer_remaining(rd_buf) > 0) {
365 /* skip spaces */
366 while (*(ldns_buffer_current(rd_buf)) == ' ') {
367 ldns_buffer_skip(rd_buf, 1);
370 if (*(ldns_buffer_current(rd_buf)) == '\"') {
371 delimiters = "\"\0";
372 ldns_buffer_skip(rd_buf, 1);
373 quoted = true;
377 /* because number of fields can be variable, we can't
378 rely on _maximum() only */
379 /* skip spaces */
380 while (ldns_buffer_position(rd_buf) < ldns_buffer_limit(rd_buf) &&
381 *(ldns_buffer_current(rd_buf)) == ' ' && !quoted
383 ldns_buffer_skip(rd_buf, 1);
386 pre_data_pos = ldns_buffer_position(rd_buf);
387 if ((c = ldns_bget_token(rd_buf, rd, delimiters,
388 LDNS_MAX_RDFLEN)) != -1) {
389 /* hmmz, rfc3597 specifies that any type can be represented with
390 * \# method, which can contain spaces...
391 * it does specify size though...
393 rd_strlen = strlen(rd);
395 /* unknown RR data */
396 if (strncmp(rd, "\\#", 2) == 0 && !quoted && (rd_strlen == 2 || rd[2]==' ')) {
397 uint16_t hex_data_size;
398 char *hex_data_str;
399 uint16_t cur_hex_data_size;
401 was_unknown_rr_format = 1;
402 /* go back to before \# and skip it while setting delimiters better */
403 ldns_buffer_set_position(rd_buf, pre_data_pos);
404 delimiters = "\n\t ";
405 (void)ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN);
406 /* read rdata octet length */
407 c = ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN);
408 if (c == -1) {
409 /* something goes very wrong here */
410 LDNS_FREE(rd);
411 LDNS_FREE(b64);
412 ldns_buffer_free(rd_buf);
413 ldns_buffer_free(rr_buf);
414 LDNS_FREE(rdata);
415 ldns_rr_free(new);
416 return LDNS_STATUS_SYNTAX_RDATA_ERR;
418 hex_data_size = (uint16_t) atoi(rd);
419 /* copy the hex chars into hex str (which is 2 chars per byte) */
420 hex_data_str = LDNS_XMALLOC(char, 2 * hex_data_size + 1);
421 if (!hex_data_str) {
422 /* malloc error */
423 LDNS_FREE(rd);
424 LDNS_FREE(b64);
425 ldns_buffer_free(rd_buf);
426 ldns_buffer_free(rr_buf);
427 LDNS_FREE(rdata);
428 ldns_rr_free(new);
429 return LDNS_STATUS_SYNTAX_RDATA_ERR;
431 cur_hex_data_size = 0;
432 while(cur_hex_data_size < 2 * hex_data_size) {
433 c = ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN);
434 if (c != -1) {
435 rd_strlen = strlen(rd);
437 if (c == -1 || (size_t)cur_hex_data_size + rd_strlen > 2 * (size_t)hex_data_size) {
438 LDNS_FREE(hex_data_str);
439 LDNS_FREE(rd);
440 LDNS_FREE(b64);
441 ldns_buffer_free(rd_buf);
442 ldns_buffer_free(rr_buf);
443 LDNS_FREE(rdata);
444 ldns_rr_free(new);
445 return LDNS_STATUS_SYNTAX_RDATA_ERR;
447 strncpy(hex_data_str + cur_hex_data_size, rd, rd_strlen);
448 cur_hex_data_size += rd_strlen;
450 hex_data_str[cur_hex_data_size] = '\0';
452 /* correct the rdf type */
453 /* if *we* know the type, interpret it as wireformat */
454 if (desc) {
455 size_t hex_pos = 0;
456 uint8_t *hex_data = LDNS_XMALLOC(uint8_t, hex_data_size + 2);
457 ldns_status s;
458 if(!hex_data) {
459 LDNS_FREE(hex_data_str);
460 LDNS_FREE(rd);
461 LDNS_FREE(b64);
462 ldns_buffer_free(rd_buf);
463 ldns_buffer_free(rr_buf);
464 LDNS_FREE(rdata);
465 ldns_rr_free(new);
466 return LDNS_STATUS_MEM_ERR;
468 ldns_write_uint16(hex_data, hex_data_size);
469 ldns_hexstring_to_data(hex_data + 2, hex_data_str);
470 s = ldns_wire2rdf(new, hex_data,
471 hex_data_size+2, &hex_pos);
472 if(s != LDNS_STATUS_OK) {
473 LDNS_FREE(hex_data_str);
474 LDNS_FREE(rd);
475 LDNS_FREE(b64);
476 ldns_buffer_free(rd_buf);
477 ldns_buffer_free(rr_buf);
478 LDNS_FREE(rdata);
479 ldns_rr_free(new);
480 LDNS_FREE(hex_data);
481 return s;
483 LDNS_FREE(hex_data);
484 } else {
485 r = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_HEX, hex_data_str);
486 if(!r) {
487 LDNS_FREE(hex_data_str);
488 LDNS_FREE(rd);
489 LDNS_FREE(b64);
490 ldns_buffer_free(rd_buf);
491 ldns_buffer_free(rr_buf);
492 LDNS_FREE(rdata);
493 ldns_rr_free(new);
494 return LDNS_STATUS_MEM_ERR;
496 ldns_rdf_set_type(r, LDNS_RDF_TYPE_UNKNOWN);
497 if(!ldns_rr_push_rdf(new, r)) {
498 LDNS_FREE(hex_data_str);
499 LDNS_FREE(rd);
500 LDNS_FREE(b64);
501 ldns_buffer_free(rd_buf);
502 ldns_buffer_free(rr_buf);
503 LDNS_FREE(rdata);
504 ldns_rr_free(new);
505 return LDNS_STATUS_MEM_ERR;
508 LDNS_FREE(hex_data_str);
509 } else {
510 /* Normal RR */
511 switch(ldns_rr_descriptor_field_type(desc, r_cnt)) {
512 case LDNS_RDF_TYPE_HEX:
513 case LDNS_RDF_TYPE_B64:
514 /* can have spaces, and will always be the last
515 * record of the rrdata. Read in the rest */
516 if ((c = ldns_bget_token(rd_buf,
517 b64,
518 "\n",
519 LDNS_MAX_RDFLEN))
520 != -1) {
521 rd = strncat(rd,
522 b64,
523 LDNS_MAX_RDFLEN
524 - strlen(rd) - 1);
526 r = ldns_rdf_new_frm_str(
527 ldns_rr_descriptor_field_type(desc, r_cnt),
528 rd);
529 break;
530 case LDNS_RDF_TYPE_DNAME:
531 r = ldns_rdf_new_frm_str(
532 ldns_rr_descriptor_field_type(desc, r_cnt),
533 rd);
535 /* check if the origin should be used or concatenated */
536 if (r && ldns_rdf_size(r) > 1 && ldns_rdf_data(r)[0] == 1
537 && ldns_rdf_data(r)[1] == '@') {
538 ldns_rdf_deep_free(r);
539 if (origin) {
540 r = ldns_rdf_clone(origin);
541 } else {
542 /* if this is the SOA, use its own owner name */
543 if (rr_type == LDNS_RR_TYPE_SOA) {
544 r = ldns_rdf_clone(ldns_rr_owner(new));
545 } else {
546 r = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, ".");
549 } else if (r && rd_strlen >= 1 && !ldns_dname_str_absolute(rd) && origin) {
550 if (ldns_dname_cat(r, origin) != LDNS_STATUS_OK) {
551 LDNS_FREE(rd);
552 LDNS_FREE(b64);
553 ldns_buffer_free(rd_buf);
554 ldns_buffer_free(rr_buf);
555 LDNS_FREE(rdata);
556 ldns_rr_free(new);
557 return LDNS_STATUS_ERR;
560 break;
561 default:
562 r = ldns_rdf_new_frm_str(
563 ldns_rr_descriptor_field_type(desc, r_cnt),
564 rd);
565 break;
567 if (r) {
568 ldns_rr_push_rdf(new, r);
569 } else {
570 LDNS_FREE(rd);
571 LDNS_FREE(b64);
572 ldns_buffer_free(rd_buf);
573 ldns_buffer_free(rr_buf);
574 LDNS_FREE(rdata);
575 ldns_rr_free(new);
576 return LDNS_STATUS_SYNTAX_RDATA_ERR;
579 if (quoted) {
580 if (ldns_buffer_available(rd_buf, 1)) {
581 ldns_buffer_skip(rd_buf, 1);
582 } else {
583 done = true;
586 } else {
587 done = true;
591 LDNS_FREE(rd);
592 LDNS_FREE(b64);
593 ldns_buffer_free(rd_buf);
594 ldns_buffer_free(rr_buf);
595 LDNS_FREE(rdata);
597 if (!question && desc && !was_unknown_rr_format && ldns_rr_rd_count(new) < r_min) {
598 ldns_rr_free(new);
599 return LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR;
602 if (newrr) {
603 *newrr = new;
604 } else {
605 /* Maybe the caller just wanted to see if it would parse? */
606 ldns_rr_free(new);
608 return LDNS_STATUS_OK;
610 ldnserror:
611 LDNS_FREE(type);
612 LDNS_FREE(owner);
613 LDNS_FREE(ttl);
614 LDNS_FREE(clas);
615 LDNS_FREE(rdata);
616 LDNS_FREE(rd);
617 LDNS_FREE(rd_buf);
618 LDNS_FREE(b64);
619 ldns_rr_free(new);
620 return status;
623 ldns_status
624 ldns_rr_new_frm_str(ldns_rr **newrr, const char *str,
625 uint32_t default_ttl, ldns_rdf *origin,
626 ldns_rdf **prev)
628 return ldns_rr_new_frm_str_internal(newrr,
629 str,
630 default_ttl,
631 origin,
632 prev,
633 false);
636 ldns_status
637 ldns_rr_new_question_frm_str(ldns_rr **newrr, const char *str,
638 ldns_rdf *origin, ldns_rdf **prev)
640 return ldns_rr_new_frm_str_internal(newrr,
641 str,
643 origin,
644 prev,
645 true);
648 ldns_status
649 ldns_rr_new_frm_fp(ldns_rr **newrr, FILE *fp, uint32_t *ttl, ldns_rdf **origin, ldns_rdf **prev)
651 return ldns_rr_new_frm_fp_l(newrr, fp, ttl, origin, prev, NULL);
654 ldns_status
655 ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr)
657 char *line;
658 const char *endptr; /* unused */
659 ldns_rr *rr;
660 uint32_t ttl;
661 ldns_rdf *tmp;
662 ldns_status s;
663 ssize_t size;
664 int offset = 0;
666 if (default_ttl) {
667 ttl = *default_ttl;
668 } else {
669 ttl = 0;
672 line = LDNS_XMALLOC(char, LDNS_MAX_LINELEN + 1);
673 if (!line) {
674 return LDNS_STATUS_MEM_ERR;
677 /* read an entire line in from the file */
678 if ((size = ldns_fget_token_l(fp, line, LDNS_PARSE_SKIP_SPACE, LDNS_MAX_LINELEN, line_nr)) == -1) {
679 LDNS_FREE(line);
680 /* if last line was empty, we are now at feof, which is not
681 * always a parse error (happens when for instance last line
682 * was a comment)
684 return LDNS_STATUS_SYNTAX_ERR;
687 /* we can have the situation, where we've read ok, but still got
688 * no bytes to play with, in this case size is 0
690 if (size == 0) {
691 LDNS_FREE(line);
692 return LDNS_STATUS_SYNTAX_EMPTY;
695 if (strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) {
696 if (*origin) {
697 ldns_rdf_deep_free(*origin);
698 *origin = NULL;
700 offset = 8;
701 while (isspace(line[offset])) {
702 offset++;
704 tmp = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, line + offset);
705 if (!tmp) {
706 /* could not parse what next to $ORIGIN */
707 LDNS_FREE(line);
708 return LDNS_STATUS_SYNTAX_DNAME_ERR;
710 *origin = tmp;
711 s = LDNS_STATUS_SYNTAX_ORIGIN;
712 } else if (strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) {
713 offset = 5;
714 while (isspace(line[offset])) {
715 offset++;
717 if (default_ttl) {
718 *default_ttl = ldns_str2period(line + offset, &endptr);
720 s = LDNS_STATUS_SYNTAX_TTL;
721 } else if (strncmp(line, "$INCLUDE", 8) == 0) {
722 s = LDNS_STATUS_SYNTAX_INCLUDE;
723 } else {
724 if (origin && *origin) {
725 s = ldns_rr_new_frm_str(&rr, (const char*) line, ttl, *origin, prev);
726 } else {
727 s = ldns_rr_new_frm_str(&rr, (const char*) line, ttl, NULL, prev);
730 LDNS_FREE(line);
731 if (s == LDNS_STATUS_OK) {
732 if (newrr) {
733 *newrr = rr;
734 } else {
735 /* Just testing if it would parse? */
736 ldns_rr_free(rr);
739 return s;
742 void
743 ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
745 rr->_owner = owner;
748 void
749 ldns_rr_set_question(ldns_rr *rr, bool question)
751 rr->_rr_question = question;
754 void
755 ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
757 rr->_ttl = ttl;
760 void
761 ldns_rr_set_rd_count(ldns_rr *rr, size_t count)
763 rr->_rd_count = count;
766 void
767 ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type)
769 rr->_rr_type = rr_type;
772 void
773 ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
775 rr->_rr_class = rr_class;
778 ldns_rdf *
779 ldns_rr_set_rdf(ldns_rr *rr, const ldns_rdf *f, size_t position)
781 size_t rd_count;
782 ldns_rdf *pop;
784 rd_count = ldns_rr_rd_count(rr);
785 if (position < rd_count) {
786 /* dicard the old one */
787 pop = rr->_rdata_fields[position];
788 rr->_rdata_fields[position] = (ldns_rdf*)f;
789 return pop;
790 } else {
791 return NULL;
795 bool
796 ldns_rr_push_rdf(ldns_rr *rr, const ldns_rdf *f)
798 size_t rd_count;
799 ldns_rdf **rdata_fields;
801 rd_count = ldns_rr_rd_count(rr);
803 /* grow the array */
804 rdata_fields = LDNS_XREALLOC(
805 rr->_rdata_fields, ldns_rdf *, rd_count + 1);
806 if (!rdata_fields) {
807 return false;
810 /* add the new member */
811 rr->_rdata_fields = rdata_fields;
812 rr->_rdata_fields[rd_count] = (ldns_rdf*)f;
814 ldns_rr_set_rd_count(rr, rd_count + 1);
815 return true;
818 ldns_rdf *
819 ldns_rr_pop_rdf(ldns_rr *rr)
821 size_t rd_count;
822 ldns_rdf *pop;
823 ldns_rdf** newrd;
825 rd_count = ldns_rr_rd_count(rr);
827 if (rd_count == 0) {
828 return NULL;
831 pop = rr->_rdata_fields[rd_count - 1];
833 /* try to shrink the array */
834 if(rd_count > 1) {
835 newrd = LDNS_XREALLOC(
836 rr->_rdata_fields, ldns_rdf *, rd_count - 1);
837 if(newrd)
838 rr->_rdata_fields = newrd;
839 } else {
840 LDNS_FREE(rr->_rdata_fields);
843 ldns_rr_set_rd_count(rr, rd_count - 1);
844 return pop;
847 ldns_rdf *
848 ldns_rr_rdf(const ldns_rr *rr, size_t nr)
850 if (rr && nr < ldns_rr_rd_count(rr)) {
851 return rr->_rdata_fields[nr];
852 } else {
853 return NULL;
857 ldns_rdf *
858 ldns_rr_owner(const ldns_rr *rr)
860 return rr->_owner;
863 bool
864 ldns_rr_is_question(const ldns_rr *rr)
866 return rr->_rr_question;
869 uint32_t
870 ldns_rr_ttl(const ldns_rr *rr)
872 return rr->_ttl;
875 size_t
876 ldns_rr_rd_count(const ldns_rr *rr)
878 return rr->_rd_count;
881 ldns_rr_type
882 ldns_rr_get_type(const ldns_rr *rr)
884 return rr->_rr_type;
887 ldns_rr_class
888 ldns_rr_get_class(const ldns_rr *rr)
890 return rr->_rr_class;
893 /* rr_lists */
895 size_t
896 ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
898 if (rr_list) {
899 return rr_list->_rr_count;
900 } else {
901 return 0;
905 ldns_rr *
906 ldns_rr_list_set_rr(ldns_rr_list *rr_list, const ldns_rr *r, size_t count)
908 ldns_rr *old;
910 if (count > ldns_rr_list_rr_count(rr_list)) {
911 return NULL;
914 old = ldns_rr_list_rr(rr_list, count);
916 /* overwrite old's pointer */
917 rr_list->_rrs[count] = (ldns_rr*)r;
918 return old;
921 void
922 ldns_rr_list_set_rr_count(ldns_rr_list *rr_list, size_t count)
924 assert(count <= rr_list->_rr_capacity);
925 rr_list->_rr_count = count;
928 ldns_rr *
929 ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
931 if (nr < ldns_rr_list_rr_count(rr_list)) {
932 return rr_list->_rrs[nr];
933 } else {
934 return NULL;
938 ldns_rr_list *
939 ldns_rr_list_new()
941 ldns_rr_list *rr_list = LDNS_MALLOC(ldns_rr_list);
942 if(!rr_list) return NULL;
943 rr_list->_rr_count = 0;
944 rr_list->_rr_capacity = 0;
945 rr_list->_rrs = NULL;
946 return rr_list;
949 void
950 ldns_rr_list_free(ldns_rr_list *rr_list)
952 if (rr_list) {
953 LDNS_FREE(rr_list->_rrs);
954 LDNS_FREE(rr_list);
958 void
959 ldns_rr_list_deep_free(ldns_rr_list *rr_list)
961 size_t i;
963 if (rr_list) {
964 for (i=0; i < ldns_rr_list_rr_count(rr_list); i++) {
965 ldns_rr_free(ldns_rr_list_rr(rr_list, i));
967 LDNS_FREE(rr_list->_rrs);
968 LDNS_FREE(rr_list);
973 /* add right to left. So we modify *left! */
974 bool
975 ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right)
977 size_t r_rr_count;
978 size_t i;
980 if (!left) {
981 return false;
984 if (right) {
985 r_rr_count = ldns_rr_list_rr_count(right);
986 } else {
987 r_rr_count = 0;
990 /* push right to left */
991 for(i = 0; i < r_rr_count; i++) {
992 ldns_rr_list_push_rr(left, ldns_rr_list_rr(right, i));
994 return true;
997 ldns_rr_list *
998 ldns_rr_list_cat_clone(ldns_rr_list *left, ldns_rr_list *right)
1000 size_t l_rr_count;
1001 size_t r_rr_count;
1002 size_t i;
1003 ldns_rr_list *cat;
1005 if (left) {
1006 l_rr_count = ldns_rr_list_rr_count(left);
1007 } else {
1008 return ldns_rr_list_clone(right);
1011 if (right) {
1012 r_rr_count = ldns_rr_list_rr_count(right);
1013 } else {
1014 r_rr_count = 0;
1017 cat = ldns_rr_list_new();
1019 if (!cat) {
1020 return NULL;
1023 /* left */
1024 for(i = 0; i < l_rr_count; i++) {
1025 ldns_rr_list_push_rr(cat,
1026 ldns_rr_clone(ldns_rr_list_rr(left, i)));
1028 /* right */
1029 for(i = 0; i < r_rr_count; i++) {
1030 ldns_rr_list_push_rr(cat,
1031 ldns_rr_clone(ldns_rr_list_rr(right, i)));
1033 return cat;
1036 ldns_rr_list *
1037 ldns_rr_list_subtype_by_rdf(ldns_rr_list *l, ldns_rdf *r, size_t pos)
1039 size_t i;
1040 ldns_rr_list *subtyped;
1041 ldns_rdf *list_rdf;
1043 subtyped = ldns_rr_list_new();
1045 for(i = 0; i < ldns_rr_list_rr_count(l); i++) {
1046 list_rdf = ldns_rr_rdf(
1047 ldns_rr_list_rr(l, i),
1048 pos);
1049 if (!list_rdf) {
1050 /* pos is too large or any other error */
1051 ldns_rr_list_deep_free(subtyped);
1052 return NULL;
1055 if (ldns_rdf_compare(list_rdf, r) == 0) {
1056 /* a match */
1057 ldns_rr_list_push_rr(subtyped,
1058 ldns_rr_clone(ldns_rr_list_rr(l, i)));
1062 if (ldns_rr_list_rr_count(subtyped) > 0) {
1063 return subtyped;
1064 } else {
1065 ldns_rr_list_free(subtyped);
1066 return NULL;
1070 bool
1071 ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
1073 size_t rr_count;
1074 size_t cap;
1076 rr_count = ldns_rr_list_rr_count(rr_list);
1077 cap = rr_list->_rr_capacity;
1079 /* grow the array */
1080 if(rr_count+1 > cap) {
1081 ldns_rr **rrs;
1083 if(cap == 0)
1084 cap = LDNS_RRLIST_INIT; /* initial list size */
1085 else cap *= 2;
1086 rrs = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
1087 if (!rrs) {
1088 return false;
1090 rr_list->_rrs = rrs;
1091 rr_list->_rr_capacity = cap;
1094 /* add the new member */
1095 rr_list->_rrs[rr_count] = (ldns_rr*)rr;
1097 ldns_rr_list_set_rr_count(rr_list, rr_count + 1);
1098 return true;
1101 bool
1102 ldns_rr_list_push_rr_list(ldns_rr_list *rr_list, const ldns_rr_list *push_list)
1104 size_t i;
1106 for(i = 0; i < ldns_rr_list_rr_count(push_list); i++) {
1107 if (!ldns_rr_list_push_rr(rr_list,
1108 ldns_rr_list_rr(push_list, i))) {
1109 return false;
1112 return true;
1115 ldns_rr *
1116 ldns_rr_list_pop_rr(ldns_rr_list *rr_list)
1118 size_t rr_count;
1119 size_t cap;
1120 ldns_rr *pop;
1122 rr_count = ldns_rr_list_rr_count(rr_list);
1124 if (rr_count == 0) {
1125 return NULL;
1128 cap = rr_list->_rr_capacity;
1129 pop = ldns_rr_list_rr(rr_list, rr_count - 1);
1131 /* shrink the array */
1132 if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) {
1133 ldns_rr** a;
1134 cap /= 2;
1135 a = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
1136 if(a) {
1137 rr_list->_rrs = a;
1138 rr_list->_rr_capacity = cap;
1142 ldns_rr_list_set_rr_count(rr_list, rr_count - 1);
1144 return pop;
1147 ldns_rr_list *
1148 ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t howmany)
1150 /* pop a number of rr's and put them in a rr_list */
1151 ldns_rr_list *popped;
1152 ldns_rr *p;
1153 size_t i = howmany;
1155 popped = ldns_rr_list_new();
1157 if (!popped) {
1158 return NULL;
1162 while(i > 0 &&
1163 (p = ldns_rr_list_pop_rr(rr_list)) != NULL) {
1164 ldns_rr_list_push_rr(popped, p);
1165 i--;
1168 if (i == howmany) { /* so i <= 0 */
1169 ldns_rr_list_free(popped);
1170 return NULL;
1171 } else {
1172 return popped;
1177 bool
1178 ldns_rr_list_contains_rr(const ldns_rr_list *rr_list, ldns_rr *rr)
1180 size_t i;
1182 if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) {
1183 return false;
1186 for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1187 if (rr == ldns_rr_list_rr(rr_list, i)) {
1188 return true;
1189 } else if (ldns_rr_compare(rr, ldns_rr_list_rr(rr_list, i)) == 0) {
1190 return true;
1193 return false;
1196 bool
1197 ldns_is_rrset(ldns_rr_list *rr_list)
1199 ldns_rr_type t;
1200 ldns_rr_class c;
1201 ldns_rdf *o;
1202 ldns_rr *tmp;
1203 size_t i;
1205 if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) {
1206 return false;
1209 tmp = ldns_rr_list_rr(rr_list, 0);
1211 t = ldns_rr_get_type(tmp);
1212 c = ldns_rr_get_class(tmp);
1213 o = ldns_rr_owner(tmp);
1215 /* compare these with the rest of the rr_list, start with 1 */
1216 for (i = 1; i < ldns_rr_list_rr_count(rr_list); i++) {
1217 tmp = ldns_rr_list_rr(rr_list, i);
1218 if (t != ldns_rr_get_type(tmp)) {
1219 return false;
1221 if (c != ldns_rr_get_class(tmp)) {
1222 return false;
1224 if (ldns_rdf_compare(o, ldns_rr_owner(tmp)) != 0) {
1225 return false;
1228 return true;
1231 bool
1232 ldns_rr_set_push_rr(ldns_rr_list *rr_list, ldns_rr *rr)
1234 size_t rr_count;
1235 size_t i;
1236 ldns_rr *last;
1238 assert(rr != NULL);
1240 rr_count = ldns_rr_list_rr_count(rr_list);
1242 if (rr_count == 0) {
1243 /* nothing there, so checking it is
1244 * not needed */
1245 return ldns_rr_list_push_rr(rr_list, rr);
1246 } else {
1247 /* check with the final rr in the rr_list */
1248 last = ldns_rr_list_rr(rr_list, rr_count - 1);
1250 if (ldns_rr_get_class(last) != ldns_rr_get_class(rr)) {
1251 return false;
1253 if (ldns_rr_get_type(last) != ldns_rr_get_type(rr)) {
1254 return false;
1256 /* only check if not equal to RRSIG */
1257 if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) {
1258 if (ldns_rr_ttl(last) != ldns_rr_ttl(rr)) {
1259 return false;
1262 if (ldns_rdf_compare(ldns_rr_owner(last),
1263 ldns_rr_owner(rr)) != 0) {
1264 return false;
1266 /* ok, still alive - check if the rr already
1267 * exists - if so, dont' add it */
1268 for(i = 0; i < rr_count; i++) {
1269 if(ldns_rr_compare(
1270 ldns_rr_list_rr(rr_list, i), rr) == 0) {
1271 return false;
1274 /* it's safe, push it */
1275 return ldns_rr_list_push_rr(rr_list, rr);
1279 ldns_rr *
1280 ldns_rr_set_pop_rr(ldns_rr_list *rr_list)
1282 return ldns_rr_list_pop_rr(rr_list);
1285 ldns_rr_list *
1286 ldns_rr_list_pop_rrset(ldns_rr_list *rr_list)
1288 ldns_rr_list *rrset;
1289 ldns_rr *last_rr = NULL;
1290 ldns_rr *next_rr;
1292 if (!rr_list) {
1293 return NULL;
1296 rrset = ldns_rr_list_new();
1297 if (!last_rr) {
1298 last_rr = ldns_rr_list_pop_rr(rr_list);
1299 if (!last_rr) {
1300 ldns_rr_list_free(rrset);
1301 return NULL;
1302 } else {
1303 ldns_rr_list_push_rr(rrset, last_rr);
1307 if (ldns_rr_list_rr_count(rr_list) > 0) {
1308 next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
1309 } else {
1310 next_rr = NULL;
1313 while (next_rr) {
1314 if (
1315 ldns_rdf_compare(ldns_rr_owner(next_rr),
1316 ldns_rr_owner(last_rr)) == 0
1318 ldns_rr_get_type(next_rr) == ldns_rr_get_type(last_rr)
1320 ldns_rr_get_class(next_rr) == ldns_rr_get_class(last_rr)
1322 ldns_rr_list_push_rr(rrset, ldns_rr_list_pop_rr(rr_list));
1323 if (ldns_rr_list_rr_count(rr_list) > 0) {
1324 last_rr = next_rr;
1325 next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
1326 } else {
1327 next_rr = NULL;
1329 } else {
1330 next_rr = NULL;
1334 return rrset;
1337 ldns_rr *
1338 ldns_rr_clone(const ldns_rr *rr)
1340 size_t i;
1341 ldns_rr *new_rr;
1343 if (!rr) {
1344 return NULL;
1347 new_rr = ldns_rr_new();
1348 if (!new_rr) {
1349 return NULL;
1351 if (ldns_rr_owner(rr)) {
1352 ldns_rr_set_owner(new_rr, ldns_rdf_clone(ldns_rr_owner(rr)));
1354 ldns_rr_set_ttl(new_rr, ldns_rr_ttl(rr));
1355 ldns_rr_set_type(new_rr, ldns_rr_get_type(rr));
1356 ldns_rr_set_class(new_rr, ldns_rr_get_class(rr));
1357 ldns_rr_set_question(new_rr, ldns_rr_is_question(rr));
1359 for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1360 if (ldns_rr_rdf(rr,i)) {
1361 ldns_rr_push_rdf(new_rr, ldns_rdf_clone(ldns_rr_rdf(rr, i)));
1365 return new_rr;
1368 ldns_rr_list *
1369 ldns_rr_list_clone(const ldns_rr_list *rrlist)
1371 size_t i;
1372 ldns_rr_list *new_list;
1373 ldns_rr *r;
1375 if (!rrlist) {
1376 return NULL;
1379 new_list = ldns_rr_list_new();
1380 if (!new_list) {
1381 return NULL;
1383 for (i = 0; i < ldns_rr_list_rr_count(rrlist); i++) {
1384 r = ldns_rr_clone(
1385 ldns_rr_list_rr(rrlist, i)
1387 if (!r) {
1388 /* huh, failure in cloning */
1389 ldns_rr_list_deep_free(new_list);
1390 return NULL;
1392 ldns_rr_list_push_rr(new_list, r);
1394 return new_list;
1399 qsort_rr_compare(const void *a, const void *b)
1401 const ldns_rr *rr1 = * (const ldns_rr **) a;
1402 const ldns_rr *rr2 = * (const ldns_rr **) b;
1404 if (rr1 == NULL && rr2 == NULL) {
1405 return 0;
1407 if (rr1 == NULL) {
1408 return -1;
1410 if (rr2 == NULL) {
1411 return 1;
1413 return ldns_rr_compare(rr1, rr2);
1417 qsort_schwartz_rr_compare(const void *a, const void *b)
1419 int result = 0;
1420 ldns_rr *rr1, *rr2;
1421 ldns_buffer *rr1_buf, *rr2_buf;
1422 struct ldns_schwartzian_compare_struct *sa = *(struct ldns_schwartzian_compare_struct **) a;
1423 struct ldns_schwartzian_compare_struct *sb = *(struct ldns_schwartzian_compare_struct **) b;
1424 /* if we are doing 2wire, we need to do lowercasing on the dname (and maybe on the rdata)
1425 * this must be done for comparison only, so we need to have a temp var for both buffers,
1426 * which is only used when the transformed object value isn't there yet
1428 ldns_rr *canonical_a, *canonical_b;
1430 rr1 = (ldns_rr *) sa->original_object;
1431 rr2 = (ldns_rr *) sb->original_object;
1433 result = ldns_rr_compare_no_rdata(rr1, rr2);
1435 if (result == 0) {
1436 if (!sa->transformed_object) {
1437 canonical_a = ldns_rr_clone(sa->original_object);
1438 ldns_rr2canonical(canonical_a);
1439 sa->transformed_object = ldns_buffer_new(ldns_rr_uncompressed_size(canonical_a));
1440 if (ldns_rr2buffer_wire(sa->transformed_object, canonical_a, LDNS_SECTION_ANY) != LDNS_STATUS_OK) {
1441 ldns_buffer_free((ldns_buffer *)sa->transformed_object);
1442 sa->transformed_object = NULL;
1443 ldns_rr_free(canonical_a);
1444 return 0;
1446 ldns_rr_free(canonical_a);
1448 if (!sb->transformed_object) {
1449 canonical_b = ldns_rr_clone(sb->original_object);
1450 ldns_rr2canonical(canonical_b);
1451 sb->transformed_object = ldns_buffer_new(ldns_rr_uncompressed_size(canonical_b));
1452 if (ldns_rr2buffer_wire(sb->transformed_object, canonical_b, LDNS_SECTION_ANY) != LDNS_STATUS_OK) {
1453 ldns_buffer_free((ldns_buffer *)sa->transformed_object);
1454 ldns_buffer_free((ldns_buffer *)sb->transformed_object);
1455 sa->transformed_object = NULL;
1456 sb->transformed_object = NULL;
1457 ldns_rr_free(canonical_b);
1458 return 0;
1460 ldns_rr_free(canonical_b);
1462 rr1_buf = (ldns_buffer *) sa->transformed_object;
1463 rr2_buf = (ldns_buffer *) sb->transformed_object;
1465 result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
1468 return result;
1471 void
1472 ldns_rr_list_sort(ldns_rr_list *unsorted)
1474 struct ldns_schwartzian_compare_struct **sortables;
1475 size_t item_count;
1476 size_t i;
1478 if (unsorted) {
1479 item_count = ldns_rr_list_rr_count(unsorted);
1481 sortables = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct *,
1482 item_count);
1483 if(!sortables) return; /* no way to return error */
1484 for (i = 0; i < item_count; i++) {
1485 sortables[i] = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct, 1);
1486 if(!sortables[i]) {
1487 /* free the allocated parts */
1488 while(i>0) {
1489 i--;
1490 LDNS_FREE(sortables[i]);
1492 /* no way to return error */
1493 LDNS_FREE(sortables);
1494 return;
1496 sortables[i]->original_object = ldns_rr_list_rr(unsorted, i);
1497 sortables[i]->transformed_object = NULL;
1499 qsort(sortables,
1500 item_count,
1501 sizeof(struct ldns_schwartzian_compare_struct *),
1502 qsort_schwartz_rr_compare);
1503 for (i = 0; i < item_count; i++) {
1504 unsorted->_rrs[i] = sortables[i]->original_object;
1505 if (sortables[i]->transformed_object) {
1506 ldns_buffer_free(sortables[i]->transformed_object);
1508 LDNS_FREE(sortables[i]);
1510 LDNS_FREE(sortables);
1515 ldns_rr_compare_no_rdata(const ldns_rr *rr1, const ldns_rr *rr2)
1517 size_t rr1_len;
1518 size_t rr2_len;
1519 size_t offset;
1521 assert(rr1 != NULL);
1522 assert(rr2 != NULL);
1524 rr1_len = ldns_rr_uncompressed_size(rr1);
1525 rr2_len = ldns_rr_uncompressed_size(rr2);
1527 if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) < 0) {
1528 return -1;
1529 } else if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) > 0) {
1530 return 1;
1533 /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
1534 if (ldns_rr_get_class(rr1) != ldns_rr_get_class(rr2)) {
1535 return ldns_rr_get_class(rr1) - ldns_rr_get_class(rr2);
1538 /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
1539 if (ldns_rr_get_type(rr1) != ldns_rr_get_type(rr2)) {
1540 return ldns_rr_get_type(rr1) - ldns_rr_get_type(rr2);
1543 /* offset is the owername length + ttl + type + class + rdlen == start of wire format rdata */
1544 offset = ldns_rdf_size(ldns_rr_owner(rr1)) + 4 + 2 + 2 + 2;
1545 /* if either record doesn't have any RDATA... */
1546 if (offset > rr1_len || offset > rr2_len) {
1547 if (rr1_len == rr2_len) {
1548 return 0;
1550 return ((int) rr2_len - (int) rr1_len);
1553 return 0;
1556 int ldns_rr_compare_wire(ldns_buffer *rr1_buf, ldns_buffer *rr2_buf)
1558 size_t rr1_len, rr2_len, min_len, i, offset;
1560 rr1_len = ldns_buffer_capacity(rr1_buf);
1561 rr2_len = ldns_buffer_capacity(rr2_buf);
1563 /* jump past dname (checked in earlier part)
1564 * and especially past TTL */
1565 offset = 0;
1566 while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0) {
1567 offset += *ldns_buffer_at(rr1_buf, offset) + 1;
1569 /* jump to rdata section (PAST the rdata length field, otherwise
1570 rrs with different lengths might be sorted erroneously */
1571 offset += 11;
1572 min_len = (rr1_len < rr2_len) ? rr1_len : rr2_len;
1573 /* Compare RRs RDATA byte for byte. */
1574 for(i = offset; i < min_len; i++) {
1575 if (*ldns_buffer_at(rr1_buf,i) < *ldns_buffer_at(rr2_buf,i)) {
1576 return -1;
1577 } else if (*ldns_buffer_at(rr1_buf,i) > *ldns_buffer_at(rr2_buf,i)) {
1578 return +1;
1582 /* If both RDATAs are the same up to min_len, then the shorter one sorts first. */
1583 if (rr1_len < rr2_len) {
1584 return -1;
1585 } else if (rr1_len > rr2_len) {
1586 return +1;
1588 /* The RDATAs are equal. */
1589 return 0;
1594 ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
1596 int result;
1597 size_t rr1_len, rr2_len;
1599 ldns_buffer *rr1_buf;
1600 ldns_buffer *rr2_buf;
1602 result = ldns_rr_compare_no_rdata(rr1, rr2);
1603 if (result == 0) {
1604 rr1_len = ldns_rr_uncompressed_size(rr1);
1605 rr2_len = ldns_rr_uncompressed_size(rr2);
1607 rr1_buf = ldns_buffer_new(rr1_len);
1608 rr2_buf = ldns_buffer_new(rr2_len);
1610 if (ldns_rr2buffer_wire_canonical(rr1_buf,
1611 rr1,
1612 LDNS_SECTION_ANY)
1613 != LDNS_STATUS_OK) {
1614 ldns_buffer_free(rr1_buf);
1615 ldns_buffer_free(rr2_buf);
1616 return 0;
1618 if (ldns_rr2buffer_wire_canonical(rr2_buf,
1619 rr2,
1620 LDNS_SECTION_ANY)
1621 != LDNS_STATUS_OK) {
1622 ldns_buffer_free(rr1_buf);
1623 ldns_buffer_free(rr2_buf);
1624 return 0;
1627 result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
1629 ldns_buffer_free(rr1_buf);
1630 ldns_buffer_free(rr2_buf);
1633 return result;
1636 /* convert dnskey to a ds with the given algorithm,
1637 * then compare the result with the given ds */
1638 static int
1639 ldns_rr_compare_ds_dnskey(ldns_rr *ds,
1640 ldns_rr *dnskey)
1642 ldns_rr *ds_gen;
1643 bool result = false;
1644 ldns_hash algo;
1646 if (!dnskey || !ds ||
1647 ldns_rr_get_type(ds) != LDNS_RR_TYPE_DS ||
1648 ldns_rr_get_type(dnskey) != LDNS_RR_TYPE_DNSKEY) {
1649 return false;
1652 if (ldns_rr_rdf(ds, 2) == NULL) {
1653 return false;
1655 algo = ldns_rdf2native_int8(ldns_rr_rdf(ds, 2));
1657 ds_gen = ldns_key_rr2ds(dnskey, algo);
1658 if (ds_gen) {
1659 result = ldns_rr_compare(ds, ds_gen) == 0;
1660 ldns_rr_free(ds_gen);
1662 return result;
1665 bool
1666 ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
1668 bool result;
1669 ldns_rr *rr1 = ldns_rr_clone(orr1);
1670 ldns_rr *rr2 = ldns_rr_clone(orr2);
1672 /* set ttls to zero */
1673 ldns_rr_set_ttl(rr1, 0);
1674 ldns_rr_set_ttl(rr2, 0);
1676 if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DS &&
1677 ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DNSKEY) {
1678 result = ldns_rr_compare_ds_dnskey(rr1, rr2);
1679 } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DNSKEY &&
1680 ldns_rr_get_type(rr2) == LDNS_RR_TYPE_DS) {
1681 result = ldns_rr_compare_ds_dnskey(rr2, rr1);
1682 } else {
1683 result = (ldns_rr_compare(rr1, rr2) == 0);
1686 ldns_rr_free(rr1);
1687 ldns_rr_free(rr2);
1689 return result;
1693 ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2)
1695 size_t i = 0;
1696 int rr_cmp;
1698 assert(rrl1 != NULL);
1699 assert(rrl2 != NULL);
1701 for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) {
1702 rr_cmp = ldns_rr_compare(ldns_rr_list_rr(rrl1, i), ldns_rr_list_rr(rrl2, i));
1703 if (rr_cmp != 0) {
1704 return rr_cmp;
1708 if (i == ldns_rr_list_rr_count(rrl1) &&
1709 i != ldns_rr_list_rr_count(rrl2)) {
1710 return 1;
1711 } else if (i == ldns_rr_list_rr_count(rrl2) &&
1712 i != ldns_rr_list_rr_count(rrl1)) {
1713 return -1;
1714 } else {
1715 return 0;
1719 size_t
1720 ldns_rr_uncompressed_size(const ldns_rr *r)
1722 size_t rrsize;
1723 size_t i;
1725 rrsize = 0;
1726 /* add all the rdf sizes */
1727 for(i = 0; i < ldns_rr_rd_count(r); i++) {
1728 rrsize += ldns_rdf_size(ldns_rr_rdf(r, i));
1730 /* ownername */
1731 rrsize += ldns_rdf_size(ldns_rr_owner(r));
1732 rrsize += LDNS_RR_OVERHEAD;
1733 return rrsize;
1736 void
1737 ldns_rr2canonical(ldns_rr *rr)
1739 uint16_t i;
1741 if (!rr) {
1742 return;
1745 ldns_dname2canonical(ldns_rr_owner(rr));
1748 * lowercase the rdata dnames if the rr type is one
1749 * of the list in chapter 7 of RFC3597
1750 * Also added RRSIG, because a "Signer's Name" should be canonicalized
1751 * too. See dnssec-bis-updates-16. We can add it to this list because
1752 * the "Signer's Name" is the only dname type rdata field in a RRSIG.
1754 switch(ldns_rr_get_type(rr)) {
1755 case LDNS_RR_TYPE_NS:
1756 case LDNS_RR_TYPE_MD:
1757 case LDNS_RR_TYPE_MF:
1758 case LDNS_RR_TYPE_CNAME:
1759 case LDNS_RR_TYPE_SOA:
1760 case LDNS_RR_TYPE_MB:
1761 case LDNS_RR_TYPE_MG:
1762 case LDNS_RR_TYPE_MR:
1763 case LDNS_RR_TYPE_PTR:
1764 case LDNS_RR_TYPE_MINFO:
1765 case LDNS_RR_TYPE_MX:
1766 case LDNS_RR_TYPE_RP:
1767 case LDNS_RR_TYPE_AFSDB:
1768 case LDNS_RR_TYPE_RT:
1769 case LDNS_RR_TYPE_SIG:
1770 case LDNS_RR_TYPE_PX:
1771 case LDNS_RR_TYPE_NXT:
1772 case LDNS_RR_TYPE_NAPTR:
1773 case LDNS_RR_TYPE_KX:
1774 case LDNS_RR_TYPE_SRV:
1775 case LDNS_RR_TYPE_DNAME:
1776 case LDNS_RR_TYPE_A6:
1777 case LDNS_RR_TYPE_RRSIG:
1778 for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1779 ldns_dname2canonical(ldns_rr_rdf(rr, i));
1781 return;
1782 default:
1783 /* do nothing */
1784 return;
1788 void
1789 ldns_rr_list2canonical(ldns_rr_list *rr_list)
1791 size_t i;
1792 for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1793 ldns_rr2canonical(ldns_rr_list_rr(rr_list, i));
1797 uint8_t
1798 ldns_rr_label_count(ldns_rr *rr)
1800 if (!rr) {
1801 return 0;
1803 return ldns_dname_label_count(
1804 ldns_rr_owner(rr));
1807 /** \cond */
1808 static const ldns_rdf_type type_0_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
1809 static const ldns_rdf_type type_a_wireformat[] = { LDNS_RDF_TYPE_A };
1810 static const ldns_rdf_type type_ns_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1811 static const ldns_rdf_type type_md_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1812 static const ldns_rdf_type type_mf_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1813 static const ldns_rdf_type type_cname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1814 static const ldns_rdf_type type_soa_wireformat[] = {
1815 LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_INT32,
1816 LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD,
1817 LDNS_RDF_TYPE_PERIOD
1819 static const ldns_rdf_type type_mb_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1820 static const ldns_rdf_type type_mg_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1821 static const ldns_rdf_type type_mr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1822 static const ldns_rdf_type type_wks_wireformat[] = {
1823 LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_WKS
1825 static const ldns_rdf_type type_ptr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1826 static const ldns_rdf_type type_hinfo_wireformat[] = {
1827 LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR
1829 static const ldns_rdf_type type_minfo_wireformat[] = {
1830 LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
1832 static const ldns_rdf_type type_mx_wireformat[] = {
1833 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
1835 static const ldns_rdf_type type_rp_wireformat[] = {
1836 LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
1838 static const ldns_rdf_type type_afsdb_wireformat[] = {
1839 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
1841 static const ldns_rdf_type type_x25_wireformat[] = { LDNS_RDF_TYPE_STR };
1842 static const ldns_rdf_type type_isdn_wireformat[] = {
1843 LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR
1845 static const ldns_rdf_type type_rt_wireformat[] = {
1846 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
1848 static const ldns_rdf_type type_nsap_wireformat[] = {
1849 LDNS_RDF_TYPE_NSAP
1851 static const ldns_rdf_type type_nsap_ptr_wireformat[] = {
1852 LDNS_RDF_TYPE_STR
1854 static const ldns_rdf_type type_sig_wireformat[] = {
1855 LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32,
1856 LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16,
1857 LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64
1859 static const ldns_rdf_type type_key_wireformat[] = {
1860 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64
1862 static const ldns_rdf_type type_px_wireformat[] = {
1863 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
1865 static const ldns_rdf_type type_gpos_wireformat[] = {
1866 LDNS_RDF_TYPE_STR,
1867 LDNS_RDF_TYPE_STR,
1868 LDNS_RDF_TYPE_STR
1870 static const ldns_rdf_type type_aaaa_wireformat[] = { LDNS_RDF_TYPE_AAAA };
1871 static const ldns_rdf_type type_loc_wireformat[] = { LDNS_RDF_TYPE_LOC };
1872 static const ldns_rdf_type type_nxt_wireformat[] = {
1873 LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_UNKNOWN
1875 static const ldns_rdf_type type_eid_wireformat[] = {
1876 LDNS_RDF_TYPE_HEX
1878 static const ldns_rdf_type type_nimloc_wireformat[] = {
1879 LDNS_RDF_TYPE_HEX
1881 static const ldns_rdf_type type_srv_wireformat[] = {
1882 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
1884 static const ldns_rdf_type type_atma_wireformat[] = {
1885 LDNS_RDF_TYPE_ATMA
1887 static const ldns_rdf_type type_naptr_wireformat[] = {
1888 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_DNAME
1890 static const ldns_rdf_type type_kx_wireformat[] = {
1891 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
1893 static const ldns_rdf_type type_cert_wireformat[] = {
1894 LDNS_RDF_TYPE_CERT_ALG, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_B64
1896 static const ldns_rdf_type type_a6_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
1897 static const ldns_rdf_type type_dname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1898 static const ldns_rdf_type type_sink_wireformat[] = { LDNS_RDF_TYPE_INT8,
1899 LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64
1901 static const ldns_rdf_type type_apl_wireformat[] = {
1902 LDNS_RDF_TYPE_APL
1904 static const ldns_rdf_type type_ds_wireformat[] = {
1905 LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX
1907 static const ldns_rdf_type type_sshfp_wireformat[] = {
1908 LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX
1910 static const ldns_rdf_type type_ipseckey_wireformat[] = {
1911 LDNS_RDF_TYPE_IPSECKEY
1913 static const ldns_rdf_type type_rrsig_wireformat[] = {
1914 LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32,
1915 LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64
1917 static const ldns_rdf_type type_nsec_wireformat[] = {
1918 LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_NSEC
1920 static const ldns_rdf_type type_dhcid_wireformat[] = {
1921 LDNS_RDF_TYPE_B64
1923 static const ldns_rdf_type type_talink_wireformat[] = {
1924 LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
1926 /* nsec3 is some vars, followed by same type of data of nsec */
1927 static const ldns_rdf_type type_nsec3_wireformat[] = {
1928 /* LDNS_RDF_TYPE_NSEC3_VARS, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC*/
1929 LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_NSEC3_SALT, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC
1932 static const ldns_rdf_type type_nsec3param_wireformat[] = {
1933 /* LDNS_RDF_TYPE_NSEC3_PARAMS_VARS*/
1934 LDNS_RDF_TYPE_INT8,
1935 LDNS_RDF_TYPE_INT8,
1936 LDNS_RDF_TYPE_INT16,
1937 LDNS_RDF_TYPE_NSEC3_SALT
1940 static const ldns_rdf_type type_dnskey_wireformat[] = {
1941 LDNS_RDF_TYPE_INT16,
1942 LDNS_RDF_TYPE_INT8,
1943 LDNS_RDF_TYPE_ALG,
1944 LDNS_RDF_TYPE_B64
1946 static const ldns_rdf_type type_tsig_wireformat[] = {
1947 LDNS_RDF_TYPE_DNAME,
1948 LDNS_RDF_TYPE_TSIGTIME,
1949 LDNS_RDF_TYPE_INT16,
1950 LDNS_RDF_TYPE_INT16_DATA,
1951 LDNS_RDF_TYPE_INT16,
1952 LDNS_RDF_TYPE_INT16,
1953 LDNS_RDF_TYPE_INT16_DATA
1955 static const ldns_rdf_type type_tlsa_wireformat[] = {
1956 LDNS_RDF_TYPE_INT8,
1957 LDNS_RDF_TYPE_INT8,
1958 LDNS_RDF_TYPE_INT8,
1959 LDNS_RDF_TYPE_HEX
1961 /** \endcond */
1963 /** \cond */
1964 /* All RR's defined in 1035 are well known and can thus
1965 * be compressed. See RFC3597. These RR's are:
1966 * CNAME HINFO MB MD MF MG MINFO MR MX NULL NS PTR SOA TXT
1968 static ldns_rr_descriptor rdata_field_descriptors[] = {
1969 /* 0 */
1970 { 0, NULL, 0, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
1971 /* 1 */
1972 {LDNS_RR_TYPE_A, "A", 1, 1, type_a_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
1973 /* 2 */
1974 {LDNS_RR_TYPE_NS, "NS", 1, 1, type_ns_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1975 /* 3 */
1976 {LDNS_RR_TYPE_MD, "MD", 1, 1, type_md_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1977 /* 4 */
1978 {LDNS_RR_TYPE_MF, "MF", 1, 1, type_mf_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1979 /* 5 */
1980 {LDNS_RR_TYPE_CNAME, "CNAME", 1, 1, type_cname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1981 /* 6 */
1982 {LDNS_RR_TYPE_SOA, "SOA", 7, 7, type_soa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
1983 /* 7 */
1984 {LDNS_RR_TYPE_MB, "MB", 1, 1, type_mb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1985 /* 8 */
1986 {LDNS_RR_TYPE_MG, "MG", 1, 1, type_mg_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1987 /* 9 */
1988 {LDNS_RR_TYPE_MR, "MR", 1, 1, type_mr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1989 /* 10 */
1990 {LDNS_RR_TYPE_NULL, "NULL", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
1991 /* 11 */
1992 {LDNS_RR_TYPE_WKS, "WKS", 2, 2, type_wks_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
1993 /* 12 */
1994 {LDNS_RR_TYPE_PTR, "PTR", 1, 1, type_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
1995 /* 13 */
1996 {LDNS_RR_TYPE_HINFO, "HINFO", 2, 2, type_hinfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
1997 /* 14 */
1998 {LDNS_RR_TYPE_MINFO, "MINFO", 2, 2, type_minfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
1999 /* 15 */
2000 {LDNS_RR_TYPE_MX, "MX", 2, 2, type_mx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2001 /* 16 */
2002 {LDNS_RR_TYPE_TXT, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2003 /* 17 */
2004 {LDNS_RR_TYPE_RP, "RP", 2, 2, type_rp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2005 /* 18 */
2006 {LDNS_RR_TYPE_AFSDB, "AFSDB", 2, 2, type_afsdb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2007 /* 19 */
2008 {LDNS_RR_TYPE_X25, "X25", 1, 1, type_x25_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2009 /* 20 */
2010 {LDNS_RR_TYPE_ISDN, "ISDN", 1, 2, type_isdn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2011 /* 21 */
2012 {LDNS_RR_TYPE_RT, "RT", 2, 2, type_rt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2013 /* 22 */
2014 {LDNS_RR_TYPE_NSAP, "NSAP", 1, 1, type_nsap_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2015 /* 23 */
2016 {LDNS_RR_TYPE_NSAP_PTR, "NSAP-PTR", 1, 1, type_nsap_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2017 /* 24 */
2018 {LDNS_RR_TYPE_SIG, "SIG", 9, 9, type_sig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2019 /* 25 */
2020 {LDNS_RR_TYPE_KEY, "KEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2021 /* 26 */
2022 {LDNS_RR_TYPE_PX, "PX", 3, 3, type_px_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2023 /* 27 */
2024 {LDNS_RR_TYPE_GPOS, "GPOS", 1, 1, type_gpos_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2025 /* 28 */
2026 {LDNS_RR_TYPE_AAAA, "AAAA", 1, 1, type_aaaa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2027 /* 29 */
2028 {LDNS_RR_TYPE_LOC, "LOC", 1, 1, type_loc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2029 /* 30 */
2030 {LDNS_RR_TYPE_NXT, "NXT", 2, 2, type_nxt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2031 /* 31 */
2032 {LDNS_RR_TYPE_EID, "EID", 1, 1, type_eid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2033 /* 32 */
2034 {LDNS_RR_TYPE_NIMLOC, "NIMLOC", 1, 1, type_nimloc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2035 /* 33 */
2036 {LDNS_RR_TYPE_SRV, "SRV", 4, 4, type_srv_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2037 /* 34 */
2038 {LDNS_RR_TYPE_ATMA, "ATMA", 1, 1, type_atma_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2039 /* 35 */
2040 {LDNS_RR_TYPE_NAPTR, "NAPTR", 6, 6, type_naptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2041 /* 36 */
2042 {LDNS_RR_TYPE_KX, "KX", 2, 2, type_kx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2043 /* 37 */
2044 {LDNS_RR_TYPE_CERT, "CERT", 4, 4, type_cert_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2045 /* 38 */
2046 {LDNS_RR_TYPE_A6, "A6", 1, 1, type_a6_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2047 /* 39 */
2048 {LDNS_RR_TYPE_DNAME, "DNAME", 1, 1, type_dname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2049 /* 40 */
2050 {LDNS_RR_TYPE_SINK, "SINK", 1, 1, type_sink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2051 /* 41 */
2052 {LDNS_RR_TYPE_OPT, "OPT", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2053 /* 42 */
2054 {LDNS_RR_TYPE_APL, "APL", 0, 0, type_apl_wireformat, LDNS_RDF_TYPE_APL, LDNS_RR_NO_COMPRESS, 0 },
2055 /* 43 */
2056 {LDNS_RR_TYPE_DS, "DS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2057 /* 44 */
2058 {LDNS_RR_TYPE_SSHFP, "SSHFP", 3, 3, type_sshfp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2059 /* 45 */
2060 {LDNS_RR_TYPE_IPSECKEY, "IPSECKEY", 1, 1, type_ipseckey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2061 /* 46 */
2062 {LDNS_RR_TYPE_RRSIG, "RRSIG", 9, 9, type_rrsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2063 /* 47 */
2064 {LDNS_RR_TYPE_NSEC, "NSEC", 1, 2, type_nsec_wireformat, LDNS_RDF_TYPE_NSEC, LDNS_RR_NO_COMPRESS, 1 },
2065 /* 48 */
2066 {LDNS_RR_TYPE_DNSKEY, "DNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2067 /* 49 */
2068 {LDNS_RR_TYPE_DHCID, "DHCID", 1, 1, type_dhcid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2069 /* 50 */
2070 {LDNS_RR_TYPE_NSEC3, "NSEC3", 5, 6, type_nsec3_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2071 /* 51 */
2072 {LDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2073 /* 52 */
2074 {LDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2076 {LDNS_RR_TYPE_NULL, "TYPE53", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2077 {LDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2078 {LDNS_RR_TYPE_NULL, "TYPE55", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2079 {LDNS_RR_TYPE_NULL, "TYPE56", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2080 {LDNS_RR_TYPE_NULL, "TYPE57", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2081 /* 58 */
2082 {LDNS_RR_TYPE_TALINK, "TALINK", 2, 2, type_talink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2083 {LDNS_RR_TYPE_NULL, "TYPE59", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2084 {LDNS_RR_TYPE_NULL, "TYPE60", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2085 {LDNS_RR_TYPE_NULL, "TYPE61", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2086 {LDNS_RR_TYPE_NULL, "TYPE62", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2087 {LDNS_RR_TYPE_NULL, "TYPE63", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2088 {LDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2089 {LDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2090 {LDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2091 {LDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2092 {LDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2093 {LDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2094 {LDNS_RR_TYPE_NULL, "TYPE70", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2095 {LDNS_RR_TYPE_NULL, "TYPE71", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2096 {LDNS_RR_TYPE_NULL, "TYPE72", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2097 {LDNS_RR_TYPE_NULL, "TYPE73", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2098 {LDNS_RR_TYPE_NULL, "TYPE74", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2099 {LDNS_RR_TYPE_NULL, "TYPE75", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2100 {LDNS_RR_TYPE_NULL, "TYPE76", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2101 {LDNS_RR_TYPE_NULL, "TYPE77", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2102 {LDNS_RR_TYPE_NULL, "TYPE78", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2103 {LDNS_RR_TYPE_NULL, "TYPE79", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2104 {LDNS_RR_TYPE_NULL, "TYPE80", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2105 {LDNS_RR_TYPE_NULL, "TYPE81", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2106 {LDNS_RR_TYPE_NULL, "TYPE82", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2107 {LDNS_RR_TYPE_NULL, "TYPE83", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2108 {LDNS_RR_TYPE_NULL, "TYPE84", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2109 {LDNS_RR_TYPE_NULL, "TYPE85", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2110 {LDNS_RR_TYPE_NULL, "TYPE86", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2111 {LDNS_RR_TYPE_NULL, "TYPE87", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2112 {LDNS_RR_TYPE_NULL, "TYPE88", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2113 {LDNS_RR_TYPE_NULL, "TYPE89", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2114 {LDNS_RR_TYPE_NULL, "TYPE90", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2115 {LDNS_RR_TYPE_NULL, "TYPE91", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2116 {LDNS_RR_TYPE_NULL, "TYPE92", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2117 {LDNS_RR_TYPE_NULL, "TYPE93", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2118 {LDNS_RR_TYPE_NULL, "TYPE94", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2119 {LDNS_RR_TYPE_NULL, "TYPE95", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2120 {LDNS_RR_TYPE_NULL, "TYPE96", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2121 {LDNS_RR_TYPE_NULL, "TYPE97", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2122 {LDNS_RR_TYPE_NULL, "TYPE98", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2123 {LDNS_RR_TYPE_SPF, "SPF", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2124 {LDNS_RR_TYPE_NULL, "TYPE100", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2125 {LDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2126 {LDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2127 {LDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2128 {LDNS_RR_TYPE_NULL, "TYPE104", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2129 {LDNS_RR_TYPE_NULL, "TYPE105", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2130 {LDNS_RR_TYPE_NULL, "TYPE106", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2131 {LDNS_RR_TYPE_NULL, "TYPE107", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2132 {LDNS_RR_TYPE_NULL, "TYPE108", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2133 {LDNS_RR_TYPE_NULL, "TYPE109", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2134 {LDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2135 {LDNS_RR_TYPE_NULL, "TYPE111", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2136 {LDNS_RR_TYPE_NULL, "TYPE112", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2137 {LDNS_RR_TYPE_NULL, "TYPE113", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2138 {LDNS_RR_TYPE_NULL, "TYPE114", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2139 {LDNS_RR_TYPE_NULL, "TYPE115", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2140 {LDNS_RR_TYPE_NULL, "TYPE116", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2141 {LDNS_RR_TYPE_NULL, "TYPE117", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2142 {LDNS_RR_TYPE_NULL, "TYPE118", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2143 {LDNS_RR_TYPE_NULL, "TYPE119", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2144 {LDNS_RR_TYPE_NULL, "TYPE120", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2145 {LDNS_RR_TYPE_NULL, "TYPE121", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2146 {LDNS_RR_TYPE_NULL, "TYPE122", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2147 {LDNS_RR_TYPE_NULL, "TYPE123", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2148 {LDNS_RR_TYPE_NULL, "TYPE124", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2149 {LDNS_RR_TYPE_NULL, "TYPE125", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2150 {LDNS_RR_TYPE_NULL, "TYPE126", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2151 {LDNS_RR_TYPE_NULL, "TYPE127", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2152 {LDNS_RR_TYPE_NULL, "TYPE128", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2153 {LDNS_RR_TYPE_NULL, "TYPE129", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2154 {LDNS_RR_TYPE_NULL, "TYPE130", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2155 {LDNS_RR_TYPE_NULL, "TYPE131", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2156 {LDNS_RR_TYPE_NULL, "TYPE132", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2157 {LDNS_RR_TYPE_NULL, "TYPE133", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2158 {LDNS_RR_TYPE_NULL, "TYPE134", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2159 {LDNS_RR_TYPE_NULL, "TYPE135", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2160 {LDNS_RR_TYPE_NULL, "TYPE136", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2161 {LDNS_RR_TYPE_NULL, "TYPE137", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2162 {LDNS_RR_TYPE_NULL, "TYPE138", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2163 {LDNS_RR_TYPE_NULL, "TYPE139", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2164 {LDNS_RR_TYPE_NULL, "TYPE140", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2165 {LDNS_RR_TYPE_NULL, "TYPE141", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2166 {LDNS_RR_TYPE_NULL, "TYPE142", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2167 {LDNS_RR_TYPE_NULL, "TYPE143", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2168 {LDNS_RR_TYPE_NULL, "TYPE144", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2169 {LDNS_RR_TYPE_NULL, "TYPE145", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2170 {LDNS_RR_TYPE_NULL, "TYPE146", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2171 {LDNS_RR_TYPE_NULL, "TYPE147", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2172 {LDNS_RR_TYPE_NULL, "TYPE148", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2173 {LDNS_RR_TYPE_NULL, "TYPE149", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2174 {LDNS_RR_TYPE_NULL, "TYPE150", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2175 {LDNS_RR_TYPE_NULL, "TYPE151", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2176 {LDNS_RR_TYPE_NULL, "TYPE152", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2177 {LDNS_RR_TYPE_NULL, "TYPE153", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2178 {LDNS_RR_TYPE_NULL, "TYPE154", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2179 {LDNS_RR_TYPE_NULL, "TYPE155", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2180 {LDNS_RR_TYPE_NULL, "TYPE156", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2181 {LDNS_RR_TYPE_NULL, "TYPE157", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2182 {LDNS_RR_TYPE_NULL, "TYPE158", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2183 {LDNS_RR_TYPE_NULL, "TYPE159", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2184 {LDNS_RR_TYPE_NULL, "TYPE160", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2185 {LDNS_RR_TYPE_NULL, "TYPE161", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2186 {LDNS_RR_TYPE_NULL, "TYPE162", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2187 {LDNS_RR_TYPE_NULL, "TYPE163", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2188 {LDNS_RR_TYPE_NULL, "TYPE164", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2189 {LDNS_RR_TYPE_NULL, "TYPE165", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2190 {LDNS_RR_TYPE_NULL, "TYPE166", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2191 {LDNS_RR_TYPE_NULL, "TYPE167", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2192 {LDNS_RR_TYPE_NULL, "TYPE168", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2193 {LDNS_RR_TYPE_NULL, "TYPE169", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2194 {LDNS_RR_TYPE_NULL, "TYPE170", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2195 {LDNS_RR_TYPE_NULL, "TYPE171", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2196 {LDNS_RR_TYPE_NULL, "TYPE172", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2197 {LDNS_RR_TYPE_NULL, "TYPE173", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2198 {LDNS_RR_TYPE_NULL, "TYPE174", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2199 {LDNS_RR_TYPE_NULL, "TYPE175", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2200 {LDNS_RR_TYPE_NULL, "TYPE176", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2201 {LDNS_RR_TYPE_NULL, "TYPE177", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2202 {LDNS_RR_TYPE_NULL, "TYPE178", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2203 {LDNS_RR_TYPE_NULL, "TYPE179", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2204 {LDNS_RR_TYPE_NULL, "TYPE180", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2205 {LDNS_RR_TYPE_NULL, "TYPE181", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2206 {LDNS_RR_TYPE_NULL, "TYPE182", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2207 {LDNS_RR_TYPE_NULL, "TYPE183", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2208 {LDNS_RR_TYPE_NULL, "TYPE184", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2209 {LDNS_RR_TYPE_NULL, "TYPE185", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2210 {LDNS_RR_TYPE_NULL, "TYPE186", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2211 {LDNS_RR_TYPE_NULL, "TYPE187", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2212 {LDNS_RR_TYPE_NULL, "TYPE188", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2213 {LDNS_RR_TYPE_NULL, "TYPE189", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2214 {LDNS_RR_TYPE_NULL, "TYPE190", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2215 {LDNS_RR_TYPE_NULL, "TYPE191", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2216 {LDNS_RR_TYPE_NULL, "TYPE192", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2217 {LDNS_RR_TYPE_NULL, "TYPE193", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2218 {LDNS_RR_TYPE_NULL, "TYPE194", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2219 {LDNS_RR_TYPE_NULL, "TYPE195", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2220 {LDNS_RR_TYPE_NULL, "TYPE196", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2221 {LDNS_RR_TYPE_NULL, "TYPE197", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2222 {LDNS_RR_TYPE_NULL, "TYPE198", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2223 {LDNS_RR_TYPE_NULL, "TYPE199", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2224 {LDNS_RR_TYPE_NULL, "TYPE200", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2225 {LDNS_RR_TYPE_NULL, "TYPE201", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2226 {LDNS_RR_TYPE_NULL, "TYPE202", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2227 {LDNS_RR_TYPE_NULL, "TYPE203", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2228 {LDNS_RR_TYPE_NULL, "TYPE204", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2229 {LDNS_RR_TYPE_NULL, "TYPE205", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2230 {LDNS_RR_TYPE_NULL, "TYPE206", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2231 {LDNS_RR_TYPE_NULL, "TYPE207", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2232 {LDNS_RR_TYPE_NULL, "TYPE208", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2233 {LDNS_RR_TYPE_NULL, "TYPE209", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2234 {LDNS_RR_TYPE_NULL, "TYPE210", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2235 {LDNS_RR_TYPE_NULL, "TYPE211", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2236 {LDNS_RR_TYPE_NULL, "TYPE212", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2237 {LDNS_RR_TYPE_NULL, "TYPE213", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2238 {LDNS_RR_TYPE_NULL, "TYPE214", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2239 {LDNS_RR_TYPE_NULL, "TYPE215", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2240 {LDNS_RR_TYPE_NULL, "TYPE216", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2241 {LDNS_RR_TYPE_NULL, "TYPE217", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2242 {LDNS_RR_TYPE_NULL, "TYPE218", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2243 {LDNS_RR_TYPE_NULL, "TYPE219", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2244 {LDNS_RR_TYPE_NULL, "TYPE220", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2245 {LDNS_RR_TYPE_NULL, "TYPE221", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2246 {LDNS_RR_TYPE_NULL, "TYPE222", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2247 {LDNS_RR_TYPE_NULL, "TYPE223", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2248 {LDNS_RR_TYPE_NULL, "TYPE224", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2249 {LDNS_RR_TYPE_NULL, "TYPE225", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2250 {LDNS_RR_TYPE_NULL, "TYPE226", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2251 {LDNS_RR_TYPE_NULL, "TYPE227", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2252 {LDNS_RR_TYPE_NULL, "TYPE228", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2253 {LDNS_RR_TYPE_NULL, "TYPE229", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2254 {LDNS_RR_TYPE_NULL, "TYPE230", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2255 {LDNS_RR_TYPE_NULL, "TYPE231", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2256 {LDNS_RR_TYPE_NULL, "TYPE232", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2257 {LDNS_RR_TYPE_NULL, "TYPE233", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2258 {LDNS_RR_TYPE_NULL, "TYPE234", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2259 {LDNS_RR_TYPE_NULL, "TYPE235", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2260 {LDNS_RR_TYPE_NULL, "TYPE236", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2261 {LDNS_RR_TYPE_NULL, "TYPE237", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2262 {LDNS_RR_TYPE_NULL, "TYPE238", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2263 {LDNS_RR_TYPE_NULL, "TYPE239", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2264 {LDNS_RR_TYPE_NULL, "TYPE240", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2265 {LDNS_RR_TYPE_NULL, "TYPE241", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2266 {LDNS_RR_TYPE_NULL, "TYPE242", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2267 {LDNS_RR_TYPE_NULL, "TYPE243", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2268 {LDNS_RR_TYPE_NULL, "TYPE244", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2269 {LDNS_RR_TYPE_NULL, "TYPE245", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2270 {LDNS_RR_TYPE_NULL, "TYPE246", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2271 {LDNS_RR_TYPE_NULL, "TYPE247", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2272 {LDNS_RR_TYPE_NULL, "TYPE248", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2273 {LDNS_RR_TYPE_NULL, "TYPE249", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2274 /* LDNS_RDF_TYPE_INT16_DATA essentially takes two fields (length and data) and
2275 * makes them into one. So, while in rfc 2845 is specified that a TSIG may have
2276 * 8 or 9 rdata fields, by this implementation, the min/max are 7 each.
2278 {LDNS_RR_TYPE_TSIG, "TSIG", 7, 7, type_tsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2279 /* split in array, no longer contiguous */
2280 {LDNS_RR_TYPE_DLV, "DLV", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }
2282 /** \endcond */
2285 * \def LDNS_RDATA_FIELD_DESCRIPTORS_COUNT
2286 * computes the number of rdata fields
2288 #define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT \
2289 (sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0]))
2291 const ldns_rr_descriptor *
2292 ldns_rr_descript(uint16_t type)
2294 size_t i;
2295 if (type <= LDNS_RDATA_FIELD_DESCRIPTORS_COMMON) {
2296 return &rdata_field_descriptors[type];
2297 } else {
2298 /* because not all array index equals type code */
2299 for (i = LDNS_RDATA_FIELD_DESCRIPTORS_COMMON;
2300 i < LDNS_RDATA_FIELD_DESCRIPTORS_COUNT;
2301 i++) {
2302 if (rdata_field_descriptors[i]._type == type) {
2303 return &rdata_field_descriptors[i];
2306 return &rdata_field_descriptors[0];
2310 size_t
2311 ldns_rr_descriptor_minimum(const ldns_rr_descriptor *descriptor)
2313 if (descriptor) {
2314 return descriptor->_minimum;
2315 } else {
2316 return 0;
2320 size_t
2321 ldns_rr_descriptor_maximum(const ldns_rr_descriptor *descriptor)
2323 if (descriptor) {
2324 if (descriptor->_variable != LDNS_RDF_TYPE_NONE) {
2325 /* Should really be SIZE_MAX... bad FreeBSD. */
2326 return UINT_MAX;
2327 } else {
2328 return descriptor->_maximum;
2330 } else {
2331 return 0;
2335 ldns_rdf_type
2336 ldns_rr_descriptor_field_type(const ldns_rr_descriptor *descriptor,
2337 size_t index)
2339 assert(descriptor != NULL);
2340 assert(index < descriptor->_maximum
2341 || descriptor->_variable != LDNS_RDF_TYPE_NONE);
2342 if (index < descriptor->_maximum) {
2343 return descriptor->_wireformat[index];
2344 } else {
2345 return descriptor->_variable;
2349 ldns_rr_type
2350 ldns_get_rr_type_by_name(const char *name)
2352 unsigned int i;
2353 const char *desc_name;
2354 const ldns_rr_descriptor *desc;
2356 /* TYPEXX representation */
2357 if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
2358 return atoi(name + 4);
2361 /* Normal types */
2362 for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
2363 desc = &rdata_field_descriptors[i];
2364 desc_name = desc->_name;
2365 if(desc_name &&
2366 strlen(name) == strlen(desc_name) &&
2367 strncasecmp(name, desc_name, strlen(desc_name)) == 0) {
2368 /* because not all array index equals type code */
2369 return desc->_type;
2373 /* special cases for query types */
2374 if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
2375 return 251;
2376 } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
2377 return 252;
2378 } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
2379 return 253;
2380 } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
2381 return 254;
2382 } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
2383 return 255;
2386 return 0;
2389 ldns_rr_class
2390 ldns_get_rr_class_by_name(const char *name)
2392 ldns_lookup_table *lt;
2394 /* CLASSXX representation */
2395 if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) {
2396 return atoi(name + 5);
2399 /* Normal types */
2400 lt = ldns_lookup_by_name(ldns_rr_classes, name);
2402 if (lt) {
2403 return lt->id;
2405 return 0;
2409 ldns_rr_type
2410 ldns_rdf2rr_type(const ldns_rdf *rd)
2412 ldns_rr_type r;
2414 if (!rd) {
2415 return 0;
2418 if (ldns_rdf_get_type(rd) != LDNS_RDF_TYPE_TYPE) {
2419 return 0;
2422 r = (ldns_rr_type) ldns_rdf2native_int16(rd);
2423 return r;
2426 ldns_rr_type
2427 ldns_rr_list_type(const ldns_rr_list *rr_list)
2429 if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
2430 return ldns_rr_get_type(ldns_rr_list_rr(rr_list, 0));
2431 } else {
2432 return 0;
2436 ldns_rdf *
2437 ldns_rr_list_owner(const ldns_rr_list *rr_list)
2439 if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
2440 return ldns_rr_owner(ldns_rr_list_rr(rr_list, 0));
2441 } else {
2442 return NULL;