ldns documentation

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

dnssec_zone.h
Go to the documentation of this file.
1 /*
2 * special zone file structures and functions for better dnssec handling
3 *
4 * A zone contains a SOA dnssec_zone_rrset, and an AVL tree of 'normal'
5 * dnssec_zone_rrsets, indexed by name and type
6 */
7
8 #ifndef LDNS_DNSSEC_ZONE_H
9 #define LDNS_DNSSEC_ZONE_H
10
11 #include <ldns/rbtree.h>
12 #include <ldns/host2str.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
21 typedef struct ldns_struct_dnssec_rrs ldns_dnssec_rrs;
22 struct ldns_struct_dnssec_rrs
23 {
24 ldns_rr *rr;
25 ldns_dnssec_rrs *next;
26 };
27
31 typedef struct ldns_struct_dnssec_rrsets ldns_dnssec_rrsets;
32 struct ldns_struct_dnssec_rrsets
33 {
34 ldns_dnssec_rrs *rrs;
35 ldns_rr_type type;
36 ldns_dnssec_rrs *signatures;
37 ldns_dnssec_rrsets *next;
38 };
39
44 typedef struct ldns_struct_dnssec_name ldns_dnssec_name;
45 struct ldns_struct_dnssec_name
46 {
51 ldns_rdf *name;
59 bool name_alloced;
63 ldns_dnssec_rrsets *rrsets;
67 ldns_rr *nsec;
71 ldns_dnssec_rrs *nsec_signatures;
81 bool is_glue;
85 ldns_rdf *hashed_name;
86 };
87
91 struct ldns_struct_dnssec_zone {
93 ldns_dnssec_name *soa;
95 ldns_rbtree_t *names;
97 ldns_rbtree_t *hashed_names;
102 ldns_rr *_nsec3params;
103 };
104 typedef struct ldns_struct_dnssec_zone ldns_dnssec_zone;
105
110 ldns_dnssec_rrs *ldns_dnssec_rrs_new(void);
111
118 void ldns_dnssec_rrs_free(ldns_dnssec_rrs *rrs);
119
126 void ldns_dnssec_rrs_deep_free(ldns_dnssec_rrs *rrs);
127
136 ldns_status ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr);
137
144 void ldns_dnssec_rrs_print(FILE *out, ldns_dnssec_rrs *rrs);
145
153 void ldns_dnssec_rrs_print_fmt(FILE *out,
154 const ldns_output_format *fmt, ldns_dnssec_rrs *rrs);
155
160 ldns_dnssec_rrsets *ldns_dnssec_rrsets_new(void);
161
168 void ldns_dnssec_rrsets_free(ldns_dnssec_rrsets *rrsets);
169
176 void ldns_dnssec_rrsets_deep_free(ldns_dnssec_rrsets *rrsets);
177
184 ldns_rr_type ldns_dnssec_rrsets_type(ldns_dnssec_rrsets *rrsets);
185
193 ldns_status ldns_dnssec_rrsets_set_type(ldns_dnssec_rrsets *rrsets,
194 ldns_rr_type type);
195
204 ldns_status ldns_dnssec_rrsets_add_rr(ldns_dnssec_rrsets *rrsets, ldns_rr *rr);
205
213 void ldns_dnssec_rrsets_print(FILE *out,
214 ldns_dnssec_rrsets *rrsets,
215 bool follow);
216
225 void ldns_dnssec_rrsets_print_fmt(FILE *out,
226 const ldns_output_format *fmt,
227 ldns_dnssec_rrsets *rrsets,
228 bool follow);
229
230
235 ldns_dnssec_name *ldns_dnssec_name_new(void);
236
242 ldns_dnssec_name *ldns_dnssec_name_new_frm_rr(ldns_rr *rr);
243
250 void ldns_dnssec_name_free(ldns_dnssec_name *name);
251
258 void ldns_dnssec_name_deep_free(ldns_dnssec_name *name);
259
266 ldns_rdf *ldns_dnssec_name_name(ldns_dnssec_name *name);
267
268
275 void ldns_dnssec_name_set_name(ldns_dnssec_name *name,
276 ldns_rdf *dname);
288 bool ldns_dnssec_name_is_glue(ldns_dnssec_name *name);
289
296 void ldns_dnssec_name_set_nsec(ldns_dnssec_name *name, ldns_rr *nsec);
297
308 int ldns_dnssec_name_cmp(const void *a, const void *b);
309
318 ldns_status ldns_dnssec_name_add_rr(ldns_dnssec_name *name,
319 ldns_rr *rr);
320
328 ldns_dnssec_rrsets *ldns_dnssec_name_find_rrset(ldns_dnssec_name *name,
329 ldns_rr_type type);
330
339 ldns_dnssec_rrsets *ldns_dnssec_zone_find_rrset(ldns_dnssec_zone *zone,
340 ldns_rdf *dname,
341 ldns_rr_type type);
342
350 void ldns_dnssec_name_print(FILE *out, ldns_dnssec_name *name);
351
360 void ldns_dnssec_name_print_fmt(FILE *out,
361 const ldns_output_format *fmt, ldns_dnssec_name *name);
362
367 ldns_dnssec_zone *ldns_dnssec_zone_new(void);
368
379 ldns_status ldns_dnssec_zone_new_frm_fp(ldns_dnssec_zone** z, FILE* fp,
380 ldns_rdf* origin, uint32_t ttl, ldns_rr_class c);
381
393 ldns_status ldns_dnssec_zone_new_frm_fp_l(ldns_dnssec_zone** z, FILE* fp,
394 ldns_rdf* origin, uint32_t ttl, ldns_rr_class c, int* line_nr);
395
401 void ldns_dnssec_zone_free(ldns_dnssec_zone *zone);
402
408 void ldns_dnssec_zone_deep_free(ldns_dnssec_zone *zone);
409
420 ldns_status ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone,
421 ldns_rr *rr);
422
430 void ldns_dnssec_zone_names_print(FILE *out, ldns_rbtree_t *tree, bool print_soa);
431
440 void ldns_dnssec_zone_names_print_fmt(FILE *out, const ldns_output_format *fmt,
441 ldns_rbtree_t *tree, bool print_soa);
442
449 void ldns_dnssec_zone_print(FILE *out, ldns_dnssec_zone *zone);
450
458 void ldns_dnssec_zone_print_fmt(FILE *out,
459 const ldns_output_format *fmt, ldns_dnssec_zone *zone);
460
468 ldns_status ldns_dnssec_zone_add_empty_nonterminals(ldns_dnssec_zone *zone);
469
477 bool ldns_dnssec_zone_is_nsec3_optout(ldns_dnssec_zone* zone);
478
479 #ifdef __cplusplus
480 }
481 #endif
482
483 #endif
ldns_dnssec_name_is_glue
signed char ldns_dnssec_name_is_glue(ldns_dnssec_name *name)
Returns if dnssec_name structure is marked as glue.
Definition: dnssec_zone.c:403
ldns_struct_dnssec_rrsets::rrs
ldns_dnssec_rrs * rrs
Definition: dnssec_zone.h:34
ldns_dnssec_zone_new
ldns_dnssec_zone * ldns_dnssec_zone_new(void)
Creates a new dnssec_zone structure.
Definition: dnssec_zone.c:569
ldns_dnssec_name_new
ldns_dnssec_name * ldns_dnssec_name_new(void)
Create a new data structure for a dnssec name.
Definition: dnssec_zone.c:317
ldns_dnssec_rrsets_type
ldns_rr_type ldns_dnssec_rrsets_type(ldns_dnssec_rrsets *rrsets)
Returns the rr type of the rrset (that is head of the given list)
Definition: dnssec_zone.c:146
ldns_dnssec_name_deep_free
void ldns_dnssec_name_deep_free(ldns_dnssec_name *name)
Frees the name structure and its rrs and rrsets.
Definition: dnssec_zone.c:388
ldns_dnssec_rrsets_deep_free
void ldns_dnssec_rrsets_deep_free(ldns_dnssec_rrsets *rrsets)
Frees the list of rrsets and their rrs, and the ldns_rr records in the sets.
Definition: dnssec_zone.c:140
ldns_dnssec_zone_find_rrset
ldns_dnssec_rrsets * ldns_dnssec_zone_find_rrset(ldns_dnssec_zone *zone, ldns_rdf *dname, ldns_rr_type type)
Find the RRset with the given name and type in the zone.
Definition: dnssec_zone.c:508
ldns_dnssec_zone_free
void ldns_dnssec_zone_free(ldns_dnssec_zone *zone)
Frees the given zone structure, and its rbtree of dnssec_names Individual ldns_rr RRs within those na...
Definition: dnssec_zone.c:749
ldns_dnssec_name_add_rr
ldns_status ldns_dnssec_name_add_rr(ldns_dnssec_name *name, ldns_rr *rr)
Inserts the given rr at the right place in the current dnssec_name No checking is done whether the na...
Definition: dnssec_zone.c:448
ldns_rr_class
enum ldns_enum_rr_class ldns_rr_class
Definition: rr.h:64
ldns_dnssec_zone_add_empty_nonterminals
ldns_status ldns_dnssec_zone_add_empty_nonterminals(ldns_dnssec_zone *zone)
Adds explicit dnssec_name structures for the empty nonterminals in this zone.
Definition: dnssec_zone.c:993
ldns_struct_output_format
Output format specifier.
Definition: host2str.h:86
ldns_dnssec_name_set_name
void ldns_dnssec_name_set_name(ldns_dnssec_name *name, ldns_rdf *dname)
Sets the domain name of the given dnssec_name structure.
Definition: dnssec_zone.c:412
ldns_struct_dnssec_name::name_alloced
signed char name_alloced
Usually, the name is a pointer to the owner name of the first rr for this name, but sometimes there i...
Definition: dnssec_zone.h:59
ldns_dnssec_name_set_nsec
void ldns_dnssec_name_set_nsec(ldns_dnssec_name *name, ldns_rr *nsec)
Sets the NSEC(3) RR of the given dnssec_name structure.
Definition: dnssec_zone.c:422
ldns_dnssec_name_new_frm_rr
ldns_dnssec_name * ldns_dnssec_name_new_frm_rr(ldns_rr *rr)
Create a new data structure for a dnssec name for the given RR.
Definition: dnssec_zone.c:342
ldns_struct_dnssec_name::rrsets
ldns_dnssec_rrsets * rrsets
The rrsets for this name.
Definition: dnssec_zone.h:63
ldns_dnssec_rrsets_free
void ldns_dnssec_rrsets_free(ldns_dnssec_rrsets *rrsets)
Frees the list of rrsets and their rrs, but not the ldns_rr records in the sets.
Definition: dnssec_zone.c:134
rbtree.h
Red black tree.
ldns_struct_dnssec_name
Definition: dnssec_zone.h:45
ldns_dnssec_rrs_deep_free
void ldns_dnssec_rrs_deep_free(ldns_dnssec_rrs *rrs)
Frees the list of rrs, and the individual ldns_rr records contained in the list.
Definition: dnssec_zone.c:41
ldns_dnssec_name_find_rrset
ldns_dnssec_rrsets * ldns_dnssec_name_find_rrset(ldns_dnssec_name *name, ldns_rr_type type)
Find the RRset with the given type in within this name structure.
Definition: dnssec_zone.c:492
ldns_struct_dnssec_zone
Structure containing a dnssec zone.
Definition: dnssec_zone.h:91
ldns_dnssec_zone_deep_free
void ldns_dnssec_zone_deep_free(ldns_dnssec_zone *zone)
Frees the given zone structure, and its rbtree of dnssec_names Individual ldns_rr RRs within those na...
Definition: dnssec_zone.c:764
ldns_struct_rr
Resource Record.
Definition: rr.h:299
ldns_dnssec_rrs_add_rr
ldns_status ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr)
Adds an RR to the list of RRs.
Definition: dnssec_zone.c:47
ldns_struct_dnssec_zone::names
ldns_rbtree_t * names
tree of ldns_dnssec_names
Definition: dnssec_zone.h:95
ldns_struct_dnssec_rrs::rr
ldns_rr * rr
Definition: dnssec_zone.h:24
ldns_dnssec_rrs_print
void ldns_dnssec_rrs_print(FILE *out, ldns_dnssec_rrs *rrs)
Prints the given rrs to the file descriptor.
Definition: dnssec_zone.c:97
ldns_struct_dnssec_rrsets::type
ldns_rr_type type
Definition: dnssec_zone.h:35
ldns_struct_dnssec_name::is_glue
signed char is_glue
Unlike what the name is_glue suggests, this field is set to true by ldns_dnssec_zone_mark_glue() or l...
Definition: dnssec_zone.h:81
ldns_dnssec_name_name
ldns_rdf * ldns_dnssec_name_name(ldns_dnssec_name *name)
Returns the domain name of the given dnssec_name structure.
Definition: dnssec_zone.c:394
ldns_struct_dnssec_rrsets::signatures
ldns_dnssec_rrs * signatures
Definition: dnssec_zone.h:36
ldns_dnssec_name_cmp
int ldns_dnssec_name_cmp(const void *a, const void *b)
Compares the domain names of the two arguments in their canonical ordening.
Definition: dnssec_zone.c:430
host2str.h
host2str.h - txt presentation of RRs
ldns_dnssec_rrsets_set_type
ldns_status ldns_dnssec_rrsets_set_type(ldns_dnssec_rrsets *rrsets, ldns_rr_type type)
Sets the RR type of the rrset (that is head of the given list)
Definition: dnssec_zone.c:156
ldns_dnssec_zone_print
void ldns_dnssec_zone_print(FILE *out, ldns_dnssec_zone *zone)
Prints the complete zone to the given file descriptor.
Definition: dnssec_zone.c:987
ldns_dnssec_rrsets_add_rr
ldns_status ldns_dnssec_rrsets_add_rr(ldns_dnssec_rrsets *rrsets, ldns_rr *rr)
Add an ldns_rr to the corresponding RRset in the given list of RRsets.
Definition: dnssec_zone.c:193
ldns_rbtree_t
definition for tree struct
Definition: rbtree.h:83
ldns_dnssec_rrsets_print
void ldns_dnssec_rrsets_print(FILE *out, ldns_dnssec_rrsets *rrsets, signed char follow)
Print the given list of rrsets to the fiven file descriptor.
ldns_dnssec_zone_print_fmt
void ldns_dnssec_zone_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_zone *zone)
Prints the complete zone to the given file descriptor.
Definition: dnssec_zone.c:959
ldns_struct_dnssec_zone::soa
ldns_dnssec_name * soa
points to the name containing the SOA RR
Definition: dnssec_zone.h:93
ldns_status
enum ldns_enum_status ldns_status
Definition: error.h:131
ldns_struct_dnssec_rrs::next
ldns_dnssec_rrs * next
Definition: dnssec_zone.h:25
ldns_struct_dnssec_name::hashed_name
ldns_rdf * hashed_name
pointer to store the hashed name (only used when in an NSEC3 zone
Definition: dnssec_zone.h:85
ldns_struct_dnssec_zone::_nsec3params
ldns_rr * _nsec3params
points to the first added NSEC3 rr whose parameters will be assumed for all subsequent NSEC3 rr&#39;s and...
Definition: dnssec_zone.h:102
ldns_dnssec_zone_new_frm_fp_l
ldns_status ldns_dnssec_zone_new_frm_fp_l(ldns_dnssec_zone **z, FILE *fp, ldns_rdf *origin, uint32_t ttl, ldns_rr_class c, int *line_nr)
Create a new dnssec zone from a file, keep track of the line numbering.
ldns_dnssec_rrsets_print_fmt
void ldns_dnssec_rrsets_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_rrsets *rrsets, signed char follow)
Print the given list of rrsets to the fiven file descriptor.
ldns_dnssec_rrsets_new
ldns_dnssec_rrsets * ldns_dnssec_rrsets_new(void)
Creates a new list (entry) of RRsets.
Definition: dnssec_zone.c:104
ldns_struct_rdf
Resource record data field.
Definition: rdata.h:166
ldns_dnssec_zone_new_frm_fp
ldns_status ldns_dnssec_zone_new_frm_fp(ldns_dnssec_zone **z, FILE *fp, ldns_rdf *origin, uint32_t ttl, ldns_rr_class c)
Create a new dnssec zone from a file.
ldns_struct_dnssec_rrsets::next
ldns_dnssec_rrsets * next
Definition: dnssec_zone.h:37
ldns_dnssec_zone_names_print_fmt
void ldns_dnssec_zone_names_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_rbtree_t *tree, signed char print_soa)
Prints the rbtree of ldns_dnssec_name structures to the file descriptor.
ldns_rr_type
enum ldns_enum_rr_type ldns_rr_type
Definition: rr.h:236
ldns_dnssec_name_print_fmt
void ldns_dnssec_name_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_name *name)
Prints the RRs in the dnssec name structure to the given file descriptor.
Definition: dnssec_zone.c:555
ldns_dnssec_zone_names_print
void ldns_dnssec_zone_names_print(FILE *out, ldns_rbtree_t *tree, signed char print_soa)
Prints the rbtree of ldns_dnssec_name structures to the file descriptor.
ldns_struct_dnssec_name::nsec_signatures
ldns_dnssec_rrs * nsec_signatures
signatures for the NSEC record
Definition: dnssec_zone.h:71
ldns_dnssec_rrs_print_fmt
void ldns_dnssec_rrs_print_fmt(FILE *out, const ldns_output_format *fmt, ldns_dnssec_rrs *rrs)
Prints the given rrs to the file descriptor.
Definition: dnssec_zone.c:80
ldns_struct_dnssec_zone::hashed_names
ldns_rbtree_t * hashed_names
tree of ldns_dnssec_names by nsec3 hashes (when applicible)
Definition: dnssec_zone.h:97
ldns_dnssec_name_print
void ldns_dnssec_name_print(FILE *out, ldns_dnssec_name *name)
Prints the RRs in the dnssec name structure to the given file descriptor.
Definition: dnssec_zone.c:562
ldns_dnssec_rrs_free
void ldns_dnssec_rrs_free(ldns_dnssec_rrs *rrs)
Frees the list of rrs, but not the individual ldns_rr records contained in the list.
Definition: dnssec_zone.c:35
ldns_dnssec_zone_is_nsec3_optout
signed char ldns_dnssec_zone_is_nsec3_optout(ldns_dnssec_zone *zone)
If a NSEC3PARAM is available in the apex, walks the zone and returns true on the first optout nsec3...
Definition: dnssec_zone.c:1095
ldns_struct_dnssec_rrs
Definition: dnssec_zone.h:22
ldns_struct_dnssec_name::nsec
ldns_rr * nsec
NSEC pointing to the next name (or NSEC3 pointing to the next NSEC3)
Definition: dnssec_zone.h:67
ldns_dnssec_name_free
void ldns_dnssec_name_free(ldns_dnssec_name *name)
Frees the name structure and its rrs and rrsets.
Definition: dnssec_zone.c:382
ldns_struct_dnssec_rrsets
Definition: dnssec_zone.h:32
ldns_dnssec_zone_add_rr
ldns_status ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr)
Adds the given RR to the zone.
Definition: dnssec_zone.c:880
ldns_dnssec_rrs_new
ldns_dnssec_rrs * ldns_dnssec_rrs_new(void)
Creates a new entry for 1 pointer to an rr and 1 pointer to the next rrs.
Definition: dnssec_zone.c:10
ldns_struct_dnssec_name::name
ldns_rdf * name
pointer to a dname containing the name.
Definition: dnssec_zone.h:51