unbound: iterator/iter_fwd.h File Reference

unbound 0.1

Data Structures | Functions
iter_fwd.h File Reference

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

`#include "util/rbtree.h"`

## Data Structures
struct | iter_forwards
| Iterator forward zones structure. More...
struct | iter_forward_zone
| Iterator forward servers for a particular zone. More...

## Functions
struct iter_forwards * | forwards_create (void)
| Create forwards.
void | forwards_delete (struct iter_forwards *fwd)
| Delete forwards.
int | forwards_apply_cfg (struct iter_forwards *fwd, struct config_file *cfg)
| Process forwards config.
struct delegpt * | forwards_find (struct iter_forwards *fwd, uint8_t *qname, uint16_t qclass)
| Find forward zone exactly by name.
struct delegpt * | forwards_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 delegpt * | forwards_lookup_root (struct iter_forwards *fwd, uint16_t qclass)
| Same as forwards_lookup, but for the root only.
int | forwards_next_root (struct iter_forwards *fwd, uint16_t *qclass)
| Find next root item in forwards lookup tree.
size_t | forwards_get_mem (struct iter_forwards *fwd)
| Get memory in use by forward storage.
int | fwd_cmp (const void *k1, const void *k2)
| compare two fwd entries
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.
int | forwards_add_stub_hole (struct iter_forwards *fwd, uint16_t c, uint8_t *nm)
| Add stub hole (empty entry in forward table, that makes resolution skip a forward-zone because the stub zone should override the forward zone).
void | forwards_delete_stub_hole (struct iter_forwards *fwd, uint16_t c, uint8_t *nm)
| Remove stub hole, if one exists.

## Detailed Description

This file contains functions to assist the iterator module.

Keep track of forward zones, and read those from config.

## Function Documentation

## ◆ forwards_create()

struct iter_forwards * forwards_create | ( | void |  | ) |

Create forwards.

Returns
  new forwards or NULL on error.

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

## ◆ forwards_delete()

void forwards_delete | ( | struct iter_forwards * | fwd | ) |

Delete forwards.

Parameters

  fwd | to delete.

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

## ◆ forwards_apply_cfg()

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(), and iter_forwards::tree.

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

## ◆ forwards_find()

struct delegpt * forwards_find | ( | struct iter_forwards * | fwd,
|  | uint8_t * | qname,
|  | uint16_t | qclass
| ) |  |

Find forward zone exactly by name.

Parameters

  fwd | forward storage.
  qname | The qname of the query.
  qclass | The qclass of the query.

Returns
  : A delegation point or null.

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

Referenced by can_have_last_resort().

## ◆ forwards_lookup()

struct delegpt * forwards_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.

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_type::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(), iter_stub_fwd_no_cache(), and print_root_fwds().

## ◆ forwards_lookup_root()

struct delegpt * forwards_lookup_root | ( | struct iter_forwards * | fwd,
|  | uint16_t | qclass
| ) |  |

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().

## ◆ forwards_next_root()

int forwards_next_root | ( | struct iter_forwards * | fwd,
|  | uint16_t * | qclass
| ) |  |

Find next root item in forwards lookup tree.

Parameters

  fwd | the forward storage
  qclass | class to look at next, or higher.

Returns
  false if none found, or if true stored in qclass.

References iter_forward_zone::dclass, dname_is_root(), forwards_next_root(), rbnode_type::key, iter_forward_zone::name, iter_forward_zone::namelabs, iter_forward_zone::namelen, iter_forward_zone::node, rbtree_find_less_equal(), rbtree_first(), rbtree_next(), RBTREE_NULL, and iter_forwards::tree.

Referenced by forwards_next_root(), and iter_get_next_root().

## ◆ forwards_get_mem()

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 delegpt_get_mem(), iter_forward_zone::dp, iter_forward_zone::namelen, RBTREE_FOR, and iter_forwards::tree.

Referenced by worker_mem_report().

## ◆ forwards_add_zone()

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. malloced.

Returns
  false on failure (out of memory);

References iter_forward_zone::dp, forwards_insert(), fwd_init_parents(), delegpt::name, iter_forward_zone::node, rbtree_delete(), and iter_forwards::tree.

Referenced by do_forward(), and do_forward_add().

## ◆ forwards_delete_zone()

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.

Parameters

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

References fwd_init_parents(), iter_forward_zone::node, rbtree_delete(), and iter_forwards::tree.

Referenced by do_forward(), and do_forward_remove().

## ◆ forwards_add_stub_hole()

int forwards_add_stub_hole | ( | struct iter_forwards * | fwd,
|  | uint16_t | c,
|  | uint8_t * | nm
| ) |  |

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.

Parameters

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

Returns
  false on failure (out of memory);

References fwd_add_stub_hole(), and fwd_init_parents().

Referenced by do_stub_add().

## ◆ forwards_delete_stub_hole()

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

Remove stub hole, if one exists.

Parameters

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

References iter_forward_zone::dp, fwd_init_parents(), iter_forward_zone::node, rbtree_delete(), and iter_forwards::tree.

Referenced by do_stub_add(), and do_stub_remove().