Implementation of module.h. More...
#include "config.h"
#include "util/module.h"
#include "sldns/wire2str.h"
#include "util/config_file.h"
#include "util/regional.h"
#include "util/data/dname.h"
#include "util/net_help.h"
Functions | |
const char * | strextstate (enum module_ext_state s) |
Debug utility: module external qstate to string. More... | |
const char * | strmodulevent (enum module_ev e) |
Debug utility: module event to string. More... | |
void | errinf (struct module_qstate *qstate, const char *str) |
Append text to the error info for validation. More... | |
void | errinf_ede (struct module_qstate *qstate, const char *str, sldns_ede_code reason_bogus) |
void | errinf_origin (struct module_qstate *qstate, struct sock_list *origin) |
Append text to error info: from 1.2.3.4. More... | |
char * | errinf_to_str_bogus (struct module_qstate *qstate, struct regional *region) |
Create error info in string. More... | |
sldns_ede_code | errinf_to_reason_bogus (struct module_qstate *qstate) |
Check the sldns_ede_code of the qstate->errinf. More... | |
char * | errinf_to_str_servfail (struct module_qstate *qstate) |
Create error info in string. More... | |
char * | errinf_to_str_misc (struct module_qstate *qstate) |
Create error info in string. More... | |
void | errinf_rrset (struct module_qstate *qstate, struct ub_packed_rrset_key *rr) |
Append text to error info: for RRset name type class. More... | |
void | errinf_dname (struct module_qstate *qstate, const char *str, uint8_t *dname) |
Append text to error info: str dname. More... | |
int | edns_known_options_init (struct module_env *env) |
Initialize the edns known options by allocating the required space. More... | |
void | edns_known_options_delete (struct module_env *env) |
Free the allocated space for the known edns options. More... | |
int | edns_register_option (uint16_t opt_code, int bypass_cache_stage, int no_aggregation, struct module_env *env) |
Register a known edns option. More... | |
int | inplace_cb_register (void *cb, enum inplace_cb_list_type type, void *cbarg, struct module_env *env, int id) |
Register an inplace callback function. More... | |
void | inplace_cb_delete (struct module_env *env, enum inplace_cb_list_type type, int id) |
Delete callback for specified type and module id. More... | |
struct edns_known_option * | edns_option_is_known (uint16_t opt_code, struct module_env *env) |
Check if an edns option is known. More... | |
int | edns_bypass_cache_stage (struct edns_option *list, struct module_env *env) |
Check if an edns option needs to bypass the reply from cache stage. More... | |
int | unique_mesh_state (struct edns_option *list, struct module_env *env) |
Check if an unique mesh state is required. More... | |
void | log_edns_known_options (enum verbosity_value level, struct module_env *env) |
Log the known edns options. More... | |
void | copy_state_to_super (struct module_qstate *qstate, int ATTR_UNUSED(id), struct module_qstate *super) |
Implementation of module.h.
const char* strextstate | ( | enum module_ext_state | s | ) |
Debug utility: module external qstate to string.
s | the state value. |
References module_error, module_finished, module_restart_next, module_state_initial, module_wait_module, module_wait_reply, and module_wait_subquery.
Referenced by dns64_operate(), get_mesh_status(), ipset_operate(), iter_operate(), mesh_run(), and val_operate().
const char* strmodulevent | ( | enum module_ev | e | ) |
Debug utility: module event to string.
e | the module event value. |
References module_event_capsfail, module_event_error, module_event_moddone, module_event_new, module_event_noreply, module_event_pass, and module_event_reply.
Referenced by dns64_operate(), ipset_operate(), iter_operate(), and val_operate().
void errinf | ( | struct module_qstate * | qstate, |
const char * | str | ||
) |
Append text to the error info for validation.
qstate | query state. |
str | copied into query region and appended. Failures to allocate are logged. |
Referenced by auth_zone_delegpt(), errinf_origin(), errinf_reply(), errinf_rrset(), iter_operate(), prime_stub(), process_response(), processCollectClass(), processFinished(), processInitRequest(), processInitRequest2(), processLastResort(), processQueryTargets(), and validate_suspend_setup_timer().
void errinf_origin | ( | struct module_qstate * | qstate, |
struct sock_list * | origin | ||
) |
Append text to error info: from 1.2.3.4.
qstate | query state. |
origin | sock list with origin of trouble. Every element added. If NULL: nothing is added. if 0len element: 'from cache' is added. |
References sock_list::addr, addr_to_str(), module_env::cfg, module_qstate::env, errinf(), sock_list::len, config_file::log_servfail, sock_list::next, and config_file::val_log_level.
Referenced by process_ds_response().
char* errinf_to_str_bogus | ( | struct module_qstate * | qstate, |
struct regional * | region | ||
) |
Create error info in string.
For validation failures.
qstate | query state. |
region | the region for the result or NULL for malloced result. |
References dname_str(), module_qstate::errinf, LDNS_MAX_DOMAINLEN, log_err(), errinf_strlist::next, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qtype, regional_strdup(), sldns_wire2str_class_buf(), sldns_wire2str_type_buf(), and errinf_strlist::str.
sldns_ede_code errinf_to_reason_bogus | ( | struct module_qstate * | qstate | ) |
Check the sldns_ede_code of the qstate->errinf.
qstate | query state. |
char* errinf_to_str_servfail | ( | struct module_qstate * | qstate | ) |
Create error info in string.
For other servfails.
qstate | query state. |
References dname_str(), module_qstate::errinf, LDNS_MAX_DOMAINLEN, log_err(), errinf_strlist::next, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qtype, module_qstate::region, regional_strdup(), sldns_wire2str_class_buf(), sldns_wire2str_type_buf(), and errinf_strlist::str.
char* errinf_to_str_misc | ( | struct module_qstate * | qstate | ) |
Create error info in string.
For misc failures that are not servfail.
qstate | query state. |
References module_qstate::errinf, log_err(), errinf_strlist::next, module_qstate::region, regional_strdup(), and errinf_strlist::str.
void errinf_rrset | ( | struct module_qstate * | qstate, |
struct ub_packed_rrset_key * | rr | ||
) |
Append text to error info: for RRset name type class.
qstate | query state. |
rr | rrset_key. |
References module_env::cfg, packed_rrset_key::dname, dname_str(), module_qstate::env, errinf(), LDNS_MAX_DOMAINLEN, config_file::log_servfail, ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, sldns_wire2str_class_buf(), sldns_wire2str_type_buf(), packed_rrset_key::type, and config_file::val_log_level.
void errinf_dname | ( | struct module_qstate * | qstate, |
const char * | str, | ||
uint8_t * | dname | ||
) |
Append text to error info: str dname.
qstate | query state. |
str | explanation string |
dname | the dname. |
Referenced by process_ds_response(), processDSNSFind(), processInitRequest(), and processLastResort().
int edns_known_options_init | ( | struct module_env * | env | ) |
Initialize the edns known options by allocating the required space.
env | the module environment. |
References module_env::edns_known_options, and MAX_KNOWN_EDNS_OPTS.
Referenced by ub_ctx_create_nopipe().
void edns_known_options_delete | ( | struct module_env * | env | ) |
Free the allocated space for the known edns options.
env | the module environment. |
References module_env::edns_known_options.
Referenced by daemon_delete(), ub_ctx_create(), and ub_ctx_create_nopipe().
int edns_register_option | ( | uint16_t | opt_code, |
int | bypass_cache_stage, | ||
int | no_aggregation, | ||
struct module_env * | env | ||
) |
Register a known edns option.
Overwrite the flags if it is already registered. Used before creating workers to register known edns options.
opt_code | the edns option code. |
bypass_cache_stage | whether the option interacts with the cache. |
no_aggregation | whether the option implies more specific aggregation. |
env | the module environment. |
Checking if we are full first is faster but it does not provide the option to change the flags when the array is full. It only impacts unbound initialization, leave it for now.
References edns_known_option::bypass_cache_stage, module_env::edns_known_options, log_err(), MAX_KNOWN_EDNS_OPTS, edns_known_option::no_aggregation, edns_known_option::opt_code, and module_env::worker.
int inplace_cb_register | ( | void * | cb, |
enum inplace_cb_list_type | type, | ||
void * | cbarg, | ||
struct module_env * | env, | ||
int | id | ||
) |
Register an inplace callback function.
cb | pointer to the callback function. |
type | inplace callback type. |
cbarg | argument for the callback function, or NULL. |
env | the module environment. |
id | module id. |
References inplace_cb::cb, inplace_cb::id, log_err(), and module_env::worker.
void inplace_cb_delete | ( | struct module_env * | env, |
enum inplace_cb_list_type | type, | ||
int | id | ||
) |
Delete callback for specified type and module id.
env | the module environment. |
type | inplace callback type. |
id | module id. |
References inplace_cb::id, and inplace_cb::next.
struct edns_known_option* edns_option_is_known | ( | uint16_t | opt_code, |
struct module_env * | env | ||
) |
Check if an edns option is known.
opt_code | the edns option code. |
env | the module environment. |
References module_env::edns_known_options, and edns_known_option::opt_code.
int edns_bypass_cache_stage | ( | struct edns_option * | list, |
struct module_env * | env | ||
) |
Check if an edns option needs to bypass the reply from cache stage.
list | the edns options. |
env | the module environment. |
References edns_known_option::bypass_cache_stage, module_env::edns_known_options, edns_option::next, edns_option::opt_code, and edns_known_option::opt_code.
int unique_mesh_state | ( | struct edns_option * | list, |
struct module_env * | env | ||
) |
Check if an unique mesh state is required.
Might be triggered by EDNS option or set for the complete env.
list | the edns options. |
env | the module environment. |
References module_env::edns_known_options, edns_option::next, edns_known_option::no_aggregation, edns_option::opt_code, and edns_known_option::opt_code.
Referenced by mesh_new_callback(), and mesh_new_client().
void log_edns_known_options | ( | enum verbosity_value | level, |
struct module_env * | env | ||
) |
Log the known edns options.
level | the desired verbosity level. |
env | the module environment. |
Referenced by context_finalize().