rr.c
Go to the documentation of this file.
1 /* rr.c
2  *
3  * access functions for ldns_rr -
4  * a Net::DNS like library for C
5  * LibDNS Team @ NLnet Labs
6  *
7  * (c) NLnet Labs, 2004-2006
8  * See the file LICENSE for the license
9  */
10 #include <ldns/config.h>
11 
12 #include <ldns/ldns.h>
13 
14 #include <strings.h>
15 #include <limits.h>
16 
17 #include <errno.h>
18 
19 #define LDNS_SYNTAX_DATALEN 16
20 #define LDNS_TTL_DATALEN 21
21 #define LDNS_RRLIST_INIT 8
22 
23 #define _IS_WHITESPACE(chr) \
24  ( NULL != strchr( LDNS_PARSE_NO_NL, chr) )
25 
26 #define _BUFFER_IS_AT_WHITESPACE(rd_buf) \
27  _IS_WHITESPACE(*(ldns_buffer_current(rd_buf)))
28 
29 ldns_rr *
31 {
32  ldns_rr *rr;
33  rr = LDNS_MALLOC(ldns_rr);
34  if (!rr) {
35  return NULL;
36  }
37 
38  ldns_rr_set_owner(rr, NULL);
39  ldns_rr_set_question(rr, false);
40  ldns_rr_set_rd_count(rr, 0);
41  rr->_rdata_fields = NULL;
44  return rr;
45 }
46 
47 ldns_rr *
49 {
50  ldns_rr *rr;
51  const ldns_rr_descriptor *desc;
52  size_t i;
53 
54  rr = LDNS_MALLOC(ldns_rr);
55  if (!rr) {
56  return NULL;
57  }
58 
59  desc = ldns_rr_descript(t);
60 
62  if(!rr->_rdata_fields) {
63  LDNS_FREE(rr);
64  return NULL;
65  }
66  for (i = 0; i < ldns_rr_descriptor_minimum(desc); i++) {
67  rr->_rdata_fields[i] = NULL;
68  }
69 
70  ldns_rr_set_owner(rr, NULL);
71  ldns_rr_set_question(rr, false);
72  /* set the count to minimum */
76  ldns_rr_set_type(rr, t);
77  return rr;
78 }
79 
80 void
82 {
83  size_t i;
84  if (rr) {
85  if (ldns_rr_owner(rr)) {
87  }
88  for (i = 0; i < ldns_rr_rd_count(rr); i++) {
90  }
92  LDNS_FREE(rr);
93  }
94 }
95 
96 /* Syntactic sugar for ldns_rr_new_frm_str_internal */
97 INLINE bool
98 ldns_rdf_type_maybe_quoted(ldns_rdf_type rdf_type)
99 {
100  return rdf_type == LDNS_RDF_TYPE_STR ||
101  rdf_type == LDNS_RDF_TYPE_LONG_STR;
102 }
103 
104 /*
105  * trailing spaces are allowed
106  * leading spaces are not allowed
107  * allow ttl to be optional
108  * class is optional too
109  * if ttl is missing, and default_ttl is 0, use DEF_TTL
110  * allow ttl to be written as 1d3h
111  * So the RR should look like. e.g.
112  * miek.nl. 3600 IN MX 10 elektron.atoom.net
113  * or
114  * miek.nl. 1h IN MX 10 elektron.atoom.net
115  * or
116  * miek.nl. IN MX 10 elektron.atoom.net
117  */
118 static ldns_status
119 ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str,
120  uint32_t default_ttl, const ldns_rdf *origin,
121  ldns_rdf **prev, bool question,
122  bool *explicit_ttl)
123 {
124  ldns_rr *new;
125  const ldns_rr_descriptor *desc;
126  ldns_rr_type rr_type;
127  ldns_buffer *rr_buf = NULL;
128  ldns_buffer *rd_buf = NULL;
129  uint32_t ttl_val;
130  char *owner = NULL;
131  char *ttl = NULL;
132  ldns_rr_class clas_val;
133  char *clas = NULL;
134  char *type = NULL;
135  size_t type_sz;
136  char *rdata = NULL;
137  char *rd = NULL;
138  char *xtok = NULL; /* For RDF types with spaces (i.e. extra tokens) */
139  size_t rd_strlen;
140  const char *delimiters;
141  ssize_t c;
142  ldns_rdf *owner_dname;
143  const char* endptr;
144  int was_unknown_rr_format = 0;
145  ldns_status status = LDNS_STATUS_OK;
146 
147  /* used for types with unknown number of rdatas */
148  bool done;
149  bool quoted;
150 
151  ldns_rdf *r = NULL;
152  uint16_t r_cnt;
153  uint16_t r_min;
154  uint16_t r_max;
155  size_t pre_data_pos;
156 
157  uint16_t hex_data_size;
158  char *hex_data_str = NULL;
159  uint16_t cur_hex_data_size;
160  size_t hex_pos = 0;
161  uint8_t *hex_data = NULL;
162 
163  new = ldns_rr_new();
164 
165  owner = LDNS_XMALLOC(char, LDNS_MAX_DOMAINLEN + 1);
166  ttl = LDNS_XMALLOC(char, LDNS_TTL_DATALEN);
167  clas = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
168  rdata = LDNS_XMALLOC(char, LDNS_MAX_PACKETLEN + 1);
169  rr_buf = LDNS_MALLOC(ldns_buffer);
170  rd_buf = LDNS_MALLOC(ldns_buffer);
171  rd = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
172  xtok = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
173  if (rr_buf) {
174  rr_buf->_data = NULL;
175  }
176  if (rd_buf) {
177  rd_buf->_data = NULL;
178  }
179  if (!new || !owner || !ttl || !clas || !rdata ||
180  !rr_buf || !rd_buf || !rd || !xtok) {
181 
182  goto memerror;
183  }
184 
185  ldns_buffer_new_frm_data(rr_buf, (char*)str, strlen(str));
186 
187  /* split the rr in its parts -1 signals trouble */
188  if (ldns_bget_token(rr_buf, owner, "\t\n ", LDNS_MAX_DOMAINLEN) == -1){
189 
190  status = LDNS_STATUS_SYNTAX_ERR;
191  goto error;
192  }
193 
194  if (ldns_bget_token(rr_buf, ttl, "\t\n ", LDNS_TTL_DATALEN) == -1) {
195 
197  goto error;
198  }
199  ttl_val = (uint32_t) ldns_str2period(ttl, &endptr);
200 
201  if (strlen(ttl) > 0 && !isdigit((int) ttl[0])) {
202  /* ah, it's not there or something */
203  if (default_ttl == 0) {
204  ttl_val = LDNS_DEFAULT_TTL;
205  } else {
206  ttl_val = default_ttl;
207  }
208  if (explicit_ttl)
209  *explicit_ttl = false;
210 
211  /* we not ASSUMING the TTL is missing and that
212  * the rest of the RR is still there. That is
213  * CLASS TYPE RDATA
214  * so ttl value we read is actually the class
215  */
216  clas_val = ldns_get_rr_class_by_name(ttl);
217  /* class can be left out too, assume IN, current
218  * token must be type
219  */
220  if (clas_val == 0) {
221  clas_val = LDNS_RR_CLASS_IN;
222  type_sz = strlen(ttl) + 1;
223  type = LDNS_XMALLOC(char, type_sz);
224  if (!type) {
225  goto memerror;
226  }
227  strlcpy(type, ttl, type_sz);
228  }
229  } else {
230  if (explicit_ttl)
231  *explicit_ttl = true;
232 
233  if (-1 == ldns_bget_token(
234  rr_buf, clas, "\t\n ", LDNS_SYNTAX_DATALEN)) {
235 
237  goto error;
238  }
239  clas_val = ldns_get_rr_class_by_name(clas);
240  /* class can be left out too, assume IN, current
241  * token must be type
242  */
243  if (clas_val == 0) {
244  clas_val = LDNS_RR_CLASS_IN;
245  type_sz = strlen(clas) + 1;
246  type = LDNS_XMALLOC(char, type_sz);
247  if (!type) {
248  goto memerror;
249  }
250  strlcpy(type, clas, type_sz);
251  }
252  }
253  /* the rest should still be waiting for us */
254 
255  if (!type) {
256  type = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
257  if (!type) {
258  goto memerror;
259  }
260  if (-1 == ldns_bget_token(
261  rr_buf, type, "\t\n ", LDNS_SYNTAX_DATALEN)) {
262 
264  goto error;
265  }
266  }
267 
268  if (ldns_bget_token(rr_buf, rdata, "\0", LDNS_MAX_PACKETLEN) == -1) {
269  /* apparently we are done, and it's only a question RR
270  * so do not set status and go to ldnserror here
271  */
272  }
273  ldns_buffer_new_frm_data(rd_buf, rdata, strlen(rdata));
274 
275  if (strncmp(owner, "@", 1) == 0) {
276  if (origin) {
277  ldns_rr_set_owner(new, ldns_rdf_clone(origin));
278  } else if (prev && *prev) {
279  ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
280  } else {
281  /* default to root */
283  }
284 
285  /* @ also overrides prev */
286  if (prev) {
287  ldns_rdf_deep_free(*prev);
288  *prev = ldns_rdf_clone(ldns_rr_owner(new));
289  if (!*prev) {
290  goto memerror;
291  }
292  }
293  } else {
294  if (strlen(owner) == 0) {
295  /* no ownername was given, try prev, if that fails
296  * origin, else default to root */
297  if (prev && *prev) {
298  ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
299  } else if (origin) {
300  ldns_rr_set_owner(new, ldns_rdf_clone(origin));
301  } else {
302  ldns_rr_set_owner(new,
304  }
305  if(!ldns_rr_owner(new)) {
306  goto memerror;
307  }
308  } else {
309  owner_dname = ldns_dname_new_frm_str(owner);
310  if (!owner_dname) {
311  status = LDNS_STATUS_SYNTAX_ERR;
312  goto error;
313  }
314 
315  ldns_rr_set_owner(new, owner_dname);
316  if (!ldns_dname_str_absolute(owner) && origin) {
317  if(ldns_dname_cat(ldns_rr_owner(new), origin)
318  != LDNS_STATUS_OK) {
319 
320  status = LDNS_STATUS_SYNTAX_ERR;
321  goto error;
322  }
323  }
324  if (prev) {
325  ldns_rdf_deep_free(*prev);
326  *prev = ldns_rdf_clone(ldns_rr_owner(new));
327  if (!*prev) {
328  goto error;
329  }
330  }
331  }
332  }
333  LDNS_FREE(owner);
334 
335  ldns_rr_set_question(new, question);
336 
337  ldns_rr_set_ttl(new, ttl_val);
338  LDNS_FREE(ttl);
339 
340  ldns_rr_set_class(new, clas_val);
341  LDNS_FREE(clas);
342 
343  rr_type = ldns_get_rr_type_by_name(type);
344  LDNS_FREE(type);
345 
346  desc = ldns_rr_descript((uint16_t)rr_type);
347  ldns_rr_set_type(new, rr_type);
348  if (desc) {
349  /* only the rdata remains */
350  r_max = ldns_rr_descriptor_maximum(desc);
351  r_min = ldns_rr_descriptor_minimum(desc);
352  } else {
353  r_min = 0;
354  r_max = 1;
355  }
356 
357  for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) {
358  quoted = false;
359 
360  switch (ldns_rr_descriptor_field_type(desc, r_cnt)) {
361  case LDNS_RDF_TYPE_B64 :
362  case LDNS_RDF_TYPE_HEX : /* These rdf types may con- */
363  case LDNS_RDF_TYPE_NSEC : /* tain whitespace, only if */
364  case LDNS_RDF_TYPE_LOC : /* it is the last rd field. */
365  case LDNS_RDF_TYPE_WKS :
368  case LDNS_RDF_TYPE_SVCPARAMS : if (r_cnt == r_max - 1) {
369  delimiters = "\n";
370  break;
371  }
372  /* fallthrough */
373  default : delimiters = "\n\t ";
374  }
375 
376  if (ldns_rdf_type_maybe_quoted(
378  desc, r_cnt)) &&
379  ldns_buffer_remaining(rd_buf) > 0){
380 
381  /* skip whitespace */
382  while (ldns_buffer_remaining(rd_buf) > 0 &&
383  _BUFFER_IS_AT_WHITESPACE(rd_buf)) {
384  ldns_buffer_skip(rd_buf, 1);
385  }
386 
387  if (ldns_buffer_remaining(rd_buf) > 0 &&
388  *(ldns_buffer_current(rd_buf)) == '\"') {
389  delimiters = "\"\0";
390  ldns_buffer_skip(rd_buf, 1);
391  quoted = true;
392  }
393  if (!quoted && ldns_rr_descriptor_field_type(desc, r_cnt)
395 
397  goto error;
398  }
399  }
400 
401  /* because number of fields can be variable, we can't rely on
402  * _maximum() only
403  */
404 
405  /* skip whitespace */
406  while (ldns_buffer_position(rd_buf) < ldns_buffer_limit(rd_buf)
407  && _BUFFER_IS_AT_WHITESPACE(rd_buf)
408  && !quoted) {
409 
410  ldns_buffer_skip(rd_buf, 1);
411  }
412 
413  pre_data_pos = ldns_buffer_position(rd_buf);
414  if (-1 == (c = ldns_bget_token(
415  rd_buf, rd, delimiters, LDNS_MAX_RDFLEN))) {
416 
417  done = true;
418  (void)done; /* we're breaking, so done not read anymore */
419  break;
420  }
421  /* hmmz, rfc3597 specifies that any type can be represented
422  * with \# method, which can contain spaces...
423  * it does specify size though...
424  */
425  rd_strlen = strlen(rd);
426 
427  /* unknown RR data */
428  if (strncmp(rd, "\\#", 2) == 0 && !quoted &&
429  (rd_strlen == 2 || _IS_WHITESPACE(rd[2]))) {
430 
431  was_unknown_rr_format = 1;
432  /* go back to before \#
433  * and skip it while setting delimiters better
434  */
435  ldns_buffer_set_position(rd_buf, pre_data_pos);
436  delimiters = "\n\t ";
437  (void)ldns_bget_token(rd_buf, rd,
438  delimiters, LDNS_MAX_RDFLEN);
439  /* read rdata octet length */
440  c = ldns_bget_token(rd_buf, rd,
441  delimiters, LDNS_MAX_RDFLEN);
442  if (c == -1) {
443  /* something goes very wrong here */
445  goto error;
446  }
447  hex_data_size = (uint16_t) atoi(rd);
448  /* copy hex chars into hex str (2 chars per byte) */
449  hex_data_str = LDNS_XMALLOC(char, 2*hex_data_size + 1);
450  if (!hex_data_str) {
451  /* malloc error */
452  goto memerror;
453  }
454  cur_hex_data_size = 0;
455  while(cur_hex_data_size < 2 * hex_data_size) {
456  c = ldns_bget_token(rd_buf, rd,
457  delimiters, LDNS_MAX_RDFLEN);
458  if (c == -1) {
460  goto error;
461  }
462  rd_strlen = strlen(rd);
463  if ((size_t)cur_hex_data_size + rd_strlen >
464  2 * (size_t)hex_data_size) {
466  goto error;
467  }
468  strlcpy(hex_data_str + cur_hex_data_size, rd,
469  rd_strlen + 1);
470 
471  cur_hex_data_size += rd_strlen;
472  }
473  hex_data_str[cur_hex_data_size] = '\0';
474 
475  /* correct the rdf type */
476  /* if *we* know the type, interpret it as wireformat */
477  if (desc) {
478  hex_pos = 0;
479  hex_data =
480  LDNS_XMALLOC(uint8_t, hex_data_size+2);
481 
482  if (!hex_data) {
483  goto memerror;
484  }
485  ldns_write_uint16(hex_data, hex_data_size);
487  hex_data + 2, hex_data_str);
488  status = ldns_wire2rdf(new, hex_data,
489  hex_data_size + 2, &hex_pos);
490  if (status != LDNS_STATUS_OK) {
491  goto error;
492  }
493  LDNS_FREE(hex_data);
494  } else {
496  hex_data_str);
497  if (!r) {
498  goto memerror;
499  }
501  if (!ldns_rr_push_rdf(new, r)) {
502  goto memerror;
503  }
504  }
505  LDNS_FREE(hex_data_str);
506 
507  } else if(rd_strlen > 0 || quoted) {
508  /* Normal RR */
509  switch(ldns_rr_descriptor_field_type(desc, r_cnt)) {
510 
511  case LDNS_RDF_TYPE_HEX:
512  case LDNS_RDF_TYPE_B64:
513  /* When this is the last rdata field, then the
514  * rest should be read in (cause then these
515  * rdf types may contain spaces).
516  */
517  if (r_cnt == r_max - 1) {
518  c = ldns_bget_token(rd_buf, xtok,
519  "\n", LDNS_MAX_RDFLEN);
520  if (c != -1) {
521  (void) strncat(rd, xtok,
523  strlen(rd) - 1);
524  }
525  }
528  desc, r_cnt), rd);
529  break;
530 
531  case LDNS_RDF_TYPE_HIP:
532  /*
533  * In presentation format this RDATA type has
534  * three tokens: An algorithm byte, then a
535  * variable length HIT (in hexbytes) and then
536  * a variable length Public Key (in base64).
537  *
538  * We have just read the algorithm, so we need
539  * two more tokens: HIT and Public Key.
540  */
541  do {
542  /* Read and append HIT */
543  if (ldns_bget_token(rd_buf,
544  xtok, delimiters,
545  LDNS_MAX_RDFLEN) == -1)
546  break;
547 
548  (void) strncat(rd, " ",
550  strlen(rd) - 1);
551  (void) strncat(rd, xtok,
553  strlen(rd) - 1);
554 
555  /* Read and append Public Key*/
556  if (ldns_bget_token(rd_buf,
557  xtok, delimiters,
558  LDNS_MAX_RDFLEN) == -1)
559  break;
560 
561  (void) strncat(rd, " ",
563  strlen(rd) - 1);
564  (void) strncat(rd, xtok,
566  strlen(rd) - 1);
567  } while (false);
568 
571  desc, r_cnt), rd);
572  break;
573 
574  case LDNS_RDF_TYPE_DNAME:
577  desc, r_cnt), rd);
578 
579  /* check if the origin should be used
580  * or concatenated
581  */
582  if (r && ldns_rdf_size(r) > 1 &&
583  ldns_rdf_data(r)[0] == 1 &&
584  ldns_rdf_data(r)[1] == '@') {
585 
587 
588  r = origin ? ldns_rdf_clone(origin)
589 
590  : ( rr_type == LDNS_RR_TYPE_SOA ?
591 
593  ldns_rr_owner(new))
594 
596  LDNS_RDF_TYPE_DNAME, ".")
597  );
598 
599  } else if (r && rd_strlen >= 1
600  && (origin || rr_type == LDNS_RR_TYPE_SOA)
601  && !ldns_dname_str_absolute(rd)) {
602 
603  status = ldns_dname_cat(r, origin
604  ? origin : ldns_rr_owner(new));
605  if (status != LDNS_STATUS_OK) {
606  goto error;
607  }
608  }
609  break;
610  default:
613  desc, r_cnt), rd);
614  break;
615  }
616  if (!r) {
618  goto error;
619  }
620  ldns_rr_push_rdf(new, r);
621  }
622  } /* for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) */
623  LDNS_FREE(rd);
624  LDNS_FREE(xtok);
625  ldns_buffer_free(rr_buf);
626  LDNS_FREE(rdata);
627  if (ldns_buffer_remaining(rd_buf) > 0) {
628  ldns_buffer_free(rd_buf);
629  ldns_rr_free(new);
631  }
632  ldns_buffer_free(rd_buf);
633 
634  if (!question && desc && !was_unknown_rr_format &&
635  ldns_rr_rd_count(new) < r_min) {
636 
637  ldns_rr_free(new);
639  }
640 
641  if (newrr) {
642  *newrr = new;
643  } else {
644  /* Maybe the caller just wanted to see if it would parse? */
645  ldns_rr_free(new);
646  }
647  return LDNS_STATUS_OK;
648 
649 memerror:
650  status = LDNS_STATUS_MEM_ERR;
651 error:
652  if (rd_buf && rd_buf->_data) {
653  ldns_buffer_free(rd_buf);
654  } else {
655  LDNS_FREE(rd_buf);
656  }
657  if (rr_buf && rr_buf->_data) {
658  ldns_buffer_free(rr_buf);
659  } else {
660  LDNS_FREE(rr_buf);
661  }
662  LDNS_FREE(type);
663  LDNS_FREE(owner);
664  LDNS_FREE(ttl);
665  LDNS_FREE(clas);
666  LDNS_FREE(hex_data);
667  LDNS_FREE(hex_data_str);
668  LDNS_FREE(xtok);
669  LDNS_FREE(rd);
670  LDNS_FREE(rdata);
671  ldns_rr_free(new);
672  return status;
673 }
674 
676 ldns_rr_new_frm_str(ldns_rr **newrr, const char *str,
677  uint32_t default_ttl, const ldns_rdf *origin,
678  ldns_rdf **prev)
679 {
680  return ldns_rr_new_frm_str_internal(newrr,
681  str,
682  default_ttl,
683  origin,
684  prev,
685  false,
686  NULL);
687 }
688 
690 ldns_rr_new_question_frm_str(ldns_rr **newrr, const char *str,
691  const ldns_rdf *origin, ldns_rdf **prev)
692 {
693  return ldns_rr_new_frm_str_internal(newrr,
694  str,
695  0,
696  origin,
697  prev,
698  true,
699  NULL);
700 }
701 
702 /* Strip whitespace from the start and the end of <line>. */
703 static char *
704 ldns_strip_ws(char *line)
705 {
706  char *s = line, *e;
707 
708  for (s = line; *s && isspace((unsigned char)*s); s++)
709  ;
710 
711  for (e = strchr(s, 0); e > s+2 && isspace((unsigned char)e[-1]) && e[-2] != '\\'; e--)
712  ;
713  *e = 0;
714 
715  return s;
716 }
717 
719 ldns_rr_new_frm_fp(ldns_rr **newrr, FILE *fp, uint32_t *ttl, ldns_rdf **origin, ldns_rdf **prev)
720 {
721  return ldns_rr_new_frm_fp_l(newrr, fp, ttl, origin, prev, NULL);
722 }
723 
726  uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev,
727  int *line_nr, bool *explicit_ttl)
728 {
729  char *line = NULL;
730  size_t limit = 0;
731  const char *endptr; /* unused */
732  ldns_rr *rr;
733  uint32_t ttl;
734  ldns_rdf *tmp;
735  ldns_status s;
736 
737  if (default_ttl) {
738  ttl = *default_ttl;
739  } else {
740  ttl = 0;
741  }
742  /* read an entire line in from the file */
743  if ((s = ldns_fget_token_l_st( fp, &line, &limit, false
744  , LDNS_PARSE_SKIP_SPACE, line_nr))) {
745  LDNS_FREE(line);
746  return s;
747  }
748 
749  if (strncmp(line, "$ORIGIN", 7) == 0 && isspace((unsigned char)line[7])) {
750  if (*origin) {
751  ldns_rdf_deep_free(*origin);
752  *origin = NULL;
753  }
755  ldns_strip_ws(line + 8));
756  if (!tmp) {
757  /* could not parse what next to $ORIGIN */
758  LDNS_FREE(line);
760  }
761  *origin = tmp;
763  } else if (strncmp(line, "$TTL", 4) == 0 && isspace((unsigned char)line[4])) {
764  if (default_ttl) {
765  *default_ttl = ldns_str2period(
766  ldns_strip_ws(line + 5), &endptr);
767  }
769  } else if (strncmp(line, "$INCLUDE", 8) == 0) {
771  } else if (!*ldns_strip_ws(line)) {
772  LDNS_FREE(line);
774  } else {
775  if (origin && *origin) {
776  s = ldns_rr_new_frm_str_internal(&rr, (const char*)line,
777  ttl, *origin, prev, false, explicit_ttl);
778  } else {
779  s = ldns_rr_new_frm_str_internal(&rr, (const char*)line,
780  ttl, NULL, prev, false, explicit_ttl);
781  }
782  }
783  LDNS_FREE(line);
784  if (s == LDNS_STATUS_OK) {
785  if (newrr) {
786  *newrr = rr;
787  } else {
788  /* Just testing if it would parse? */
789  ldns_rr_free(rr);
790  }
791  }
792  return s;
793 }
794 
796 ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl,
797  ldns_rdf **origin, ldns_rdf **prev, int *line_nr)
798 {
799  return _ldns_rr_new_frm_fp_l_internal(newrr, fp, default_ttl, origin,
800  prev, line_nr, NULL);
801 }
802 
803 void
805 {
806  rr->_owner = owner;
807 }
808 
809 void
810 ldns_rr_set_question(ldns_rr *rr, bool question)
811 {
812  rr->_rr_question = question;
813 }
814 
815 void
816 ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
817 {
818  rr->_ttl = ttl;
819 }
820 
821 void
822 ldns_rr_set_rd_count(ldns_rr *rr, size_t count)
823 {
824  rr->_rd_count = count;
825 }
826 
827 void
829 {
830  rr->_rr_type = rr_type;
831 }
832 
833 void
835 {
836  rr->_rr_class = rr_class;
837 }
838 
839 ldns_rdf *
840 ldns_rr_set_rdf(ldns_rr *rr, const ldns_rdf *f, size_t position)
841 {
842  size_t rd_count;
843  ldns_rdf *pop;
844 
845  rd_count = ldns_rr_rd_count(rr);
846  if (position < rd_count) {
847  /* discard the old one */
848  pop = rr->_rdata_fields[position];
849  rr->_rdata_fields[position] = (ldns_rdf*)f;
850  return pop;
851  } else {
852  return NULL;
853  }
854 }
855 
856 bool
858 {
859  size_t rd_count;
860  ldns_rdf **rdata_fields;
861 
862  rd_count = ldns_rr_rd_count(rr);
863 
864  /* grow the array */
865  rdata_fields = LDNS_XREALLOC(
866  rr->_rdata_fields, ldns_rdf *, rd_count + 1);
867  if (!rdata_fields) {
868  return false;
869  }
870 
871  /* add the new member */
872  rr->_rdata_fields = rdata_fields;
873  rr->_rdata_fields[rd_count] = (ldns_rdf*)f;
874 
875  ldns_rr_set_rd_count(rr, rd_count + 1);
876  return true;
877 }
878 
879 ldns_rdf *
881 {
882  size_t rd_count;
883  ldns_rdf *pop;
884  ldns_rdf** newrd;
885 
886  rd_count = ldns_rr_rd_count(rr);
887 
888  if (rd_count == 0) {
889  return NULL;
890  }
891 
892  pop = rr->_rdata_fields[rd_count - 1];
893 
894  /* try to shrink the array */
895  if(rd_count > 1) {
896  newrd = LDNS_XREALLOC(
897  rr->_rdata_fields, ldns_rdf *, rd_count - 1);
898  if(newrd)
899  rr->_rdata_fields = newrd;
900  } else {
902  }
903 
904  ldns_rr_set_rd_count(rr, rd_count - 1);
905  return pop;
906 }
907 
908 ldns_rdf *
909 ldns_rr_rdf(const ldns_rr *rr, size_t nr)
910 {
911  if (rr && nr < ldns_rr_rd_count(rr)) {
912  return rr->_rdata_fields[nr];
913  } else {
914  return NULL;
915  }
916 }
917 
918 ldns_rdf *
920 {
921  return rr->_owner;
922 }
923 
924 bool
926 {
927  return rr->_rr_question;
928 }
929 
930 uint32_t
932 {
933  return rr->_ttl;
934 }
935 
936 size_t
938 {
939  return rr->_rd_count;
940 }
941 
944 {
945  return rr->_rr_type;
946 }
947 
950 {
951  return rr->_rr_class;
952 }
953 
954 /* rr_lists */
955 
956 size_t
958 {
959  if (rr_list) {
960  return rr_list->_rr_count;
961  } else {
962  return 0;
963  }
964 }
965 
966 ldns_rr *
967 ldns_rr_list_set_rr(ldns_rr_list *rr_list, const ldns_rr *r, size_t count)
968 {
969  ldns_rr *old;
970 
971  if (count > ldns_rr_list_rr_count(rr_list)) {
972  return NULL;
973  }
974 
975  old = ldns_rr_list_rr(rr_list, count);
976 
977  /* overwrite old's pointer */
978  rr_list->_rrs[count] = (ldns_rr*)r;
979  return old;
980 }
981 
982 void
984 {
985  assert(count <= rr_list->_rr_capacity);
986  rr_list->_rr_count = count;
987 }
988 
989 ldns_rr *
990 ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
991 {
992  if (nr < ldns_rr_list_rr_count(rr_list)) {
993  return rr_list->_rrs[nr];
994  } else {
995  return NULL;
996  }
997 }
998 
999 ldns_rr_list *
1001 {
1003  if(!rr_list) return NULL;
1004  rr_list->_rr_count = 0;
1005  rr_list->_rr_capacity = 0;
1006  rr_list->_rrs = NULL;
1007  return rr_list;
1008 }
1009 
1010 void
1012 {
1013  if (rr_list) {
1014  LDNS_FREE(rr_list->_rrs);
1015  LDNS_FREE(rr_list);
1016  }
1017 }
1018 
1019 void
1021 {
1022  size_t i;
1023 
1024  if (rr_list) {
1025  for (i=0; i < ldns_rr_list_rr_count(rr_list); i++) {
1026  ldns_rr_free(ldns_rr_list_rr(rr_list, i));
1027  }
1028  LDNS_FREE(rr_list->_rrs);
1029  LDNS_FREE(rr_list);
1030  }
1031 }
1032 
1033 
1034 /* add right to left. So we modify *left! */
1035 bool
1037 {
1038  size_t r_rr_count;
1039  size_t i;
1040 
1041  if (!left) {
1042  return false;
1043  }
1044 
1045  if (right) {
1046  r_rr_count = ldns_rr_list_rr_count(right);
1047  } else {
1048  r_rr_count = 0;
1049  }
1050 
1051  /* push right to left */
1052  for(i = 0; i < r_rr_count; i++) {
1053  ldns_rr_list_push_rr(left, ldns_rr_list_rr(right, i));
1054  }
1055  return true;
1056 }
1057 
1058 ldns_rr_list *
1060 {
1061  size_t l_rr_count;
1062  size_t r_rr_count;
1063  size_t i;
1064  ldns_rr_list *cat;
1065 
1066  if (left) {
1067  l_rr_count = ldns_rr_list_rr_count(left);
1068  } else {
1069  return ldns_rr_list_clone(right);
1070  }
1071 
1072  if (right) {
1073  r_rr_count = ldns_rr_list_rr_count(right);
1074  } else {
1075  r_rr_count = 0;
1076  }
1077 
1078  cat = ldns_rr_list_new();
1079 
1080  if (!cat) {
1081  return NULL;
1082  }
1083 
1084  /* left */
1085  for(i = 0; i < l_rr_count; i++) {
1087  ldns_rr_clone(ldns_rr_list_rr(left, i)));
1088  }
1089  /* right */
1090  for(i = 0; i < r_rr_count; i++) {
1092  ldns_rr_clone(ldns_rr_list_rr(right, i)));
1093  }
1094  return cat;
1095 }
1096 
1097 ldns_rr_list *
1098 ldns_rr_list_subtype_by_rdf(const ldns_rr_list *l, const ldns_rdf *r, size_t pos)
1099 {
1100  size_t i;
1101  ldns_rr_list *subtyped;
1102  ldns_rdf *list_rdf;
1103 
1104  subtyped = ldns_rr_list_new();
1105 
1106  for(i = 0; i < ldns_rr_list_rr_count(l); i++) {
1107  list_rdf = ldns_rr_rdf(
1108  ldns_rr_list_rr(l, i),
1109  pos);
1110  if (!list_rdf) {
1111  /* pos is too large or any other error */
1112  ldns_rr_list_deep_free(subtyped);
1113  return NULL;
1114  }
1115 
1116  if (ldns_rdf_compare(list_rdf, r) == 0) {
1117  /* a match */
1118  ldns_rr_list_push_rr(subtyped,
1120  }
1121  }
1122 
1123  if (ldns_rr_list_rr_count(subtyped) > 0) {
1124  return subtyped;
1125  } else {
1126  ldns_rr_list_free(subtyped);
1127  return NULL;
1128  }
1129 }
1130 
1131 bool
1133 {
1134  size_t rr_count;
1135  size_t cap;
1136 
1137  rr_count = ldns_rr_list_rr_count(rr_list);
1138  cap = rr_list->_rr_capacity;
1139 
1140  /* grow the array */
1141  if(rr_count+1 > cap) {
1142  ldns_rr **rrs;
1143 
1144  if(cap == 0)
1145  cap = LDNS_RRLIST_INIT; /* initial list size */
1146  else cap *= 2;
1147  rrs = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
1148  if (!rrs) {
1149  return false;
1150  }
1151  rr_list->_rrs = rrs;
1152  rr_list->_rr_capacity = cap;
1153  }
1154 
1155  /* add the new member */
1156  rr_list->_rrs[rr_count] = (ldns_rr*)rr;
1157 
1158  ldns_rr_list_set_rr_count(rr_list, rr_count + 1);
1159  return true;
1160 }
1161 
1162 bool
1164 {
1165  size_t i;
1166 
1167  for(i = 0; i < ldns_rr_list_rr_count(push_list); i++) {
1168  if (!ldns_rr_list_push_rr(rr_list,
1169  ldns_rr_list_rr(push_list, i))) {
1170  return false;
1171  }
1172  }
1173  return true;
1174 }
1175 
1176 ldns_rr *
1178 {
1179  size_t rr_count;
1180  size_t cap;
1181  ldns_rr *pop;
1182 
1183  rr_count = ldns_rr_list_rr_count(rr_list);
1184 
1185  if (rr_count == 0) {
1186  return NULL;
1187  }
1188 
1189  cap = rr_list->_rr_capacity;
1190  pop = ldns_rr_list_rr(rr_list, rr_count - 1);
1191 
1192  /* shrink the array */
1193  if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) {
1194  ldns_rr** a;
1195  cap /= 2;
1196  a = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
1197  if(a) {
1198  rr_list->_rrs = a;
1199  rr_list->_rr_capacity = cap;
1200  }
1201  /* if the realloc fails, the capacity for the list remains unchanged */
1202  }
1203 
1204  ldns_rr_list_set_rr_count(rr_list, rr_count - 1);
1205 
1206  return pop;
1207 }
1208 
1209 ldns_rr_list *
1210 ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t howmany)
1211 {
1212  /* pop a number of rr's and put them in a rr_list */
1213  ldns_rr_list *popped;
1214  ldns_rr *p;
1215  size_t i = howmany;
1216 
1217  popped = ldns_rr_list_new();
1218 
1219  if (!popped) {
1220  return NULL;
1221  }
1222 
1223 
1224  while(i > 0 &&
1225  (p = ldns_rr_list_pop_rr(rr_list)) != NULL) {
1226  ldns_rr_list_push_rr(popped, p);
1227  i--;
1228  }
1229 
1230  if (i == howmany) { /* so i <= 0 */
1231  ldns_rr_list_free(popped);
1232  return NULL;
1233  } else {
1234  return popped;
1235  }
1236 }
1237 
1238 
1239 bool
1241 {
1242  size_t i;
1243 
1244  if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) {
1245  return false;
1246  }
1247 
1248  for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1249  if (rr == ldns_rr_list_rr(rr_list, i)) {
1250  return true;
1251  } else if (ldns_rr_compare(rr, ldns_rr_list_rr(rr_list, i)) == 0) {
1252  return true;
1253  }
1254  }
1255  return false;
1256 }
1257 
1258 bool
1260 {
1261  ldns_rr_type t;
1262  ldns_rr_class c;
1263  ldns_rdf *o;
1264  ldns_rr *tmp;
1265  size_t i;
1266 
1267  if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) {
1268  return false;
1269  }
1270 
1271  tmp = ldns_rr_list_rr(rr_list, 0);
1272 
1273  t = ldns_rr_get_type(tmp);
1274  c = ldns_rr_get_class(tmp);
1275  o = ldns_rr_owner(tmp);
1276 
1277  /* compare these with the rest of the rr_list, start with 1 */
1278  for (i = 1; i < ldns_rr_list_rr_count(rr_list); i++) {
1279  tmp = ldns_rr_list_rr(rr_list, i);
1280  if (t != ldns_rr_get_type(tmp)) {
1281  return false;
1282  }
1283  if (c != ldns_rr_get_class(tmp)) {
1284  return false;
1285  }
1286  if (ldns_rdf_compare(o, ldns_rr_owner(tmp)) != 0) {
1287  return false;
1288  }
1289  }
1290  return true;
1291 }
1292 
1293 bool
1295 {
1296  size_t rr_count;
1297  size_t i;
1298  ldns_rr *last;
1299 
1300  assert(rr != NULL);
1301 
1302  rr_count = ldns_rr_list_rr_count(rr_list);
1303 
1304  if (rr_count == 0) {
1305  /* nothing there, so checking it is
1306  * not needed */
1307  return ldns_rr_list_push_rr(rr_list, rr);
1308  } else {
1309  /* check with the final rr in the rr_list */
1310  last = ldns_rr_list_rr(rr_list, rr_count - 1);
1311 
1312  if (ldns_rr_get_class(last) != ldns_rr_get_class(rr)) {
1313  return false;
1314  }
1315  if (ldns_rr_get_type(last) != ldns_rr_get_type(rr)) {
1316  return false;
1317  }
1318  /* only check if not equal to RRSIG */
1319  if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) {
1320  if (ldns_rr_ttl(last) != ldns_rr_ttl(rr)) {
1321  return false;
1322  }
1323  }
1324  if (ldns_rdf_compare(ldns_rr_owner(last),
1325  ldns_rr_owner(rr)) != 0) {
1326  return false;
1327  }
1328  /* ok, still alive - check if the rr already
1329  * exists - if so, don't add it */
1330  for(i = 0; i < rr_count; i++) {
1331  if(ldns_rr_compare(
1332  ldns_rr_list_rr(rr_list, i), rr) == 0) {
1333  return false;
1334  }
1335  }
1336  /* it's safe, push it */
1337  return ldns_rr_list_push_rr(rr_list, rr);
1338  }
1339 }
1340 
1341 ldns_rr *
1343 {
1344  return ldns_rr_list_pop_rr(rr_list);
1345 }
1346 
1347 ldns_rr_list *
1349 {
1350  ldns_rr_list *rrset;
1351  ldns_rr *last_rr = NULL;
1352  ldns_rr *next_rr;
1353 
1354  if (!rr_list) {
1355  return NULL;
1356  }
1357 
1358  rrset = ldns_rr_list_new();
1359  if (!last_rr) {
1360  last_rr = ldns_rr_list_pop_rr(rr_list);
1361  if (!last_rr) {
1362  ldns_rr_list_free(rrset);
1363  return NULL;
1364  } else {
1365  ldns_rr_list_push_rr(rrset, last_rr);
1366  }
1367  }
1368 
1369  if (ldns_rr_list_rr_count(rr_list) > 0) {
1370  next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
1371  } else {
1372  next_rr = NULL;
1373  }
1374 
1375  while (next_rr) {
1376  if (
1378  ldns_rr_owner(last_rr)) == 0
1379  &&
1380  ldns_rr_get_type(next_rr) == ldns_rr_get_type(last_rr)
1381  &&
1382  ldns_rr_get_class(next_rr) == ldns_rr_get_class(last_rr)
1383  ) {
1384  ldns_rr_list_push_rr(rrset, ldns_rr_list_pop_rr(rr_list));
1385  if (ldns_rr_list_rr_count(rr_list) > 0) {
1386  last_rr = next_rr;
1387  next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
1388  } else {
1389  next_rr = NULL;
1390  }
1391  } else {
1392  next_rr = NULL;
1393  }
1394  }
1395 
1396  return rrset;
1397 }
1398 
1399 ldns_rr *
1401 {
1402  size_t i;
1403  ldns_rr *new_rr;
1404 
1405  if (!rr) {
1406  return NULL;
1407  }
1408 
1409  new_rr = ldns_rr_new();
1410  if (!new_rr) {
1411  return NULL;
1412  }
1413  if (ldns_rr_owner(rr)) {
1415  }
1416  ldns_rr_set_ttl(new_rr, ldns_rr_ttl(rr));
1417  ldns_rr_set_type(new_rr, ldns_rr_get_type(rr));
1418  ldns_rr_set_class(new_rr, ldns_rr_get_class(rr));
1420 
1421  for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1422  if (ldns_rr_rdf(rr,i)) {
1423  ldns_rr_push_rdf(new_rr, ldns_rdf_clone(ldns_rr_rdf(rr, i)));
1424  }
1425  }
1426 
1427  return new_rr;
1428 }
1429 
1430 ldns_rr_list *
1432 {
1433  size_t i;
1434  ldns_rr_list *new_list;
1435  ldns_rr *r;
1436 
1437  if (!rrlist) {
1438  return NULL;
1439  }
1440 
1441  new_list = ldns_rr_list_new();
1442  if (!new_list) {
1443  return NULL;
1444  }
1445  for (i = 0; i < ldns_rr_list_rr_count(rrlist); i++) {
1446  r = ldns_rr_clone(
1447  ldns_rr_list_rr(rrlist, i)
1448  );
1449  if (!r) {
1450  /* huh, failure in cloning */
1451  ldns_rr_list_deep_free(new_list);
1452  return NULL;
1453  }
1454  ldns_rr_list_push_rr(new_list, r);
1455  }
1456  return new_list;
1457 }
1458 
1459 
1460 static int
1461 qsort_schwartz_rr_compare(const void *a, const void *b)
1462 {
1463  int result = 0;
1464  ldns_rr *rr1, *rr2;
1465  ldns_buffer *rr1_buf, *rr2_buf;
1468  /* if we are doing 2wire, we need to do lowercasing on the dname (and maybe on the rdata)
1469  * this must be done for comparison only, so we need to have a temp var for both buffers,
1470  * which is only used when the transformed object value isn't there yet
1471  */
1472  ldns_rr *canonical_a, *canonical_b;
1473 
1474  rr1 = (ldns_rr *) sa->original_object;
1475  rr2 = (ldns_rr *) sb->original_object;
1476 
1477  result = ldns_rr_compare_no_rdata(rr1, rr2);
1478 
1479  if (result == 0) {
1480  if (!sa->transformed_object) {
1481  canonical_a = ldns_rr_clone(sa->original_object);
1482  ldns_rr2canonical(canonical_a);
1486  sa->transformed_object = NULL;
1487  ldns_rr_free(canonical_a);
1488  return 0;
1489  }
1490  ldns_rr_free(canonical_a);
1491  }
1492  if (!sb->transformed_object) {
1493  canonical_b = ldns_rr_clone(sb->original_object);
1494  ldns_rr2canonical(canonical_b);
1499  sa->transformed_object = NULL;
1500  sb->transformed_object = NULL;
1501  ldns_rr_free(canonical_b);
1502  return 0;
1503  }
1504  ldns_rr_free(canonical_b);
1505  }
1506  rr1_buf = (ldns_buffer *) sa->transformed_object;
1507  rr2_buf = (ldns_buffer *) sb->transformed_object;
1508 
1509  result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
1510  }
1511 
1512  return result;
1513 }
1514 
1515 void
1517 {
1518  struct ldns_schwartzian_compare_struct **sortables;
1519  size_t item_count;
1520  size_t i;
1521 
1522  if (unsorted) {
1523  item_count = ldns_rr_list_rr_count(unsorted);
1524 
1525  sortables = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct *,
1526  item_count);
1527  if(!sortables) return; /* no way to return error */
1528  for (i = 0; i < item_count; i++) {
1529  sortables[i] = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct, 1);
1530  if(!sortables[i]) {
1531  /* free the allocated parts */
1532  while(i>0) {
1533  i--;
1534  LDNS_FREE(sortables[i]);
1535  }
1536  /* no way to return error */
1537  LDNS_FREE(sortables);
1538  return;
1539  }
1540  sortables[i]->original_object = ldns_rr_list_rr(unsorted, i);
1541  sortables[i]->transformed_object = NULL;
1542  }
1543  qsort(sortables,
1544  item_count,
1545  sizeof(struct ldns_schwartzian_compare_struct *),
1546  qsort_schwartz_rr_compare);
1547  for (i = 0; i < item_count; i++) {
1548  unsorted->_rrs[i] = sortables[i]->original_object;
1549  if (sortables[i]->transformed_object) {
1550  ldns_buffer_free(sortables[i]->transformed_object);
1551  }
1552  LDNS_FREE(sortables[i]);
1553  }
1554  LDNS_FREE(sortables);
1555  }
1556 }
1557 
1558 int
1560 {
1561  size_t rr1_len;
1562  size_t rr2_len;
1563  size_t offset;
1564 
1565  assert(rr1 != NULL);
1566  assert(rr2 != NULL);
1567 
1568  rr1_len = ldns_rr_uncompressed_size(rr1);
1569  rr2_len = ldns_rr_uncompressed_size(rr2);
1570 
1571  if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) < 0) {
1572  return -1;
1573  } else if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) > 0) {
1574  return 1;
1575  }
1576 
1577  /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
1578  if (ldns_rr_get_class(rr1) != ldns_rr_get_class(rr2)) {
1579  return ldns_rr_get_class(rr1) - ldns_rr_get_class(rr2);
1580  }
1581 
1582  /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
1583  if (ldns_rr_get_type(rr1) != ldns_rr_get_type(rr2)) {
1584  return ldns_rr_get_type(rr1) - ldns_rr_get_type(rr2);
1585  }
1586 
1587  /* offset is the owername length + ttl + type + class + rdlen == start of wire format rdata */
1588  offset = ldns_rdf_size(ldns_rr_owner(rr1)) + 4 + 2 + 2 + 2;
1589  /* if either record doesn't have any RDATA... */
1590  if (offset > rr1_len || offset > rr2_len) {
1591  if (rr1_len == rr2_len) {
1592  return 0;
1593  }
1594  return ((int) rr2_len - (int) rr1_len);
1595  }
1596 
1597  return 0;
1598 }
1599 
1600 int ldns_rr_compare_wire(const ldns_buffer *rr1_buf, const ldns_buffer *rr2_buf)
1601 {
1602  size_t rr1_len, rr2_len, min_len, i, offset;
1603 
1604  rr1_len = ldns_buffer_capacity(rr1_buf);
1605  rr2_len = ldns_buffer_capacity(rr2_buf);
1606 
1607  /* jump past dname (checked in earlier part)
1608  * and especially past TTL */
1609  offset = 0;
1610  while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0) {
1611  offset += *ldns_buffer_at(rr1_buf, offset) + 1;
1612  }
1613  /* jump to rdata section (PAST the rdata length field, otherwise
1614  rrs with different lengths might be sorted erroneously */
1615  offset += 11;
1616  min_len = (rr1_len < rr2_len) ? rr1_len : rr2_len;
1617  /* Compare RRs RDATA byte for byte. */
1618  for(i = offset; i < min_len; i++) {
1619  if (*ldns_buffer_at(rr1_buf,i) < *ldns_buffer_at(rr2_buf,i)) {
1620  return -1;
1621  } else if (*ldns_buffer_at(rr1_buf,i) > *ldns_buffer_at(rr2_buf,i)) {
1622  return +1;
1623  }
1624  }
1625 
1626  /* If both RDATAs are the same up to min_len, then the shorter one sorts first. */
1627  if (rr1_len < rr2_len) {
1628  return -1;
1629  } else if (rr1_len > rr2_len) {
1630  return +1;
1631  }
1632  /* The RDATAs are equal. */
1633  return 0;
1634 
1635 }
1636 
1637 int
1638 ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
1639 {
1640  int result;
1641  size_t rr1_len, rr2_len;
1642 
1643  ldns_buffer *rr1_buf;
1644  ldns_buffer *rr2_buf;
1645 
1646  result = ldns_rr_compare_no_rdata(rr1, rr2);
1647  if (result == 0) {
1648  rr1_len = ldns_rr_uncompressed_size(rr1);
1649  rr2_len = ldns_rr_uncompressed_size(rr2);
1650 
1651  rr1_buf = ldns_buffer_new(rr1_len);
1652  rr2_buf = ldns_buffer_new(rr2_len);
1653 
1654  if (ldns_rr2buffer_wire_canonical(rr1_buf,
1655  rr1,
1657  != LDNS_STATUS_OK) {
1658  ldns_buffer_free(rr1_buf);
1659  ldns_buffer_free(rr2_buf);
1660  return 0;
1661  }
1662  if (ldns_rr2buffer_wire_canonical(rr2_buf,
1663  rr2,
1665  != LDNS_STATUS_OK) {
1666  ldns_buffer_free(rr1_buf);
1667  ldns_buffer_free(rr2_buf);
1668  return 0;
1669  }
1670 
1671  result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
1672 
1673  ldns_buffer_free(rr1_buf);
1674  ldns_buffer_free(rr2_buf);
1675  }
1676 
1677  return result;
1678 }
1679 
1680 /* convert dnskey to a ds with the given algorithm,
1681  * then compare the result with the given ds */
1682 static int
1683 ldns_rr_compare_ds_dnskey(ldns_rr *ds,
1684  ldns_rr *dnskey)
1685 {
1686  ldns_rr *ds_gen;
1687  bool result = false;
1688  ldns_hash algo;
1689 
1690  if (!dnskey || !ds ||
1693  return false;
1694  }
1695 
1696  if (ldns_rr_rdf(ds, 2) == NULL) {
1697  return false;
1698  }
1699  algo = ldns_rdf2native_int8(ldns_rr_rdf(ds, 2));
1700 
1701  ds_gen = ldns_key_rr2ds(dnskey, algo);
1702  if (ds_gen) {
1703  result = ldns_rr_compare(ds, ds_gen) == 0;
1704  ldns_rr_free(ds_gen);
1705  }
1706  return result;
1707 }
1708 
1709 bool
1710 ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
1711 {
1712  bool result;
1713  ldns_rr *rr1 = ldns_rr_clone(orr1);
1714  ldns_rr *rr2 = ldns_rr_clone(orr2);
1715 
1716  /* set ttls to zero */
1717  ldns_rr_set_ttl(rr1, 0);
1718  ldns_rr_set_ttl(rr2, 0);
1719 
1720  if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DS &&
1722  result = ldns_rr_compare_ds_dnskey(rr1, rr2);
1723  } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DNSKEY &&
1725  result = ldns_rr_compare_ds_dnskey(rr2, rr1);
1726  } else {
1727  result = (ldns_rr_compare(rr1, rr2) == 0);
1728  }
1729 
1730  ldns_rr_free(rr1);
1731  ldns_rr_free(rr2);
1732 
1733  return result;
1734 }
1735 
1736 int
1738 {
1739  size_t i = 0;
1740  int rr_cmp;
1741 
1742  assert(rrl1 != NULL);
1743  assert(rrl2 != NULL);
1744 
1745  for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) {
1746  rr_cmp = ldns_rr_compare(ldns_rr_list_rr(rrl1, i), ldns_rr_list_rr(rrl2, i));
1747  if (rr_cmp != 0) {
1748  return rr_cmp;
1749  }
1750  }
1751 
1752  if (i == ldns_rr_list_rr_count(rrl1) &&
1753  i != ldns_rr_list_rr_count(rrl2)) {
1754  return 1;
1755  } else if (i == ldns_rr_list_rr_count(rrl2) &&
1756  i != ldns_rr_list_rr_count(rrl1)) {
1757  return -1;
1758  } else {
1759  return 0;
1760  }
1761 }
1762 
1763 size_t
1765 {
1766  size_t rrsize;
1767  size_t i;
1768 
1769  rrsize = 0;
1770  /* add all the rdf sizes */
1771  for(i = 0; i < ldns_rr_rd_count(r); i++) {
1772  rrsize += ldns_rdf_size(ldns_rr_rdf(r, i));
1773  }
1774  /* ownername */
1775  rrsize += ldns_rdf_size(ldns_rr_owner(r));
1776  rrsize += LDNS_RR_OVERHEAD;
1777  return rrsize;
1778 }
1779 
1780 void
1782 {
1783  uint16_t i;
1784 
1785  if (!rr) {
1786  return;
1787  }
1788 
1790 
1791  /*
1792  * lowercase the rdata dnames if the rr type is one
1793  * of the list in chapter 7 of RFC3597
1794  * Also added RRSIG, because a "Signer's Name" should be canonicalized
1795  * too. See dnssec-bis-updates-16. We can add it to this list because
1796  * the "Signer's Name" is the only dname type rdata field in a RRSIG.
1797  */
1798  switch(ldns_rr_get_type(rr)) {
1799  case LDNS_RR_TYPE_NS:
1800  case LDNS_RR_TYPE_MD:
1801  case LDNS_RR_TYPE_MF:
1802  case LDNS_RR_TYPE_CNAME:
1803  case LDNS_RR_TYPE_SOA:
1804  case LDNS_RR_TYPE_MB:
1805  case LDNS_RR_TYPE_MG:
1806  case LDNS_RR_TYPE_MR:
1807  case LDNS_RR_TYPE_PTR:
1808  case LDNS_RR_TYPE_MINFO:
1809  case LDNS_RR_TYPE_MX:
1810  case LDNS_RR_TYPE_RP:
1811  case LDNS_RR_TYPE_AFSDB:
1812  case LDNS_RR_TYPE_RT:
1813  case LDNS_RR_TYPE_SIG:
1814  case LDNS_RR_TYPE_PX:
1815  case LDNS_RR_TYPE_NXT:
1816  case LDNS_RR_TYPE_NAPTR:
1817  case LDNS_RR_TYPE_KX:
1818  case LDNS_RR_TYPE_SRV:
1819  case LDNS_RR_TYPE_DNAME:
1820  case LDNS_RR_TYPE_A6:
1821  case LDNS_RR_TYPE_RRSIG:
1822  for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1824  }
1825  return;
1826  default:
1827  /* do nothing */
1828  return;
1829  }
1830 }
1831 
1832 void
1834 {
1835  size_t i;
1836  for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1837  ldns_rr2canonical(ldns_rr_list_rr(rr_list, i));
1838  }
1839 }
1840 
1841 uint8_t
1843 {
1844  if (!rr) {
1845  return 0;
1846  }
1847  return ldns_dname_label_count(
1848  ldns_rr_owner(rr));
1849 }
1850 
1852 static const ldns_rdf_type type_0_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
1853 static const ldns_rdf_type type_a_wireformat[] = { LDNS_RDF_TYPE_A };
1854 static const ldns_rdf_type type_ns_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1855 static const ldns_rdf_type type_md_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1856 static const ldns_rdf_type type_mf_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1857 static const ldns_rdf_type type_cname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1858 static const ldns_rdf_type type_soa_wireformat[] = {
1862 };
1863 static const ldns_rdf_type type_mb_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1864 static const ldns_rdf_type type_mg_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1865 static const ldns_rdf_type type_mr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1866 static const ldns_rdf_type type_wks_wireformat[] = {
1868 };
1869 static const ldns_rdf_type type_ptr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1870 static const ldns_rdf_type type_hinfo_wireformat[] = {
1872 };
1873 static const ldns_rdf_type type_minfo_wireformat[] = {
1875 };
1876 static const ldns_rdf_type type_mx_wireformat[] = {
1878 };
1879 static const ldns_rdf_type type_rp_wireformat[] = {
1881 };
1882 static const ldns_rdf_type type_afsdb_wireformat[] = {
1884 };
1885 static const ldns_rdf_type type_x25_wireformat[] = { LDNS_RDF_TYPE_STR };
1886 static const ldns_rdf_type type_isdn_wireformat[] = {
1888 };
1889 static const ldns_rdf_type type_rt_wireformat[] = {
1891 };
1892 static const ldns_rdf_type type_nsap_wireformat[] = {
1894 };
1895 static const ldns_rdf_type type_nsap_ptr_wireformat[] = {
1897 };
1898 static const ldns_rdf_type type_sig_wireformat[] = {
1902 };
1903 static const ldns_rdf_type type_key_wireformat[] = {
1905 };
1906 static const ldns_rdf_type type_px_wireformat[] = {
1908 };
1909 static const ldns_rdf_type type_gpos_wireformat[] = {
1911 };
1912 static const ldns_rdf_type type_aaaa_wireformat[] = { LDNS_RDF_TYPE_AAAA };
1913 static const ldns_rdf_type type_loc_wireformat[] = { LDNS_RDF_TYPE_LOC };
1914 static const ldns_rdf_type type_nxt_wireformat[] = {
1916 };
1917 static const ldns_rdf_type type_eid_wireformat[] = {
1919 };
1920 static const ldns_rdf_type type_nimloc_wireformat[] = {
1922 };
1923 static const ldns_rdf_type type_srv_wireformat[] = {
1925 };
1926 static const ldns_rdf_type type_atma_wireformat[] = {
1928 };
1929 static const ldns_rdf_type type_naptr_wireformat[] = {
1931 };
1932 static const ldns_rdf_type type_kx_wireformat[] = {
1934 };
1935 static const ldns_rdf_type type_cert_wireformat[] = {
1937 };
1938 static const ldns_rdf_type type_a6_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
1939 static const ldns_rdf_type type_dname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1940 static const ldns_rdf_type type_sink_wireformat[] = { LDNS_RDF_TYPE_INT8,
1942 };
1943 static const ldns_rdf_type type_apl_wireformat[] = {
1945 };
1946 static const ldns_rdf_type type_ds_wireformat[] = {
1948 };
1949 static const ldns_rdf_type type_sshfp_wireformat[] = {
1951 };
1952 static const ldns_rdf_type type_ipseckey_wireformat[] = {
1954 };
1955 static const ldns_rdf_type type_rrsig_wireformat[] = {
1958 };
1959 static const ldns_rdf_type type_nsec_wireformat[] = {
1961 };
1962 static const ldns_rdf_type type_dhcid_wireformat[] = {
1964 };
1965 static const ldns_rdf_type type_talink_wireformat[] = {
1967 };
1968 #ifdef RRTYPE_OPENPGPKEY
1969 static const ldns_rdf_type type_openpgpkey_wireformat[] = {
1971 };
1972 #endif
1973 static const ldns_rdf_type type_csync_wireformat[] = {
1975 };
1976 static const ldns_rdf_type type_zonemd_wireformat[] = {
1979 };
1980 #ifdef RRTYPE_SVCB_HTTPS
1981 static const ldns_rdf_type type_svcb_wireformat[] = {
1985 };
1986 #endif
1987 /* nsec3 is some vars, followed by same type of data of nsec */
1988 static const ldns_rdf_type type_nsec3_wireformat[] = {
1989 /* LDNS_RDF_TYPE_NSEC3_VARS, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC*/
1991 };
1992 
1993 static const ldns_rdf_type type_nsec3param_wireformat[] = {
1994 /* LDNS_RDF_TYPE_NSEC3_PARAMS_VARS*/
1999 };
2000 
2001 static const ldns_rdf_type type_dnskey_wireformat[] = {
2006 };
2007 static const ldns_rdf_type type_tkey_wireformat[] = {
2015 };
2016 static const ldns_rdf_type type_tsig_wireformat[] = {
2024 };
2025 static const ldns_rdf_type type_tlsa_wireformat[] = {
2030 };
2031 static const ldns_rdf_type type_hip_wireformat[] = {
2033 };
2034 static const ldns_rdf_type type_nid_wireformat[] = {
2037 };
2038 static const ldns_rdf_type type_l32_wireformat[] = {
2041 };
2042 static const ldns_rdf_type type_l64_wireformat[] = {
2045 };
2046 static const ldns_rdf_type type_lp_wireformat[] = {
2049 };
2050 static const ldns_rdf_type type_eui48_wireformat[] = {
2052 };
2053 static const ldns_rdf_type type_eui64_wireformat[] = {
2055 };
2056 static const ldns_rdf_type type_uri_wireformat[] = {
2060 };
2061 static const ldns_rdf_type type_caa_wireformat[] = {
2065 };
2066 #ifdef RRTYPE_DOA
2067 static const ldns_rdf_type type_doa_wireformat[] = {
2073 };
2074 #endif
2075 #ifdef RRTYPE_AMTRELAY
2076 static const ldns_rdf_type type_amtrelay_wireformat[] = {
2078 };
2079 #endif
2080 
2081 
2085 /* All RR's defined in 1035 are well known and can thus
2086  * be compressed. See RFC3597. These RR's are:
2087  * CNAME HINFO MB MD MF MG MINFO MR MX NULL NS PTR SOA TXT
2088  */
2089 static ldns_rr_descriptor rdata_field_descriptors[] = {
2090  /* 0 */
2091  { 0, NULL, 0, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2092  /* 1 */
2093  {LDNS_RR_TYPE_A, "A", 1, 1, type_a_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2094  /* 2 */
2095  {LDNS_RR_TYPE_NS, "NS", 1, 1, type_ns_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2096  /* 3 */
2097  {LDNS_RR_TYPE_MD, "MD", 1, 1, type_md_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2098  /* 4 */
2099  {LDNS_RR_TYPE_MF, "MF", 1, 1, type_mf_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2100  /* 5 */
2101  {LDNS_RR_TYPE_CNAME, "CNAME", 1, 1, type_cname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2102  /* 6 */
2103  {LDNS_RR_TYPE_SOA, "SOA", 7, 7, type_soa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
2104  /* 7 */
2105  {LDNS_RR_TYPE_MB, "MB", 1, 1, type_mb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2106  /* 8 */
2107  {LDNS_RR_TYPE_MG, "MG", 1, 1, type_mg_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2108  /* 9 */
2109  {LDNS_RR_TYPE_MR, "MR", 1, 1, type_mr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2110  /* 10 */
2111  {LDNS_RR_TYPE_NULL, "NULL", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2112  /* 11 */
2113  {LDNS_RR_TYPE_WKS, "WKS", 2, 2, type_wks_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2114  /* 12 */
2115  {LDNS_RR_TYPE_PTR, "PTR", 1, 1, type_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2116  /* 13 */
2117  {LDNS_RR_TYPE_HINFO, "HINFO", 2, 2, type_hinfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2118  /* 14 */
2119  {LDNS_RR_TYPE_MINFO, "MINFO", 2, 2, type_minfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
2120  /* 15 */
2121  {LDNS_RR_TYPE_MX, "MX", 2, 2, type_mx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2122  /* 16 */
2123  {LDNS_RR_TYPE_TXT, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2124  /* 17 */
2125  {LDNS_RR_TYPE_RP, "RP", 2, 2, type_rp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2126  /* 18 */
2127  {LDNS_RR_TYPE_AFSDB, "AFSDB", 2, 2, type_afsdb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2128  /* 19 */
2129  {LDNS_RR_TYPE_X25, "X25", 1, 1, type_x25_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2130  /* 20 */
2131  {LDNS_RR_TYPE_ISDN, "ISDN", 1, 2, type_isdn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2132  /* 21 */
2133  {LDNS_RR_TYPE_RT, "RT", 2, 2, type_rt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2134  /* 22 */
2135  {LDNS_RR_TYPE_NSAP, "NSAP", 1, 1, type_nsap_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2136  /* 23 */
2137  {LDNS_RR_TYPE_NSAP_PTR, "NSAP-PTR", 1, 1, type_nsap_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2138  /* 24 */
2139  {LDNS_RR_TYPE_SIG, "SIG", 9, 9, type_sig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2140  /* 25 */
2141  {LDNS_RR_TYPE_KEY, "KEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2142  /* 26 */
2143  {LDNS_RR_TYPE_PX, "PX", 3, 3, type_px_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2144  /* 27 */
2145  {LDNS_RR_TYPE_GPOS, "GPOS", 3, 3, type_gpos_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2146  /* 28 */
2147  {LDNS_RR_TYPE_AAAA, "AAAA", 1, 1, type_aaaa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2148  /* 29 */
2149  {LDNS_RR_TYPE_LOC, "LOC", 1, 1, type_loc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2150  /* 30 */
2151  {LDNS_RR_TYPE_NXT, "NXT", 2, 2, type_nxt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2152  /* 31 */
2153  {LDNS_RR_TYPE_EID, "EID", 1, 1, type_eid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2154  /* 32 */
2155  {LDNS_RR_TYPE_NIMLOC, "NIMLOC", 1, 1, type_nimloc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2156  /* 33 */
2157  {LDNS_RR_TYPE_SRV, "SRV", 4, 4, type_srv_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2158  /* 34 */
2159  {LDNS_RR_TYPE_ATMA, "ATMA", 1, 1, type_atma_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2160  /* 35 */
2161  {LDNS_RR_TYPE_NAPTR, "NAPTR", 6, 6, type_naptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2162  /* 36 */
2163  {LDNS_RR_TYPE_KX, "KX", 2, 2, type_kx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2164  /* 37 */
2165  {LDNS_RR_TYPE_CERT, "CERT", 4, 4, type_cert_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2166  /* 38 */
2167  {LDNS_RR_TYPE_A6, "A6", 1, 1, type_a6_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2168  /* 39 */
2169  {LDNS_RR_TYPE_DNAME, "DNAME", 1, 1, type_dname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2170  /* 40 */
2171  {LDNS_RR_TYPE_SINK, "SINK", 1, 1, type_sink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2172  /* 41 */
2173  {LDNS_RR_TYPE_OPT, "OPT", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2174  /* 42 */
2175  {LDNS_RR_TYPE_APL, "APL", 0, 0, type_apl_wireformat, LDNS_RDF_TYPE_APL, LDNS_RR_NO_COMPRESS, 0 },
2176  /* 43 */
2177  {LDNS_RR_TYPE_DS, "DS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2178  /* 44 */
2179  {LDNS_RR_TYPE_SSHFP, "SSHFP", 3, 3, type_sshfp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2180  /* 45 */
2181  {LDNS_RR_TYPE_IPSECKEY, "IPSECKEY", 1, 1, type_ipseckey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2182  /* 46 */
2183  {LDNS_RR_TYPE_RRSIG, "RRSIG", 9, 9, type_rrsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2184  /* 47 */
2185  {LDNS_RR_TYPE_NSEC, "NSEC", 1, 2, type_nsec_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2186  /* 48 */
2187  {LDNS_RR_TYPE_DNSKEY, "DNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2188  /* 49 */
2189  {LDNS_RR_TYPE_DHCID, "DHCID", 1, 1, type_dhcid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2190  /* 50 */
2191  {LDNS_RR_TYPE_NSEC3, "NSEC3", 5, 6, type_nsec3_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2192  /* 51 */
2193  {LDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2194  /* 52 */
2195  {LDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2196 
2197  {LDNS_RR_TYPE_SMIMEA, "SMIMEA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2198 {LDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2199 
2200  /* 55
2201  * Hip ends with 0 or more Rendezvous Servers represented as dname's.
2202  * Hence the LDNS_RDF_TYPE_DNAME _variable field and the _maximum field
2203  * set to 0.
2204  */
2205  {LDNS_RR_TYPE_HIP, "HIP", 1, 1, type_hip_wireformat, LDNS_RDF_TYPE_DNAME, LDNS_RR_NO_COMPRESS, 0 },
2206 
2207 #ifdef RRTYPE_NINFO
2208  /* 56 */
2209  {LDNS_RR_TYPE_NINFO, "NINFO", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2210 #else
2211 {LDNS_RR_TYPE_NULL, "TYPE56", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2212 #endif
2213 #ifdef RRTYPE_RKEY
2214  /* 57 */
2215  {LDNS_RR_TYPE_RKEY, "RKEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2216 #else
2217 {LDNS_RR_TYPE_NULL, "TYPE57", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2218 #endif
2219  /* 58 */
2220  {LDNS_RR_TYPE_TALINK, "TALINK", 2, 2, type_talink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2221 
2222  /* 59 */
2223  {LDNS_RR_TYPE_CDS, "CDS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2224  /* 60 */
2225  {LDNS_RR_TYPE_CDNSKEY, "CDNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2226 
2227 #ifdef RRTYPE_OPENPGPKEY
2228  /* 61 */
2229  {LDNS_RR_TYPE_OPENPGPKEY, "OPENPGPKEY", 1, 1, type_openpgpkey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2230 #else
2231 {LDNS_RR_TYPE_NULL, "TYPE61", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2232 #endif
2233  /* 62 */
2234  {LDNS_RR_TYPE_CSYNC, "CSYNC", 3, 3, type_csync_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2235  /* 63 */
2236  {LDNS_RR_TYPE_ZONEMD, "ZONEMD", 4, 4, type_zonemd_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2237 #ifdef RRTYPE_SVCB_HTTPS
2238  /* 64 */
2239  {LDNS_RR_TYPE_SVCB, "SVCB", 2, 3, type_svcb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2240  /* 65 */
2241  {LDNS_RR_TYPE_HTTPS, "HTTPS", 2, 3, type_svcb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2242 
2243 #else
2244 {LDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2245 {LDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2246 #endif
2247 {LDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2248 {LDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2249 {LDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2250 {LDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2251 {LDNS_RR_TYPE_NULL, "TYPE70", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2252 {LDNS_RR_TYPE_NULL, "TYPE71", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2253 {LDNS_RR_TYPE_NULL, "TYPE72", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2254 {LDNS_RR_TYPE_NULL, "TYPE73", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2255 {LDNS_RR_TYPE_NULL, "TYPE74", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2256 {LDNS_RR_TYPE_NULL, "TYPE75", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2257 {LDNS_RR_TYPE_NULL, "TYPE76", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2258 {LDNS_RR_TYPE_NULL, "TYPE77", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2259 {LDNS_RR_TYPE_NULL, "TYPE78", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2260 {LDNS_RR_TYPE_NULL, "TYPE79", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2261 {LDNS_RR_TYPE_NULL, "TYPE80", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2262 {LDNS_RR_TYPE_NULL, "TYPE81", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2263 {LDNS_RR_TYPE_NULL, "TYPE82", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2264 {LDNS_RR_TYPE_NULL, "TYPE83", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2265 {LDNS_RR_TYPE_NULL, "TYPE84", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2266 {LDNS_RR_TYPE_NULL, "TYPE85", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2267 {LDNS_RR_TYPE_NULL, "TYPE86", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2268 {LDNS_RR_TYPE_NULL, "TYPE87", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2269 {LDNS_RR_TYPE_NULL, "TYPE88", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2270 {LDNS_RR_TYPE_NULL, "TYPE89", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2271 {LDNS_RR_TYPE_NULL, "TYPE90", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2272 {LDNS_RR_TYPE_NULL, "TYPE91", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2273 {LDNS_RR_TYPE_NULL, "TYPE92", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2274 {LDNS_RR_TYPE_NULL, "TYPE93", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2275 {LDNS_RR_TYPE_NULL, "TYPE94", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2276 {LDNS_RR_TYPE_NULL, "TYPE95", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2277 {LDNS_RR_TYPE_NULL, "TYPE96", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2278 {LDNS_RR_TYPE_NULL, "TYPE97", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2279 {LDNS_RR_TYPE_NULL, "TYPE98", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2280 
2281  /* 99 */
2282  {LDNS_RR_TYPE_SPF, "SPF", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2283 
2284  /* UINFO [IANA-Reserved] */
2285 {LDNS_RR_TYPE_NULL, "TYPE100", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2286  /* UID [IANA-Reserved] */
2287 {LDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2288  /* GID [IANA-Reserved] */
2289 {LDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2290  /* UNSPEC [IANA-Reserved] */
2291 {LDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2292 
2293  /* 104 */
2294  {LDNS_RR_TYPE_NID, "NID", 2, 2, type_nid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2295  /* 105 */
2296  {LDNS_RR_TYPE_L32, "L32", 2, 2, type_l32_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2297  /* 106 */
2298  {LDNS_RR_TYPE_L64, "L64", 2, 2, type_l64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2299  /* 107 */
2300  {LDNS_RR_TYPE_LP, "LP", 2, 2, type_lp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2301  /* 108 */
2302  {LDNS_RR_TYPE_EUI48, "EUI48", 1, 1, type_eui48_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2303  /* 109 */
2304  {LDNS_RR_TYPE_EUI64, "EUI64", 1, 1, type_eui64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2305 
2306 {LDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2307 {LDNS_RR_TYPE_NULL, "TYPE111", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2308 {LDNS_RR_TYPE_NULL, "TYPE112", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2309 {LDNS_RR_TYPE_NULL, "TYPE113", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2310 {LDNS_RR_TYPE_NULL, "TYPE114", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2311 {LDNS_RR_TYPE_NULL, "TYPE115", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2312 {LDNS_RR_TYPE_NULL, "TYPE116", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2313 {LDNS_RR_TYPE_NULL, "TYPE117", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2314 {LDNS_RR_TYPE_NULL, "TYPE118", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2315 {LDNS_RR_TYPE_NULL, "TYPE119", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2316 {LDNS_RR_TYPE_NULL, "TYPE120", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2317 {LDNS_RR_TYPE_NULL, "TYPE121", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2318 {LDNS_RR_TYPE_NULL, "TYPE122", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2319 {LDNS_RR_TYPE_NULL, "TYPE123", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2320 {LDNS_RR_TYPE_NULL, "TYPE124", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2321 {LDNS_RR_TYPE_NULL, "TYPE125", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2322 {LDNS_RR_TYPE_NULL, "TYPE126", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2323 {LDNS_RR_TYPE_NULL, "TYPE127", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2324 {LDNS_RR_TYPE_NULL, "TYPE128", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2325 {LDNS_RR_TYPE_NULL, "TYPE129", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2326 {LDNS_RR_TYPE_NULL, "TYPE130", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2327 {LDNS_RR_TYPE_NULL, "TYPE131", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2328 {LDNS_RR_TYPE_NULL, "TYPE132", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2329 {LDNS_RR_TYPE_NULL, "TYPE133", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2330 {LDNS_RR_TYPE_NULL, "TYPE134", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2331 {LDNS_RR_TYPE_NULL, "TYPE135", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2332 {LDNS_RR_TYPE_NULL, "TYPE136", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2333 {LDNS_RR_TYPE_NULL, "TYPE137", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2334 {LDNS_RR_TYPE_NULL, "TYPE138", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2335 {LDNS_RR_TYPE_NULL, "TYPE139", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2336 {LDNS_RR_TYPE_NULL, "TYPE140", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2337 {LDNS_RR_TYPE_NULL, "TYPE141", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2338 {LDNS_RR_TYPE_NULL, "TYPE142", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2339 {LDNS_RR_TYPE_NULL, "TYPE143", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2340 {LDNS_RR_TYPE_NULL, "TYPE144", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2341 {LDNS_RR_TYPE_NULL, "TYPE145", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2342 {LDNS_RR_TYPE_NULL, "TYPE146", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2343 {LDNS_RR_TYPE_NULL, "TYPE147", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2344 {LDNS_RR_TYPE_NULL, "TYPE148", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2345 {LDNS_RR_TYPE_NULL, "TYPE149", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2346 {LDNS_RR_TYPE_NULL, "TYPE150", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2347 {LDNS_RR_TYPE_NULL, "TYPE151", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2348 {LDNS_RR_TYPE_NULL, "TYPE152", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2349 {LDNS_RR_TYPE_NULL, "TYPE153", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2350 {LDNS_RR_TYPE_NULL, "TYPE154", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2351 {LDNS_RR_TYPE_NULL, "TYPE155", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2352 {LDNS_RR_TYPE_NULL, "TYPE156", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2353 {LDNS_RR_TYPE_NULL, "TYPE157", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2354 {LDNS_RR_TYPE_NULL, "TYPE158", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2355 {LDNS_RR_TYPE_NULL, "TYPE159", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2356 {LDNS_RR_TYPE_NULL, "TYPE160", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2357 {LDNS_RR_TYPE_NULL, "TYPE161", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2358 {LDNS_RR_TYPE_NULL, "TYPE162", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2359 {LDNS_RR_TYPE_NULL, "TYPE163", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2360 {LDNS_RR_TYPE_NULL, "TYPE164", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2361 {LDNS_RR_TYPE_NULL, "TYPE165", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2362 {LDNS_RR_TYPE_NULL, "TYPE166", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2363 {LDNS_RR_TYPE_NULL, "TYPE167", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2364 {LDNS_RR_TYPE_NULL, "TYPE168", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2365 {LDNS_RR_TYPE_NULL, "TYPE169", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2366 {LDNS_RR_TYPE_NULL, "TYPE170", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2367 {LDNS_RR_TYPE_NULL, "TYPE171", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2368 {LDNS_RR_TYPE_NULL, "TYPE172", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2369 {LDNS_RR_TYPE_NULL, "TYPE173", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2370 {LDNS_RR_TYPE_NULL, "TYPE174", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2371 {LDNS_RR_TYPE_NULL, "TYPE175", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2372 {LDNS_RR_TYPE_NULL, "TYPE176", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2373 {LDNS_RR_TYPE_NULL, "TYPE177", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2374 {LDNS_RR_TYPE_NULL, "TYPE178", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2375 {LDNS_RR_TYPE_NULL, "TYPE179", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2376 {LDNS_RR_TYPE_NULL, "TYPE180", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2377 {LDNS_RR_TYPE_NULL, "TYPE181", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2378 {LDNS_RR_TYPE_NULL, "TYPE182", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2379 {LDNS_RR_TYPE_NULL, "TYPE183", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2380 {LDNS_RR_TYPE_NULL, "TYPE184", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2381 {LDNS_RR_TYPE_NULL, "TYPE185", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2382 {LDNS_RR_TYPE_NULL, "TYPE186", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2383 {LDNS_RR_TYPE_NULL, "TYPE187", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2384 {LDNS_RR_TYPE_NULL, "TYPE188", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2385 {LDNS_RR_TYPE_NULL, "TYPE189", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2386 {LDNS_RR_TYPE_NULL, "TYPE190", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2387 {LDNS_RR_TYPE_NULL, "TYPE191", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2388 {LDNS_RR_TYPE_NULL, "TYPE192", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2389 {LDNS_RR_TYPE_NULL, "TYPE193", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2390 {LDNS_RR_TYPE_NULL, "TYPE194", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2391 {LDNS_RR_TYPE_NULL, "TYPE195", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2392 {LDNS_RR_TYPE_NULL, "TYPE196", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2393 {LDNS_RR_TYPE_NULL, "TYPE197", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2394 {LDNS_RR_TYPE_NULL, "TYPE198", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2395 {LDNS_RR_TYPE_NULL, "TYPE199", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2396 {LDNS_RR_TYPE_NULL, "TYPE200", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2397 {LDNS_RR_TYPE_NULL, "TYPE201", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2398 {LDNS_RR_TYPE_NULL, "TYPE202", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2399 {LDNS_RR_TYPE_NULL, "TYPE203", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2400 {LDNS_RR_TYPE_NULL, "TYPE204", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2401 {LDNS_RR_TYPE_NULL, "TYPE205", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2402 {LDNS_RR_TYPE_NULL, "TYPE206", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2403 {LDNS_RR_TYPE_NULL, "TYPE207", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2404 {LDNS_RR_TYPE_NULL, "TYPE208", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2405 {LDNS_RR_TYPE_NULL, "TYPE209", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2406 {LDNS_RR_TYPE_NULL, "TYPE210", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2407 {LDNS_RR_TYPE_NULL, "TYPE211", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2408 {LDNS_RR_TYPE_NULL, "TYPE212", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2409 {LDNS_RR_TYPE_NULL, "TYPE213", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2410 {LDNS_RR_TYPE_NULL, "TYPE214", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2411 {LDNS_RR_TYPE_NULL, "TYPE215", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2412 {LDNS_RR_TYPE_NULL, "TYPE216", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2413 {LDNS_RR_TYPE_NULL, "TYPE217", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2414 {LDNS_RR_TYPE_NULL, "TYPE218", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2415 {LDNS_RR_TYPE_NULL, "TYPE219", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2416 {LDNS_RR_TYPE_NULL, "TYPE220", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2417 {LDNS_RR_TYPE_NULL, "TYPE221", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2418 {LDNS_RR_TYPE_NULL, "TYPE222", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2419 {LDNS_RR_TYPE_NULL, "TYPE223", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2420 {LDNS_RR_TYPE_NULL, "TYPE224", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2421 {LDNS_RR_TYPE_NULL, "TYPE225", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2422 {LDNS_RR_TYPE_NULL, "TYPE226", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2423 {LDNS_RR_TYPE_NULL, "TYPE227", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2424 {LDNS_RR_TYPE_NULL, "TYPE228", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2425 {LDNS_RR_TYPE_NULL, "TYPE229", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2426 {LDNS_RR_TYPE_NULL, "TYPE230", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2427 {LDNS_RR_TYPE_NULL, "TYPE231", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2428 {LDNS_RR_TYPE_NULL, "TYPE232", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2429 {LDNS_RR_TYPE_NULL, "TYPE233", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2430 {LDNS_RR_TYPE_NULL, "TYPE234", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2431 {LDNS_RR_TYPE_NULL, "TYPE235", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2432 {LDNS_RR_TYPE_NULL, "TYPE236", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2433 {LDNS_RR_TYPE_NULL, "TYPE237", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2434 {LDNS_RR_TYPE_NULL, "TYPE238", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2435 {LDNS_RR_TYPE_NULL, "TYPE239", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2436 {LDNS_RR_TYPE_NULL, "TYPE240", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2437 {LDNS_RR_TYPE_NULL, "TYPE241", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2438 {LDNS_RR_TYPE_NULL, "TYPE242", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2439 {LDNS_RR_TYPE_NULL, "TYPE243", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2440 {LDNS_RR_TYPE_NULL, "TYPE244", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2441 {LDNS_RR_TYPE_NULL, "TYPE245", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2442 {LDNS_RR_TYPE_NULL, "TYPE246", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2443 {LDNS_RR_TYPE_NULL, "TYPE247", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2444 {LDNS_RR_TYPE_NULL, "TYPE248", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2445 
2446  /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one.
2447  * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9.
2448  */
2449  /* 249 */
2450  {LDNS_RR_TYPE_TKEY, "TKEY", 7, 7, type_tkey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2451  /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one.
2452  * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9.
2453  */
2454  /* 250 */
2455  {LDNS_RR_TYPE_TSIG, "TSIG", 7, 7, type_tsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2456 
2457  /* IXFR: A request for a transfer of an incremental zone transfer */
2458 {LDNS_RR_TYPE_NULL, "TYPE251", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2459  /* AXFR: A request for a transfer of an entire zone */
2460 {LDNS_RR_TYPE_NULL, "TYPE252", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2461  /* MAILB: A request for mailbox-related records (MB, MG or MR) */
2462 {LDNS_RR_TYPE_NULL, "TYPE253", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2463  /* MAILA: A request for mail agent RRs (Obsolete - see MX) */
2464 {LDNS_RR_TYPE_NULL, "TYPE254", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2465  /* ANY: A request for all (available) records */
2466 {LDNS_RR_TYPE_NULL, "TYPE255", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2467 
2468  /* 256 */
2469  {LDNS_RR_TYPE_URI, "URI", 3, 3, type_uri_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2470  /* 257 */
2471  {LDNS_RR_TYPE_CAA, "CAA", 3, 3, type_caa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2472 
2473 #ifdef RRTYPE_AVC
2474  /* 258 */
2475  {LDNS_RR_TYPE_AVC, "AVC", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2476 #else
2477 {LDNS_RR_TYPE_NULL, "TYPE258", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2478 #endif
2479 #ifdef RRTYPE_DOA
2480  /* 259 */
2481  {LDNS_RR_TYPE_DOA, "DOA", 5, 5, type_doa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2482 #else
2483 {LDNS_RR_TYPE_NULL, "TYPE259", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2484 #endif
2485 #ifdef RRTYPE_AMTRELAY
2486  /* 260 */
2487  {LDNS_RR_TYPE_AMTRELAY, "AMTRELAY", 1, 1, type_amtrelay_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2488 #else
2489 {LDNS_RR_TYPE_NULL, "TYPE260", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2490 #endif
2491 
2492 /* split in array, no longer contiguous */
2493 
2494 #ifdef RRTYPE_TA
2495  /* 32768 */
2496  {LDNS_RR_TYPE_TA, "TA", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2497 #else
2498 {LDNS_RR_TYPE_NULL, "TYPE32768", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2499 #endif
2500  /* 32769 */
2501  {LDNS_RR_TYPE_DLV, "DLV", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }
2502 };
2509 #define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT \
2510  (sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0]))
2511 
2512 
2513 /*---------------------------------------------------------------------------*
2514  * The functions below return an bitmap RDF with the space required to set
2515  * or unset all known RR types. Arguably these functions are better situated
2516  * in rdata.c, however for the space calculation it is necessary to walk
2517  * through rdata_field_descriptors which is not easily possible from anywhere
2518  * other than rr.c where it is declared static.
2519  *
2520  * Alternatively rr.c could have provided an iterator for rr_type or
2521  * rdf_descriptors, but this seemed overkill for internal use only.
2522  */
2523 static ldns_rr_descriptor* rdata_field_descriptors_end =
2524  &rdata_field_descriptors[LDNS_RDATA_FIELD_DESCRIPTORS_COUNT];
2525 
2526 /* From RFC3845:
2527  *
2528  * 2.1.2. The List of Type Bit Map(s) Field
2529  *
2530  * The RR type space is split into 256 window blocks, each representing
2531  * the low-order 8 bits of the 16-bit RR type space. Each block that
2532  * has at least one active RR type is encoded using a single octet
2533  * window number (from 0 to 255), a single octet bitmap length (from 1
2534  * to 32) indicating the number of octets used for the window block's
2535  * bitmap, and up to 32 octets (256 bits) of bitmap.
2536  *
2537  * Window blocks are present in the NSEC RR RDATA in increasing
2538  * numerical order.
2539  *
2540  * "|" denotes concatenation
2541  *
2542  * Type Bit Map(s) Field = ( Window Block # | Bitmap Length | Bitmap ) +
2543  *
2544  * <cut>
2545  *
2546  * Blocks with no types present MUST NOT be included. Trailing zero
2547  * octets in the bitmap MUST be omitted. The length of each block's
2548  * bitmap is determined by the type code with the largest numerical
2549  * value within that block, among the set of RR types present at the
2550  * NSEC RR's owner name. Trailing zero octets not specified MUST be
2551  * interpreted as zero octets.
2552  */
2553 static ldns_status
2554 ldns_rdf_bitmap_known_rr_types_set(ldns_rdf** rdf, int value)
2555 {
2556  uint8_t window; /* most significant octet of type */
2557  uint8_t subtype; /* least significant octet of type */
2558  uint16_t windows[256] /* Max subtype per window */
2559 #ifndef S_SPLINT_S
2560  = { 0 }
2561 #endif
2562  ;
2563  ldns_rr_descriptor* d; /* used to traverse rdata_field_descriptors */
2564  size_t i; /* used to traverse windows array */
2565 
2566  size_t sz; /* size needed for type bitmap rdf */
2567  uint8_t* data = NULL; /* rdf data */
2568  uint8_t* dptr; /* used to itraverse rdf data */
2569 
2570  assert(rdf != NULL);
2571 
2572  /* Which windows need to be in the bitmap rdf?
2573  */
2574  for (d=rdata_field_descriptors; d < rdata_field_descriptors_end; d++) {
2575  window = d->_type >> 8;
2576  subtype = d->_type & 0xff;
2577  if (windows[window] < subtype) {
2578  windows[window] = subtype;
2579  }
2580  }
2581 
2582  /* How much space do we need in the rdf for those windows?
2583  */
2584  sz = 0;
2585  for (i = 0; i < 256; i++) {
2586  if (windows[i]) {
2587  sz += windows[i] / 8 + 3;
2588  }
2589  }
2590  if (sz > 0) {
2591  /* Format rdf data according RFC3845 Section 2.1.2 (see above)
2592  */
2593  dptr = data = LDNS_XMALLOC(uint8_t, sz);
2594  if (!data) {
2595  return LDNS_STATUS_MEM_ERR;
2596  }
2597  memset(data, value, sz);
2598  for (i = 0; i < 256; i++) {
2599  if (windows[i]) {
2600  *dptr++ = (uint8_t)i;
2601  *dptr++ = (uint8_t)(windows[i] / 8 + 1);
2602  dptr += dptr[-1];
2603  }
2604  }
2605  }
2606  /* Allocate and return rdf structure for the data
2607  */
2608  *rdf = ldns_rdf_new(LDNS_RDF_TYPE_BITMAP, sz, data);
2609  if (!*rdf) {
2610  LDNS_FREE(data);
2611  return LDNS_STATUS_MEM_ERR;
2612  }
2613  return LDNS_STATUS_OK;
2614 }
2615 
2618 {
2619  return ldns_rdf_bitmap_known_rr_types_set(rdf, 0);
2620 }
2621 
2624 {
2625  return ldns_rdf_bitmap_known_rr_types_set(rdf, 255);
2626 }
2627 /* End of RDF bitmap functions
2628  *---------------------------------------------------------------------------*/
2629 
2630 
2631 const ldns_rr_descriptor *
2632 ldns_rr_descript(uint16_t type)
2633 {
2634  size_t i;
2636  return &rdata_field_descriptors[type];
2637  } else {
2638  /* because not all array index equals type code */
2641  i++) {
2642  if (rdata_field_descriptors[i]._type == type) {
2643  return &rdata_field_descriptors[i];
2644  }
2645  }
2646  return &rdata_field_descriptors[0];
2647  }
2648 }
2649 
2650 size_t
2652 {
2653  if (descriptor) {
2654  return descriptor->_minimum;
2655  } else {
2656  return 0;
2657  }
2658 }
2659 
2660 size_t
2662 {
2663  if (descriptor) {
2664  if (descriptor->_variable != LDNS_RDF_TYPE_NONE) {
2665  /* Should really be SIZE_MAX... bad FreeBSD. */
2666  return UINT_MAX;
2667  } else {
2668  return descriptor->_maximum;
2669  }
2670  } else {
2671  return 0;
2672  }
2673 }
2674 
2677  size_t index)
2678 {
2679  assert(descriptor != NULL);
2680  assert(index < descriptor->_maximum
2681  || descriptor->_variable != LDNS_RDF_TYPE_NONE);
2682  if (index < descriptor->_maximum) {
2683  return descriptor->_wireformat[index];
2684  } else {
2685  return descriptor->_variable;
2686  }
2687 }
2688 
2690 ldns_get_rr_type_by_name(const char *name)
2691 {
2692  unsigned int i;
2693  const char *desc_name;
2694  const ldns_rr_descriptor *desc;
2695 
2696  /* TYPEXX representation */
2697  if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
2698  return atoi(name + 4);
2699  }
2700 
2701  /* Normal types */
2702  for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
2703  desc = &rdata_field_descriptors[i];
2704  desc_name = desc->_name;
2705  if(desc_name &&
2706  strlen(name) == strlen(desc_name) &&
2707  strncasecmp(name, desc_name, strlen(desc_name)) == 0) {
2708  /* because not all array index equals type code */
2709  return desc->_type;
2710  }
2711  }
2712 
2713  /* special cases for query types */
2714  if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
2715  return 251;
2716  } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
2717  return 252;
2718  } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
2719  return 253;
2720  } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
2721  return 254;
2722  } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
2723  return 255;
2724  }
2725 
2726  return 0;
2727 }
2728 
2730 ldns_get_rr_class_by_name(const char *name)
2731 {
2732  ldns_lookup_table *lt;
2733 
2734  /* CLASSXX representation */
2735  if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) {
2736  return atoi(name + 5);
2737  }
2738 
2739  /* Normal types */
2741 
2742  if (lt) {
2743  return lt->id;
2744  }
2745  return 0;
2746 }
2747 
2748 
2751 {
2752  ldns_rr_type r;
2753 
2754  if (!rd) {
2755  return 0;
2756  }
2757 
2759  return 0;
2760  }
2761 
2763  return r;
2764 }
2765 
2768 {
2769  if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
2770  return ldns_rr_get_type(ldns_rr_list_rr(rr_list, 0));
2771  } else {
2772  return 0;
2773  }
2774 }
2775 
2776 ldns_rdf *
2778 {
2779  if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
2780  return ldns_rr_owner(ldns_rr_list_rr(rr_list, 0));
2781  } else {
2782  return NULL;
2783  }
2784 }
void ldns_buffer_free(ldns_buffer *buffer)
frees the buffer.
Definition: buffer.c:137
ldns_buffer * ldns_buffer_new(size_t capacity)
creates a new buffer with the specified capacity.
Definition: buffer.c:16
void ldns_buffer_new_frm_data(ldns_buffer *buffer, const void *data, size_t size)
creates a buffer with the specified data.
Definition: buffer.c:41
size_t strlcpy(char *dst, const char *src, size_t siz)
bool ldns_dname_str_absolute(const char *dname_str)
Checks whether the given dname string is absolute (i.e.
Definition: dname.c:518
int ldns_dname_compare(const ldns_rdf *dname1, const ldns_rdf *dname2)
Compares the two dname rdf's according to the algorithm for ordering in RFC4034 Section 6.
Definition: dname.c:359
void ldns_dname2canonical(const ldns_rdf *rd)
Put a dname into canonical fmt - ie.
Definition: dname.c:280
uint8_t ldns_dname_label_count(const ldns_rdf *r)
count the number of labels inside a LDNS_RDF_DNAME type rdf.
Definition: dname.c:214
ldns_status ldns_dname_cat(ldns_rdf *rd1, const ldns_rdf *rd2)
concatenates rd2 after rd1 (rd2 is copied, rd1 is modified)
Definition: dname.c:90
ldns_rdf * ldns_dname_new_frm_str(const char *str)
creates a new dname rdf from a string.
Definition: dname.c:268
ldns_rr * ldns_key_rr2ds(const ldns_rr *key, ldns_hash h)
returns a new DS rr that represents the given key rr.
Definition: dnssec.c:508
@ LDNS_STATUS_SYNTAX_SUPERFLUOUS_TEXT_ERR
Definition: error.h:130
@ LDNS_STATUS_SYNTAX_ERR
Definition: error.h:97
@ LDNS_STATUS_SYNTAX_DNAME_ERR
Definition: error.h:84
@ LDNS_STATUS_MEM_ERR
Definition: error.h:34
@ LDNS_STATUS_SYNTAX_TTL
Definition: error.h:88
@ LDNS_STATUS_SYNTAX_RDATA_ERR
Definition: error.h:83
@ LDNS_STATUS_SYNTAX_TYPE_ERR
Definition: error.h:79
@ LDNS_STATUS_OK
Definition: error.h:26
@ LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR
Definition: error.h:93
@ LDNS_STATUS_SYNTAX_EMPTY
Definition: error.h:91
@ LDNS_STATUS_SYNTAX_CLASS_ERR
Definition: error.h:80
@ LDNS_STATUS_SYNTAX_INCLUDE
Definition: error.h:90
@ LDNS_STATUS_SYNTAX_TTL_ERR
Definition: error.h:81
@ LDNS_STATUS_SYNTAX_ORIGIN
Definition: error.h:89
enum ldns_enum_status ldns_status
Definition: error.h:146
ldns_lookup_table ldns_rr_classes[]
rr types
Definition: host2str.c:99
ldns_status ldns_rr2buffer_wire_canonical(ldns_buffer *buffer, const ldns_rr *rr, int section)
Copies the rr data to the buffer in wire format, in canonical format according to RFC3597 (every dnam...
Definition: host2wire.c:171
ldns_status ldns_rr2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr, int section)
Copies the rr data to the buffer in wire format.
Definition: host2wire.c:244
enum ldns_enum_hash ldns_hash
Definition: keys.h:76
Including this file will include all ldns files, and define some lookup tables.
#define LDNS_DEFAULT_TTL
Definition: ldns.h:136
#define LDNS_MAX_PACKETLEN
Definition: packet.h:24
@ LDNS_SECTION_ANY
bogus section, if not interested
Definition: packet.h:283
ldns_status ldns_fget_token_l_st(FILE *f, char **token, size_t *limit, bool fixed, const char *delim, int *line_nr)
returns a token/char from the stream f.
Definition: parse.c:31
ssize_t ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit)
returns a token/char from the buffer b.
Definition: parse.c:274
#define LDNS_PARSE_SKIP_SPACE
Definition: parse.h:20
uint32_t ldns_str2period(const char *nptr, const char **endptr)
converts a ttl value (like 5d2h) to a long.
Definition: rdata.c:691
ldns_rdf_type ldns_rdf_get_type(const ldns_rdf *rd)
returns the type of the rdf.
Definition: rdata.c:31
void ldns_rdf_set_type(ldns_rdf *rd, ldns_rdf_type type)
sets the size of the rdf.
Definition: rdata.c:53
void ldns_rdf_deep_free(ldns_rdf *rd)
frees a rdf structure and frees the data.
Definition: rdata.c:230
ldns_rdf * ldns_rdf_new(ldns_rdf_type type, size_t size, void *data)
allocates a new rdf structure and fills it.
Definition: rdata.c:179
uint16_t ldns_rdf2native_int16(const ldns_rdf *rd)
returns the native uint16_t representation from the rdf.
Definition: rdata.c:84
ldns_rdf * ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str)
creates a new rdf from a string.
Definition: rdata.c:249
uint8_t ldns_rdf2native_int8(const ldns_rdf *rd)
returns the native uint8_t representation from the rdf.
Definition: rdata.c:70
size_t ldns_rdf_size(const ldns_rdf *rd)
returns the size of the rdf.
Definition: rdata.c:24
uint8_t * ldns_rdf_data(const ldns_rdf *rd)
returns the data of the rdf.
Definition: rdata.c:38
int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2)
compares two rdf's on their wire formats.
Definition: rdata.c:657
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
Definition: rdata.c:222
#define LDNS_MAX_RDFLEN
Definition: rdata.h:31
@ LDNS_RDF_TYPE_INT32
32 bits
Definition: rdata.h:56
@ LDNS_RDF_TYPE_TAG
A non-zero sequence of US-ASCII letters and numbers in lower case.
Definition: rdata.h:126
@ LDNS_RDF_TYPE_NSAP
NSAP.
Definition: rdata.h:103
@ LDNS_RDF_TYPE_HIP
Represents the Public Key Algorithm, HIT and Public Key fields for the HIP RR types.
Definition: rdata.h:92
@ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
nsec3 base32 string (with length byte on wire
Definition: rdata.h:111
@ LDNS_RDF_TYPE_CERT_ALG
certificate algorithm
Definition: rdata.h:78
@ LDNS_RDF_TYPE_EUI48
6 * 8 bit hex numbers separated by dashes.
Definition: rdata.h:119
@ LDNS_RDF_TYPE_EUI64
8 * 8 bit hex numbers separated by dashes.
Definition: rdata.h:121
@ LDNS_RDF_TYPE_PERIOD
period
Definition: rdata.h:86
@ LDNS_RDF_TYPE_B64
b64 string
Definition: rdata.h:68
@ LDNS_RDF_TYPE_AAAA
AAAA record.
Definition: rdata.h:60
@ LDNS_RDF_TYPE_UNKNOWN
unknown types
Definition: rdata.h:82
@ LDNS_RDF_TYPE_WKS
well known services
Definition: rdata.h:101
@ LDNS_RDF_TYPE_DNAME
domain name
Definition: rdata.h:50
@ LDNS_RDF_TYPE_TIME
time (32 bits)
Definition: rdata.h:84
@ LDNS_RDF_TYPE_BITMAP
Definition: rdata.h:149
@ LDNS_RDF_TYPE_SVCPARAMS
draft-ietf-dnsop-svcb-https
Definition: rdata.h:146
@ LDNS_RDF_TYPE_NSEC
nsec type codes
Definition: rdata.h:72
@ LDNS_RDF_TYPE_SELECTOR
Definition: rdata.h:139
@ LDNS_RDF_TYPE_NSEC3_SALT
nsec3 hash salt
Definition: rdata.h:109
@ LDNS_RDF_TYPE_APL
apl data
Definition: rdata.h:64
@ LDNS_RDF_TYPE_A
A record.
Definition: rdata.h:58
@ LDNS_RDF_TYPE_LONG_STR
A <character-string> encoding of the value field as specified [RFC1035], Section 5....
Definition: rdata.h:132
@ LDNS_RDF_TYPE_LOC
location data
Definition: rdata.h:99
@ LDNS_RDF_TYPE_INT16_DATA
variable length any type rdata where the length is specified by the first 2 bytes
Definition: rdata.h:95
@ LDNS_RDF_TYPE_ILNP64
4 shorts represented as 4 * 16 bit hex numbers separated by colons.
Definition: rdata.h:116
@ LDNS_RDF_TYPE_ATMA
ATMA.
Definition: rdata.h:105
@ LDNS_RDF_TYPE_HEX
hex string
Definition: rdata.h:70
@ LDNS_RDF_TYPE_NONE
none
Definition: rdata.h:48
@ LDNS_RDF_TYPE_INT8
8 bits
Definition: rdata.h:52
@ LDNS_RDF_TYPE_MATCHING_TYPE
Definition: rdata.h:140
@ LDNS_RDF_TYPE_IPSECKEY
IPSECKEY.
Definition: rdata.h:107
@ LDNS_RDF_TYPE_CERTIFICATE_USAGE
Since RFC7218 TLSA records can be given with mnemonics, hence these rdata field types.
Definition: rdata.h:138
@ LDNS_RDF_TYPE_STR
txt string
Definition: rdata.h:62
@ LDNS_RDF_TYPE_INT16
16 bits
Definition: rdata.h:54
@ LDNS_RDF_TYPE_ALG
a key algorithm
Definition: rdata.h:80
@ LDNS_RDF_TYPE_AMTRELAY
draft-ietf-mboned-driad-amt-discovery
Definition: rdata.h:143
@ LDNS_RDF_TYPE_TSIGTIME
tsig time 48 bits
Definition: rdata.h:88
@ LDNS_RDF_TYPE_TYPE
a RR type
Definition: rdata.h:74
enum ldns_enum_rdf_type ldns_rdf_type
Definition: rdata.h:151
void ldns_rr_list_free(ldns_rr_list *rr_list)
frees an rr_list structure.
Definition: rr.c:1011
ldns_rr * ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
returns a specific rr of an rrlist.
Definition: rr.c:990
ldns_rr * ldns_rr_list_pop_rr(ldns_rr_list *rr_list)
pops the last rr from an rrlist.
Definition: rr.c:1177
ldns_rr_class ldns_get_rr_class_by_name(const char *name)
retrieves a class by looking up its name.
Definition: rr.c:2730
ldns_status ldns_rr_new_frm_str(ldns_rr **newrr, const char *str, uint32_t default_ttl, const ldns_rdf *origin, ldns_rdf **prev)
creates an rr from a string.
Definition: rr.c:676
uint32_t ldns_rr_ttl(const ldns_rr *rr)
returns the ttl of an rr structure.
Definition: rr.c:931
ldns_status _ldns_rr_new_frm_fp_l_internal(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr, bool *explicit_ttl)
Definition: rr.c:725
bool ldns_rr_set_push_rr(ldns_rr_list *rr_list, ldns_rr *rr)
pushes an rr to an rrset (which really are rr_list's).
Definition: rr.c:1294
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
Definition: rr.c:919
ldns_rr_type ldns_rdf2rr_type(const ldns_rdf *rd)
convert an rdf of type LDNS_RDF_TYPE_TYPE to an actual LDNS_RR_TYPE.
Definition: rr.c:2750
ldns_status ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr)
creates a new rr from a file containing a string.
Definition: rr.c:796
void ldns_rr_list_deep_free(ldns_rr_list *rr_list)
frees an rr_list structure and all rrs contained therein.
Definition: rr.c:1020
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
Definition: rr.c:2632
void ldns_rr_free(ldns_rr *rr)
frees an RR structure
Definition: rr.c:81
ldns_rr * ldns_rr_set_pop_rr(ldns_rr_list *rr_list)
pops the last rr from an rrset.
Definition: rr.c:1342
void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
sets the owner in the rr structure.
Definition: rr.c:804
#define _BUFFER_IS_AT_WHITESPACE(rd_buf)
Definition: rr.c:26
ldns_rr_type ldns_rr_list_type(const ldns_rr_list *rr_list)
Returns the type of the first element of the RR If there are no elements present, 0 is returned.
Definition: rr.c:2767
#define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT
computes the number of rdata fields
Definition: rr.c:2509
#define LDNS_TTL_DATALEN
Definition: rr.c:20
#define LDNS_RRLIST_INIT
Definition: rr.c:21
ldns_rr_list * ldns_rr_list_pop_rrset(ldns_rr_list *rr_list)
pops the first rrset from the list, the list must be sorted, so that all rr's from each rrset are nex...
Definition: rr.c:1348
ldns_rr * ldns_rr_new_frm_type(ldns_rr_type t)
creates a new rr structure, based on the given type.
Definition: rr.c:48
ldns_status ldns_rr_new_frm_fp(ldns_rr **newrr, FILE *fp, uint32_t *ttl, ldns_rdf **origin, ldns_rdf **prev)
creates a new rr from a file containing a string.
Definition: rr.c:719
void ldns_rr_list_sort(ldns_rr_list *unsorted)
sorts an rr_list (canonical wire format).
Definition: rr.c:1516
#define _IS_WHITESPACE(chr)
Definition: rr.c:23
void ldns_rr_set_type(ldns_rr *rr, ldns_rr_type rr_type)
sets the type in the rr.
Definition: rr.c:828
bool ldns_rr_list_push_rr_list(ldns_rr_list *rr_list, const ldns_rr_list *push_list)
pushes an rr_list to an rrlist.
Definition: rr.c:1163
void ldns_rr2canonical(ldns_rr *rr)
converts each dname in a rr to its canonical form.
Definition: rr.c:1781
size_t ldns_rr_rd_count(const ldns_rr *rr)
returns the rd_count of an rr structure.
Definition: rr.c:937
uint8_t ldns_rr_label_count(const ldns_rr *rr)
counts the number of labels of the ownername.
Definition: rr.c:1842
ldns_rdf * ldns_rr_set_rdf(ldns_rr *rr, const ldns_rdf *f, size_t position)
sets a rdf member, it will be set on the position given.
Definition: rr.c:840
ldns_rdf_type ldns_rr_descriptor_field_type(const ldns_rr_descriptor *descriptor, size_t index)
returns the rdf type for the given rdata field number of the rr type for the given descriptor.
Definition: rr.c:2676
size_t ldns_rr_list_rr_count(const ldns_rr_list *rr_list)
returns the number of rr's in an rr_list.
Definition: rr.c:957
#define LDNS_SYNTAX_DATALEN
Definition: rr.c:19
int ldns_rr_compare_wire(const ldns_buffer *rr1_buf, const ldns_buffer *rr2_buf)
compares the wireformat of two rrs, contained in the given buffers.
Definition: rr.c:1600
void ldns_rr_set_question(ldns_rr *rr, bool question)
sets the question flag in the rr structure.
Definition: rr.c:810
void ldns_rr_list2canonical(const ldns_rr_list *rr_list)
converts each dname in each rr in a rr_list to its canonical form.
Definition: rr.c:1833
bool ldns_is_rrset(const ldns_rr_list *rr_list)
checks if an rr_list is a rrset.
Definition: rr.c:1259
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
Definition: rr.c:943
void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
sets the ttl in the rr structure.
Definition: rr.c:816
ldns_rdf * ldns_rr_list_owner(const ldns_rr_list *rr_list)
Returns the owner domain name rdf of the first element of the RR If there are no elements present,...
Definition: rr.c:2777
bool ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
Definition: rr.c:1132
ldns_rr_list * ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t howmany)
pops an rr_list of size s from an rrlist.
Definition: rr.c:1210
size_t ldns_rr_descriptor_maximum(const ldns_rr_descriptor *descriptor)
returns the maximum number of rdata fields of the rr type this descriptor describes.
Definition: rr.c:2661
int ldns_rr_compare_no_rdata(const ldns_rr *rr1, const ldns_rr *rr2)
compares two rrs, up to the rdata.
Definition: rr.c:1559
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
Definition: rr.c:949
ldns_rr_list * ldns_rr_list_cat_clone(const ldns_rr_list *left, const ldns_rr_list *right)
concatenates two ldns_rr_lists together, but makes clones of the rr's (instead of pointer copying).
Definition: rr.c:1059
bool ldns_rr_list_contains_rr(const ldns_rr_list *rr_list, const ldns_rr *rr)
returns true if the given rr is one of the rrs in the list, or if it is equal to one
Definition: rr.c:1240
bool ldns_rr_is_question(const ldns_rr *rr)
returns the question flag of an rr structure.
Definition: rr.c:925
void ldns_rr_set_rd_count(ldns_rr *rr, size_t count)
sets the rd_count in the rr.
Definition: rr.c:822
ldns_status ldns_rdf_bitmap_known_rr_types_space(ldns_rdf **rdf)
Create a rr type bitmap rdf providing enough space to set all known (to ldns) rr types.
Definition: rr.c:2617
void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
sets the class in the rr.
Definition: rr.c:834
ldns_rr * ldns_rr_list_set_rr(ldns_rr_list *rr_list, const ldns_rr *r, size_t count)
set a rr on a specific index in a ldns_rr_list
Definition: rr.c:967
ldns_rr_list * ldns_rr_list_new(void)
creates a new rr_list structure.
Definition: rr.c:1000
ldns_rr_list * ldns_rr_list_subtype_by_rdf(const ldns_rr_list *l, const ldns_rdf *r, size_t pos)
Return the rr_list which matches the rdf at position field.
Definition: rr.c:1098
bool ldns_rr_push_rdf(ldns_rr *rr, const ldns_rdf *f)
sets rd_field member, it will be placed in the next available spot.
Definition: rr.c:857
int ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2)
compares two rr lists.
Definition: rr.c:1737
int ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
compares two rrs.
Definition: rr.c:1638
bool ldns_rr_list_cat(ldns_rr_list *left, const ldns_rr_list *right)
concatenates two ldns_rr_lists together.
Definition: rr.c:1036
bool ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
returns true of the given rr's are equal.
Definition: rr.c:1710
void ldns_rr_list_set_rr_count(ldns_rr_list *rr_list, size_t count)
sets the number of rr's in an rr_list.
Definition: rr.c:983
ldns_rr * ldns_rr_clone(const ldns_rr *rr)
clones a rr and all its data
Definition: rr.c:1400
ldns_rr_list * ldns_rr_list_clone(const ldns_rr_list *rrlist)
clones an rrlist.
Definition: rr.c:1431
size_t ldns_rr_descriptor_minimum(const ldns_rr_descriptor *descriptor)
returns the minimum number of rdata fields of the rr type this descriptor describes.
Definition: rr.c:2651
ldns_status ldns_rr_new_question_frm_str(ldns_rr **newrr, const char *str, const ldns_rdf *origin, ldns_rdf **prev)
creates an rr for the question section from a string, i.e.
Definition: rr.c:690
ldns_rdf * ldns_rr_rdf(const ldns_rr *rr, size_t nr)
returns the rdata field member counter.
Definition: rr.c:909
ldns_rr * ldns_rr_new(void)
creates a new rr structure.
Definition: rr.c:30
size_t ldns_rr_uncompressed_size(const ldns_rr *r)
calculates the uncompressed size of an RR.
Definition: rr.c:1764
ldns_rdf * ldns_rr_pop_rdf(ldns_rr *rr)
removes a rd_field member, it will be popped from the last position.
Definition: rr.c:880
ldns_status ldns_rdf_bitmap_known_rr_types(ldns_rdf **rdf)
Create a rr type bitmap rdf with at least all known (to ldns) rr types set.
Definition: rr.c:2623
ldns_rr_type ldns_get_rr_type_by_name(const char *name)
retrieves a rrtype by looking up its name.
Definition: rr.c:2690
#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON
Definition: rr.h:246
@ LDNS_RR_NO_COMPRESS
Definition: rr.h:70
@ LDNS_RR_COMPRESS
compression is allowed
Definition: rr.h:69
enum ldns_enum_rr_type ldns_rr_type
Definition: rr.h:243
#define LDNS_RR_OVERHEAD
The bytes TTL, CLASS and length use up in an rr.
Definition: rr.h:37
@ LDNS_RR_TYPE_MF
a mail forwarder (Obsolete - use MX)
Definition: rr.h:86
@ LDNS_RR_TYPE_CERT
RFC2538.
Definition: rr.h:152
@ LDNS_RR_TYPE_RP
RFC1183.
Definition: rr.h:112
@ LDNS_RR_TYPE_KX
RFC2230.
Definition: rr.h:150
@ LDNS_RR_TYPE_DOA
Definition: rr.h:226
@ LDNS_RR_TYPE_SPF
Definition: rr.h:198
@ LDNS_RR_TYPE_OPT
OPT record RFC 6891.
Definition: rr.h:160
@ LDNS_RR_TYPE_RRSIG
DNSSEC.
Definition: rr.h:170
@ LDNS_RR_TYPE_SINK
dnsind-kitchen-sink-02.txt
Definition: rr.h:158
@ LDNS_RR_TYPE_A
a host address
Definition: rr.h:80
@ LDNS_RR_TYPE_HIP
Definition: rr.h:182
@ LDNS_RR_TYPE_LP
Definition: rr.h:208
@ LDNS_RR_TYPE_ISDN
RFC1183.
Definition: rr.h:118
@ LDNS_RR_TYPE_MINFO
mailbox or mail list information
Definition: rr.h:106
@ LDNS_RR_TYPE_L32
Definition: rr.h:206
@ LDNS_RR_TYPE_GPOS
RFC1712.
Definition: rr.h:132
@ LDNS_RR_TYPE_TKEY
Definition: rr.h:213
@ LDNS_RR_TYPE_ZONEMD
Definition: rr.h:194
@ LDNS_RR_TYPE_DNSKEY
Definition: rr.h:172
@ LDNS_RR_TYPE_SOA
marks the start of a zone of authority
Definition: rr.h:90
@ LDNS_RR_TYPE_SSHFP
SSH Key Fingerprint.
Definition: rr.h:166
@ LDNS_RR_TYPE_TSIG
Definition: rr.h:214
@ LDNS_RR_TYPE_X25
RFC1183.
Definition: rr.h:116
@ LDNS_RR_TYPE_WKS
a well known service description
Definition: rr.h:100
@ LDNS_RR_TYPE_TLSA
Definition: rr.h:179
@ LDNS_RR_TYPE_PX
RFC2163.
Definition: rr.h:130
@ LDNS_RR_TYPE_RT
RFC1183.
Definition: rr.h:120
@ LDNS_RR_TYPE_NSEC
Definition: rr.h:171
@ LDNS_RR_TYPE_DNAME
RFC2672.
Definition: rr.h:156
@ LDNS_RR_TYPE_OPENPGPKEY
Definition: rr.h:192
@ LDNS_RR_TYPE_AMTRELAY
draft-ietf-mboned-driad-amt-discovery
Definition: rr.h:229
@ LDNS_RR_TYPE_DS
RFC4034, RFC3658.
Definition: rr.h:164
@ LDNS_RR_TYPE_KEY
2535typecode
Definition: rr.h:128
@ LDNS_RR_TYPE_NULL
a null RR (EXPERIMENTAL)
Definition: rr.h:98
@ LDNS_RR_TYPE_NSEC3PARAM
Definition: rr.h:177
@ LDNS_RR_TYPE_RKEY
draft-reid-dnsext-rkey
Definition: rr.h:187
@ LDNS_RR_TYPE_NXT
2535typecode
Definition: rr.h:138
@ LDNS_RR_TYPE_DLV
Definition: rr.h:234
@ LDNS_RR_TYPE_SIG
2535typecode
Definition: rr.h:126
@ LDNS_RR_TYPE_CNAME
the canonical name for an alias
Definition: rr.h:88
@ LDNS_RR_TYPE_NID
Definition: rr.h:205
@ LDNS_RR_TYPE_NSEC3
Definition: rr.h:176
@ LDNS_RR_TYPE_DHCID
Definition: rr.h:174
@ LDNS_RR_TYPE_CDNSKEY
Definition: rr.h:191
@ LDNS_RR_TYPE_TA
DNSSEC Trust Authorities.
Definition: rr.h:232
@ LDNS_RR_TYPE_LOC
LOC record RFC1876.
Definition: rr.h:136
@ LDNS_RR_TYPE_TXT
text strings
Definition: rr.h:110
@ LDNS_RR_TYPE_PTR
a domain name pointer
Definition: rr.h:102
@ LDNS_RR_TYPE_AAAA
ipv6 address
Definition: rr.h:134
@ LDNS_RR_TYPE_EUI64
Definition: rr.h:211
@ LDNS_RR_TYPE_MD
a mail destination (Obsolete - use MX)
Definition: rr.h:84
@ LDNS_RR_TYPE_A6
RFC2874.
Definition: rr.h:154
@ LDNS_RR_TYPE_NS
an authoritative name server
Definition: rr.h:82
@ LDNS_RR_TYPE_MR
a mail rename domain name (EXPERIMENTAL)
Definition: rr.h:96
@ LDNS_RR_TYPE_CAA
Definition: rr.h:224
@ LDNS_RR_TYPE_SVCB
Definition: rr.h:195
@ LDNS_RR_TYPE_EUI48
Definition: rr.h:210
@ LDNS_RR_TYPE_HTTPS
Definition: rr.h:196
@ LDNS_RR_TYPE_MB
a mailbox domain name (EXPERIMENTAL)
Definition: rr.h:92
@ LDNS_RR_TYPE_NINFO
draft-reid-dnsext-zs
Definition: rr.h:185
@ LDNS_RR_TYPE_TALINK
draft-ietf-dnsop-trust-history
Definition: rr.h:189
@ LDNS_RR_TYPE_ATMA
http://www.jhsoft.com/rfc/af-saa-0069.000.rtf
Definition: rr.h:146
@ LDNS_RR_TYPE_HINFO
host information
Definition: rr.h:104
@ LDNS_RR_TYPE_CSYNC
Definition: rr.h:193
@ LDNS_RR_TYPE_EID
draft-ietf-nimrod-dns-01.txt
Definition: rr.h:140
@ LDNS_RR_TYPE_AFSDB
RFC1183.
Definition: rr.h:114
@ LDNS_RR_TYPE_L64
Definition: rr.h:207
@ LDNS_RR_TYPE_NSAP
RFC1706.
Definition: rr.h:122
@ LDNS_RR_TYPE_URI
Definition: rr.h:223
@ LDNS_RR_TYPE_AVC
Definition: rr.h:225
@ LDNS_RR_TYPE_CDS
Definition: rr.h:190
@ LDNS_RR_TYPE_NAPTR
RFC2915.
Definition: rr.h:148
@ LDNS_RR_TYPE_SMIMEA
Definition: rr.h:180
@ LDNS_RR_TYPE_SRV
SRV record RFC2782.
Definition: rr.h:144
@ LDNS_RR_TYPE_IPSECKEY
IPsec Key.
Definition: rr.h:168
@ LDNS_RR_TYPE_APL
RFC3123.
Definition: rr.h:162
@ LDNS_RR_TYPE_MX
mail exchange
Definition: rr.h:108
@ LDNS_RR_TYPE_NIMLOC
draft-ietf-nimrod-dns-01.txt
Definition: rr.h:142
@ LDNS_RR_TYPE_MG
a mail group member (EXPERIMENTAL)
Definition: rr.h:94
@ LDNS_RR_TYPE_NSAP_PTR
RFC1348.
Definition: rr.h:124
enum ldns_enum_rr_class ldns_rr_class
Definition: rr.h:61
#define LDNS_MAX_DOMAINLEN
Maximum length of a complete dname.
Definition: rr.h:33
@ LDNS_RR_CLASS_IN
the Internet
Definition: rr.h:47
Structure to do a Schwartzian-like transformation, for instance when sorting.
Definition: util.h:144
implementation of buffers to ease operations
Definition: buffer.h:51
uint8_t * _data
The data contained in the buffer.
Definition: buffer.h:62
A general purpose lookup table.
Definition: util.h:156
Resource record data field.
Definition: rdata.h:197
Contains all information about resource record types.
Definition: rr.h:351
uint8_t _maximum
Maximum number of rdata fields in the RRs of this type.
Definition: rr.h:359
const char * _name
Textual name of the RR type.
Definition: rr.h:355
ldns_rdf_type _variable
Special rdf types.
Definition: rr.h:363
ldns_rr_type _type
Type of the RR that is described here.
Definition: rr.h:353
uint8_t _minimum
Minimum number of rdata fields in the RRs of this type.
Definition: rr.h:357
const ldns_rdf_type * _wireformat
Wireformat specification for the rr, i.e.
Definition: rr.h:361
List or Set of Resource Records.
Definition: rr.h:338
size_t _rr_capacity
Definition: rr.h:340
ldns_rr ** _rrs
Definition: rr.h:341
size_t _rr_count
Definition: rr.h:339
Resource Record.
Definition: rr.h:310
bool _rr_question
question rr [it would be nicer if thous is after _rd_count] ABI change: Fix this in next major releas...
Definition: rr.h:327
ldns_rr_type _rr_type
the type of the RR.
Definition: rr.h:318
ldns_rdf * _owner
Owner name, uncompressed.
Definition: rr.h:312
ldns_rdf ** _rdata_fields
The array of rdata's.
Definition: rr.h:323
uint32_t _ttl
Time to live
Definition: rr.h:314
ldns_rr_class _rr_class
Class of the resource record.
Definition: rr.h:320
size_t _rd_count
Number of data fields.
Definition: rr.h:316
int ldns_hexstring_to_data(uint8_t *data, const char *str)
Converts a hex string to binary data.
Definition: util.c:138
ldns_lookup_table * ldns_lookup_by_name(ldns_lookup_table *table, const char *name)
Definition: util.c:30
#define INLINE
splint static inline workaround
Definition: util.h:42
#define LDNS_FREE(ptr)
Definition: util.h:60
#define LDNS_MALLOC(type)
Memory management macros.
Definition: util.h:49
#define LDNS_XMALLOC(type, count)
Definition: util.h:51
#define LDNS_XREALLOC(ptr, type, count)
Definition: util.h:57
ldns_status ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos)
converts the data on the uint8_t bytearray (in wire format) to DNS rdata fields, and adds them to the...
Definition: wire2host.c:158