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 
725 _ldns_rr_new_frm_fp_l_internal(ldns_rr **newrr, FILE *fp,
726  uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev,
727  int *line_nr, bool *explicit_ttl);
730  uint32_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev,
731  int *line_nr, bool *explicit_ttl)
732 {
733  char *line = NULL;
734  size_t limit = 0;
735  const char *endptr; /* unused */
736  ldns_rr *rr;
737  uint32_t ttl;
738  ldns_rdf *tmp;
739  ldns_status s;
740 
741  if (default_ttl) {
742  ttl = *default_ttl;
743  } else {
744  ttl = 0;
745  }
746  /* read an entire line in from the file */
747  if ((s = ldns_fget_token_l_st( fp, &line, &limit, false
748  , LDNS_PARSE_SKIP_SPACE, line_nr))) {
749  LDNS_FREE(line);
750  return s;
751  }
752 
753  if (strncmp(line, "$ORIGIN", 7) == 0 && isspace((unsigned char)line[7])) {
754  if (*origin) {
755  ldns_rdf_deep_free(*origin);
756  *origin = NULL;
757  }
759  ldns_strip_ws(line + 8));
760  if (!tmp) {
761  /* could not parse what next to $ORIGIN */
762  LDNS_FREE(line);
764  }
765  *origin = tmp;
767  } else if (strncmp(line, "$TTL", 4) == 0 && isspace((unsigned char)line[4])) {
768  if (default_ttl) {
769  *default_ttl = ldns_str2period(
770  ldns_strip_ws(line + 5), &endptr);
771  }
773  } else if (strncmp(line, "$INCLUDE", 8) == 0) {
775  } else if (!*ldns_strip_ws(line)) {
776  LDNS_FREE(line);
778  } else {
779  if (origin && *origin) {
780  s = ldns_rr_new_frm_str_internal(&rr, (const char*)line,
781  ttl, *origin, prev, false, explicit_ttl);
782  } else {
783  s = ldns_rr_new_frm_str_internal(&rr, (const char*)line,
784  ttl, NULL, prev, false, explicit_ttl);
785  }
786  }
787  LDNS_FREE(line);
788  if (s == LDNS_STATUS_OK) {
789  if (newrr) {
790  *newrr = rr;
791  } else {
792  /* Just testing if it would parse? */
793  ldns_rr_free(rr);
794  }
795  }
796  return s;
797 }
798 
800 ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl,
801  ldns_rdf **origin, ldns_rdf **prev, int *line_nr)
802 {
803  return _ldns_rr_new_frm_fp_l_internal(newrr, fp, default_ttl, origin,
804  prev, line_nr, NULL);
805 }
806 
807 void
809 {
810  rr->_owner = owner;
811 }
812 
813 void
814 ldns_rr_set_question(ldns_rr *rr, bool question)
815 {
816  rr->_rr_question = question;
817 }
818 
819 void
820 ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
821 {
822  rr->_ttl = ttl;
823 }
824 
825 void
826 ldns_rr_set_rd_count(ldns_rr *rr, size_t count)
827 {
828  rr->_rd_count = count;
829 }
830 
831 void
833 {
834  rr->_rr_type = rr_type;
835 }
836 
837 void
839 {
840  rr->_rr_class = rr_class;
841 }
842 
843 ldns_rdf *
844 ldns_rr_set_rdf(ldns_rr *rr, const ldns_rdf *f, size_t position)
845 {
846  size_t rd_count;
847  ldns_rdf *pop;
848 
849  rd_count = ldns_rr_rd_count(rr);
850  if (position < rd_count) {
851  /* discard the old one */
852  pop = rr->_rdata_fields[position];
853  rr->_rdata_fields[position] = (ldns_rdf*)f;
854  return pop;
855  } else {
856  return NULL;
857  }
858 }
859 
860 bool
862 {
863  size_t rd_count;
864  ldns_rdf **rdata_fields;
865 
866  rd_count = ldns_rr_rd_count(rr);
867 
868  /* grow the array */
869  rdata_fields = LDNS_XREALLOC(
870  rr->_rdata_fields, ldns_rdf *, rd_count + 1);
871  if (!rdata_fields) {
872  return false;
873  }
874 
875  /* add the new member */
876  rr->_rdata_fields = rdata_fields;
877  rr->_rdata_fields[rd_count] = (ldns_rdf*)f;
878 
879  ldns_rr_set_rd_count(rr, rd_count + 1);
880  return true;
881 }
882 
883 ldns_rdf *
885 {
886  size_t rd_count;
887  ldns_rdf *pop;
888  ldns_rdf** newrd;
889 
890  rd_count = ldns_rr_rd_count(rr);
891 
892  if (rd_count == 0) {
893  return NULL;
894  }
895 
896  pop = rr->_rdata_fields[rd_count - 1];
897 
898  /* try to shrink the array */
899  if(rd_count > 1) {
900  newrd = LDNS_XREALLOC(
901  rr->_rdata_fields, ldns_rdf *, rd_count - 1);
902  if(newrd)
903  rr->_rdata_fields = newrd;
904  } else {
906  }
907 
908  ldns_rr_set_rd_count(rr, rd_count - 1);
909  return pop;
910 }
911 
912 ldns_rdf *
913 ldns_rr_rdf(const ldns_rr *rr, size_t nr)
914 {
915  if (rr && nr < ldns_rr_rd_count(rr)) {
916  return rr->_rdata_fields[nr];
917  } else {
918  return NULL;
919  }
920 }
921 
922 ldns_rdf *
924 {
925  return rr->_owner;
926 }
927 
928 bool
930 {
931  return rr->_rr_question;
932 }
933 
934 uint32_t
936 {
937  return rr->_ttl;
938 }
939 
940 size_t
942 {
943  return rr->_rd_count;
944 }
945 
948 {
949  return rr->_rr_type;
950 }
951 
954 {
955  return rr->_rr_class;
956 }
957 
958 /* rr_lists */
959 
960 size_t
962 {
963  if (rr_list) {
964  return rr_list->_rr_count;
965  } else {
966  return 0;
967  }
968 }
969 
970 ldns_rr *
971 ldns_rr_list_set_rr(ldns_rr_list *rr_list, const ldns_rr *r, size_t count)
972 {
973  ldns_rr *old;
974 
975  if (count > ldns_rr_list_rr_count(rr_list)) {
976  return NULL;
977  }
978 
979  old = ldns_rr_list_rr(rr_list, count);
980 
981  /* overwrite old's pointer */
982  rr_list->_rrs[count] = (ldns_rr*)r;
983  return old;
984 }
985 
986 void
988 {
989  assert(count <= rr_list->_rr_capacity);
990  rr_list->_rr_count = count;
991 }
992 
993 ldns_rr *
994 ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr)
995 {
996  if (nr < ldns_rr_list_rr_count(rr_list)) {
997  return rr_list->_rrs[nr];
998  } else {
999  return NULL;
1000  }
1001 }
1002 
1003 ldns_rr_list *
1005 {
1007  if(!rr_list) return NULL;
1008  rr_list->_rr_count = 0;
1009  rr_list->_rr_capacity = 0;
1010  rr_list->_rrs = NULL;
1011  return rr_list;
1012 }
1013 
1014 void
1016 {
1017  if (rr_list) {
1018  LDNS_FREE(rr_list->_rrs);
1019  LDNS_FREE(rr_list);
1020  }
1021 }
1022 
1023 void
1025 {
1026  size_t i;
1027 
1028  if (rr_list) {
1029  for (i=0; i < ldns_rr_list_rr_count(rr_list); i++) {
1030  ldns_rr_free(ldns_rr_list_rr(rr_list, i));
1031  }
1032  LDNS_FREE(rr_list->_rrs);
1033  LDNS_FREE(rr_list);
1034  }
1035 }
1036 
1037 
1038 /* add right to left. So we modify *left! */
1039 bool
1041 {
1042  size_t r_rr_count;
1043  size_t i;
1044 
1045  if (!left) {
1046  return false;
1047  }
1048 
1049  if (right) {
1050  r_rr_count = ldns_rr_list_rr_count(right);
1051  } else {
1052  r_rr_count = 0;
1053  }
1054 
1055  /* push right to left */
1056  for(i = 0; i < r_rr_count; i++) {
1057  ldns_rr_list_push_rr(left, ldns_rr_list_rr(right, i));
1058  }
1059  return true;
1060 }
1061 
1062 ldns_rr_list *
1064 {
1065  size_t l_rr_count;
1066  size_t r_rr_count;
1067  size_t i;
1068  ldns_rr_list *cat;
1069 
1070  if (left) {
1071  l_rr_count = ldns_rr_list_rr_count(left);
1072  } else {
1073  return ldns_rr_list_clone(right);
1074  }
1075 
1076  if (right) {
1077  r_rr_count = ldns_rr_list_rr_count(right);
1078  } else {
1079  r_rr_count = 0;
1080  }
1081 
1082  cat = ldns_rr_list_new();
1083 
1084  if (!cat) {
1085  return NULL;
1086  }
1087 
1088  /* left */
1089  for(i = 0; i < l_rr_count; i++) {
1091  ldns_rr_clone(ldns_rr_list_rr(left, i)));
1092  }
1093  /* right */
1094  for(i = 0; i < r_rr_count; i++) {
1096  ldns_rr_clone(ldns_rr_list_rr(right, i)));
1097  }
1098  return cat;
1099 }
1100 
1101 ldns_rr_list *
1102 ldns_rr_list_subtype_by_rdf(const ldns_rr_list *l, const ldns_rdf *r, size_t pos)
1103 {
1104  size_t i;
1105  ldns_rr_list *subtyped;
1106  ldns_rdf *list_rdf;
1107 
1108  subtyped = ldns_rr_list_new();
1109 
1110  for(i = 0; i < ldns_rr_list_rr_count(l); i++) {
1111  list_rdf = ldns_rr_rdf(
1112  ldns_rr_list_rr(l, i),
1113  pos);
1114  if (!list_rdf) {
1115  /* pos is too large or any other error */
1116  ldns_rr_list_deep_free(subtyped);
1117  return NULL;
1118  }
1119 
1120  if (ldns_rdf_compare(list_rdf, r) == 0) {
1121  /* a match */
1122  ldns_rr_list_push_rr(subtyped,
1124  }
1125  }
1126 
1127  if (ldns_rr_list_rr_count(subtyped) > 0) {
1128  return subtyped;
1129  } else {
1130  ldns_rr_list_free(subtyped);
1131  return NULL;
1132  }
1133 }
1134 
1135 bool
1137 {
1138  size_t rr_count;
1139  size_t cap;
1140 
1141  rr_count = ldns_rr_list_rr_count(rr_list);
1142  cap = rr_list->_rr_capacity;
1143 
1144  /* grow the array */
1145  if(rr_count+1 > cap) {
1146  ldns_rr **rrs;
1147 
1148  if(cap == 0)
1149  cap = LDNS_RRLIST_INIT; /* initial list size */
1150  else cap *= 2;
1151  rrs = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
1152  if (!rrs) {
1153  return false;
1154  }
1155  rr_list->_rrs = rrs;
1156  rr_list->_rr_capacity = cap;
1157  }
1158 
1159  /* add the new member */
1160  rr_list->_rrs[rr_count] = (ldns_rr*)rr;
1161 
1162  ldns_rr_list_set_rr_count(rr_list, rr_count + 1);
1163  return true;
1164 }
1165 
1166 bool
1168 {
1169  size_t i;
1170 
1171  for(i = 0; i < ldns_rr_list_rr_count(push_list); i++) {
1172  if (!ldns_rr_list_push_rr(rr_list,
1173  ldns_rr_list_rr(push_list, i))) {
1174  return false;
1175  }
1176  }
1177  return true;
1178 }
1179 
1180 ldns_rr *
1182 {
1183  size_t rr_count;
1184  size_t cap;
1185  ldns_rr *pop;
1186 
1187  rr_count = ldns_rr_list_rr_count(rr_list);
1188 
1189  if (rr_count == 0) {
1190  return NULL;
1191  }
1192 
1193  cap = rr_list->_rr_capacity;
1194  pop = ldns_rr_list_rr(rr_list, rr_count - 1);
1195 
1196  /* shrink the array */
1197  if(cap > LDNS_RRLIST_INIT && rr_count-1 <= cap/2) {
1198  ldns_rr** a;
1199  cap /= 2;
1200  a = LDNS_XREALLOC(rr_list->_rrs, ldns_rr *, cap);
1201  if(a) {
1202  rr_list->_rrs = a;
1203  rr_list->_rr_capacity = cap;
1204  }
1205  /* if the realloc fails, the capacity for the list remains unchanged */
1206  }
1207 
1208  ldns_rr_list_set_rr_count(rr_list, rr_count - 1);
1209 
1210  return pop;
1211 }
1212 
1213 ldns_rr_list *
1214 ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t howmany)
1215 {
1216  /* pop a number of rr's and put them in a rr_list */
1217  ldns_rr_list *popped;
1218  ldns_rr *p;
1219  size_t i = howmany;
1220 
1221  popped = ldns_rr_list_new();
1222 
1223  if (!popped) {
1224  return NULL;
1225  }
1226 
1227 
1228  while(i > 0 &&
1229  (p = ldns_rr_list_pop_rr(rr_list)) != NULL) {
1230  ldns_rr_list_push_rr(popped, p);
1231  i--;
1232  }
1233 
1234  if (i == howmany) { /* so i <= 0 */
1235  ldns_rr_list_free(popped);
1236  return NULL;
1237  } else {
1238  return popped;
1239  }
1240 }
1241 
1242 
1243 bool
1245 {
1246  size_t i;
1247 
1248  if (!rr_list || !rr || ldns_rr_list_rr_count(rr_list) == 0) {
1249  return false;
1250  }
1251 
1252  for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1253  if (rr == ldns_rr_list_rr(rr_list, i)) {
1254  return true;
1255  } else if (ldns_rr_compare(rr, ldns_rr_list_rr(rr_list, i)) == 0) {
1256  return true;
1257  }
1258  }
1259  return false;
1260 }
1261 
1262 bool
1264 {
1265  ldns_rr_type t;
1266  ldns_rr_class c;
1267  ldns_rdf *o;
1268  ldns_rr *tmp;
1269  size_t i;
1270 
1271  if (!rr_list || ldns_rr_list_rr_count(rr_list) == 0) {
1272  return false;
1273  }
1274 
1275  tmp = ldns_rr_list_rr(rr_list, 0);
1276 
1277  t = ldns_rr_get_type(tmp);
1278  c = ldns_rr_get_class(tmp);
1279  o = ldns_rr_owner(tmp);
1280 
1281  /* compare these with the rest of the rr_list, start with 1 */
1282  for (i = 1; i < ldns_rr_list_rr_count(rr_list); i++) {
1283  tmp = ldns_rr_list_rr(rr_list, i);
1284  if (t != ldns_rr_get_type(tmp)) {
1285  return false;
1286  }
1287  if (c != ldns_rr_get_class(tmp)) {
1288  return false;
1289  }
1290  if (ldns_rdf_compare(o, ldns_rr_owner(tmp)) != 0) {
1291  return false;
1292  }
1293  }
1294  return true;
1295 }
1296 
1297 bool
1299 {
1300  size_t rr_count;
1301  size_t i;
1302  ldns_rr *last;
1303 
1304  assert(rr != NULL);
1305 
1306  rr_count = ldns_rr_list_rr_count(rr_list);
1307 
1308  if (rr_count == 0) {
1309  /* nothing there, so checking it is
1310  * not needed */
1311  return ldns_rr_list_push_rr(rr_list, rr);
1312  } else {
1313  /* check with the final rr in the rr_list */
1314  last = ldns_rr_list_rr(rr_list, rr_count - 1);
1315 
1316  if (ldns_rr_get_class(last) != ldns_rr_get_class(rr)) {
1317  return false;
1318  }
1319  if (ldns_rr_get_type(last) != ldns_rr_get_type(rr)) {
1320  return false;
1321  }
1322  /* only check if not equal to RRSIG */
1323  if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) {
1324  if (ldns_rr_ttl(last) != ldns_rr_ttl(rr)) {
1325  return false;
1326  }
1327  }
1328  if (ldns_rdf_compare(ldns_rr_owner(last),
1329  ldns_rr_owner(rr)) != 0) {
1330  return false;
1331  }
1332  /* ok, still alive - check if the rr already
1333  * exists - if so, don't add it */
1334  for(i = 0; i < rr_count; i++) {
1335  if(ldns_rr_compare(
1336  ldns_rr_list_rr(rr_list, i), rr) == 0) {
1337  return false;
1338  }
1339  }
1340  /* it's safe, push it */
1341  return ldns_rr_list_push_rr(rr_list, rr);
1342  }
1343 }
1344 
1345 ldns_rr *
1347 {
1348  return ldns_rr_list_pop_rr(rr_list);
1349 }
1350 
1351 ldns_rr_list *
1353 {
1354  ldns_rr_list *rrset;
1355  ldns_rr *last_rr = NULL;
1356  ldns_rr *next_rr;
1357 
1358  if (!rr_list) {
1359  return NULL;
1360  }
1361 
1362  rrset = ldns_rr_list_new();
1363  if (!last_rr) {
1364  last_rr = ldns_rr_list_pop_rr(rr_list);
1365  if (!last_rr) {
1366  ldns_rr_list_free(rrset);
1367  return NULL;
1368  } else {
1369  ldns_rr_list_push_rr(rrset, last_rr);
1370  }
1371  }
1372 
1373  if (ldns_rr_list_rr_count(rr_list) > 0) {
1374  next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
1375  } else {
1376  next_rr = NULL;
1377  }
1378 
1379  while (next_rr) {
1380  if (
1382  ldns_rr_owner(last_rr)) == 0
1383  &&
1384  ldns_rr_get_type(next_rr) == ldns_rr_get_type(last_rr)
1385  &&
1386  ldns_rr_get_class(next_rr) == ldns_rr_get_class(last_rr)
1387  ) {
1388  ldns_rr_list_push_rr(rrset, ldns_rr_list_pop_rr(rr_list));
1389  if (ldns_rr_list_rr_count(rr_list) > 0) {
1390  last_rr = next_rr;
1391  next_rr = ldns_rr_list_rr(rr_list, ldns_rr_list_rr_count(rr_list) - 1);
1392  } else {
1393  next_rr = NULL;
1394  }
1395  } else {
1396  next_rr = NULL;
1397  }
1398  }
1399 
1400  return rrset;
1401 }
1402 
1403 ldns_rr *
1405 {
1406  size_t i;
1407  ldns_rr *new_rr;
1408 
1409  if (!rr) {
1410  return NULL;
1411  }
1412 
1413  new_rr = ldns_rr_new();
1414  if (!new_rr) {
1415  return NULL;
1416  }
1417  if (ldns_rr_owner(rr)) {
1419  }
1420  ldns_rr_set_ttl(new_rr, ldns_rr_ttl(rr));
1421  ldns_rr_set_type(new_rr, ldns_rr_get_type(rr));
1422  ldns_rr_set_class(new_rr, ldns_rr_get_class(rr));
1424 
1425  for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1426  if (ldns_rr_rdf(rr,i)) {
1427  ldns_rr_push_rdf(new_rr, ldns_rdf_clone(ldns_rr_rdf(rr, i)));
1428  }
1429  }
1430 
1431  return new_rr;
1432 }
1433 
1434 ldns_rr_list *
1436 {
1437  size_t i;
1438  ldns_rr_list *new_list;
1439  ldns_rr *r;
1440 
1441  if (!rrlist) {
1442  return NULL;
1443  }
1444 
1445  new_list = ldns_rr_list_new();
1446  if (!new_list) {
1447  return NULL;
1448  }
1449  for (i = 0; i < ldns_rr_list_rr_count(rrlist); i++) {
1450  r = ldns_rr_clone(
1451  ldns_rr_list_rr(rrlist, i)
1452  );
1453  if (!r) {
1454  /* huh, failure in cloning */
1455  ldns_rr_list_deep_free(new_list);
1456  return NULL;
1457  }
1458  ldns_rr_list_push_rr(new_list, r);
1459  }
1460  return new_list;
1461 }
1462 
1463 
1464 static int
1465 qsort_schwartz_rr_compare(const void *a, const void *b)
1466 {
1467  int result = 0;
1468  ldns_rr *rr1, *rr2;
1469  ldns_buffer *rr1_buf, *rr2_buf;
1472  /* if we are doing 2wire, we need to do lowercasing on the dname (and maybe on the rdata)
1473  * this must be done for comparison only, so we need to have a temp var for both buffers,
1474  * which is only used when the transformed object value isn't there yet
1475  */
1476  ldns_rr *canonical_a, *canonical_b;
1477 
1478  rr1 = (ldns_rr *) sa->original_object;
1479  rr2 = (ldns_rr *) sb->original_object;
1480 
1481  result = ldns_rr_compare_no_rdata(rr1, rr2);
1482 
1483  if (result == 0) {
1484  if (!sa->transformed_object) {
1485  canonical_a = ldns_rr_clone(sa->original_object);
1486  ldns_rr2canonical(canonical_a);
1490  sa->transformed_object = NULL;
1491  ldns_rr_free(canonical_a);
1492  return 0;
1493  }
1494  ldns_rr_free(canonical_a);
1495  }
1496  if (!sb->transformed_object) {
1497  canonical_b = ldns_rr_clone(sb->original_object);
1498  ldns_rr2canonical(canonical_b);
1503  sa->transformed_object = NULL;
1504  sb->transformed_object = NULL;
1505  ldns_rr_free(canonical_b);
1506  return 0;
1507  }
1508  ldns_rr_free(canonical_b);
1509  }
1510  rr1_buf = (ldns_buffer *) sa->transformed_object;
1511  rr2_buf = (ldns_buffer *) sb->transformed_object;
1512 
1513  result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
1514  }
1515 
1516  return result;
1517 }
1518 
1519 void
1521 {
1522  struct ldns_schwartzian_compare_struct **sortables;
1523  size_t item_count;
1524  size_t i;
1525 
1526  if (unsorted) {
1527  item_count = ldns_rr_list_rr_count(unsorted);
1528 
1529  sortables = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct *,
1530  item_count);
1531  if(!sortables) return; /* no way to return error */
1532  for (i = 0; i < item_count; i++) {
1533  sortables[i] = LDNS_XMALLOC(struct ldns_schwartzian_compare_struct, 1);
1534  if(!sortables[i]) {
1535  /* free the allocated parts */
1536  while(i>0) {
1537  i--;
1538  LDNS_FREE(sortables[i]);
1539  }
1540  /* no way to return error */
1541  LDNS_FREE(sortables);
1542  return;
1543  }
1544  sortables[i]->original_object = ldns_rr_list_rr(unsorted, i);
1545  sortables[i]->transformed_object = NULL;
1546  }
1547  qsort(sortables,
1548  item_count,
1549  sizeof(struct ldns_schwartzian_compare_struct *),
1550  qsort_schwartz_rr_compare);
1551  for (i = 0; i < item_count; i++) {
1552  unsorted->_rrs[i] = sortables[i]->original_object;
1553  if (sortables[i]->transformed_object) {
1554  ldns_buffer_free(sortables[i]->transformed_object);
1555  }
1556  LDNS_FREE(sortables[i]);
1557  }
1558  LDNS_FREE(sortables);
1559  }
1560 }
1561 
1562 int
1564 {
1565  size_t rr1_len;
1566  size_t rr2_len;
1567  size_t offset;
1568 
1569  assert(rr1 != NULL);
1570  assert(rr2 != NULL);
1571 
1572  rr1_len = ldns_rr_uncompressed_size(rr1);
1573  rr2_len = ldns_rr_uncompressed_size(rr2);
1574 
1575  if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) < 0) {
1576  return -1;
1577  } else if (ldns_dname_compare(ldns_rr_owner(rr1), ldns_rr_owner(rr2)) > 0) {
1578  return 1;
1579  }
1580 
1581  /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
1582  if (ldns_rr_get_class(rr1) != ldns_rr_get_class(rr2)) {
1583  return ldns_rr_get_class(rr1) - ldns_rr_get_class(rr2);
1584  }
1585 
1586  /* should return -1 if rr1 comes before rr2, so need to do rr1 - rr2, not rr2 - rr1 */
1587  if (ldns_rr_get_type(rr1) != ldns_rr_get_type(rr2)) {
1588  return ldns_rr_get_type(rr1) - ldns_rr_get_type(rr2);
1589  }
1590 
1591  /* offset is the owername length + ttl + type + class + rdlen == start of wire format rdata */
1592  offset = ldns_rdf_size(ldns_rr_owner(rr1)) + 4 + 2 + 2 + 2;
1593  /* if either record doesn't have any RDATA... */
1594  if (offset > rr1_len || offset > rr2_len) {
1595  if (rr1_len == rr2_len) {
1596  return 0;
1597  }
1598  return ((int) rr2_len - (int) rr1_len);
1599  }
1600 
1601  return 0;
1602 }
1603 
1604 int ldns_rr_compare_wire(const ldns_buffer *rr1_buf, const ldns_buffer *rr2_buf)
1605 {
1606  size_t rr1_len, rr2_len, min_len, i, offset;
1607 
1608  rr1_len = ldns_buffer_capacity(rr1_buf);
1609  rr2_len = ldns_buffer_capacity(rr2_buf);
1610 
1611  /* jump past dname (checked in earlier part)
1612  * and especially past TTL */
1613  offset = 0;
1614  while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0) {
1615  offset += *ldns_buffer_at(rr1_buf, offset) + 1;
1616  }
1617  /* jump to rdata section (PAST the rdata length field, otherwise
1618  rrs with different lengths might be sorted erroneously */
1619  offset += 11;
1620  min_len = (rr1_len < rr2_len) ? rr1_len : rr2_len;
1621  /* Compare RRs RDATA byte for byte. */
1622  for(i = offset; i < min_len; i++) {
1623  if (*ldns_buffer_at(rr1_buf,i) < *ldns_buffer_at(rr2_buf,i)) {
1624  return -1;
1625  } else if (*ldns_buffer_at(rr1_buf,i) > *ldns_buffer_at(rr2_buf,i)) {
1626  return +1;
1627  }
1628  }
1629 
1630  /* If both RDATAs are the same up to min_len, then the shorter one sorts first. */
1631  if (rr1_len < rr2_len) {
1632  return -1;
1633  } else if (rr1_len > rr2_len) {
1634  return +1;
1635  }
1636  /* The RDATAs are equal. */
1637  return 0;
1638 
1639 }
1640 
1641 int
1642 ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
1643 {
1644  int result;
1645  size_t rr1_len, rr2_len;
1646 
1647  ldns_buffer *rr1_buf;
1648  ldns_buffer *rr2_buf;
1649 
1650  result = ldns_rr_compare_no_rdata(rr1, rr2);
1651  if (result == 0) {
1652  rr1_len = ldns_rr_uncompressed_size(rr1);
1653  rr2_len = ldns_rr_uncompressed_size(rr2);
1654 
1655  rr1_buf = ldns_buffer_new(rr1_len);
1656  rr2_buf = ldns_buffer_new(rr2_len);
1657 
1658  if (ldns_rr2buffer_wire_canonical(rr1_buf,
1659  rr1,
1661  != LDNS_STATUS_OK) {
1662  ldns_buffer_free(rr1_buf);
1663  ldns_buffer_free(rr2_buf);
1664  return 0;
1665  }
1666  if (ldns_rr2buffer_wire_canonical(rr2_buf,
1667  rr2,
1669  != LDNS_STATUS_OK) {
1670  ldns_buffer_free(rr1_buf);
1671  ldns_buffer_free(rr2_buf);
1672  return 0;
1673  }
1674 
1675  result = ldns_rr_compare_wire(rr1_buf, rr2_buf);
1676 
1677  ldns_buffer_free(rr1_buf);
1678  ldns_buffer_free(rr2_buf);
1679  }
1680 
1681  return result;
1682 }
1683 
1684 /* convert dnskey to a ds with the given algorithm,
1685  * then compare the result with the given ds */
1686 static int
1687 ldns_rr_compare_ds_dnskey(ldns_rr *ds,
1688  ldns_rr *dnskey)
1689 {
1690  ldns_rr *ds_gen;
1691  bool result = false;
1692  ldns_hash algo;
1693 
1694  if (!dnskey || !ds ||
1697  return false;
1698  }
1699 
1700  if (ldns_rr_rdf(ds, 2) == NULL) {
1701  return false;
1702  }
1703  algo = ldns_rdf2native_int8(ldns_rr_rdf(ds, 2));
1704 
1705  ds_gen = ldns_key_rr2ds(dnskey, algo);
1706  if (ds_gen) {
1707  result = ldns_rr_compare(ds, ds_gen) == 0;
1708  ldns_rr_free(ds_gen);
1709  }
1710  return result;
1711 }
1712 
1713 bool
1714 ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
1715 {
1716  bool result;
1717  ldns_rr *rr1 = ldns_rr_clone(orr1);
1718  ldns_rr *rr2 = ldns_rr_clone(orr2);
1719 
1720  /* set ttls to zero */
1721  ldns_rr_set_ttl(rr1, 0);
1722  ldns_rr_set_ttl(rr2, 0);
1723 
1724  if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DS &&
1726  result = ldns_rr_compare_ds_dnskey(rr1, rr2);
1727  } else if (ldns_rr_get_type(rr1) == LDNS_RR_TYPE_DNSKEY &&
1729  result = ldns_rr_compare_ds_dnskey(rr2, rr1);
1730  } else {
1731  result = (ldns_rr_compare(rr1, rr2) == 0);
1732  }
1733 
1734  ldns_rr_free(rr1);
1735  ldns_rr_free(rr2);
1736 
1737  return result;
1738 }
1739 
1740 int
1742 {
1743  size_t i = 0;
1744  int rr_cmp;
1745 
1746  assert(rrl1 != NULL);
1747  assert(rrl2 != NULL);
1748 
1749  for (i = 0; i < ldns_rr_list_rr_count(rrl1) && i < ldns_rr_list_rr_count(rrl2); i++) {
1750  rr_cmp = ldns_rr_compare(ldns_rr_list_rr(rrl1, i), ldns_rr_list_rr(rrl2, i));
1751  if (rr_cmp != 0) {
1752  return rr_cmp;
1753  }
1754  }
1755 
1756  if (i == ldns_rr_list_rr_count(rrl1) &&
1757  i != ldns_rr_list_rr_count(rrl2)) {
1758  return 1;
1759  } else if (i == ldns_rr_list_rr_count(rrl2) &&
1760  i != ldns_rr_list_rr_count(rrl1)) {
1761  return -1;
1762  } else {
1763  return 0;
1764  }
1765 }
1766 
1767 size_t
1769 {
1770  size_t rrsize;
1771  size_t i;
1772 
1773  rrsize = 0;
1774  /* add all the rdf sizes */
1775  for(i = 0; i < ldns_rr_rd_count(r); i++) {
1776  rrsize += ldns_rdf_size(ldns_rr_rdf(r, i));
1777  }
1778  /* ownername */
1779  rrsize += ldns_rdf_size(ldns_rr_owner(r));
1780  rrsize += LDNS_RR_OVERHEAD;
1781  return rrsize;
1782 }
1783 
1784 void
1786 {
1787  uint16_t i;
1788 
1789  if (!rr) {
1790  return;
1791  }
1792 
1794 
1795  /*
1796  * lowercase the rdata dnames if the rr type is one
1797  * of the list in chapter 7 of RFC3597
1798  * Also added RRSIG, because a "Signer's Name" should be canonicalized
1799  * too. See dnssec-bis-updates-16. We can add it to this list because
1800  * the "Signer's Name" is the only dname type rdata field in a RRSIG.
1801  */
1802  switch(ldns_rr_get_type(rr)) {
1803  case LDNS_RR_TYPE_NS:
1804  case LDNS_RR_TYPE_MD:
1805  case LDNS_RR_TYPE_MF:
1806  case LDNS_RR_TYPE_CNAME:
1807  case LDNS_RR_TYPE_SOA:
1808  case LDNS_RR_TYPE_MB:
1809  case LDNS_RR_TYPE_MG:
1810  case LDNS_RR_TYPE_MR:
1811  case LDNS_RR_TYPE_PTR:
1812  case LDNS_RR_TYPE_MINFO:
1813  case LDNS_RR_TYPE_MX:
1814  case LDNS_RR_TYPE_RP:
1815  case LDNS_RR_TYPE_AFSDB:
1816  case LDNS_RR_TYPE_RT:
1817  case LDNS_RR_TYPE_SIG:
1818  case LDNS_RR_TYPE_PX:
1819  case LDNS_RR_TYPE_NXT:
1820  case LDNS_RR_TYPE_NAPTR:
1821  case LDNS_RR_TYPE_KX:
1822  case LDNS_RR_TYPE_SRV:
1823  case LDNS_RR_TYPE_DNAME:
1824  case LDNS_RR_TYPE_A6:
1825  case LDNS_RR_TYPE_RRSIG:
1826  for (i = 0; i < ldns_rr_rd_count(rr); i++) {
1828  }
1829  return;
1830  default:
1831  /* do nothing */
1832  return;
1833  }
1834 }
1835 
1836 void
1838 {
1839  size_t i;
1840  for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++) {
1841  ldns_rr2canonical(ldns_rr_list_rr(rr_list, i));
1842  }
1843 }
1844 
1845 uint8_t
1847 {
1848  if (!rr) {
1849  return 0;
1850  }
1851  return ldns_dname_label_count(
1852  ldns_rr_owner(rr));
1853 }
1854 
1856 static const ldns_rdf_type type_0_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
1857 static const ldns_rdf_type type_a_wireformat[] = { LDNS_RDF_TYPE_A };
1858 static const ldns_rdf_type type_ns_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1859 static const ldns_rdf_type type_md_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1860 static const ldns_rdf_type type_mf_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1861 static const ldns_rdf_type type_cname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1862 static const ldns_rdf_type type_soa_wireformat[] = {
1866 };
1867 static const ldns_rdf_type type_mb_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1868 static const ldns_rdf_type type_mg_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1869 static const ldns_rdf_type type_mr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1870 static const ldns_rdf_type type_wks_wireformat[] = {
1872 };
1873 static const ldns_rdf_type type_ptr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1874 static const ldns_rdf_type type_hinfo_wireformat[] = {
1876 };
1877 static const ldns_rdf_type type_minfo_wireformat[] = {
1879 };
1880 static const ldns_rdf_type type_mx_wireformat[] = {
1882 };
1883 static const ldns_rdf_type type_rp_wireformat[] = {
1885 };
1886 static const ldns_rdf_type type_afsdb_wireformat[] = {
1888 };
1889 static const ldns_rdf_type type_x25_wireformat[] = { LDNS_RDF_TYPE_STR };
1890 static const ldns_rdf_type type_isdn_wireformat[] = {
1892 };
1893 static const ldns_rdf_type type_rt_wireformat[] = {
1895 };
1896 static const ldns_rdf_type type_nsap_wireformat[] = {
1898 };
1899 static const ldns_rdf_type type_nsap_ptr_wireformat[] = {
1901 };
1902 static const ldns_rdf_type type_sig_wireformat[] = {
1906 };
1907 static const ldns_rdf_type type_key_wireformat[] = {
1909 };
1910 static const ldns_rdf_type type_px_wireformat[] = {
1912 };
1913 static const ldns_rdf_type type_gpos_wireformat[] = {
1915 };
1916 static const ldns_rdf_type type_aaaa_wireformat[] = { LDNS_RDF_TYPE_AAAA };
1917 static const ldns_rdf_type type_loc_wireformat[] = { LDNS_RDF_TYPE_LOC };
1918 static const ldns_rdf_type type_nxt_wireformat[] = {
1920 };
1921 static const ldns_rdf_type type_eid_wireformat[] = {
1923 };
1924 static const ldns_rdf_type type_nimloc_wireformat[] = {
1926 };
1927 static const ldns_rdf_type type_srv_wireformat[] = {
1929 };
1930 static const ldns_rdf_type type_atma_wireformat[] = {
1932 };
1933 static const ldns_rdf_type type_naptr_wireformat[] = {
1935 };
1936 static const ldns_rdf_type type_kx_wireformat[] = {
1938 };
1939 static const ldns_rdf_type type_cert_wireformat[] = {
1941 };
1942 static const ldns_rdf_type type_a6_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
1943 static const ldns_rdf_type type_dname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
1944 static const ldns_rdf_type type_sink_wireformat[] = { LDNS_RDF_TYPE_INT8,
1946 };
1947 static const ldns_rdf_type type_apl_wireformat[] = {
1949 };
1950 static const ldns_rdf_type type_ds_wireformat[] = {
1952 };
1953 static const ldns_rdf_type type_sshfp_wireformat[] = {
1955 };
1956 static const ldns_rdf_type type_ipseckey_wireformat[] = {
1958 };
1959 static const ldns_rdf_type type_rrsig_wireformat[] = {
1962 };
1963 static const ldns_rdf_type type_nsec_wireformat[] = {
1965 };
1966 static const ldns_rdf_type type_dhcid_wireformat[] = {
1968 };
1969 static const ldns_rdf_type type_talink_wireformat[] = {
1971 };
1972 #ifdef RRTYPE_OPENPGPKEY
1973 static const ldns_rdf_type type_openpgpkey_wireformat[] = {
1975 };
1976 #endif
1977 static const ldns_rdf_type type_csync_wireformat[] = {
1979 };
1980 static const ldns_rdf_type type_zonemd_wireformat[] = {
1983 };
1984 #ifdef RRTYPE_SVCB_HTTPS
1985 static const ldns_rdf_type type_svcb_wireformat[] = {
1989 };
1990 #endif
1991 /* nsec3 is some vars, followed by same type of data of nsec */
1992 static const ldns_rdf_type type_nsec3_wireformat[] = {
1993 /* LDNS_RDF_TYPE_NSEC3_VARS, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC*/
1995 };
1996 
1997 static const ldns_rdf_type type_nsec3param_wireformat[] = {
1998 /* LDNS_RDF_TYPE_NSEC3_PARAMS_VARS*/
2003 };
2004 
2005 static const ldns_rdf_type type_dnskey_wireformat[] = {
2010 };
2011 static const ldns_rdf_type type_tkey_wireformat[] = {
2019 };
2020 static const ldns_rdf_type type_tsig_wireformat[] = {
2028 };
2029 static const ldns_rdf_type type_tlsa_wireformat[] = {
2034 };
2035 static const ldns_rdf_type type_hip_wireformat[] = {
2037 };
2038 static const ldns_rdf_type type_nid_wireformat[] = {
2041 };
2042 static const ldns_rdf_type type_l32_wireformat[] = {
2045 };
2046 static const ldns_rdf_type type_l64_wireformat[] = {
2049 };
2050 static const ldns_rdf_type type_lp_wireformat[] = {
2053 };
2054 static const ldns_rdf_type type_eui48_wireformat[] = {
2056 };
2057 static const ldns_rdf_type type_eui64_wireformat[] = {
2059 };
2060 static const ldns_rdf_type type_uri_wireformat[] = {
2064 };
2065 static const ldns_rdf_type type_caa_wireformat[] = {
2069 };
2070 #ifdef RRTYPE_DOA
2071 static const ldns_rdf_type type_doa_wireformat[] = {
2077 };
2078 #endif
2079 #ifdef RRTYPE_AMTRELAY
2080 static const ldns_rdf_type type_amtrelay_wireformat[] = {
2082 };
2083 #endif
2084 
2085 
2089 /* All RR's defined in 1035 are well known and can thus
2090  * be compressed. See RFC3597. These RR's are:
2091  * CNAME HINFO MB MD MF MG MINFO MR MX NULL NS PTR SOA TXT
2092  */
2093 static ldns_rr_descriptor rdata_field_descriptors[] = {
2094  /* 0 */
2095  { 0, NULL, 0, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2096  /* 1 */
2097  {LDNS_RR_TYPE_A, "A", 1, 1, type_a_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2098  /* 2 */
2099  {LDNS_RR_TYPE_NS, "NS", 1, 1, type_ns_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2100  /* 3 */
2101  {LDNS_RR_TYPE_MD, "MD", 1, 1, type_md_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2102  /* 4 */
2103  {LDNS_RR_TYPE_MF, "MF", 1, 1, type_mf_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2104  /* 5 */
2105  {LDNS_RR_TYPE_CNAME, "CNAME", 1, 1, type_cname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2106  /* 6 */
2107  {LDNS_RR_TYPE_SOA, "SOA", 7, 7, type_soa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
2108  /* 7 */
2109  {LDNS_RR_TYPE_MB, "MB", 1, 1, type_mb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2110  /* 8 */
2111  {LDNS_RR_TYPE_MG, "MG", 1, 1, type_mg_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2112  /* 9 */
2113  {LDNS_RR_TYPE_MR, "MR", 1, 1, type_mr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2114  /* 10 */
2115  {LDNS_RR_TYPE_NULL, "NULL", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2116  /* 11 */
2117  {LDNS_RR_TYPE_WKS, "WKS", 2, 2, type_wks_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2118  /* 12 */
2119  {LDNS_RR_TYPE_PTR, "PTR", 1, 1, type_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2120  /* 13 */
2121  {LDNS_RR_TYPE_HINFO, "HINFO", 2, 2, type_hinfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2122  /* 14 */
2123  {LDNS_RR_TYPE_MINFO, "MINFO", 2, 2, type_minfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
2124  /* 15 */
2125  {LDNS_RR_TYPE_MX, "MX", 2, 2, type_mx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
2126  /* 16 */
2127  {LDNS_RR_TYPE_TXT, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2128  /* 17 */
2129  {LDNS_RR_TYPE_RP, "RP", 2, 2, type_rp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2130  /* 18 */
2131  {LDNS_RR_TYPE_AFSDB, "AFSDB", 2, 2, type_afsdb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2132  /* 19 */
2133  {LDNS_RR_TYPE_X25, "X25", 1, 1, type_x25_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2134  /* 20 */
2135  {LDNS_RR_TYPE_ISDN, "ISDN", 1, 2, type_isdn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2136  /* 21 */
2137  {LDNS_RR_TYPE_RT, "RT", 2, 2, type_rt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2138  /* 22 */
2139  {LDNS_RR_TYPE_NSAP, "NSAP", 1, 1, type_nsap_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2140  /* 23 */
2141  {LDNS_RR_TYPE_NSAP_PTR, "NSAP-PTR", 1, 1, type_nsap_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2142  /* 24 */
2143  {LDNS_RR_TYPE_SIG, "SIG", 9, 9, type_sig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2144  /* 25 */
2145  {LDNS_RR_TYPE_KEY, "KEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2146  /* 26 */
2147  {LDNS_RR_TYPE_PX, "PX", 3, 3, type_px_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2148  /* 27 */
2149  {LDNS_RR_TYPE_GPOS, "GPOS", 3, 3, type_gpos_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2150  /* 28 */
2151  {LDNS_RR_TYPE_AAAA, "AAAA", 1, 1, type_aaaa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2152  /* 29 */
2153  {LDNS_RR_TYPE_LOC, "LOC", 1, 1, type_loc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2154  /* 30 */
2155  {LDNS_RR_TYPE_NXT, "NXT", 2, 2, type_nxt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2156  /* 31 */
2157  {LDNS_RR_TYPE_EID, "EID", 1, 1, type_eid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2158  /* 32 */
2159  {LDNS_RR_TYPE_NIMLOC, "NIMLOC", 1, 1, type_nimloc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2160  /* 33 */
2161  {LDNS_RR_TYPE_SRV, "SRV", 4, 4, type_srv_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2162  /* 34 */
2163  {LDNS_RR_TYPE_ATMA, "ATMA", 1, 1, type_atma_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2164  /* 35 */
2165  {LDNS_RR_TYPE_NAPTR, "NAPTR", 6, 6, type_naptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2166  /* 36 */
2167  {LDNS_RR_TYPE_KX, "KX", 2, 2, type_kx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2168  /* 37 */
2169  {LDNS_RR_TYPE_CERT, "CERT", 4, 4, type_cert_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2170  /* 38 */
2171  {LDNS_RR_TYPE_A6, "A6", 1, 1, type_a6_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2172  /* 39 */
2173  {LDNS_RR_TYPE_DNAME, "DNAME", 1, 1, type_dname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2174  /* 40 */
2175  {LDNS_RR_TYPE_SINK, "SINK", 1, 1, type_sink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2176  /* 41 */
2177  {LDNS_RR_TYPE_OPT, "OPT", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2178  /* 42 */
2179  {LDNS_RR_TYPE_APL, "APL", 0, 0, type_apl_wireformat, LDNS_RDF_TYPE_APL, LDNS_RR_NO_COMPRESS, 0 },
2180  /* 43 */
2181  {LDNS_RR_TYPE_DS, "DS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2182  /* 44 */
2183  {LDNS_RR_TYPE_SSHFP, "SSHFP", 3, 3, type_sshfp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2184  /* 45 */
2185  {LDNS_RR_TYPE_IPSECKEY, "IPSECKEY", 1, 1, type_ipseckey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2186  /* 46 */
2187  {LDNS_RR_TYPE_RRSIG, "RRSIG", 9, 9, type_rrsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2188  /* 47 */
2189  {LDNS_RR_TYPE_NSEC, "NSEC", 1, 2, type_nsec_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2190  /* 48 */
2191  {LDNS_RR_TYPE_DNSKEY, "DNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2192  /* 49 */
2193  {LDNS_RR_TYPE_DHCID, "DHCID", 1, 1, type_dhcid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2194  /* 50 */
2195  {LDNS_RR_TYPE_NSEC3, "NSEC3", 5, 6, type_nsec3_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2196  /* 51 */
2197  {LDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2198  /* 52 */
2199  {LDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2200 
2201  {LDNS_RR_TYPE_SMIMEA, "SMIMEA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2202 {LDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2203 
2204  /* 55
2205  * Hip ends with 0 or more Rendezvous Servers represented as dname's.
2206  * Hence the LDNS_RDF_TYPE_DNAME _variable field and the _maximum field
2207  * set to 0.
2208  */
2209  {LDNS_RR_TYPE_HIP, "HIP", 1, 1, type_hip_wireformat, LDNS_RDF_TYPE_DNAME, LDNS_RR_NO_COMPRESS, 0 },
2210 
2211 #ifdef RRTYPE_NINFO
2212  /* 56 */
2213  {LDNS_RR_TYPE_NINFO, "NINFO", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2214 #else
2215 {LDNS_RR_TYPE_NULL, "TYPE56", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2216 #endif
2217 #ifdef RRTYPE_RKEY
2218  /* 57 */
2219  {LDNS_RR_TYPE_RKEY, "RKEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2220 #else
2221 {LDNS_RR_TYPE_NULL, "TYPE57", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2222 #endif
2223  /* 58 */
2224  {LDNS_RR_TYPE_TALINK, "TALINK", 2, 2, type_talink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
2225 
2226  /* 59 */
2227  {LDNS_RR_TYPE_CDS, "CDS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2228  /* 60 */
2229  {LDNS_RR_TYPE_CDNSKEY, "CDNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2230 
2231 #ifdef RRTYPE_OPENPGPKEY
2232  /* 61 */
2233  {LDNS_RR_TYPE_OPENPGPKEY, "OPENPGPKEY", 1, 1, type_openpgpkey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2234 #else
2235 {LDNS_RR_TYPE_NULL, "TYPE61", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2236 #endif
2237  /* 62 */
2238  {LDNS_RR_TYPE_CSYNC, "CSYNC", 3, 3, type_csync_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2239  /* 63 */
2240  {LDNS_RR_TYPE_ZONEMD, "ZONEMD", 4, 4, type_zonemd_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2241 #ifdef RRTYPE_SVCB_HTTPS
2242  /* 64 */
2243  {LDNS_RR_TYPE_SVCB, "SVCB", 2, 3, type_svcb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2244  /* 65 */
2245  {LDNS_RR_TYPE_HTTPS, "HTTPS", 2, 3, type_svcb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2246 
2247 #else
2248 {LDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2249 {LDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2250 #endif
2251 {LDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2252 {LDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2253 {LDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2254 {LDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2255 {LDNS_RR_TYPE_NULL, "TYPE70", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2256 {LDNS_RR_TYPE_NULL, "TYPE71", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2257 {LDNS_RR_TYPE_NULL, "TYPE72", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2258 {LDNS_RR_TYPE_NULL, "TYPE73", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2259 {LDNS_RR_TYPE_NULL, "TYPE74", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2260 {LDNS_RR_TYPE_NULL, "TYPE75", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2261 {LDNS_RR_TYPE_NULL, "TYPE76", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2262 {LDNS_RR_TYPE_NULL, "TYPE77", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2263 {LDNS_RR_TYPE_NULL, "TYPE78", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2264 {LDNS_RR_TYPE_NULL, "TYPE79", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2265 {LDNS_RR_TYPE_NULL, "TYPE80", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2266 {LDNS_RR_TYPE_NULL, "TYPE81", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2267 {LDNS_RR_TYPE_NULL, "TYPE82", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2268 {LDNS_RR_TYPE_NULL, "TYPE83", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2269 {LDNS_RR_TYPE_NULL, "TYPE84", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2270 {LDNS_RR_TYPE_NULL, "TYPE85", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2271 {LDNS_RR_TYPE_NULL, "TYPE86", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2272 {LDNS_RR_TYPE_NULL, "TYPE87", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2273 {LDNS_RR_TYPE_NULL, "TYPE88", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2274 {LDNS_RR_TYPE_NULL, "TYPE89", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2275 {LDNS_RR_TYPE_NULL, "TYPE90", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2276 {LDNS_RR_TYPE_NULL, "TYPE91", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2277 {LDNS_RR_TYPE_NULL, "TYPE92", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2278 {LDNS_RR_TYPE_NULL, "TYPE93", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2279 {LDNS_RR_TYPE_NULL, "TYPE94", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2280 {LDNS_RR_TYPE_NULL, "TYPE95", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2281 {LDNS_RR_TYPE_NULL, "TYPE96", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2282 {LDNS_RR_TYPE_NULL, "TYPE97", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2283 {LDNS_RR_TYPE_NULL, "TYPE98", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2284 
2285  /* 99 */
2286  {LDNS_RR_TYPE_SPF, "SPF", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2287 
2288  /* UINFO [IANA-Reserved] */
2289 {LDNS_RR_TYPE_NULL, "TYPE100", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2290  /* UID [IANA-Reserved] */
2291 {LDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2292  /* GID [IANA-Reserved] */
2293 {LDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2294  /* UNSPEC [IANA-Reserved] */
2295 {LDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2296 
2297  /* 104 */
2298  {LDNS_RR_TYPE_NID, "NID", 2, 2, type_nid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2299  /* 105 */
2300  {LDNS_RR_TYPE_L32, "L32", 2, 2, type_l32_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2301  /* 106 */
2302  {LDNS_RR_TYPE_L64, "L64", 2, 2, type_l64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2303  /* 107 */
2304  {LDNS_RR_TYPE_LP, "LP", 2, 2, type_lp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2305  /* 108 */
2306  {LDNS_RR_TYPE_EUI48, "EUI48", 1, 1, type_eui48_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2307  /* 109 */
2308  {LDNS_RR_TYPE_EUI64, "EUI64", 1, 1, type_eui64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2309 
2310 {LDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2311 {LDNS_RR_TYPE_NULL, "TYPE111", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2312 {LDNS_RR_TYPE_NULL, "TYPE112", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2313 {LDNS_RR_TYPE_NULL, "TYPE113", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2314 {LDNS_RR_TYPE_NULL, "TYPE114", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2315 {LDNS_RR_TYPE_NULL, "TYPE115", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2316 {LDNS_RR_TYPE_NULL, "TYPE116", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2317 {LDNS_RR_TYPE_NULL, "TYPE117", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2318 {LDNS_RR_TYPE_NULL, "TYPE118", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2319 {LDNS_RR_TYPE_NULL, "TYPE119", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2320 {LDNS_RR_TYPE_NULL, "TYPE120", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2321 {LDNS_RR_TYPE_NULL, "TYPE121", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2322 {LDNS_RR_TYPE_NULL, "TYPE122", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2323 {LDNS_RR_TYPE_NULL, "TYPE123", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2324 {LDNS_RR_TYPE_NULL, "TYPE124", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2325 {LDNS_RR_TYPE_NULL, "TYPE125", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2326 {LDNS_RR_TYPE_NULL, "TYPE126", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2327 {LDNS_RR_TYPE_NULL, "TYPE127", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2328 {LDNS_RR_TYPE_NXNAME, "NXNAME", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2329 {LDNS_RR_TYPE_NULL, "TYPE129", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2330 {LDNS_RR_TYPE_NULL, "TYPE130", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2331 {LDNS_RR_TYPE_NULL, "TYPE131", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2332 {LDNS_RR_TYPE_NULL, "TYPE132", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2333 {LDNS_RR_TYPE_NULL, "TYPE133", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2334 {LDNS_RR_TYPE_NULL, "TYPE134", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2335 {LDNS_RR_TYPE_NULL, "TYPE135", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2336 {LDNS_RR_TYPE_NULL, "TYPE136", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2337 {LDNS_RR_TYPE_NULL, "TYPE137", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2338 {LDNS_RR_TYPE_NULL, "TYPE138", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2339 {LDNS_RR_TYPE_NULL, "TYPE139", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2340 {LDNS_RR_TYPE_NULL, "TYPE140", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2341 {LDNS_RR_TYPE_NULL, "TYPE141", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2342 {LDNS_RR_TYPE_NULL, "TYPE142", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2343 {LDNS_RR_TYPE_NULL, "TYPE143", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2344 {LDNS_RR_TYPE_NULL, "TYPE144", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2345 {LDNS_RR_TYPE_NULL, "TYPE145", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2346 {LDNS_RR_TYPE_NULL, "TYPE146", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2347 {LDNS_RR_TYPE_NULL, "TYPE147", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2348 {LDNS_RR_TYPE_NULL, "TYPE148", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2349 {LDNS_RR_TYPE_NULL, "TYPE149", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2350 {LDNS_RR_TYPE_NULL, "TYPE150", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2351 {LDNS_RR_TYPE_NULL, "TYPE151", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2352 {LDNS_RR_TYPE_NULL, "TYPE152", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2353 {LDNS_RR_TYPE_NULL, "TYPE153", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2354 {LDNS_RR_TYPE_NULL, "TYPE154", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2355 {LDNS_RR_TYPE_NULL, "TYPE155", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2356 {LDNS_RR_TYPE_NULL, "TYPE156", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2357 {LDNS_RR_TYPE_NULL, "TYPE157", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2358 {LDNS_RR_TYPE_NULL, "TYPE158", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2359 {LDNS_RR_TYPE_NULL, "TYPE159", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2360 {LDNS_RR_TYPE_NULL, "TYPE160", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2361 {LDNS_RR_TYPE_NULL, "TYPE161", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2362 {LDNS_RR_TYPE_NULL, "TYPE162", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2363 {LDNS_RR_TYPE_NULL, "TYPE163", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2364 {LDNS_RR_TYPE_NULL, "TYPE164", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2365 {LDNS_RR_TYPE_NULL, "TYPE165", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2366 {LDNS_RR_TYPE_NULL, "TYPE166", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2367 {LDNS_RR_TYPE_NULL, "TYPE167", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2368 {LDNS_RR_TYPE_NULL, "TYPE168", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2369 {LDNS_RR_TYPE_NULL, "TYPE169", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2370 {LDNS_RR_TYPE_NULL, "TYPE170", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2371 {LDNS_RR_TYPE_NULL, "TYPE171", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2372 {LDNS_RR_TYPE_NULL, "TYPE172", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2373 {LDNS_RR_TYPE_NULL, "TYPE173", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2374 {LDNS_RR_TYPE_NULL, "TYPE174", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2375 {LDNS_RR_TYPE_NULL, "TYPE175", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2376 {LDNS_RR_TYPE_NULL, "TYPE176", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2377 {LDNS_RR_TYPE_NULL, "TYPE177", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2378 {LDNS_RR_TYPE_NULL, "TYPE178", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2379 {LDNS_RR_TYPE_NULL, "TYPE179", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2380 {LDNS_RR_TYPE_NULL, "TYPE180", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2381 {LDNS_RR_TYPE_NULL, "TYPE181", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2382 {LDNS_RR_TYPE_NULL, "TYPE182", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2383 {LDNS_RR_TYPE_NULL, "TYPE183", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2384 {LDNS_RR_TYPE_NULL, "TYPE184", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2385 {LDNS_RR_TYPE_NULL, "TYPE185", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2386 {LDNS_RR_TYPE_NULL, "TYPE186", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2387 {LDNS_RR_TYPE_NULL, "TYPE187", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2388 {LDNS_RR_TYPE_NULL, "TYPE188", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2389 {LDNS_RR_TYPE_NULL, "TYPE189", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2390 {LDNS_RR_TYPE_NULL, "TYPE190", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2391 {LDNS_RR_TYPE_NULL, "TYPE191", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2392 {LDNS_RR_TYPE_NULL, "TYPE192", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2393 {LDNS_RR_TYPE_NULL, "TYPE193", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2394 {LDNS_RR_TYPE_NULL, "TYPE194", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2395 {LDNS_RR_TYPE_NULL, "TYPE195", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2396 {LDNS_RR_TYPE_NULL, "TYPE196", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2397 {LDNS_RR_TYPE_NULL, "TYPE197", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2398 {LDNS_RR_TYPE_NULL, "TYPE198", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2399 {LDNS_RR_TYPE_NULL, "TYPE199", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2400 {LDNS_RR_TYPE_NULL, "TYPE200", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2401 {LDNS_RR_TYPE_NULL, "TYPE201", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2402 {LDNS_RR_TYPE_NULL, "TYPE202", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2403 {LDNS_RR_TYPE_NULL, "TYPE203", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2404 {LDNS_RR_TYPE_NULL, "TYPE204", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2405 {LDNS_RR_TYPE_NULL, "TYPE205", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2406 {LDNS_RR_TYPE_NULL, "TYPE206", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2407 {LDNS_RR_TYPE_NULL, "TYPE207", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2408 {LDNS_RR_TYPE_NULL, "TYPE208", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2409 {LDNS_RR_TYPE_NULL, "TYPE209", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2410 {LDNS_RR_TYPE_NULL, "TYPE210", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2411 {LDNS_RR_TYPE_NULL, "TYPE211", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2412 {LDNS_RR_TYPE_NULL, "TYPE212", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2413 {LDNS_RR_TYPE_NULL, "TYPE213", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2414 {LDNS_RR_TYPE_NULL, "TYPE214", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2415 {LDNS_RR_TYPE_NULL, "TYPE215", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2416 {LDNS_RR_TYPE_NULL, "TYPE216", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2417 {LDNS_RR_TYPE_NULL, "TYPE217", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2418 {LDNS_RR_TYPE_NULL, "TYPE218", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2419 {LDNS_RR_TYPE_NULL, "TYPE219", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2420 {LDNS_RR_TYPE_NULL, "TYPE220", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2421 {LDNS_RR_TYPE_NULL, "TYPE221", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2422 {LDNS_RR_TYPE_NULL, "TYPE222", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2423 {LDNS_RR_TYPE_NULL, "TYPE223", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2424 {LDNS_RR_TYPE_NULL, "TYPE224", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2425 {LDNS_RR_TYPE_NULL, "TYPE225", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2426 {LDNS_RR_TYPE_NULL, "TYPE226", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2427 {LDNS_RR_TYPE_NULL, "TYPE227", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2428 {LDNS_RR_TYPE_NULL, "TYPE228", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2429 {LDNS_RR_TYPE_NULL, "TYPE229", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2430 {LDNS_RR_TYPE_NULL, "TYPE230", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2431 {LDNS_RR_TYPE_NULL, "TYPE231", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2432 {LDNS_RR_TYPE_NULL, "TYPE232", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2433 {LDNS_RR_TYPE_NULL, "TYPE233", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2434 {LDNS_RR_TYPE_NULL, "TYPE234", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2435 {LDNS_RR_TYPE_NULL, "TYPE235", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2436 {LDNS_RR_TYPE_NULL, "TYPE236", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2437 {LDNS_RR_TYPE_NULL, "TYPE237", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2438 {LDNS_RR_TYPE_NULL, "TYPE238", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2439 {LDNS_RR_TYPE_NULL, "TYPE239", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2440 {LDNS_RR_TYPE_NULL, "TYPE240", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2441 {LDNS_RR_TYPE_NULL, "TYPE241", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2442 {LDNS_RR_TYPE_NULL, "TYPE242", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2443 {LDNS_RR_TYPE_NULL, "TYPE243", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2444 {LDNS_RR_TYPE_NULL, "TYPE244", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2445 {LDNS_RR_TYPE_NULL, "TYPE245", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2446 {LDNS_RR_TYPE_NULL, "TYPE246", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2447 {LDNS_RR_TYPE_NULL, "TYPE247", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2448 {LDNS_RR_TYPE_NULL, "TYPE248", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2449 
2450  /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one.
2451  * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9.
2452  */
2453  /* 249 */
2454  {LDNS_RR_TYPE_TKEY, "TKEY", 7, 7, type_tkey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2455  /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one.
2456  * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9.
2457  */
2458  /* 250 */
2459  {LDNS_RR_TYPE_TSIG, "TSIG", 7, 7, type_tsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
2460 
2461  /* IXFR: A request for a transfer of an incremental zone transfer */
2462 {LDNS_RR_TYPE_NULL, "TYPE251", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2463  /* AXFR: A request for a transfer of an entire zone */
2464 {LDNS_RR_TYPE_NULL, "TYPE252", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2465  /* MAILB: A request for mailbox-related records (MB, MG or MR) */
2466 {LDNS_RR_TYPE_NULL, "TYPE253", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2467  /* MAILA: A request for mail agent RRs (Obsolete - see MX) */
2468 {LDNS_RR_TYPE_NULL, "TYPE254", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2469  /* ANY: A request for all (available) records */
2470 {LDNS_RR_TYPE_NULL, "TYPE255", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2471 
2472  /* 256 */
2473  {LDNS_RR_TYPE_URI, "URI", 3, 3, type_uri_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2474  /* 257 */
2475  {LDNS_RR_TYPE_CAA, "CAA", 3, 3, type_caa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2476 
2477 #ifdef RRTYPE_AVC
2478  /* 258 */
2479  {LDNS_RR_TYPE_AVC, "AVC", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2480 #else
2481 {LDNS_RR_TYPE_NULL, "TYPE258", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2482 #endif
2483 #ifdef RRTYPE_DOA
2484  /* 259 */
2485  {LDNS_RR_TYPE_DOA, "DOA", 5, 5, type_doa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2486 #else
2487 {LDNS_RR_TYPE_NULL, "TYPE259", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2488 #endif
2489 #ifdef RRTYPE_AMTRELAY
2490  /* 260 */
2491  {LDNS_RR_TYPE_AMTRELAY, "AMTRELAY", 1, 1, type_amtrelay_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2492 #else
2493 {LDNS_RR_TYPE_NULL, "TYPE260", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2494 #endif
2495 #ifdef RRTYPE_RESINFO
2496  /* 261 */
2497  {LDNS_RR_TYPE_RESINFO, "RESINFO", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2498 #else
2499 {LDNS_RR_TYPE_NULL, "TYPE261", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2500 #endif
2501  /* 262 */
2502  {LDNS_RR_TYPE_WALLET, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
2503 
2504 /* split in array, no longer contiguous */
2505 
2506 #ifdef RRTYPE_TA
2507  /* 32768 */
2508  {LDNS_RR_TYPE_TA, "TA", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2509 #else
2510 {LDNS_RR_TYPE_NULL, "TYPE32768", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
2511 #endif
2512  /* 32769 */
2513  {LDNS_RR_TYPE_DLV, "DLV", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }
2514 };
2521 #define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT \
2522  (sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0]))
2523 
2524 
2525 /*---------------------------------------------------------------------------*
2526  * The functions below return an bitmap RDF with the space required to set
2527  * or unset all known RR types. Arguably these functions are better situated
2528  * in rdata.c, however for the space calculation it is necessary to walk
2529  * through rdata_field_descriptors which is not easily possible from anywhere
2530  * other than rr.c where it is declared static.
2531  *
2532  * Alternatively rr.c could have provided an iterator for rr_type or
2533  * rdf_descriptors, but this seemed overkill for internal use only.
2534  */
2535 static ldns_rr_descriptor* rdata_field_descriptors_end =
2536  &rdata_field_descriptors[LDNS_RDATA_FIELD_DESCRIPTORS_COUNT];
2537 
2538 /* From RFC3845:
2539  *
2540  * 2.1.2. The List of Type Bit Map(s) Field
2541  *
2542  * The RR type space is split into 256 window blocks, each representing
2543  * the low-order 8 bits of the 16-bit RR type space. Each block that
2544  * has at least one active RR type is encoded using a single octet
2545  * window number (from 0 to 255), a single octet bitmap length (from 1
2546  * to 32) indicating the number of octets used for the window block's
2547  * bitmap, and up to 32 octets (256 bits) of bitmap.
2548  *
2549  * Window blocks are present in the NSEC RR RDATA in increasing
2550  * numerical order.
2551  *
2552  * "|" denotes concatenation
2553  *
2554  * Type Bit Map(s) Field = ( Window Block # | Bitmap Length | Bitmap ) +
2555  *
2556  * <cut>
2557  *
2558  * Blocks with no types present MUST NOT be included. Trailing zero
2559  * octets in the bitmap MUST be omitted. The length of each block's
2560  * bitmap is determined by the type code with the largest numerical
2561  * value within that block, among the set of RR types present at the
2562  * NSEC RR's owner name. Trailing zero octets not specified MUST be
2563  * interpreted as zero octets.
2564  */
2565 static ldns_status
2566 ldns_rdf_bitmap_known_rr_types_set(ldns_rdf** rdf, int value)
2567 {
2568  uint8_t window; /* most significant octet of type */
2569  uint8_t subtype; /* least significant octet of type */
2570  uint16_t windows[256] /* Max subtype per window */
2571 #ifndef S_SPLINT_S
2572  = { 0 }
2573 #endif
2574  ;
2575  ldns_rr_descriptor* d; /* used to traverse rdata_field_descriptors */
2576  size_t i; /* used to traverse windows array */
2577 
2578  size_t sz; /* size needed for type bitmap rdf */
2579  uint8_t* data = NULL; /* rdf data */
2580  uint8_t* dptr; /* used to itraverse rdf data */
2581 
2582  assert(rdf != NULL);
2583 
2584  /* Which windows need to be in the bitmap rdf?
2585  */
2586  for (d=rdata_field_descriptors; d < rdata_field_descriptors_end; d++) {
2587  window = d->_type >> 8;
2588  subtype = d->_type & 0xff;
2589  if (windows[window] < subtype) {
2590  windows[window] = subtype;
2591  }
2592  }
2593 
2594  /* How much space do we need in the rdf for those windows?
2595  */
2596  sz = 0;
2597  for (i = 0; i < 256; i++) {
2598  if (windows[i]) {
2599  sz += windows[i] / 8 + 3;
2600  }
2601  }
2602  if (sz > 0) {
2603  /* Format rdf data according RFC3845 Section 2.1.2 (see above)
2604  */
2605  dptr = data = LDNS_XMALLOC(uint8_t, sz);
2606  if (!data) {
2607  return LDNS_STATUS_MEM_ERR;
2608  }
2609  memset(data, value, sz);
2610  for (i = 0; i < 256; i++) {
2611  if (windows[i]) {
2612  *dptr++ = (uint8_t)i;
2613  *dptr++ = (uint8_t)(windows[i] / 8 + 1);
2614  dptr += dptr[-1];
2615  }
2616  }
2617  }
2618  /* Allocate and return rdf structure for the data
2619  */
2620  *rdf = ldns_rdf_new(LDNS_RDF_TYPE_BITMAP, sz, data);
2621  if (!*rdf) {
2622  LDNS_FREE(data);
2623  return LDNS_STATUS_MEM_ERR;
2624  }
2625  return LDNS_STATUS_OK;
2626 }
2627 
2630 {
2631  return ldns_rdf_bitmap_known_rr_types_set(rdf, 0);
2632 }
2633 
2636 {
2637  return ldns_rdf_bitmap_known_rr_types_set(rdf, 255);
2638 }
2639 /* End of RDF bitmap functions
2640  *---------------------------------------------------------------------------*/
2641 
2642 
2643 const ldns_rr_descriptor *
2644 ldns_rr_descript(uint16_t type)
2645 {
2646  size_t i;
2648  return &rdata_field_descriptors[type];
2649  } else {
2650  /* because not all array index equals type code */
2653  i++) {
2654  if (rdata_field_descriptors[i]._type == type) {
2655  return &rdata_field_descriptors[i];
2656  }
2657  }
2658  return &rdata_field_descriptors[0];
2659  }
2660 }
2661 
2662 size_t
2664 {
2665  if (descriptor) {
2666  return descriptor->_minimum;
2667  } else {
2668  return 0;
2669  }
2670 }
2671 
2672 size_t
2674 {
2675  if (descriptor) {
2676  if (descriptor->_variable != LDNS_RDF_TYPE_NONE) {
2677  /* Should really be SIZE_MAX... bad FreeBSD. */
2678  return UINT_MAX;
2679  } else {
2680  return descriptor->_maximum;
2681  }
2682  } else {
2683  return 0;
2684  }
2685 }
2686 
2689  size_t index)
2690 {
2691  assert(descriptor != NULL);
2692  assert(index < descriptor->_maximum
2693  || descriptor->_variable != LDNS_RDF_TYPE_NONE);
2694  if (index < descriptor->_maximum) {
2695  return descriptor->_wireformat[index];
2696  } else {
2697  return descriptor->_variable;
2698  }
2699 }
2700 
2702 ldns_get_rr_type_by_name(const char *name)
2703 {
2704  unsigned int i;
2705  const char *desc_name;
2706  const ldns_rr_descriptor *desc;
2707 
2708  /* TYPEXX representation */
2709  if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
2710  return atoi(name + 4);
2711  }
2712 
2713  /* Normal types */
2714  for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
2715  desc = &rdata_field_descriptors[i];
2716  desc_name = desc->_name;
2717  if(desc_name &&
2718  strlen(name) == strlen(desc_name) &&
2719  strncasecmp(name, desc_name, strlen(desc_name)) == 0) {
2720  /* because not all array index equals type code */
2721  return desc->_type;
2722  }
2723  }
2724 
2725  /* special cases for query types */
2726  if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
2727  return 251;
2728  } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
2729  return 252;
2730  } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
2731  return 253;
2732  } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
2733  return 254;
2734  } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
2735  return 255;
2736  }
2737 
2738  return 0;
2739 }
2740 
2742 ldns_get_rr_class_by_name(const char *name)
2743 {
2744  ldns_lookup_table *lt;
2745 
2746  /* CLASSXX representation */
2747  if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) {
2748  return atoi(name + 5);
2749  }
2750 
2751  /* Normal types */
2753 
2754  if (lt) {
2755  return lt->id;
2756  }
2757  return 0;
2758 }
2759 
2760 
2763 {
2764  ldns_rr_type r;
2765 
2766  if (!rd) {
2767  return 0;
2768  }
2769 
2771  return 0;
2772  }
2773 
2775  return r;
2776 }
2777 
2780 {
2781  if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
2782  return ldns_rr_get_type(ldns_rr_list_rr(rr_list, 0));
2783  } else {
2784  return 0;
2785  }
2786 }
2787 
2788 ldns_rdf *
2790 {
2791  if (rr_list && ldns_rr_list_rr_count(rr_list) > 0) {
2792  return ldns_rr_owner(ldns_rr_list_rr(rr_list, 0));
2793  } else {
2794  return NULL;
2795  }
2796 }
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)
signed char 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 *rdf)
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:148
ldns_status ldns_rr2buffer_wire(ldns_buffer *output, const ldns_rr *rr, int section)
Copies the rr data to the buffer in wire format.
Definition: host2wire.c:244
ldns_status ldns_rr2buffer_wire_canonical(ldns_buffer *output, 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
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
ldns_lookup_table ldns_rr_classes[]
rr types
Definition: host2str.c:99
#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, signed char fixed, const char *delim, int *line_nr)
returns a token/char from the stream f.
Definition: parse.c:226
#define LDNS_PARSE_SKIP_SPACE
Definition: parse.h:20
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:301
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
#define LDNS_MAX_RDFLEN
Definition: rdata.h:31
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
@ 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
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
enum ldns_enum_rdf_type ldns_rdf_type
Definition: rdata.h:151
ldns_rdf * ldns_rdf_clone(const ldns_rdf *rd)
clones a rdf structure.
Definition: rdata.c:222
void ldns_rr_list_free(ldns_rr_list *rr_list)
frees an rr_list structure.
Definition: rr.c:1015
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:994
ldns_rr * ldns_rr_list_pop_rr(ldns_rr_list *rr_list)
pops the last rr from an rrlist.
Definition: rr.c:1181
ldns_rr_class ldns_get_rr_class_by_name(const char *name)
retrieves a class by looking up its name.
Definition: rr.c:2742
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:935
ldns_rdf * ldns_rr_owner(const ldns_rr *rr)
returns the owner name of an rr structure.
Definition: rr.c:923
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:2762
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:800
void ldns_rr_list_deep_free(ldns_rr_list *rr_list)
frees an rr_list structure and all rrs contained therein.
Definition: rr.c:1024
const ldns_rr_descriptor * ldns_rr_descript(uint16_t type)
returns the resource record descriptor for the given rr type.
Definition: rr.c:2644
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:1346
void ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *owner)
sets the owner in the rr structure.
Definition: rr.c:808
#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:2779
#define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT
computes the number of rdata fields
Definition: rr.c:2521
#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:1352
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
signed char 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:1298
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
signed char 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:1244
void ldns_rr_list_sort(ldns_rr_list *unsorted)
sorts an rr_list (canonical wire format).
Definition: rr.c:1520
#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:832
signed char ldns_rr_list_push_rr(ldns_rr_list *rr_list, const ldns_rr *rr)
pushes an rr to an rrlist.
Definition: rr.c:1136
signed char 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:1167
signed char ldns_rr_is_question(const ldns_rr *rr)
returns the question flag of an rr structure.
Definition: rr.c:929
void ldns_rr2canonical(ldns_rr *rr)
converts each dname in a rr to its canonical form.
Definition: rr.c:1785
size_t ldns_rr_rd_count(const ldns_rr *rr)
returns the rd_count of an rr structure.
Definition: rr.c:941
uint8_t ldns_rr_label_count(const ldns_rr *rr)
counts the number of labels of the ownername.
Definition: rr.c:1846
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:844
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:2688
signed char ldns_rr_compare_ds(const ldns_rr *orr1, const ldns_rr *orr2)
returns true of the given rr's are equal.
Definition: rr.c:1714
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:961
#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:1604
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:1837
ldns_rr_type ldns_rr_get_type(const ldns_rr *rr)
returns the type of the rr.
Definition: rr.c:947
void ldns_rr_set_ttl(ldns_rr *rr, uint32_t ttl)
sets the ttl in the rr structure.
Definition: rr.c:820
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:2789
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, signed char *explicit_ttl)
Definition: rr.c:729
void ldns_rr_set_question(ldns_rr *rr, signed char question)
sets the question flag in the rr structure.
Definition: rr.c:814
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:1214
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:2673
int ldns_rr_compare_no_rdata(const ldns_rr *rr1, const ldns_rr *rr2)
compares two rrs, up to the rdata.
Definition: rr.c:1563
ldns_rr_class ldns_rr_get_class(const ldns_rr *rr)
returns the class of the rr.
Definition: rr.c:953
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:1063
void ldns_rr_set_rd_count(ldns_rr *rr, size_t count)
sets the rd_count in the rr.
Definition: rr.c:826
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:2629
void ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class)
sets the class in the rr.
Definition: rr.c:838
signed char ldns_is_rrset(const ldns_rr_list *rr_list)
checks if an rr_list is a rrset.
Definition: rr.c:1263
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:971
ldns_rr_list * ldns_rr_list_new(void)
creates a new rr_list structure.
Definition: rr.c:1004
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:1102
signed char ldns_rr_list_cat(ldns_rr_list *left, const ldns_rr_list *right)
concatenates two ldns_rr_lists together.
Definition: rr.c:1040
int ldns_rr_list_compare(const ldns_rr_list *rrl1, const ldns_rr_list *rrl2)
compares two rr lists.
Definition: rr.c:1741
signed char 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:861
int ldns_rr_compare(const ldns_rr *rr1, const ldns_rr *rr2)
compares two rrs.
Definition: rr.c:1642
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:987
ldns_rr * ldns_rr_clone(const ldns_rr *rr)
clones a rr and all its data
Definition: rr.c:1404
ldns_rr_list * ldns_rr_list_clone(const ldns_rr_list *rrlist)
clones an rrlist.
Definition: rr.c:1435
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:2663
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:913
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:1768
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:884
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:2635
ldns_rr_type ldns_get_rr_type_by_name(const char *name)
retrieves a rrtype by looking up its name.
Definition: rr.c:2702
#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON
Definition: rr.h:254
@ 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:251
#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:228
@ LDNS_RR_TYPE_SPF
Definition: rr.h:198
@ LDNS_RR_TYPE_RESINFO
RFC 9606.
Definition: rr.h:234
@ 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:215
@ 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:216
@ 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
RFC 8777.
Definition: rr.h:231
@ 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:242
@ 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:240
@ LDNS_RR_TYPE_NXNAME
Definition: rr.h:213
@ 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_WALLET
https://iana.org/assignments/dns-parameters/WALLET/wallet-completed-template
Definition: rr.h:237
@ LDNS_RR_TYPE_CAA
Definition: rr.h:226
@ 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:225
@ LDNS_RR_TYPE_AVC
Definition: rr.h:227
@ 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:359
uint8_t _maximum
Maximum number of rdata fields in the RRs of this type.
Definition: rr.h:367
const char * _name
Textual name of the RR type.
Definition: rr.h:363
ldns_rdf_type _variable
Special rdf types.
Definition: rr.h:371
ldns_rr_type _type
Type of the RR that is described here.
Definition: rr.h:361
uint8_t _minimum
Minimum number of rdata fields in the RRs of this type.
Definition: rr.h:365
const ldns_rdf_type * _wireformat
Wireformat specification for the rr, i.e.
Definition: rr.h:369
List or Set of Resource Records.
Definition: rr.h:346
size_t _rr_capacity
Definition: rr.h:348
ldns_rr ** _rrs
Definition: rr.h:349
size_t _rr_count
Definition: rr.h:347
Resource Record.
Definition: rr.h:318
ldns_rr_type _rr_type
the type of the RR.
Definition: rr.h:326
ldns_rdf * _owner
Owner name, uncompressed.
Definition: rr.h:320
ldns_rdf ** _rdata_fields
The array of rdata's.
Definition: rr.h:331
signed char _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:335
uint32_t _ttl
Time to live
Definition: rr.h:322
ldns_rr_class _rr_class
Class of the resource record.
Definition: rr.h:328
size_t _rd_count
Number of data fields.
Definition: rr.h:324
int ldns_hexstring_to_data(uint8_t *data, const char *str)
Converts a hex string to binary data.
Definition: util.c:138
#define INLINE
splint static inline workaround
Definition: util.h:42
#define LDNS_FREE(ptr)
Definition: util.h:60
ldns_lookup_table * ldns_lookup_by_name(ldns_lookup_table table[], const char *name)
Looks up the table entry by name, returns NULL if not found.
#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:156