unbound: module_env Struct Reference

unbound 0.1

Data Fields
module_env Struct Reference

Module environment. More...

`#include <module.h>`

## Data Fields
struct config_file * | cfg
| config file with config options
struct slabhash * | msg_cache
| shared message cache
struct rrset_cache * | rrset_cache
| shared rrset cache
struct infra_cache * | infra_cache
| shared infrastructure cache (edns, lameness)
struct key_cache * | key_cache
| shared key cache
struct outbound_entry *(* | send_query )(struct query_info *qinfo, uint16_t flags, int dnssec, int want_dnssec, int nocaps, int check_ratelimit, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *zone, size_t zonelen, int tcp_upstream, int ssl_upstream, char *tls_auth_name, struct module_qstate *q, int *was_ratelimited)
| Send serviced DNS query to server.
void(* | detach_subs )(struct module_qstate *qstate)
| Detach-subqueries.
int(* | attach_sub )(struct module_qstate *qstate, struct query_info *qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate **newq)
| Attach subquery.
int(* | add_sub )(struct module_qstate *qstate, struct query_info *qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate **newq, struct mesh_state **sub)
| Add detached query.
void(* | kill_sub )(struct module_qstate *newq)
| Kill newly attached sub.
int(* | detect_cycle )(struct module_qstate *qstate, struct query_info *qinfo, uint16_t flags, int prime, int valrec)
| Detect if adding a dependency for qstate on name,type,class will create a dependency cycle.
struct regional * | scratch
| region for temporary usage.
struct sldns_buffer * | scratch_buffer
| buffer for temporary usage.
struct worker * | worker
| internal data for daemon - worker thread.
struct comm_base * | worker_base
| the worker event base
struct outside_network * | outnet
| the outside network
struct mesh_area * | mesh
| mesh area with query state dependencies
struct alloc_cache * | alloc
| allocation service
struct ub_randstate * | rnd
| random table to generate random numbers
time_t * | now
| time in seconds, converted to integer
struct timeval * | now_tv
| time in microseconds.
int | need_to_validate
| is validation required for messages, controls client-facing validation status (AD bits) and servfails
struct val_anchors * | anchors
| trusted key storage; these are the configured keys, if not NULL, otherwise configured by validator.
struct val_neg_cache * | neg_cache
| negative cache, configured by the validator.
struct comm_timer * | probe_timer
| the 5011-probe timer (if any)
struct auth_zones * | auth_zones
| auth zones
struct iter_forwards * | fwds
| Mapping of forwarding zones to targets.
struct iter_hints * | hints
| iterator stub information.
void * | modinfo [MAX_MODULE]
| module specific data.
struct inplace_cb * | inplace_cb_lists [inplace_cb_types_total]
struct edns_known_option * | edns_known_options
| Shared array of known edns options (size MAX_KNOWN_EDNS_OPTS).
size_t | edns_known_options_num
struct edns_strings * | edns_strings
| EDNS client string information.
struct module_stack * | modstack
| module stack
int | unique_mesh

## Detailed Description

Module environment.

Services and data provided to the module.

## Field Documentation

## ◆ send_query

struct outbound_entry *(* module_env::send_query) (struct query_info *qinfo, uint16_t flags, int dnssec, int want_dnssec, int nocaps, int check_ratelimit, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *zone, size_t zonelen, int tcp_upstream, int ssl_upstream, char *tls_auth_name, struct module_qstate *q, int *was_ratelimited)

Send serviced DNS query to server.

UDP/TCP and EDNS is handled. operate() should return with wait_reply. Later on a callback will cause operate() to be called with event timeout or reply. The time until a timeout is calculated from roundtrip timing, several UDP retries are attempted.

Parameters

  qinfo | query info.
  flags | host order flags word, with opcode and CD bit.
  dnssec | if set, EDNS record will have bits set. If EDNS_DO bit is set, DO bit is set in EDNS records. If BIT_CD is set, CD bit is set in queries with EDNS records.
  want_dnssec | if set, the validator wants DNSSEC. Without EDNS, the answer is likely to be useless for this domain.
  nocaps | do not use caps_for_id, use the qname as given. (ignored if caps_for_id is disabled).
  check_ratelimit | if set, will check ratelimit before sending out.
  addr | where to.
  addrlen | length of addr.
  zone | delegation point name.
  zonelen | length of zone name.
  tcp_upstream | use TCP for upstream queries.
  ssl_upstream | use SSL for upstream queries.
  tls_auth_name | if ssl_upstream, use this name with TLS authentication.
  q | which query state to reactivate upon return.
  was_ratelimited | it will signal back if the query failed to pass the ratelimit check.

Returns
  : false on failure (memory or socket related). no query was sent. Or returns an outbound entry with qsent and qstate set. This outbound_entry will be used on later module invocations that involve this query (timeout, error or reply).

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

## ◆ detach_subs

void(* module_env::detach_subs) (struct module_qstate *qstate)

Detach-subqueries.

Remove all sub-query references from this query state. Keeps super-references of those sub-queries correct. Updates stat items in mesh_area structure.

Parameters

  qstate | used to find mesh state.

Referenced by libworker_setup(), processInitRequest3(), processQueryResponse(), processQueryTargets(), and worker_init().

## ◆ attach_sub

int(* module_env::attach_sub) (struct module_qstate *qstate, struct query_info *qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate **newq)

Attach subquery.

Creates it if it does not exist already. Keeps sub and super references correct. Updates stat items in mesh_area structure. Pass if it is priming query or not. return: o if error (malloc) happened. o need to initialise the new state (module init; it is a new state). so that the next run of the query with this module is successful. o no init needed, attachment successful.

Parameters

  qstate | the state to find mesh state, and that wants to receive the results from the new subquery.
  qinfo | what to query for (copied).
  qflags | what flags to use (RD, CD flag or not).
  prime | if it is a (stub) priming query.
  valrec | validation lookup recursion, does not need validation
  newq | If the new subquery needs initialisation, it is returned, otherwise NULL is returned.

Returns
  : false on error, true if success (and init may be needed).

Referenced by generate_request(), generate_sub_request(), handle_ipv6_ptr(), libworker_setup(), and worker_init().

## ◆ add_sub

int(* module_env::add_sub) (struct module_qstate *qstate, struct query_info *qinfo, uint16_t qflags, int prime, int valrec, struct module_qstate **newq, struct mesh_state **sub)

Add detached query.

Creates it if it does not exist already. Does not make super/sub references. Performs a cycle detection - for double check - and fails if there is one. Updates stat items in mesh_area structure. Pass if it is priming query or not. return: o if error (malloc) happened. o need to initialise the new state (module init; it is a new state). so that the next run of the query with this module is successful. o no init needed, attachment successful. o added subquery, created if it did not exist already.

Parameters

  qstate | the state to find mesh state, and that wants to receive the results from the new subquery.
  qinfo | what to query for (copied).
  qflags | what flags to use (RD / CD flag or not).
  prime | if it is a (stub) priming query.
  valrec | if it is a validation recursion query (lookup of key, DS).
  newq | If the new subquery needs initialisation, it is returned, otherwise NULL is returned.
  sub | The added mesh state, created if it did not exist already.

Returns
  : false on error, true if success (and init may be needed).

Referenced by generate_request(), generate_sub_request(), libworker_setup(), and worker_init().

## ◆ kill_sub

void(* module_env::kill_sub) (struct module_qstate *newq)

Kill newly attached sub.

If attach_sub returns newq for initialisation, but that fails, then this routine will cleanup and delete the freshly created sub.

Parameters

  newq | the new subquery that is no longer needed. It is removed.

Referenced by generate_ns_check(), generate_sub_request(), libworker_setup(), prime_root(), prime_stub(), and worker_init().

## ◆ detect_cycle

int(* module_env::detect_cycle) (struct module_qstate *qstate, struct query_info *qinfo, uint16_t flags, int prime, int valrec)

Detect if adding a dependency for qstate on name,type,class will create a dependency cycle.

Parameters

  qstate | given mesh querystate.
  qinfo | query info for dependency.
  flags | query flags of dependency, RD/CD flags.
  prime | if dependency is a priming query or not.
  valrec | validation lookup recursion, does not need validation

Returns
  true if the name,type,class exists and the given qstate mesh exists as a dependency of that name. Thus if qstate becomes dependent on name,type,class then a cycle is created.

Referenced by causes_cycle(), generate_request(), libworker_setup(), and worker_init().

## ◆ scratch

struct regional* module_env::scratch

region for temporary usage.

May be cleared after operate() call.

Referenced by auth_xfer_probe_lookup_callback(), auth_xfer_transfer_lookup_callback(), auth_zone_verify_zonemd(), auth_zone_verify_zonemd_key_with_ds(), auth_zone_zonemd_check_hash(), auth_zonemd_dnskey_lookup_callback(), autr_probe_timer(), check_mod(), createResponse(), dnskey_verify_rrset(), dnskeyset_verify_rrset_sig(), ds_digest_match_dnskey(), dstest_file(), handle_newq(), iter_indicates_dnssec(), iter_store_parentside_neg(), libworker_attach_mesh(), libworker_delete_env(), libworker_fg(), libworker_fillup_fg(), libworker_setup(), mesh_continue(), mesh_do_callback(), mesh_new_client(), mesh_run(), mesh_send_reply(), mesh_serve_expired_lookup(), probe_anchor(), process_response(), processInitRequest(), processQueryTargets(), verifytest_file(), worker_delete(), worker_init(), zonemd_get_dnskey_from_anchor(), zonemd_offline_verify(), and zonemd_verify_test().

## ◆ scratch_buffer

struct sldns_buffer* module_env::scratch_buffer

buffer for temporary usage.

May be cleared after operate() call.

Referenced by auth_zone_zonemd_check_hash(), check_mod(), dnskey_verify_rrset(), dnskeyset_verify_rrset_sig(), do_list_local_data(), ds_create_dnskey_digest(), dstest_file(), find_covering_nsec3(), find_matching_nsec3(), libworker_bg_done_cb(), libworker_delete_env(), libworker_setup(), load_cache(), load_msg_cache(), load_rrset_cache(), probe_anchor(), processInitRequest(), val_find_DS(), verifytest_file(), worker_delete(), worker_init(), worker_mem_report(), xfr_probe_lookup_host(), xfr_probe_send_probe(), xfr_process_chunk_list(), xfr_transfer_init_fetch(), xfr_transfer_lookup_host(), zonemd_lookup_dnskey(), zonemd_offline_verify(), and zonemd_verify_test().

## ◆ now_tv

struct timeval* module_env::now_tv

time in microseconds.

Relatively recent.

Referenced by answer_from_cache(), answer_norec_from_cache(), auth_answer_encode(), auth_error_encode(), chaos_replystr(), get_mesh_age(), libworker_setup(), local_encode(), local_error_encode(), mesh_make_new_space(), mesh_new_client(), mesh_query_done(), mesh_send_reply(), mesh_serve_expired_callback(), mesh_state_add_reply(), print_uptime(), rpz_local_encode(), worker_handle_request(), and worker_init().

## ◆ anchors

struct val_anchors* module_env::anchors

trusted key storage; these are the configured keys, if not NULL, otherwise configured by validator.

These are the trust anchors, and are not primed and ready for validation, but on the bright side, they are read only memory, thus no locks and fast.

Referenced by auth_zone_verify_zonemd(), autr_tp_remove(), chaos_trustanchor(), do_forward_add(), do_forward_remove(), do_insecure_add(), do_insecure_remove(), do_list_forwards(), do_list_stubs(), do_stub_add(), do_stub_remove(), iter_indicates_dnssec(), iter_qname_indicates_dnssec(), process_prime_response(), processFinished(), processInit(), reset_worker_timer(), set_next_probe(), todo_probe(), val_apply_cfg(), val_deinit(), val_init(), worker_init(), worker_mem_report(), and zonemd_verify_test().

## ◆ neg_cache

struct val_neg_cache* module_env::neg_cache

negative cache, configured by the validator.

if not NULL, contains NSEC record lookup trees.

Referenced by processFinished(), processInitRequest(), processQueryResponse(), val_apply_cfg(), val_deinit(), and val_find_DS().

## ◆ fwds

struct iter_forwards* module_env::fwds

Mapping of forwarding zones to targets.

iterator forwarder information.

Referenced by can_have_last_resort(), context_finalize(), daemon_cleanup(), daemon_fork(), do_forward(), do_forward_add(), do_forward_remove(), do_list_forwards(), do_stub_add(), do_stub_remove(), forward_request(), iter_stub_fwd_no_cache(), processCollectClass(), processInitRequest(), ub_ctx_delete(), and worker_mem_report().

## ◆ hints

struct iter_hints* module_env::hints

iterator stub information.

The hints – these aren't stored in the cache because they don't expire. The hints are always used to "prime" the cache. Note that both root hints and stub zone "hints" are stored in this data structure.

Referenced by can_have_last_resort(), context_finalize(), daemon_cleanup(), daemon_fork(), do_list_stubs(), do_stub_add(), do_stub_remove(), iter_stub_fwd_no_cache(), prime_root(), prime_stub(), processCollectClass(), processInitRequest(), processInitRequest2(), processLastResort(), ub_ctx_delete(), and worker_mem_report().

## ◆ modinfo

void* module_env::modinfo[MAX_MODULE]

module specific data.

indexed by module id.

Referenced by auth_zone_verify_zonemd_key_with_ds(), dns64_adjust_a(), dns64_always_synth_for_qname(), dns64_deinit(), dns64_get_mem(), dns64_init(), do_set_option(), ds_response_to_ke(), dynlibmod_clear(), dynlibmod_deinit(), dynlibmod_get_mem(), dynlibmod_inform_super(), dynlibmod_init(), dynlibmod_operate(), error_supers(), generate_a_aaaa_check(), generate_ns_check(), get_queries_ratelimit(), get_rrset_bogus(), handle_ipv6_ptr(), ipset_destartup(), ipset_get_mem(), ipset_init(), ipset_operate(), ipset_startup(), iter_deinit(), iter_get_mem(), iter_init(), iter_operate(), iterator_set_ip46_support(), primeResponseToKE(), process_dnskey_response(), process_ds_response(), process_prime_response(), processTargetResponse(), pythonmod_deinit(), pythonmod_get_mem(), pythonmod_inform_super(), pythonmod_init(), set_neg_cache_stats(), val_deinit(), val_get_mem(), val_init(), val_operate(), zonemd_dnssec_verify_rrset(), and zonemd_get_dnskey_from_anchor().

## ◆ edns_known_options

struct edns_known_option* module_env::edns_known_options

Shared array of known edns options (size MAX_KNOWN_EDNS_OPTS).

Filled by edns literate modules during init.

Referenced by edns_bypass_cache_stage(), edns_known_options_delete(), edns_known_options_init(), edns_option_is_known(), edns_register_option(), log_edns_known_options(), and unique_mesh_state().

The documentation for this struct was generated from the following file:

- util/module.h