This file contains functions to assist the iterator module. More...
#include "config.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_delegpt.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/data/dname.h"
#include "sldns/rrdef.h"
#include "sldns/str2wire.h"
Functions | |
int | fwd_cmp (const void *k1, const void *k2) |
compare two fwd entries | |
struct iter_forwards * | forwards_create (void) |
Create forwards. More... | |
static void | fwd_zone_free (struct iter_forward_zone *n) |
static void | delfwdnode (rbnode_type *n, void *ATTR_UNUSED(arg)) |
static void | fwd_del_tree (struct iter_forwards *fwd) |
void | forwards_delete (struct iter_forwards *fwd) |
Delete forwards. More... | |
static int | forwards_insert_data (struct iter_forwards *fwd, uint16_t c, uint8_t *nm, size_t nmlen, int nmlabs, struct delegpt *dp) |
insert info into forward structure | |
static int | forwards_insert (struct iter_forwards *fwd, uint16_t c, struct delegpt *dp) |
insert new info into forward structure given dp | |
static void | fwd_init_parents (struct iter_forwards *fwd) |
initialise parent pointers in the tree | |
static struct delegpt * | read_fwds_name (struct config_stub *s) |
set zone name | |
static int | read_fwds_host (struct config_stub *s, struct delegpt *dp) |
set fwd host names | |
static int | read_fwds_addr (struct config_stub *s, struct delegpt *dp) |
set fwd server addresses | |
static int | read_forwards (struct iter_forwards *fwd, struct config_file *cfg) |
read forwards config | |
static int | fwd_add_stub_hole (struct iter_forwards *fwd, uint16_t c, uint8_t *nm) |
insert a stub hole (if necessary) for stub name | |
static int | make_stub_holes (struct iter_forwards *fwd, struct config_file *cfg) |
make NULL entries for stubs | |
int | forwards_apply_cfg (struct iter_forwards *fwd, struct config_file *cfg) |
Process forwards config. More... | |
struct delegpt * | forwards_find (struct iter_forwards *fwd, uint8_t *qname, uint16_t qclass, int nolock) |
Find forward zone exactly by name The return value is contents of the forwards structure. More... | |
struct delegpt * | forwards_lookup (struct iter_forwards *fwd, uint8_t *qname, uint16_t qclass, int nolock) |
Find forward zone information For this qname/qclass find forward zone information, returns delegation point with server names and addresses, or NULL if no forwarding is needed. More... | |
struct delegpt * | forwards_lookup_root (struct iter_forwards *fwd, uint16_t qclass, int nolock) |
Same as forwards_lookup, but for the root only. More... | |
static int | next_root_locked (struct iter_forwards *fwd, uint16_t *dclass) |
int | forwards_next_root (struct iter_forwards *fwd, uint16_t *dclass, int nolock) |
Find next root item in forwards lookup tree. More... | |
size_t | forwards_get_mem (struct iter_forwards *fwd) |
Get memory in use by forward storage Locks and unlocks the structure. More... | |
static struct iter_forward_zone * | fwd_zone_find (struct iter_forwards *fwd, uint16_t c, uint8_t *nm) |
int | forwards_add_zone (struct iter_forwards *fwd, uint16_t c, struct delegpt *dp, int nolock) |
Add zone to forward structure. More... | |
void | forwards_delete_zone (struct iter_forwards *fwd, uint16_t c, uint8_t *nm, int nolock) |
Remove zone from forward structure. More... | |
int | forwards_add_stub_hole (struct iter_forwards *fwd, uint16_t c, uint8_t *nm, int nolock) |
Add stub hole (empty entry in forward table, that makes resolution skip a forward-zone because the stub zone should override the forward zone). More... | |
void | forwards_delete_stub_hole (struct iter_forwards *fwd, uint16_t c, uint8_t *nm, int nolock) |
Remove stub hole, if one exists. More... | |
This file contains functions to assist the iterator module.
Keep track of forward zones and config settings.
struct iter_forwards* forwards_create | ( | void | ) |
Create forwards.
References iter_forwards::lock.
Referenced by check_fwd(), and context_finalize().
void forwards_delete | ( | struct iter_forwards * | fwd | ) |
Delete forwards.
fwd | to delete. |
References iter_forwards::lock.
Referenced by daemon_cleanup().
int forwards_apply_cfg | ( | struct iter_forwards * | fwd, |
struct config_file * | cfg | ||
) |
Process forwards config.
fwd | where to store. |
cfg | config options. |
References iter_forwards::lock, and iter_forwards::tree.
Referenced by check_fwd(), and context_finalize().
struct delegpt* forwards_find | ( | struct iter_forwards * | fwd, |
uint8_t * | qname, | ||
uint16_t | qclass, | ||
int | nolock | ||
) |
Find forward zone exactly by name The return value is contents of the forwards structure.
Caller should lock and unlock a readlock on the forwards structure if nolock is set. Otherwise caller should unlock the readlock on the forwards structure if a value was returned.
fwd | forward storage. |
qname | The qname of the query. |
qclass | The qclass of the query. |
nolock | Skip locking, locking is handled by the caller. |
References iter_forward_zone::dclass, dname_count_size_labels(), iter_forward_zone::dp, rbnode_type::key, iter_forwards::lock, iter_forward_zone::name, iter_forward_zone::namelabs, iter_forward_zone::namelen, iter_forward_zone::node, rbtree_search(), and iter_forwards::tree.
struct delegpt* forwards_lookup | ( | struct iter_forwards * | fwd, |
uint8_t * | qname, | ||
uint16_t | qclass, | ||
int | nolock | ||
) |
Find forward zone information For this qname/qclass find forward zone information, returns delegation point with server names and addresses, or NULL if no forwarding is needed.
The return value is contents of the forwards structure. Caller should lock and unlock a readlock on the forwards structure if nolock is set. Otherwise caller should unlock the readlock on the forwards structure if a value was returned.
fwd | forward storage. |
qname | The qname of the query. |
qclass | The qclass of the query. |
nolock | Skip locking, locking is handled by the caller. |
References iter_forward_zone::dclass, dname_count_size_labels(), dname_lab_cmp(), iter_forward_zone::dp, rbnode_type::key, iter_forwards::lock, iter_forward_zone::name, iter_forward_zone::namelabs, iter_forward_zone::namelen, iter_forward_zone::node, iter_forward_zone::parent, rbtree_find_less_equal(), and iter_forwards::tree.
Referenced by forward_request(), forwards_lookup_root(), iter_stub_fwd_no_cache(), and print_root_fwds().
struct delegpt* forwards_lookup_root | ( | struct iter_forwards * | fwd, |
uint16_t | qclass, | ||
int | nolock | ||
) |
Same as forwards_lookup, but for the root only.
fwd | forward storage. |
qclass | The qclass of the query. |
nolock | Skip locking, locking is handled by the caller. |
References forwards_lookup().
int forwards_next_root | ( | struct iter_forwards * | fwd, |
uint16_t * | qclass, | ||
int | nolock | ||
) |
Find next root item in forwards lookup tree.
Handles its own locking unless nolock is set. In that case the caller should lock and unlock a readlock on the forwards structure.
fwd | the forward storage |
qclass | class to look at next, or higher. |
nolock | Skip locking, locking is handled by the caller. |
References iter_forwards::lock.
Referenced by iter_get_next_root().
size_t forwards_get_mem | ( | struct iter_forwards * | fwd | ) |
Get memory in use by forward storage Locks and unlocks the structure.
fwd | forward storage. |
References delegpt_get_mem(), iter_forward_zone::dp, iter_forwards::lock, iter_forward_zone::namelen, RBTREE_FOR, and iter_forwards::tree.
int forwards_add_zone | ( | struct iter_forwards * | fwd, |
uint16_t | c, | ||
struct delegpt * | dp, | ||
int | nolock | ||
) |
Add zone to forward structure.
For external use since it recalcs the tree parents. Handles its own locking unless nolock is set. In that case the caller should lock and unlock a writelock on the forwards structure.
fwd | the forward data structure |
c | class of zone |
dp | delegation point with name and target nameservers for new forward zone. malloced. |
nolock | Skip locking, locking is handled by the caller. |
References iter_forwards::lock.
Referenced by do_forward().
void forwards_delete_zone | ( | struct iter_forwards * | fwd, |
uint16_t | c, | ||
uint8_t * | nm, | ||
int | nolock | ||
) |
Remove zone from forward structure.
For external use since it recalcs the tree parents. Handles its own locking unless nolock is set. In that case the caller should lock and unlock a writelock on the forwards structure.
fwd | the forward data structure |
c | class of zone |
nm | name of zone (in uncompressed wireformat). |
nolock | Skip locking, locking is handled by the caller. |
References iter_forwards::lock.
Referenced by do_forward().
int forwards_add_stub_hole | ( | struct iter_forwards * | fwd, |
uint16_t | c, | ||
uint8_t * | nm, | ||
int | nolock | ||
) |
Add stub hole (empty entry in forward table, that makes resolution skip a forward-zone because the stub zone should override the forward zone).
Does not add one if not necessary. Handles its own locking unless nolock is set. In that case the caller should lock and unlock a writelock on the forwards structure.
fwd | the forward data structure |
c | class of zone |
nm | name of zone (in uncompressed wireformat). |
nolock | Skip locking, locking is handled by the caller. |
References iter_forwards::lock.
void forwards_delete_stub_hole | ( | struct iter_forwards * | fwd, |
uint16_t | c, | ||
uint8_t * | nm, | ||
int | nolock | ||
) |
Remove stub hole, if one exists.
Handles its own locking unless nolock is set. In that case the caller should lock and unlock a writelock on the forwards structure.
fwd | the forward data structure |
c | class of zone |
nm | name of zone (in uncompressed wireformat). |
nolock | Skip locking, locking is handled by the caller. |
References iter_forwards::lock.