The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Wrappers around dlopen to manage loading modules at runtime. More...
#include <freeradius-devel/server/cf_parse.h>
#include <freeradius-devel/util/dl.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/version.h>
Go to the source code of this file.
Data Structures | |
struct | dl_module_common_t |
Fields common to all types of loadable modules. More... | |
struct | dl_module_s |
Macros | |
#define | _CONST const |
#define | DL_EXTENSION ".so" |
#define | DL_MODULE_COMMON |
Common fields for the interface struct modules export. More... | |
#define | DL_PRIORITY_BOOTSTRAP 10 |
Callback priority for bootstrap callback. More... | |
#define | DL_PRIORITY_DICT 30 |
Callback priorities. More... | |
#define | DL_PRIORITY_DICT_ATTR 29 |
Callback priority for attribute resolution. More... | |
#define | DL_PRIORITY_DICT_ENUM 28 |
Callback priority for enum resolution. More... | |
#define | DL_PRIORITY_LIB 20 |
Callback priority for library config. More... | |
#define | MODULE_MAGIC_INIT RADIUSD_MAGIC_NUMBER |
Stop people using different module/library/server versions together. More... | |
Typedefs | |
typedef struct dl_module_loader_s | dl_module_loader_t |
typedef int(* | dl_module_onload_t) (void) |
Callback to call when a module is first loaded. More... | |
typedef struct dl_module_s | dl_module_t |
Module handle. More... | |
typedef void(* | dl_module_unload_t) (void) |
Callback when a module is destroyed. More... | |
Enumerations | |
enum | dl_module_type_t { DL_MODULE_TYPE_MODULE = 0 , DL_MODULE_TYPE_PROTO , DL_MODULE_TYPE_PROCESS , DL_MODULE_TYPE_SUBMODULE } |
Functions | |
dl_loader_t * | dl_loader_from_module_loader (dl_module_loader_t *dl_module_loader) |
dl_module_t * | dl_module_alloc (dl_module_t const *parent, char const *name, dl_module_type_t type) |
Load a module library using dlopen() or return a previously loaded module from the cache. More... | |
int | dl_module_free (dl_module_t *dl_module) |
Free a dl_module (when there are no more references to it) More... | |
dl_module_loader_t * | dl_module_loader_init (char const *lib_dir) |
Initialise structures needed by the dynamic linker. More... | |
char const * | dl_module_search_path (void) |
Variables | |
fr_table_num_sorted_t const | dl_module_type_prefix [] |
Name prefixes matching the types of loadable module. More... | |
size_t | dl_module_type_prefix_len |
Wrappers around dlopen to manage loading modules at runtime.
Definition in file dl_module.h.
struct dl_module_common_t |
Fields common to all types of loadable modules.
Definition at line 108 of file dl_module.h.
Data Fields | ||
---|---|---|
DL_MODULE_COMMON |
struct dl_module_s |
Definition at line 117 of file dl_module.h.
Data Fields | ||
---|---|---|
CONF_SECTION *_CONST | conf |
The module's global configuration (as opposed to the instance, configuration). May be NULL. |
dl_t *_CONST | dl | Dynamic loader handle. |
dl_module_common_t * | exported | Symbol exported by the module, containing its public functions, name and behaviour control flags. |
bool _CONST | in_tree | |
dl_module_loader_t *_CONST | loader | Loader that owns this dl. |
char const *_CONST | name | Name of the module. The name passed to dl_module_alloc. |
dl_module_t const *_CONST | parent | of this module. |
unsigned int | refs |
Number of references to this module. This is maintained as a separate counter (instead of using talloc refs) because it needs to be thread safe. The talloc code accesses the chunk after calling the destructor, so we can't lock the loader mutex inside the destructor and expect things to work correctly. |
dl_module_type_t _CONST | type | of this module. |
#define _CONST const |
Definition at line 47 of file dl_module.h.
#define DL_EXTENSION ".so" |
Definition at line 57 of file dl_module.h.
#define DL_MODULE_COMMON |
Common fields for the interface struct modules export.
These are just enough for the loader to be able to load and unload the module.
Definition at line 98 of file dl_module.h.
#define DL_PRIORITY_BOOTSTRAP 10 |
Callback priority for bootstrap callback.
Definition at line 80 of file dl_module.h.
#define DL_PRIORITY_DICT 30 |
Callback priorities.
The higher the priority, the earlier in callback gets called. Callback priority for dictionary autoloading
Definition at line 76 of file dl_module.h.
#define DL_PRIORITY_DICT_ATTR 29 |
Callback priority for attribute resolution.
Definition at line 77 of file dl_module.h.
#define DL_PRIORITY_DICT_ENUM 28 |
Callback priority for enum resolution.
Definition at line 78 of file dl_module.h.
#define DL_PRIORITY_LIB 20 |
Callback priority for library config.
Definition at line 79 of file dl_module.h.
#define MODULE_MAGIC_INIT RADIUSD_MAGIC_NUMBER |
Stop people using different module/library/server versions together.
Definition at line 63 of file dl_module.h.
typedef struct dl_module_loader_s dl_module_loader_t |
Definition at line 1 of file dl_module.h.
typedef int(* dl_module_onload_t) (void) |
Callback to call when a module is first loaded.
Definition at line 87 of file dl_module.h.
typedef struct dl_module_s dl_module_t |
Module handle.
Contains module's dlhandle, and the functions it exports.
Definition at line 92 of file dl_module.h.
typedef void(* dl_module_unload_t) (void) |
Callback when a module is destroyed.
Definition at line 92 of file dl_module.h.
enum dl_module_type_t |
Definition at line 65 of file dl_module.h.
dl_loader_t* dl_loader_from_module_loader | ( | dl_module_loader_t * | dl_module_loader | ) |
Definition at line 488 of file dl_module.c.
dl_module_t* dl_module_alloc | ( | dl_module_t const * | parent, |
char const * | name, | ||
dl_module_type_t | type | ||
) |
Load a module library using dlopen() or return a previously loaded module from the cache.
When the dl_module_t is no longer used, talloc_free() may be used to free it.
When all references to the original dlhandle are freed, dlclose() will be called on the dlhandle to unload the module.
[in] | parent | The dl_module_t of the parent module, e.g. rlm_sql for rlm_sql_postgresql. |
[in] | name | of the module e.g. sql for rlm_sql. |
[in] | type | Used to determine module name prefixes. Must be one of:
|
Definition at line 315 of file dl_module.c.
int dl_module_free | ( | dl_module_t * | dl_module | ) |
Free a dl_module (when there are no more references to it)
Decrement the reference count for a module, freeing it and unloading the module if there are no more references.
Definition at line 281 of file dl_module.c.
dl_module_loader_t* dl_module_loader_init | ( | char const * | lib_dir | ) |
Initialise structures needed by the dynamic linker.
Definition at line 532 of file dl_module.c.
char const* dl_module_search_path | ( | void | ) |
Definition at line 483 of file dl_module.c.
|
extern |
Name prefixes matching the types of loadable module.
Definition at line 57 of file dl_module.c.
|
extern |
Definition at line 63 of file dl_module.c.