The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Interface to the FreeRADIUS module system. More...
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/server/module_ctx.h>
#include <freeradius-devel/unlang/action.h>
#include <freeradius-devel/unlang/compile.h>
#include <freeradius-devel/unlang/call_env.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/server/components.h>
#include <freeradius-devel/server/dl_module.h>
#include <freeradius-devel/server/exfile.h>
#include <freeradius-devel/server/pool.h>
#include <freeradius-devel/server/rcode.h>
#include <freeradius-devel/io/schedule.h>
#include <freeradius-devel/features.h>
Go to the source code of this file.
Data Structures | |
struct | module_instance_s |
Per instance data. More... | |
struct | module_list_t |
A list of modules. More... | |
struct | module_method_name_s |
Named methods exported by a module. More... | |
struct | module_s |
Struct exported by a rlm_* module. More... | |
struct | module_state_func_table_t |
Map string values to module state method. More... | |
struct | module_thread_instance_s |
Per thread per instance data. More... | |
Macros | |
#define | MODULE_NAME_TERMINATOR { NULL } |
Typedefs | |
typedef struct module_instance_s | module_instance_t |
typedef int(* | module_instantiate_t) (module_inst_ctx_t const *mctx) |
Module instantiation callback. More... | |
typedef struct module_list_t | module_list_t |
typedef struct module_method_name_s | module_method_name_t |
typedef unlang_action_t(* | module_method_t) (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
Module section callback. More... | |
typedef struct module_s | module_t |
typedef int(* | module_thread_detach_t) (module_thread_inst_ctx_t const *mctx) |
Module thread destruction callback. More... | |
typedef struct module_thread_instance_s | module_thread_instance_t |
typedef int(* | module_thread_instantiate_t) (module_thread_inst_ctx_t const *mctx) |
Module thread creation callback. More... | |
Enumerations | |
enum | module_flags_t { MODULE_TYPE_THREAD_SAFE = (0 << 0) , MODULE_TYPE_THREAD_UNSAFE = (1 << 0) , MODULE_TYPE_RESUMABLE = (1 << 2) , MODULE_TYPE_RETRY = (1 << 3) } |
enum | module_instance_state_t { MODULE_INSTANCE_INIT = 0 , MODULE_INSTANCE_BOOTSTRAPPED , MODULE_INSTANCE_INSTANTIATED } |
What state the module instance is currently in. More... | |
Callbacks for the conf_parser_t | |
int | module_submodule_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, UNUSED conf_parser_t const *rule) |
Module and module thread lookup | |
module_instance_t * | module_by_data (module_list_t const *ml, void const *data) |
Find an existing module instance by its private instance data. More... | |
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. More... | |
module_instance_t * | module_parent (module_instance_t const *child) |
Find the module's parent (if any) More... | |
module_instance_t * | module_root (module_instance_t const *child) |
Find the module's shallowest parent. More... | |
module_thread_instance_t * | module_thread (module_instance_t *mi) |
Retrieve module/thread specific instance for a module. More... | |
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. More... | |
Module and module thread initialisation and instantiation | |
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. More... | |
int | module_bootstrap (module_instance_t *mi) |
Manually complete module bootstrap by calling its instantiate function. More... | |
int | module_conf_parse (module_instance_t *mi, CONF_SECTION *mod_cs) |
Parse the configuration associated with a module. More... | |
void | module_free (module_instance_t *mi) |
Explicitly free a module if a fatal error occurs during bootstrap. More... | |
int | module_instantiate (module_instance_t *mi) |
Manually complete module setup by calling its instantiate function. More... | |
module_list_t * | module_list_alloc (TALLOC_CTX *ctx, char const *name) |
Allocate a new module list. More... | |
int | modules_bootstrap (module_list_t const *ml) |
Bootstrap any modules which have not been bootstrapped already. More... | |
void | modules_init (char const *lib_dir) |
Perform global initialisation for modules. More... | |
int | modules_instantiate (module_list_t const *ml) |
Completes instantiation of modules. More... | |
void | modules_thread_detach (module_list_t const *ml) |
Remove thread-specific data for a given module list. More... | |
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. More... | |
Interface to the FreeRADIUS module system.
Definition in file module.h.
struct module_instance_s |
Per instance data.
Per-instance data structure, to correlate the modules with the instance names (may NOT be the module names!), and the per-instance data structures.
Data Fields | ||
---|---|---|
unlang_actions_t | actions | default actions and retries. |
rlm_rcode_t | code | Code module will return when 'force' has has been set to true. |
fr_rb_node_t | data_node | Entry in the data tree. |
dl_module_inst_t * | dl_inst |
Structure containing the module's instance data, configuration, and dl handle. This can be used to access the parsed configuration data for the module. |
bool | force |
Force the module to return a specific code. Usually set via an administrative interface. |
fr_heap_index_t | inst_idx |
Entry in the bootstrap/instantiation heap. should be an identical value to the thread-specific data for this module. |
module_list_t * | ml | Module list this instance belongs to. |
module_t const * | module |
Public module structure. Cached for convenience. This exports module methods, i.e. the functions which allow the module to perform actions. |
pthread_mutex_t | mutex | Used prevent multiple threads entering a thread unsafe module simultaneously. |
char const * | name | Instance name e.g. user_database. |
fr_rb_node_t | name_node | Entry in the name tree. |
uint32_t | number | Unique module number. |
module_instance_state_t | state | What's been done with this module so far. |
struct module_list_t |
A list of modules.
This allows modules to be instantiated and freed in phases, i.e. proto modules before rlm modules.
Data Fields | ||
---|---|---|
fr_rb_tree_t * | data_tree | Modules indexed by data. |
uint32_t | last_number | Last identifier assigned to a module instance. |
char const * | name | Friendly list identifier. |
fr_rb_tree_t * | name_tree | Modules indexed by name. |
struct module_method_name_s |
Data Fields | ||
---|---|---|
module_method_t | method | Module method to call. |
call_env_method_t const * | method_env | Call specific conf parsing. |
char const * | name1 | i.e. "recv", "send", "process" |
char const * | name2 | The packet type i.e Access-Request, Access-Reject. |
struct module_s |
Struct exported by a rlm_* module.
Determines the capabilities of the module, and maps internal functions within the module to different sections.
Data Fields | ||
---|---|---|
module_instantiate_t | bootstrap | |
DL_MODULE_COMMON | Common fields for all loadable modules. | |
int | flags | |
module_instantiate_t | instantiate | |
module_thread_detach_t | thread_detach | |
size_t | thread_inst_size | |
char const * | thread_inst_type | |
module_thread_instantiate_t | thread_instantiate |
struct module_state_func_table_t |
Data Fields | ||
---|---|---|
module_method_t | func | State function. |
char const * | name | String identifier for state. |
struct module_thread_instance_s |
Per thread per instance data.
Stores module and thread specific data.
Data Fields | ||
---|---|---|
uint64_t | active_callers | total number of times we've been called |
void * | data | Thread specific instance data. |
fr_event_list_t * | el | Event list associated with this thread. |
fr_heap_index_t | inst_idx |
Entry in the thread-specific bootstrap heap. Should be an identical value to the global instance data for the same module. |
module_instance_t const * | mi | As opposed to the thread local inst. |
uint64_t | total_calls |
typedef struct module_instance_s module_instance_t |
typedef int(* module_instantiate_t) (module_inst_ctx_t const *mctx) |
typedef struct module_list_t module_list_t |
typedef struct module_method_name_s module_method_name_t |
typedef unlang_action_t(* module_method_t) (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request) |
Module section callback.
Is called when the module is listed in a particular section of a virtual server, and the request has reached the module call.
[out] | p_result | Result code of the module method. |
[in] | mctx | Holds global instance data, thread instance data and call specific instance data. |
[in] | request | to process. |
typedef int(* module_thread_detach_t) (module_thread_inst_ctx_t const *mctx) |
typedef struct module_thread_instance_s module_thread_instance_t |
typedef int(* module_thread_instantiate_t) (module_thread_inst_ctx_t const *mctx) |
enum module_flags_t |
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.
[in] | ml | To add module to. |
[in] | parent | of the module being bootstrapped, if this is a submodule. If this is not a submodule parent must be NULL. |
[in] | type | What type of module we're loading. Determines the prefix added to the library name. Should be one of:
|
[in] | mod_name | The name of this module, i.e. 'redis' for 'rlm_redis'. |
[in] | inst_name | Instance name for this module, i.e. "aws_redis_01". The notable exception is if this is a submodule, in which case inst_name is usually the mod_name. |
Definition at line 976 of file module.c.
int module_bootstrap | ( | module_instance_t * | mi | ) |
Manually complete module bootstrap by calling its instantiate function.
[in] | mi | Module instance to bootstrap. |
Definition at line 788 of file module.c.
module_instance_t* module_by_data | ( | module_list_t const * | ml, |
void const * | data | ||
) |
Find an existing module instance by its private instance data.
[in] | ml | to search in. |
[in] | data | to resolve to module_instance_t. |
Definition at line 438 of file module.c.
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.
[in] | ml | to search in. |
[in] | parent | to qualify search with. |
[in] | asked_name | The name of the module we're attempting to find. May include '-' which indicates that it's ok for the module not to be loaded. |
Definition at line 367 of file module.c.
int module_conf_parse | ( | module_instance_t * | mi, |
CONF_SECTION * | mod_conf | ||
) |
void module_free | ( | module_instance_t * | mi | ) |
int module_instantiate | ( | module_instance_t * | instance | ) |
module_list_t* module_list_alloc | ( | TALLOC_CTX * | ctx, |
char const * | name | ||
) |
Allocate a new module list.
This is used to instantiate and destroy modules in distinct phases for example, we may need to load all proto modules before rlm modules.
If the list is freed all module instance data will be freed. If no more instances of the module exist the module be unloaded.
[in] | ctx | To allocate the list in. |
[in] | name | of the list. |
Definition at line 1118 of file module.c.
module_instance_t* module_parent | ( | module_instance_t const * | child | ) |
module_instance_t* module_root | ( | module_instance_t const * | child | ) |
int module_submodule_parse | ( | UNUSED TALLOC_CTX * | ctx, |
void * | out, | ||
void * | parent, | ||
CONF_ITEM * | ci, | ||
UNUSED conf_parser_t const * | rule | ||
) |
module_thread_instance_t* module_thread | ( | module_instance_t * | mi | ) |
Retrieve module/thread specific instance for a module.
[in] | mi | to find thread specific data for. |
Definition at line 459 of file module.c.
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.
[in] | ml | Module list module belongs to. |
[in] | data | Private instance data of the module. Same as what would be provided by module_by_data. |
Definition at line 485 of file module.c.
int modules_bootstrap | ( | module_list_t const * | ml | ) |
Bootstrap any modules which have not been bootstrapped already.
Allows the module to initialise connection pools, and complete any registrations that depend on attributes created during the bootstrap phase.
[in] | ml | containing modules to bootstrap. |
Definition at line 830 of file module.c.
void modules_init | ( | char const * | lib_dir | ) |
int modules_instantiate | ( | module_list_t const * | ml | ) |
Completes instantiation of modules.
Allows the module to initialise connection pools, and complete any registrations that depend on attributes created during the bootstrap phase.
[in] | ml | containing modules to instantiate. |
Definition at line 759 of file module.c.
void modules_thread_detach | ( | module_list_t const * | ml | ) |
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.
Must be called by any new threads before attempting to execute unlang sections.
[in] | ctx | Talloc ctx to bind thread specific data to. |
[in] | ml | Module list to perform thread instantiation for. |
[in] | el | Event list serviced by this thread. |
Definition at line 663 of file module.c.