Data Structures | Functions
iter_hints.h File Reference

This file contains functions to assist the iterator module. More...

#include "util/storage/dnstree.h"

Data Structures

struct  iter_hints
 Iterator hints structure. More...
 
struct  iter_hints_stub
 Iterator hints for a particular stub. More...
 

Functions

struct iter_hintshints_create (void)
 Create hints. More...
 
void hints_delete (struct iter_hints *hints)
 Delete hints. More...
 
int hints_apply_cfg (struct iter_hints *hints, struct config_file *cfg)
 Process hints config. More...
 
struct delegpthints_lookup_root (struct iter_hints *hints, uint16_t qclass)
 Find root hints for the given class. More...
 
int hints_next_root (struct iter_hints *hints, uint16_t *qclass)
 Find next root hints (to cycle through all root hints). More...
 
struct iter_hints_stubhints_lookup_stub (struct iter_hints *hints, uint8_t *qname, uint16_t qclass, struct delegpt *dp)
 Given a qname/qclass combination, and the delegation point from the cache for this qname/qclass, determine if this combination indicates that a stub hint exists and must be primed. More...
 
size_t hints_get_mem (struct iter_hints *hints)
 Get memory in use by hints. More...
 
int hints_add_stub (struct iter_hints *hints, uint16_t c, struct delegpt *dp, int noprime)
 Add stub to hints structure. More...
 
void hints_delete_stub (struct iter_hints *hints, uint16_t c, uint8_t *nm)
 Remove stub from hints structure. More...
 

Detailed Description

This file contains functions to assist the iterator module.

Keep track of stub and root hints, and read those from config.

Function Documentation

◆ hints_create()

struct iter_hints* hints_create ( void  )

Create hints.

Returns
new hints or NULL on error.

Referenced by check_hints(), and libworker_setup().

◆ hints_delete()

void hints_delete ( struct iter_hints hints)

Delete hints.

Parameters
hintsto delete.

Referenced by libworker_delete_env(), libworker_setup(), and worker_delete().

◆ hints_apply_cfg()

int hints_apply_cfg ( struct iter_hints hints,
struct config_file cfg 
)

Process hints config.

Sets default values for root hints if no config.

Parameters
hintswhere to store.
cfgconfig options.
Returns
0 on error.

Referenced by check_hints(), and libworker_setup().

◆ hints_lookup_root()

struct delegpt* hints_lookup_root ( struct iter_hints hints,
uint16_t  qclass 
)

Find root hints for the given class.

Parameters
hintshint storage.
qclassclass for which root hints are requested. host order.
Returns
: NULL if no hints, or a ptr to stored hints.

References iter_hints_stub::dp, name_tree_find(), and iter_hints::tree.

Referenced by prime_root().

◆ hints_next_root()

int hints_next_root ( struct iter_hints hints,
uint16_t *  qclass 
)

Find next root hints (to cycle through all root hints).

Parameters
hintshint storage
qclassclass for which root hints are sought. 0 means give the first available root hints class. x means, give class x or a higher class if any. returns the found class in this variable.
Returns
true if a root hint class is found. false if not root hint class is found (qclass may have been changed).

References name_tree_next_root(), and iter_hints::tree.

Referenced by iter_get_next_root().

◆ hints_lookup_stub()

struct iter_hints_stub* hints_lookup_stub ( struct iter_hints hints,
uint8_t *  qname,
uint16_t  qclass,
struct delegpt dp 
)

Given a qname/qclass combination, and the delegation point from the cache for this qname/qclass, determine if this combination indicates that a stub hint exists and must be primed.

Parameters
hintshint storage.
qnameThe qname that generated the delegation point.
qclassThe qclass that generated the delegation point.
dpThe cache generated delegation point.
Returns
: A priming delegation point if there is a stub hint that must be primed, otherwise null.

References dname_count_size_labels(), dname_strict_subdomain(), iter_hints_stub::dp, delegpt::name, name_tree_lookup(), delegpt::namelabs, iter_hints_stub::noprime, query_dname_compare(), and iter_hints::tree.

Referenced by prime_stub().

◆ hints_get_mem()

size_t hints_get_mem ( struct iter_hints hints)

Get memory in use by hints.

Parameters
hintshint storage.
Returns
bytes in use

References delegpt_get_mem(), iter_hints_stub::dp, RBTREE_FOR, and iter_hints::tree.

◆ hints_add_stub()

int hints_add_stub ( struct iter_hints hints,
uint16_t  c,
struct delegpt dp,
int  noprime 
)

Add stub to hints structure.

For external use since it recalcs the tree parents.

Parameters
hintsthe hints data structure
cclass of zone
dpdelegation point with name and target nameservers for new hints stub. malloced.
noprimeset noprime option to true or false on new hint stub.
Returns
false on failure (out of memory);

References delegpt::name, name_tree_find(), delegpt::namelabs, delegpt::namelen, iter_hints_stub::node, rbtree_delete(), and iter_hints::tree.

◆ hints_delete_stub()

void hints_delete_stub ( struct iter_hints hints,
uint16_t  c,
uint8_t *  nm 
)

Remove stub from hints structure.

For external use since it recalcs the tree parents.

Parameters
hintsthe hints data structure
cclass of stub zone
nmname of stub zone (in uncompressed wireformat).

References dname_count_size_labels(), name_tree_find(), iter_hints_stub::node, rbtree_delete(), and iter_hints::tree.