27 RCSIDH(modules_h,
"$Id: f725600b1b874e3e68e17303ff810ba5582adfe2 $")
33 #include <freeradius-devel/server/cf_util.h>
34 #include <freeradius-devel/server/request.h>
35 #include <freeradius-devel/server/module_ctx.h>
36 #include <freeradius-devel/unlang/action.h>
37 #include <freeradius-devel/unlang/compile.h>
38 #include <freeradius-devel/unlang/call_env.h>
39 #include <freeradius-devel/util/event.h>
48 typedef enum CC_HINT(flag_enum) {
111 #include <freeradius-devel/server/components.h>
112 #include <freeradius-devel/server/dl_module.h>
113 #include <freeradius-devel/server/exfile.h>
114 #include <freeradius-devel/server/pool.h>
115 #include <freeradius-devel/server/rcode.h>
117 #include <freeradius-devel/io/schedule.h>
118 #include <freeradius-devel/features.h>
135 #define MODULE_NAME_TERMINATOR { NULL }
267 CC_HINT(
nonnull(1,3)) CC_HINT(warn_unused_result);
299 CC_HINT(
nonnull(1)) CC_HINT(warn_unused_result);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Defines a CONF_PAIR to C data type mapping.
Common header for all CONF_* types.
A section grouping multiple CONF_PAIR.
unsigned int fr_heap_index_t
Stores all information relating to an event list.
static char const * mod_name(fr_listen_t *li)
Temporary structure to hold arguments for module calls.
Temporary structure to hold arguments for instantiation calls.
Temporary structure to hold arguments for thread_instantiation calls.
Specifies a module method identifier.
The main red black tree structure.
rlm_rcode_t
Return codes indicating the result of the module call.
module_instance_t const * mi
As opposed to the thread local inst.
char const * name
String identifier for state.
unlang_actions_t actions
default actions and retries.
module_instance_t * module_by_name(module_list_t const *ml, module_instance_t const *parent, char const *asked_name))
Find an existing module instance by its name and parent.
void modules_init(char const *lib_dir)
Perform global initialisation for modules.
char const * name
Instance name e.g. user_database.
@ MODULE_TYPE_THREAD_UNSAFE
Module is not threadsafe.
@ MODULE_TYPE_RESUMABLE
does yield / resume
@ MODULE_TYPE_RETRY
can handle retries
@ MODULE_TYPE_THREAD_SAFE
Module is threadsafe.
fr_rb_node_t name_node
Entry in the name tree.
uint64_t active_callers
total number of times we've been called
bool force
Force the module to return a specific code.
module_thread_instance_t * module_thread(module_instance_t *mi)
Retrieve module/thread specific instance for a module.
module_instance_state_t state
What's been done with this module so far.
int module_submodule_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule)
module_thread_instantiate_t thread_instantiate
module_instantiate_t instantiate
int modules_thread_instantiate(TALLOC_CTX *ctx, module_list_t const *ml, fr_event_list_t *el)
Creates per-thread instance data for modules which need it.
module_instance_t * module_alloc(module_list_t *ml, module_instance_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name))
Allocate a new module and add it to a module list for later bootstrap/instantiation.
char const * name2
The packet type i.e Access-Request, Access-Reject.
int modules_instantiate(module_list_t const *ml)
Completes instantiation of modules.
fr_rb_tree_t * name_tree
Modules indexed by name.
call_env_method_t const * method_env
Call specific conf parsing.
int(* module_instantiate_t)(module_inst_ctx_t const *mctx)
Module instantiation callback.
module_instance_t * module_by_data(module_list_t const *ml, void const *data)
Find an existing module instance by its private instance data.
dl_module_inst_t * dl_inst
Structure containing the module's instance data, configuration, and dl handle.
void * data
Thread specific instance data.
rlm_rcode_t code
Code module will return when 'force' has has been set to true.
module_thread_instance_t * module_thread_by_data(module_list_t const *ml, void const *data)
Retrieve module/thread specific instance data for a module.
void modules_thread_detach(module_list_t const *ml)
Remove thread-specific data for a given module list.
void module_free(module_instance_t *mi)
Explicitly free a module if a fatal error occurs during bootstrap.
fr_rb_tree_t * data_tree
Modules indexed by data.
fr_heap_index_t inst_idx
Entry in the bootstrap/instantiation heap.
char const * name1
i.e. "recv", "send", "process"
module_instance_state_t
What state the module instance is currently in.
@ MODULE_INSTANCE_INSTANTIATED
@ MODULE_INSTANCE_BOOTSTRAPPED
int(* module_thread_detach_t)(module_thread_inst_ctx_t const *mctx)
Module thread destruction callback.
uint32_t number
Unique module number.
module_method_t method
Module method to call.
module_instance_t * module_root(module_instance_t const *child)
Find the module's shallowest parent.
int module_instantiate(module_instance_t *mi)
Manually complete module setup by calling its instantiate function.
char const * thread_inst_type
module_instantiate_t bootstrap
int modules_bootstrap(module_list_t const *ml)
Bootstrap any modules which have not been bootstrapped already.
fr_rb_node_t data_node
Entry in the data tree.
DL_MODULE_COMMON
Common fields for all loadable modules.
module_thread_detach_t thread_detach
int(* module_thread_instantiate_t)(module_thread_inst_ctx_t const *mctx)
Module thread creation callback.
int module_conf_parse(module_instance_t *mi, CONF_SECTION *mod_cs)
Parse the configuration associated with a module.
module_t const * module
Public module structure.
uint32_t last_number
Last identifier assigned to a module instance.
module_list_t * ml
Module list this instance belongs to.
char const * name
Friendly list identifier.
fr_event_list_t * el
Event list associated with this thread.
fr_heap_index_t inst_idx
Entry in the thread-specific bootstrap heap.
module_method_t func
State function.
module_instance_t * module_parent(module_instance_t const *child)
Find the module's parent (if any)
unlang_action_t(* module_method_t)(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Module section callback.
pthread_mutex_t mutex
Used prevent multiple threads entering a thread unsafe module simultaneously.
module_list_t * module_list_alloc(TALLOC_CTX *ctx, char const *name)
Allocate a new module list.
int module_bootstrap(module_instance_t *mi)
Manually complete module bootstrap by calling its instantiate function.
Named methods exported by a module.
Struct exported by a rlm_* module.
Map string values to module state method.
Per thread per instance data.
fr_aka_sim_id_type_t type
static fr_event_list_t * el
static size_t char ** out