Functions
module.c File Reference

Implementation of module.h. More...

#include "config.h"
#include "util/module.h"
#include "sldns/wire2str.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...
 
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_optionedns_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...
 

Detailed Description

Implementation of module.h.

Function Documentation

◆ strextstate()

const char* strextstate ( enum module_ext_state  s)

Debug utility: module external qstate to string.

Parameters
sthe state value.
Returns
descriptive string.

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(), iter_operate(), mesh_run(), and val_operate().

◆ strmodulevent()

const char* strmodulevent ( enum module_ev  e)

Debug utility: module event to string.

Parameters
ethe module event value.
Returns
descriptive string.

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(), iter_operate(), pylib::setTTL(), and val_operate().

◆ edns_known_options_init()

int edns_known_options_init ( struct module_env env)

Initialize the edns known options by allocating the required space.

Parameters
envthe module environment.
Returns
false on failure (no memory).

References module_env::edns_known_options, and MAX_KNOWN_EDNS_OPTS.

Referenced by ub_ctx_create_nopipe().

◆ edns_known_options_delete()

void edns_known_options_delete ( struct module_env env)

Free the allocated space for the known edns options.

Parameters
envthe module environment.

References module_env::edns_known_options.

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

◆ edns_register_option()

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.

Parameters
opt_codethe edns option code.
bypass_cache_stagewhether the option interacts with the cache.
no_aggregationwhether the option implies more specific aggregation.
envthe module environment.
Returns
true on success, false on failure (registering more options than allowed or trying to register after the environment is copied to the threads.)

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.

◆ inplace_cb_register()

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.

Parameters
cbpointer to the callback function.
typeinplace callback type.
cbargargument for the callback function, or NULL.
envthe module environment.
idmodule id.
Returns
true on success, false on failure (out of memory or trying to register after the environment is copied to the threads.)

References inplace_cb::cb, inplace_cb::id, log_err(), inplace_cb::next, and module_env::worker.

◆ inplace_cb_delete()

void inplace_cb_delete ( struct module_env env,
enum inplace_cb_list_type  type,
int  id 
)

Delete callback for specified type and module id.

Parameters
envthe module environment.
typeinplace callback type.
idmodule id.

References inplace_cb::id, and inplace_cb::next.

◆ edns_option_is_known()

struct edns_known_option* edns_option_is_known ( uint16_t  opt_code,
struct module_env env 
)

Check if an edns option is known.

Parameters
opt_codethe edns option code.
envthe module environment.
Returns
pointer to registered option if the edns option is known, NULL otherwise.

References module_env::edns_known_options, and edns_known_option::opt_code.

◆ edns_bypass_cache_stage()

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.

Parameters
listthe edns options.
envthe module environment.
Returns
true if an edns option needs to bypass the cache stage, false otherwise.

References edns_known_option::bypass_cache_stage, module_env::edns_known_options, edns_option::next, edns_known_option::opt_code, and edns_option::opt_code.

◆ unique_mesh_state()

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.

Parameters
listthe edns options.
envthe module environment.
Returns
true if an edns option needs a unique mesh state, false otherwise.

References module_env::edns_known_options, edns_option::next, edns_known_option::no_aggregation, edns_known_option::opt_code, and edns_option::opt_code.

Referenced by mesh_new_callback(), and mesh_new_client().

◆ log_edns_known_options()

void log_edns_known_options ( enum verbosity_value  level,
struct module_env env 
)

Log the known edns options.

Parameters
levelthe desired verbosity level.
envthe module environment.

References edns_known_option::bypass_cache_stage, module_env::edns_known_options, edns_known_option::no_aggregation, edns_known_option::opt_code, sldns_wire2str_edns_option_code_print(), verbose(), and verbosity.

Referenced by context_finalize().