unbound  0.1
Data Structures | Functions
val_anchor.h File Reference

This file contains storage for the trust anchors for the validator. More...

#include "util/rbtree.h"
#include "util/locks.h"

Data Structures

struct  val_anchors
 Trust anchor store. More...
struct  ta_key
 Trust anchor key. More...
struct  trust_anchor
 A trust anchor in the trust anchor store. More...

Functions

struct val_anchorsanchors_create (void)
 Create trust anchor storage.
void anchors_delete (struct val_anchors *anchors)
 Delete trust anchor storage.
int anchors_apply_cfg (struct val_anchors *anchors, struct config_file *cfg)
 Process trust anchor config.
void anchors_init_parents_locked (struct val_anchors *anchors)
 Recalculate parent pointers.
struct trust_anchoranchors_lookup (struct val_anchors *anchors, uint8_t *qname, size_t qname_len, uint16_t qclass)
 Given a qname/qclass combination, find the trust anchor closest above it.
struct trust_anchoranchor_find (struct val_anchors *anchors, uint8_t *name, int namelabs, size_t namelen, uint16_t dclass)
 Find a trust anchor.
struct trust_anchoranchor_store_str (struct val_anchors *anchors, ldns_buffer *buffer, const char *str)
 Store one string as trust anchor RR.
size_t anchors_get_mem (struct val_anchors *anchors)
 Get memory in use by the trust anchor storage.
int anchor_cmp (const void *k1, const void *k2)
 compare two trust anchors
int anchors_add_insecure (struct val_anchors *anchors, uint16_t c, uint8_t *nm)
 Add insecure point trust anchor.
void anchors_delete_insecure (struct val_anchors *anchors, uint16_t c, uint8_t *nm)
 Delete insecure point trust anchor.

Detailed Description

This file contains storage for the trust anchors for the validator.

Function Documentation

struct val_anchors* anchors_create ( void  )
read

Create trust anchor storage.

Returns
new storage or NULL on error.

References anchor_cmp(), anchors_delete(), val_anchors::autr, autr_global_create(), val_anchors::lock, rbtree_create(), and val_anchors::tree.

Referenced by anchors_test(), and val_apply_cfg().

void anchors_delete ( struct val_anchors anchors)

Delete trust anchor storage.

Parameters
anchors,:to delete.

References anchors_delfunc(), val_anchors::autr, autr_global_delete(), val_anchors::lock, traverse_postorder(), and val_anchors::tree.

Referenced by anchors_create(), anchors_test(), and val_deinit().

int anchors_apply_cfg ( struct val_anchors anchors,
struct config_file cfg 
)
void anchors_init_parents_locked ( struct val_anchors anchors)

Recalculate parent pointers.

The caller must hold the lock on the anchors structure (say after removing an item from the rbtree). Caller must not hold any locks on trust anchors. After the call is complete the parent pointers are updated and an item just removed is no longer referenced in parent pointers.

Parameters
anchors,:the structure to update.

References trust_anchor::dclass, dname_lab_cmp(), trust_anchor::lock, trust_anchor::name, trust_anchor::namelabs, trust_anchor::node, trust_anchor::parent, RBTREE_FOR, and val_anchors::tree.

Referenced by anchors_add_insecure(), anchors_delete_insecure(), autr_tp_remove(), and init_parents().

struct trust_anchor* anchors_lookup ( struct val_anchors anchors,
uint8_t *  qname,
size_t  qname_len,
uint16_t  qclass 
)
read

Given a qname/qclass combination, find the trust anchor closest above it.

Or return NULL if none exists.

Parameters
anchors,:struct anchor storage
qname,:query name, uncompressed wireformat.
qname_len,:length of qname.
qclass,:class to query for.
Returns
the trust anchor or NULL if none is found. The anchor is locked.

References trust_anchor::dclass, dname_count_labels(), dname_lab_cmp(), rbnode_t::key, val_anchors::lock, trust_anchor::lock, trust_anchor::name, trust_anchor::namelabs, trust_anchor::namelen, trust_anchor::node, trust_anchor::parent, rbtree_find_less_equal(), and val_anchors::tree.

Referenced by check_no_anchor(), processInit(), test_anchor_empty(), test_anchor_one(), and test_anchors().

struct trust_anchor* anchor_find ( struct val_anchors anchors,
uint8_t *  name,
int  namelabs,
size_t  namelen,
uint16_t  dclass 
)
read

Find a trust anchor.

Exact matching.

Parameters
anchors,:anchor storage.
name,:name of trust anchor (wireformat)
namelabs,:labels in name
namelen,:length of name
dclass,:class of trust anchor
Returns
NULL if not found. The anchor is locked.

References trust_anchor::dclass, rbnode_t::key, val_anchors::lock, trust_anchor::name, trust_anchor::namelabs, trust_anchor::namelen, trust_anchor::node, rbtree_search(), and val_anchors::tree.

Referenced by anchor_store_new_key(), find_add_tp(), iter_indicates_dnssec(), and process_prime_response().

struct trust_anchor* anchor_store_str ( struct val_anchors anchors,
ldns_buffer *  buffer,
const char *  str 
)
read

Store one string as trust anchor RR.

Parameters
anchors,:anchor storage.
buffer,:parsing buffer, to generate the RR wireformat in.
str,:string.
Returns
NULL on error.

References anchor_store_new_rr(), and log_err().

Referenced by anchors_apply_cfg(), process_bind_contents(), test_anchor_one(), and test_anchors().

size_t anchors_get_mem ( struct val_anchors anchors)

Get memory in use by the trust anchor storage.

Parameters
anchors,:anchor storage.
Returns
memory in use in bytes.

References trust_anchor::namelen, RBTREE_FOR, and val_anchors::tree.

Referenced by worker_mem_report().

int anchors_add_insecure ( struct val_anchors anchors,
uint16_t  c,
uint8_t *  nm 
)

Add insecure point trust anchor.

For external use (locks and init_parents)

Parameters
anchors,:anchor storage.
c,:class.
nm,:name of insecure trust point.
Returns
false on alloc failure.

References anchor_new_ta(), anchors_init_parents_locked(), trust_anchor::dclass, dname_count_size_labels(), rbnode_t::key, val_anchors::lock, log_err(), trust_anchor::name, trust_anchor::namelabs, trust_anchor::namelen, trust_anchor::node, rbtree_search(), and val_anchors::tree.

Referenced by do_forward_add(), and do_stub_add().

void anchors_delete_insecure ( struct val_anchors anchors,
uint16_t  c,
uint8_t *  nm 
)

Delete insecure point trust anchor.

Does not remove if no such point. For external use (locks and init_parents)

Parameters
anchors,:anchor storage.
c,:class.
nm,:name of insecure trust point.

References anchors_delfunc(), anchors_init_parents_locked(), trust_anchor::autr, trust_anchor::dclass, dname_count_size_labels(), rbnode_t::key, trust_anchor::keylist, val_anchors::lock, trust_anchor::lock, trust_anchor::name, trust_anchor::namelabs, trust_anchor::namelen, trust_anchor::node, trust_anchor::numDNSKEY, trust_anchor::numDS, rbtree_delete(), rbtree_search(), and val_anchors::tree.

Referenced by do_forward_remove(), do_stub_add(), and do_stub_remove().