This file contains structures combining types and functions to manipulate those structures that help building DNS lookup trees. More...
#include "util/rbtree.h"
Data Structures | |
struct | name_tree_node |
Tree of domain names. More... | |
struct | addr_tree_node |
Tree of IP addresses. More... | |
Functions | |
void | name_tree_init (rbtree_type *tree) |
Init a name tree to be empty. More... | |
int | name_tree_insert (rbtree_type *tree, struct name_tree_node *node, uint8_t *name, size_t len, int labs, uint16_t dclass) |
insert element into name tree. More... | |
void | name_tree_init_parents (rbtree_type *tree) |
Initialize parent pointers in name tree. More... | |
struct name_tree_node * | name_tree_find (rbtree_type *tree, uint8_t *name, size_t len, int labs, uint16_t dclass) |
Lookup exact match in name tree. More... | |
struct name_tree_node * | name_tree_lookup (rbtree_type *tree, uint8_t *name, size_t len, int labs, uint16_t dclass) |
Lookup closest encloser in name tree. More... | |
int | name_tree_next_root (rbtree_type *tree, uint16_t *dclass) |
Find next root item in name tree. More... | |
void | addr_tree_init (rbtree_type *tree) |
Init addr tree to be empty. More... | |
void | addr_tree_addrport_init (rbtree_type *tree) |
Init addr tree to be empty. More... | |
int | addr_tree_insert (rbtree_type *tree, struct addr_tree_node *node, struct sockaddr_storage *addr, socklen_t addrlen, int net) |
insert element into addr tree. More... | |
void | addr_tree_init_parents (rbtree_type *tree) |
Initialize parent pointers in addr tree. More... | |
void | addr_tree_init_parents_node (struct addr_tree_node *node) |
Initialize parent pointers in partial addr tree. More... | |
struct addr_tree_node * | addr_tree_lookup (rbtree_type *tree, struct sockaddr_storage *addr, socklen_t addrlen) |
Lookup closest encloser in addr tree. More... | |
struct addr_tree_node * | addr_tree_find (rbtree_type *tree, struct sockaddr_storage *addr, socklen_t addrlen, int net) |
Find element in addr tree. More... | |
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 | |
int | addr_tree_addrport_compare (const void *k1, const void *k2) |
compare addr tree nodes (address and port only) | |
This file contains structures combining types and functions to manipulate those structures that help building DNS lookup trees.
void name_tree_init | ( | rbtree_type * | tree | ) |
Init a name tree to be empty.
tree | to init. |
References name_tree_compare(), and rbtree_init().
Referenced by dns64_init(), priv_apply_cfg(), priv_create(), and setup_domain_limits().
int name_tree_insert | ( | rbtree_type * | tree, |
struct name_tree_node * | node, | ||
uint8_t * | name, | ||
size_t | len, | ||
int | labs, | ||
uint16_t | dclass | ||
) |
insert element into name tree.
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 |
References rbnode_type::key, addr_tree_node::node, rbnode_type::parent, and rbtree_insert().
Referenced by caps_white_apply_cfg(), domain_limit_findcreate(), hints_insert(), and read_names().
void name_tree_init_parents | ( | rbtree_type * | tree | ) |
Initialize parent pointers in name tree.
Should be performed after insertions are done, before lookups
tree | name tree |
References name_tree_node::dclass, dname_lab_cmp(), name_tree_node::labs, name_tree_node::name, name_tree_node::node, rbnode_type::parent, name_tree_node::parent, and RBTREE_FOR.
Referenced by caps_white_apply_cfg(), dns64_apply_cfg(), priv_apply_cfg(), and setup_domain_limits().
struct name_tree_node* name_tree_find | ( | rbtree_type * | tree, |
uint8_t * | name, | ||
size_t | len, | ||
int | labs, | ||
uint16_t | dclass | ||
) |
Lookup exact match in name tree.
tree | name tree |
name | wireformat name |
len | length of name |
labs | labels in name |
dclass | class of name |
References name_tree_node::dclass, rbnode_type::key, name_tree_node::labs, name_tree_node::len, name_tree_node::name, name_tree_node::node, and rbtree_search().
Referenced by domain_limit_findcreate(), hints_add_stub(), hints_delete_stub(), and hints_find().
struct name_tree_node* name_tree_lookup | ( | rbtree_type * | tree, |
uint8_t * | name, | ||
size_t | len, | ||
int | labs, | ||
uint16_t | dclass | ||
) |
Lookup closest encloser in name tree.
tree | name tree |
name | wireformat name |
len | length of name |
labs | labels in name |
dclass | class of name |
References name_tree_node::dclass, dname_lab_cmp(), rbnode_type::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 dns64_always_synth_for_qname(), hints_lookup_stub(), infra_find_ratelimit(), is_caps_whitelisted(), and priv_lookup_name().
int name_tree_next_root | ( | rbtree_type * | tree, |
uint16_t * | dclass | ||
) |
Find next root item in name tree.
tree | the nametree. |
dclass | the class to look for next (or higher). |
References name_tree_node::dclass, dname_is_root(), rbnode_type::key, name_tree_node::labs, name_tree_node::len, name_tree_node::name, name_tree_node::node, rbtree_find_less_equal(), rbtree_first(), rbtree_next(), and RBTREE_NULL.
Referenced by hints_next_root().
void addr_tree_init | ( | rbtree_type * | tree | ) |
Init addr tree to be empty.
tree | to init. |
References addr_tree_compare(), and rbtree_init().
Referenced by acl_list_apply_cfg(), donotq_apply_cfg(), edns_strings_apply_cfg(), lz_enter_override(), priv_apply_cfg(), priv_create(), respip_set_create(), setup_wait_limits(), and tcl_list_apply_cfg().
void addr_tree_addrport_init | ( | rbtree_type * | tree | ) |
Init addr tree to be empty.
The comparison function to be used is addr_tree_addrport_compare.
tree | to init. |
References addr_tree_addrport_compare(), and rbtree_init().
Referenced by acl_interface_init().
int addr_tree_insert | ( | rbtree_type * | tree, |
struct addr_tree_node * | node, | ||
struct sockaddr_storage * | addr, | ||
socklen_t | addrlen, | ||
int | net | ||
) |
insert element into addr tree.
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. |
References addr_tree_node::addr, addr_tree_node::addrlen, rbnode_type::key, addr_tree_node::net, addr_tree_node::node, rbnode_type::parent, and rbtree_insert().
Referenced by acl_list_insert(), donotq_insert(), lz_enter_override(), read_addrs(), respip_sockaddr_find_or_create(), and tcl_list_insert().
void addr_tree_init_parents | ( | rbtree_type * | tree | ) |
Initialize parent pointers in addr tree.
Should be performed after insertions are done, before lookups
tree | addr tree |
References addr_tree_init_parents_node(), and rbtree_first().
Referenced by acl_list_apply_cfg(), donotq_apply_cfg(), priv_apply_cfg(), respip_sockaddr_delete(), rpz_finish_config(), setup_wait_limits(), and tcl_list_apply_cfg().
void addr_tree_init_parents_node | ( | struct addr_tree_node * | node | ) |
Initialize parent pointers in partial addr tree.
Reinitialize pointer for part of tree, used after node deletion
node | node to start parent pointer initialization for. |
References addr_tree_node::addr, addr_in_common(), addr_tree_node::addrlen, addr_tree_node::net, addr_tree_node::node, rbnode_type::parent, addr_tree_node::parent, rbtree_next(), and RBTREE_NULL.
Referenced by addr_tree_init_parents(), and respip_sockaddr_delete().
struct addr_tree_node* addr_tree_lookup | ( | rbtree_type * | tree, |
struct sockaddr_storage * | addr, | ||
socklen_t | addrlen | ||
) |
Lookup closest encloser in addr tree.
tree | addr tree |
addr | to lookup. |
addrlen | length of addr |
References addr_tree_node::addr, addr_in_common(), addr_is_ip6(), addr_tree_node::addrlen, rbnode_type::key, addr_tree_node::net, addr_tree_node::node, addr_tree_node::parent, and rbtree_find_less_equal().
Referenced by acl_addr_lookup(), donotq_lookup(), edns_string_addr_lookup(), infra_wait_limit_allowed(), priv_lookup_addr(), respip_addr_lookup(), and tcl_addr_lookup().
struct addr_tree_node* addr_tree_find | ( | rbtree_type * | tree, |
struct sockaddr_storage * | addr, | ||
socklen_t | addrlen, | ||
int | net | ||
) |
Find element in addr tree.
(search a netblock, not a match for an address)
tree | addr tree |
addr | netblock to lookup. |
addrlen | length of addr |
net | size of subnet |
References addr_tree_node::addr, addr_tree_node::addrlen, rbnode_type::key, addr_tree_node::net, addr_tree_node::node, and rbtree_search().
Referenced by acl_find_or_create(), respip_sockaddr_find_or_create(), rpz_clientip_remove_trigger_rr(), verify_respip_set_actions(), and verify_rrset().