Electroneum
val_anchor.h File Reference
#include "util/rbtree.h"
#include "util/locks.h"
Include dependency graph for val_anchor.h:

Go to the source code of this file.

Classes

struct  val_anchors
 
struct  ta_key
 
struct  trust_anchor
 

Functions

struct val_anchorsanchors_create (void)
 
void anchors_delete (struct val_anchors *anchors)
 
int anchors_apply_cfg (struct val_anchors *anchors, struct config_file *cfg)
 
void anchors_init_parents_locked (struct val_anchors *anchors)
 
struct trust_anchoranchors_lookup (struct val_anchors *anchors, uint8_t *qname, size_t qname_len, uint16_t qclass)
 
struct trust_anchoranchor_find (struct val_anchors *anchors, uint8_t *name, int namelabs, size_t namelen, uint16_t dclass)
 
struct trust_anchoranchor_store_str (struct val_anchors *anchors, struct sldns_buffer *buffer, const char *str)
 
size_t anchors_get_mem (struct val_anchors *anchors)
 
int anchor_cmp (const void *k1, const void *k2)
 
int anchors_add_insecure (struct val_anchors *anchors, uint16_t c, uint8_t *nm)
 
void anchors_delete_insecure (struct val_anchors *anchors, uint16_t c, uint8_t *nm)
 
size_t anchor_list_keytags (struct trust_anchor *ta, uint16_t *list, size_t num)
 
int anchor_has_keytag (struct val_anchors *anchors, uint8_t *name, int namelabs, size_t namelen, uint16_t dclass, uint16_t keytag)
 

Detailed Description

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

Definition in file val_anchor.h.

Function Documentation

◆ anchor_cmp()

int anchor_cmp ( const void *  k1,
const void *  k2 
)

compare two trust anchors

◆ anchor_find()

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

Find a trust anchor. Exact matching.

Parameters
anchorsanchor storage.
namename of trust anchor (wireformat)
namelabslabels in name
namelenlength of name
dclassclass of trust anchor
Returns
NULL if not found. The anchor is locked.

◆ anchor_has_keytag()

int anchor_has_keytag ( struct val_anchors anchors,
uint8_t name,
int  namelabs,
size_t  namelen,
uint16_t  dclass,
uint16_t  keytag 
)

Check if there is a trust anchor for given zone with this keytag.

Parameters
anchorsanchor storage
namename of trust anchor (wireformat)
namelabslabels in name
namelenlength of name
dclassclass of trust anchor
keytagkeytag
Returns
1 if there is a trust anchor in the trustachor store for this zone and keytag, else 0.

◆ anchor_list_keytags()

size_t anchor_list_keytags ( struct trust_anchor ta,
uint16_t list,
size_t  num 
)

Get a list of keytags for the trust anchor. Zero tags for insecure points.

Parameters
tatrust anchor (locked by caller).
listarray of uint16_t.
numlength of array.
Returns
number of keytags filled into array. If total number of keytags is bigger than the array, it is truncated at num. On errors, less keytags are filled in. The array is sorted.

◆ anchor_store_str()

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

Store one string as trust anchor RR.

Parameters
anchorsanchor storage.
bufferparsing buffer, to generate the RR wireformat in.
strstring.
Returns
NULL on error.

◆ anchors_add_insecure()

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
anchorsanchor storage.
cclass.
nmname of insecure trust point.
Returns
false on alloc failure.

◆ anchors_apply_cfg()

int anchors_apply_cfg ( struct val_anchors anchors,
struct config_file cfg 
)

Process trust anchor config.

Parameters
anchorsstruct anchor storage
cfgconfig options.
Returns
0 on error.

◆ anchors_create()

struct val_anchors* anchors_create ( void  )

Create trust anchor storage

Returns
new storage or NULL on error.

◆ anchors_delete()

void anchors_delete ( struct val_anchors anchors)

Delete trust anchor storage.

Parameters
anchorsto delete.

◆ anchors_delete_insecure()

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
anchorsanchor storage.
cclass.
nmname of insecure trust point.

◆ anchors_get_mem()

size_t anchors_get_mem ( struct val_anchors anchors)

Get memory in use by the trust anchor storage

Parameters
anchorsanchor storage.
Returns
memory in use in bytes.

◆ anchors_init_parents_locked()

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
anchorsthe structure to update.

◆ anchors_lookup()

struct trust_anchor* anchors_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. Or return NULL if none exists.

Parameters
anchorsstruct anchor storage
qnamequery name, uncompressed wireformat.
qname_lenlength of qname.
qclassclass to query for.
Returns
the trust anchor or NULL if none is found. The anchor is locked.