iter_fwd.c File Reference

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/regional.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/data/dname.h"

Functions

int fwd_cmp (const void *k1, const void *k2)
 compare two fwd entries
struct iter_forwardsforwards_create ()
 Create forwards.
void forwards_delete (struct iter_forwards *fwd)
 Delete forwards.
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 int read_fwds_name (struct iter_forwards *fwd, struct config_stub *s, struct delegpt *dp)
 set zone name
static int read_fwds_host (struct iter_forwards *fwd, struct config_stub *s, struct delegpt *dp)
 set fwd host names
static int read_fwds_addr (struct iter_forwards *fwd, 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 need_hole_insert (rbtree_t *tree, struct iter_forward_zone *zone)
 see if zone needs to have a hole inserted
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.
struct delegptforwards_lookup (struct iter_forwards *fwd, uint8_t *qname, uint16_t qclass)
 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.
struct delegptforwards_lookup_root (struct iter_forwards *fwd, uint16_t qclass)
 Same as forwards_lookup, but for the root only.
size_t forwards_get_mem (struct iter_forwards *fwd)
 Get memory in use by forward storage.
int forwards_add_zone (struct iter_forwards *fwd, uint16_t c, struct delegpt *dp)
 Add zone to forward structure.
void forwards_delete_zone (struct iter_forwards *fwd, uint16_t c, uint8_t *nm)
 Remove zone from forward structure.


Detailed Description

This file contains functions to assist the iterator module.

Keep track of forward zones and config settings.


Function Documentation

struct iter_forwards* forwards_create (  )  [read]

Create forwards.

Returns:
new forwards or NULL on error.

References forwards_delete(), iter_forwards::region, and regional_create().

Referenced by check_fwd(), libworker_setup(), and worker_init().

void forwards_delete ( struct iter_forwards fwd  ) 

Delete forwards.

Parameters:
fwd,: to delete.

References iter_forwards::region, regional_destroy(), and iter_forwards::tree.

Referenced by check_fwd(), forwards_create(), libworker_delete(), libworker_setup(), and worker_delete().

int forwards_apply_cfg ( struct iter_forwards fwd,
struct config_file cfg 
)

Process forwards config.

Parameters:
fwd,: where to store.
cfg,: config options.
Returns:
0 on error.

References fwd_cmp(), fwd_init_parents(), make_stub_holes(), rbtree_create(), read_forwards(), iter_forwards::region, regional_free_all(), and iter_forwards::tree.

Referenced by check_fwd(), do_forward(), libworker_setup(), and worker_init().

struct delegpt* forwards_lookup ( struct iter_forwards fwd,
uint8_t *  qname,
uint16_t  qclass 
) [read]

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.

Parameters:
fwd,: forward storage.
qname,: The qname of the query.
qclass,: The qclass of the query.
Returns:
: A delegation point if the query has to be forwarded to that list, otherwise null.

References iter_forward_zone::dclass, dname_count_size_labels(), dname_lab_cmp(), iter_forward_zone::dp, rbnode_t::key, 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(), and print_root_fwds().

struct delegpt* forwards_lookup_root ( struct iter_forwards fwd,
uint16_t  qclass 
) [read]

Same as forwards_lookup, but for the root only.

Parameters:
fwd,: forward storage.
qclass,: The qclass of the query.
Returns:
: A delegation point if root forward exists, otherwise null.

References forwards_lookup().

Referenced by processInitRequest().

size_t forwards_get_mem ( struct iter_forwards fwd  ) 

Get memory in use by forward storage.

Parameters:
fwd,: forward storage.
Returns:
bytes in use

References iter_forwards::region, regional_get_mem(), and iter_forwards::tree.

Referenced by worker_mem_report().

int forwards_add_zone ( struct iter_forwards fwd,
uint16_t  c,
struct delegpt dp 
)

Add zone to forward structure.

For external use since it recalcs the tree parents.

Parameters:
fwd,: the forward data structure
c,: class of zone
dp,: delegation point with name and target nameservers for new forward zone. This delegation point and all its data must be malloced in the fwd->region. (then it is freed when the fwd is deleted).
Returns:
false on failure (out of memory);

References forwards_insert(), and fwd_init_parents().

Referenced by do_forward().

void forwards_delete_zone ( struct iter_forwards fwd,
uint16_t  c,
uint8_t *  nm 
)

Remove zone from forward structure.

For external use since it recalcs the tree parents. Does not actually release any memory, the region is unchanged.

Parameters:
fwd,: the forward data structure
c,: class of zone
nm,: name of zone (in uncompressed wireformat).

References iter_forward_zone::dclass, dname_count_size_labels(), fwd_init_parents(), rbnode_t::key, iter_forward_zone::name, iter_forward_zone::namelabs, iter_forward_zone::namelen, iter_forward_zone::node, rbtree_delete(), rbtree_search(), and iter_forwards::tree.

Referenced by do_forward().


Generated on Tue Oct 13 06:46:30 2009 for unbound by  doxygen 1.5.9