dnstree.c File Reference

This file contains structures combining types and functions to manipulate those structures that help building DNS lookup trees. More...

#include "config.h"
#include "util/storage/dnstree.h"
#include "util/data/dname.h"
#include "util/net_help.h"

Functions

int name_tree_compare (const void *k1, const void *k2)
 compare name tree nodes
int addr_tree_compare (const void *k1, const void *k2)
 compare addr tree nodes
void name_tree_init (rbtree_t *tree)
 Init a name tree to be empty.
void addr_tree_init (rbtree_t *tree)
 Init addr tree to be empty.
int name_tree_insert (rbtree_t *tree, struct name_tree_node *node, uint8_t *name, size_t len, int labs, uint16_t dclass)
 insert element into name tree.
int addr_tree_insert (rbtree_t *tree, struct addr_tree_node *node, struct sockaddr_storage *addr, socklen_t addrlen, int net)
 insert element into addr tree.
void addr_tree_init_parents (rbtree_t *tree)
 Initialize parent pointers in addr tree.
void name_tree_init_parents (rbtree_t *tree)
 Initialize parent pointers in name tree.
struct name_tree_nodename_tree_find (rbtree_t *tree, uint8_t *name, size_t len, int labs, uint16_t dclass)
 Lookup exact match in name tree.
struct name_tree_nodename_tree_lookup (rbtree_t *tree, uint8_t *name, size_t len, int labs, uint16_t dclass)
 Lookup closest encloser in name tree.
struct addr_tree_nodeaddr_tree_lookup (rbtree_t *tree, struct sockaddr_storage *addr, socklen_t addrlen)
 Lookup closest encloser in addr tree.


Detailed Description

This file contains structures combining types and functions to manipulate those structures that help building DNS lookup trees.


Function Documentation

void name_tree_init ( rbtree_t tree  ) 

Init a name tree to be empty.

Parameters:
tree,: to init.

References name_tree_compare(), and rbtree_init().

Referenced by hints_apply_cfg(), priv_apply_cfg(), and priv_create().

void addr_tree_init ( rbtree_t tree  ) 

Init addr tree to be empty.

Parameters:
tree,: to init.

References addr_tree_compare(), and rbtree_init().

Referenced by acl_list_apply_cfg(), donotq_apply_cfg(), priv_apply_cfg(), and priv_create().

int name_tree_insert ( rbtree_t tree,
struct name_tree_node node,
uint8_t *  name,
size_t  len,
int  labs,
uint16_t  dclass 
)

insert element into name tree.

Parameters:
tree,: name tree
node,: node element (at start of a structure that caller has allocated).
name,: name to insert (wireformat) this node has been allocated by the caller and it itself inserted.
len,: length of name
labs,: labels in name
dclass,: class of name
Returns:
false on error (duplicate element).

References name_tree_node::dclass, rbnode_t::key, name_tree_node::labs, name_tree_node::len, name_tree_node::name, name_tree_node::node, name_tree_node::parent, and rbtree_insert().

Referenced by hints_insert(), and read_names().

int addr_tree_insert ( rbtree_t tree,
struct addr_tree_node node,
struct sockaddr_storage *  addr,
socklen_t  addrlen,
int  net 
)

insert element into addr tree.

Parameters:
tree,: addr tree
node,: node element (at start of a structure that caller has allocated).
addr,: to insert (copied).
addrlen,: length of addr
net,: size of subnet.
Returns:
false on error (duplicate element).

References addr_tree_node::addr, addr_tree_node::addrlen, rbnode_t::key, addr_tree_node::net, addr_tree_node::node, addr_tree_node::parent, and rbtree_insert().

Referenced by acl_list_insert(), donotq_insert(), and read_addrs().

void addr_tree_init_parents ( rbtree_t tree  ) 

Initialize parent pointers in addr tree.

Should be performed after insertions are done, before lookups

Parameters:
tree,: addr tree

References addr_tree_node::addr, addr_in_common(), addr_tree_node::addrlen, addr_tree_node::net, addr_tree_node::node, addr_tree_node::parent, and RBTREE_FOR.

Referenced by acl_list_apply_cfg(), donotq_apply_cfg(), and priv_apply_cfg().

void name_tree_init_parents ( rbtree_t tree  ) 

Initialize parent pointers in name tree.

Should be performed after insertions are done, before lookups

Parameters:
tree,: name tree

References name_tree_node::dclass, dname_lab_cmp(), name_tree_node::labs, name_tree_node::name, name_tree_node::node, name_tree_node::parent, and RBTREE_FOR.

Referenced by hints_apply_cfg(), and priv_apply_cfg().

struct name_tree_node* name_tree_find ( rbtree_t tree,
uint8_t *  name,
size_t  len,
int  labs,
uint16_t  dclass 
) [read]

Lookup exact match in name tree.

Parameters:
tree,: name tree
name,: wireformat name
len,: length of name
labs,: labels in name
dclass,: class of name
Returns:
node or NULL if not found.

References name_tree_node::dclass, rbnode_t::key, name_tree_node::labs, name_tree_node::len, name_tree_node::name, name_tree_node::node, and rbtree_search().

Referenced by hints_lookup_root().

struct name_tree_node* name_tree_lookup ( rbtree_t tree,
uint8_t *  name,
size_t  len,
int  labs,
uint16_t  dclass 
) [read]

Lookup closest encloser in name tree.

Parameters:
tree,: name tree
name,: wireformat name
len,: length of name
labs,: labels in name
dclass,: class of name
Returns:
closest enclosing node (could be equal) or NULL if not found.

References name_tree_node::dclass, dname_lab_cmp(), rbnode_t::key, name_tree_node::labs, name_tree_node::len, name_tree_node::name, name_tree_node::node, name_tree_node::parent, and rbtree_find_less_equal().

Referenced by hints_lookup_stub(), and priv_lookup_name().

struct addr_tree_node* addr_tree_lookup ( rbtree_t tree,
struct sockaddr_storage *  addr,
socklen_t  addrlen 
) [read]

Lookup closest encloser in addr tree.

Parameters:
tree,: addr tree
addr,: to lookup.
addrlen,: length of addr
Returns:
closest enclosing node (could be equal) or NULL if not found.

References addr_tree_node::addr, addr_in_common(), addr_is_ip6(), addr_tree_node::addrlen, rbnode_t::key, addr_tree_node::net, addr_tree_node::node, addr_tree_node::parent, and rbtree_find_less_equal().

Referenced by acl_list_lookup(), donotq_lookup(), and priv_lookup_addr().


Generated on Tue Oct 13 06:45:51 2009 for unbound by  doxygen 1.5.9