unbound: services/modstack.h File Reference

unbound 0.1

Data Structures | Functions
modstack.h File Reference

This file contains functions to help maintain a stack of modules. More...

## Data Structures
struct | module_stack
| Stack of modules. More...

## Functions
void | modstack_init (struct module_stack *stack)
| Init a stack of modules.
void | modstack_free (struct module_stack *stack)
| Free the stack of modules.
int | modstack_call_startup (struct module_stack *stack, const char *module_conf, struct module_env *env)
| Initialises modules and assigns ids.
int | modstack_config (struct module_stack *stack, const char *module_conf)
| Read config file module settings and set up the modfunc block.
struct module_func_block * | module_factory (const char **str)
| Get funcblock for module name.
const char ** | module_list_avail (void)
| Get list of modules available.
int | modstack_call_init (struct module_stack *stack, const char *module_conf, struct module_env *env)
| Init modules.
void | modstack_call_deinit (struct module_stack *stack, struct module_env *env)
| Deinit the modules.
void | modstack_call_destartup (struct module_stack *stack, struct module_env *env)
| Destartup the modules, close, delete.
int | modstack_find (struct module_stack *stack, const char *name)
| Find index of module by name.
size_t | mod_get_mem (struct module_env *env, const char *name)
| fetch memory for a module by name, returns 0 if module not there

## Detailed Description

This file contains functions to help maintain a stack of modules.

## Function Documentation

## ◆ modstack_init()

void modstack_init | ( | struct module_stack * | stack | ) |

Init a stack of modules.

Parameters

  stack | initialised as empty.

References module_stack::mod, and module_stack::num.

Referenced by daemon_init(), ub_ctx_create_nopipe(), and zonemd_verify_test().

## ◆ modstack_free()

void modstack_free | ( | struct module_stack * | stack | ) |

Free the stack of modules.

Parameters

  stack | stack that frees up memory.

References module_stack::mod, and module_stack::num.

Referenced by daemon_delete(), modstack_call_init(), ub_ctx_create(), ub_ctx_delete(), and zonemd_verify_test().

## ◆ modstack_call_startup()

int modstack_call_startup | ( | struct module_stack * | stack,
|  | const char * | module_conf,
|  | struct module_env * | env )

Initialises modules and assigns ids.

Calls module_startup().

Parameters

  stack | Expected empty, filled according to module_conf
  module_conf | string what modules to initialize
  env | module environment which is inited by the modules. environment should have a superalloc, cfg,

Returns
  on false a module init failed.

References fptr_ok, fptr_whitelist_mod_startup(), log_err(), module_stack::mod, modstack_config(), module_func_block::name, module_stack::num, module_func_block::startup, VERB_OPS, and verbose().

Referenced by context_finalize(), daemon_privileged(), and zonemd_verify_test().

## ◆ modstack_config()

int modstack_config | ( | struct module_stack * | stack,
|  | const char * | module_conf )

Read config file module settings and set up the modfunc block.

Parameters

  stack | the stack of modules (empty before call).
  module_conf | string what modules to insert.

Returns
  false on error

References count_modules(), log_err(), MAX_MODULE, module_stack::mod, module_factory(), module_stack::num, VERB_QUERY, and verbose().

Referenced by modstack_call_init(), and modstack_call_startup().

## ◆ module_factory()

struct module_func_block * module_factory | ( | const char ** | str | ) |

Get funcblock for module name.

Parameters

  str | string with module name. Advanced to next value on success. The string is assumed whitespace separated list of module names.

Returns
  funcblock or NULL on error.

References module_funcs_avail(), and module_list_avail().

Referenced by modstack_config().

## ◆ module_list_avail()

const char ** module_list_avail | ( | void |  | ) |

Get list of modules available.

Returns
  list of modules available. Static strings, ends with NULL.

Get list of modules available.

Referenced by check_modules_exist(), module_factory(), and print_build_options().

## ◆ modstack_call_init()

int modstack_call_init | ( | struct module_stack * | stack,
|  | const char * | module_conf,
|  | struct module_env * | env )

Init modules.

Calls module_init().

Parameters

  stack | It is modstack_setupped().
  module_conf | module ordering to check against the ordering in stack. fails on changed ordering.
  env | module environment which is inited by the modules. environment should have a superalloc, cfg, env.need_to_validate is set by the modules.

Returns
  on false a module init failed.

References module_func_block::destartup, fptr_ok, fptr_whitelist_mod_init(), module_func_block::init, log_err(), module_stack::mod, modstack_config(), modstack_free(), module_func_block::name, module_env::need_to_validate, module_stack::num, module_func_block::startup, VERB_OPS, and verbose().

Referenced by context_finalize(), daemon_setup_modules(), and zonemd_verify_test().

## ◆ modstack_call_deinit()

void modstack_call_deinit | ( | struct module_stack * | stack,
|  | struct module_env * | env )

Deinit the modules.

Parameters

  stack | made empty.
  env | module env for module deinit() calls.

References module_func_block::deinit, fptr_ok, fptr_whitelist_mod_deinit(), module_stack::mod, and module_stack::num.

Referenced by daemon_delete(), daemon_setup_modules(), ub_ctx_create(), ub_ctx_delete(), and zonemd_verify_test().

## ◆ modstack_call_destartup()

void modstack_call_destartup | ( | struct module_stack * | stack,
|  | struct module_env * | env )

Destartup the modules, close, delete.

Parameters

  stack | made empty.
  env | module env for module destartup() calls.

References module_func_block::destartup, fptr_ok, fptr_whitelist_mod_destartup(), module_stack::mod, and module_stack::num.

Referenced by daemon_delete(), ub_ctx_create(), ub_ctx_delete(), and zonemd_verify_test().

## ◆ modstack_find()

int modstack_find | ( | struct module_stack * | stack,
|  | const char * | name )

Find index of module by name.

Parameters

  stack | to look in
  name | the name to look for

Returns
  -1 on failure, otherwise index number.

References module_stack::mod, module_func_block::name, and module_stack::num.

Referenced by auth_zone_verify_zonemd_key_with_ds(), daemon_fork(), do_cache_lookup_domain(), do_set_option(), fr_adjust_iter_env(), fr_adjust_val_env(), get_queries_ratelimit(), get_rrset_bogus(), iterator_set_ip46_support(), mesh_continue(), mod_get_mem(), reply_and_prefetch(), set_neg_cache_stats(), zonemd_dnssec_verify_rrset(), and zonemd_get_dnskey_from_anchor().