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