All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
modules.c File Reference
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modpriv.h>
#include <freeradius-devel/modcall.h>
#include <freeradius-devel/parser.h>
#include <freeradius-devel/rad_assert.h>
+ Include dependency graph for modules.c:

Go to the source code of this file.

Data Structures

struct  fr_module_hup_t
 
struct  indexed_modcallable
 
struct  virtual_server_t
 

Macros

#define CONNECTION_POOL_CF_KEY   "connection_pool"
 
#define FIND_SIBLING_CF_KEY   "find_sibling"
 
#define LT_SHREXT   ".so"
 
#define MAX_IGNORED   (32)
 
#define parent_name(_x)   cf_section_name(cf_item_parent(cf_section_to_item(_x)))
 
#define RTLD_LOCAL   (0)
 
#define RTLD_NOW   (0)
 

Typedefs

typedef struct indexed_modcallable indexed_modcallable
 
typedef struct virtual_server_t virtual_server_t
 

Functions

static int _module_entry_free (module_entry_t *this)
 
static int _virtual_server_free (virtual_server_t *server)
 
static int check_module_magic (CONF_SECTION *cs, module_t const *module)
 Check if the magic number in the module matches the one in the library. More...
 
static bool define_type (CONF_SECTION *cs, fr_dict_attr_t const *da, char const *name)
 
rlm_rcode_t indexed_modcall (rlm_components_t comp, int idx, REQUEST *request)
 
static int indexed_modcallable_cmp (void const *one, void const *two)
 
static bool is_reserved_word (const char *name)
 
static int load_component_section (CONF_SECTION *cs, rbtree_t *components, rlm_components_t comp)
 
static int load_subcomponent_section (CONF_SECTION *cs, rbtree_t *components, fr_dict_attr_t const *da, rlm_components_t comp)
 
static indexed_modcallablelookup_by_index (rbtree_t *components, rlm_components_t comp, int idx)
 
int lt_dlclose (lt_dlhandle handle)
 
char const * lt_dlerror (void)
 
lt_dlhandle lt_dlopenext (char const *name)
 
void * lt_dlsym (lt_dlhandle handle, char const *symbol)
 
static module_instance_tmodule_bootstrap (CONF_SECTION *modules, CONF_SECTION *cs)
 Bootstrap a module. More...
 
static int module_conf_parse (module_instance_t *node, void **handle)
 Parse module's configuration section and setup destructors. More...
 
fr_connection_pool_tmodule_connection_pool_init (CONF_SECTION *module, void *opaque, fr_connection_create_t c, fr_connection_alive_t a, char const *log_prefix)
 Initialise a module specific connection pool. More...
 
static module_entry_tmodule_dlopen (CONF_SECTION *cs)
 
static int module_entry_cmp (void const *one, void const *two)
 
module_instance_tmodule_find (CONF_SECTION *modules, char const *askedname)
 Find an existing module instance. More...
 
int module_hup_module (CONF_SECTION *cs, module_instance_t *node, time_t when)
 
static void module_instance_free (void *data)
 
static void module_instance_free_old (UNUSED CONF_SECTION *cs, module_instance_t *node, time_t when)
 
module_instance_tmodule_instantiate (CONF_SECTION *modules, char const *askedname)
 Load a module, and instantiate it. More...
 
module_instance_tmodule_instantiate_method (CONF_SECTION *modules, char const *name, rlm_components_t *method)
 
rlm_rcode_t module_preacct (REQUEST *request)
 
int module_sibling_section_find (CONF_SECTION **out, CONF_SECTION *module, char const *name)
 Resolve polymorphic item's from a module's CONF_SECTION to a subsection in another module. More...
 
int modules_bootstrap (CONF_SECTION *config)
 
int modules_free (void)
 
int modules_hup (CONF_SECTION *modules)
 
int modules_init (CONF_SECTION *config)
 Instantiate the modules. More...
 
static indexed_modcallablenew_sublist (CONF_SECTION *cs, rbtree_t *components, rlm_components_t comp, int idx)
 
static int pass2_cb (UNUSED void *ctx, void *data)
 
rlm_rcode_t process_accounting (int acct_type, REQUEST *request)
 
rlm_rcode_t process_authenticate (int auth_type, REQUEST *request)
 
rlm_rcode_t process_authorize (int autz_type, REQUEST *request)
 
int process_checksimul (int sess_type, REQUEST *request, int maxsimul)
 
rlm_rcode_t process_post_auth (int postauth_type, REQUEST *request)
 
rlm_rcode_t process_post_proxy (int type, REQUEST *request)
 
rlm_rcode_t process_pre_proxy (int type, REQUEST *request)
 
rlm_rcode_t process_recv_coa (int recv_coa_type, REQUEST *request)
 
rlm_rcode_t process_send_coa (int send_coa_type, REQUEST *request)
 
static int virtual_server_compile (CONF_SECTION *cs)
 
static bool virtual_server_define_types (CONF_SECTION *cs, rlm_components_t comp)
 
static virtual_server_tvirtual_server_find (char const *name)
 
int virtual_servers_bootstrap (CONF_SECTION *config)
 
int virtual_servers_init (CONF_SECTION *config)
 

Variables

static char const * ignored [MAX_IGNORED]
 
static int last_ignored = -1
 
static rbtree_tmodule_tree = NULL
 
char const * radlib_dir = NULL
 Path to search for modules in. More...
 
const section_type_value_t section_type_value [MOD_COUNT]
 Mappings between section names, typenames and control attributes. More...
 
char const * unlang_keyword []
 

Data Structure Documentation

struct fr_module_hup_t

Definition at line 54 of file modules.c.

+ Collaboration diagram for fr_module_hup_t:
Data Fields
void * insthandle
module_instance_t * mi
fr_module_hup_t * next
time_t when
struct indexed_modcallable

Definition at line 38 of file modules.c.

+ Collaboration diagram for indexed_modcallable:
Data Fields
rlm_components_t comp
int idx
modcallable * modulelist
struct virtual_server_t

Definition at line 44 of file modules.c.

+ Collaboration diagram for virtual_server_t:
Data Fields
rbtree_t * components
CONF_SECTION * cs
modcallable * mc[MOD_COUNT]
char const * name
CONF_SECTION * subcs[MOD_COUNT]

Macro Definition Documentation

#define CONNECTION_POOL_CF_KEY   "connection_pool"
#define FIND_SIBLING_CF_KEY   "find_sibling"
#define LT_SHREXT   ".so"

Definition at line 92 of file modules.c.

#define MAX_IGNORED   (32)

Definition at line 1019 of file modules.c.

#define parent_name (   _x)    cf_section_name(cf_item_parent(cf_section_to_item(_x)))
#define RTLD_LOCAL   (0)

Definition at line 84 of file modules.c.

#define RTLD_NOW   (0)

Definition at line 81 of file modules.c.

Typedef Documentation

Function Documentation

static int _module_entry_free ( module_entry_t this)
static

Definition at line 393 of file modules.c.

+ Here is the caller graph for this function:

static int _virtual_server_free ( virtual_server_t server)
static

Definition at line 296 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int check_module_magic ( CONF_SECTION cs,
module_t const *  module 
)
static

Check if the magic number in the module matches the one in the library.

This is used to detect potential ABI issues caused by running with modules which were built for a different version of the server.

Parameters
csbeing parsed.
modulebeing loaded.
Returns
  • 0 on success.
  • -1 if prefix mismatch.
  • -2 if version mismatch.
  • -3 if commit mismatch.

Definition at line 108 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool define_type ( CONF_SECTION cs,
fr_dict_attr_t const *  da,
char const *  name 
)
static

Definition at line 1351 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t indexed_modcall ( rlm_components_t  comp,
int  idx,
REQUEST request 
)

Definition at line 908 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int indexed_modcallable_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 303 of file modules.c.

+ Here is the caller graph for this function:

static bool is_reserved_word ( const char *  name)
static

Definition at line 1732 of file modules.c.

+ Here is the caller graph for this function:

static int load_component_section ( CONF_SECTION cs,
rbtree_t components,
rlm_components_t  comp 
)
static

Definition at line 1023 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int load_subcomponent_section ( CONF_SECTION cs,
rbtree_t components,
fr_dict_attr_t const *  da,
rlm_components_t  comp 
)
static

Definition at line 967 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static indexed_modcallable* lookup_by_index ( rbtree_t components,
rlm_components_t  comp,
int  idx 
)
static

Definition at line 859 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int lt_dlclose ( lt_dlhandle  handle)

Definition at line 274 of file modules.c.

+ Here is the caller graph for this function:

char const* lt_dlerror ( void  )

Definition at line 281 of file modules.c.

lt_dlhandle lt_dlopenext ( char const *  name)

Definition at line 151 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void* lt_dlsym ( lt_dlhandle  handle,
char const *  symbol 
)

Definition at line 269 of file modules.c.

static module_instance_t* module_bootstrap ( CONF_SECTION modules,
CONF_SECTION cs 
)
static

Bootstrap a module.

Load the module shared library, allocate instance memory for it, parse the module configuration, and call the modules "bootstrap" method.

Definition at line 546 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int module_conf_parse ( module_instance_t node,
void **  handle 
)
static

Parse module's configuration section and setup destructors.

Definition at line 507 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_connection_pool_t* module_connection_pool_init ( CONF_SECTION module,
void *  opaque,
fr_connection_create_t  c,
fr_connection_alive_t  a,
char const *  log_prefix 
)

Initialise a module specific connection pool.

See Also
fr_connection_pool_init
Parameters
[in]modulesection.
[in]opaquedata pointer to pass to callbacks.
[in]cCallback to create new connections.
[in]aCallback to check the status of connections.
[in]log_prefixoverride, if NULL will be set automatically from the module CONF_SECTION.
Returns
  • New connection pool.
  • NULL on error.

Definition at line 1759 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static module_entry_t* module_dlopen ( CONF_SECTION cs)
static

Definition at line 424 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int module_entry_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 382 of file modules.c.

+ Here is the caller graph for this function:

module_instance_t* module_find ( CONF_SECTION modules,
char const *  askedname 
)

Find an existing module instance.

Definition at line 623 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int module_hup_module ( CONF_SECTION cs,
module_instance_t node,
time_t  when 
)

Definition at line 1624 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void module_instance_free ( void *  data)
static

Definition at line 345 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void module_instance_free_old ( UNUSED CONF_SECTION cs,
module_instance_t node,
time_t  when 
)
static

Definition at line 315 of file modules.c.

+ Here is the caller graph for this function:

module_instance_t* module_instantiate ( CONF_SECTION modules,
char const *  askedname 
)

Load a module, and instantiate it.

Definition at line 644 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

module_instance_t* module_instantiate_method ( CONF_SECTION modules,
char const *  name,
rlm_components_t method 
)

Definition at line 712 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t module_preacct ( REQUEST request)

Definition at line 2115 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int module_sibling_section_find ( CONF_SECTION **  out,
CONF_SECTION module,
char const *  name 
)

Resolve polymorphic item's from a module's CONF_SECTION to a subsection in another module.

This allows certain module sections to reference module sections in other instances of the same module and share CONF_DATA associated with them.

example {
        data {
                ...
        }
}

example inst {
        data = example
}
 * 
Parameters
outwhere to write the pointer to a module's config section. May be NULL on success, indicating the config item was not found within the module CONF_SECTION or the chain of module references was followed and the module at the end of the chain did not a subsection.
moduleCONF_SECTION.
nameof the polymorphic sub-section.
Returns
  • 0 on success with referenced section.
  • 1 on success with local section.
  • -1 on failure.

Definition at line 788 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int modules_bootstrap ( CONF_SECTION config)

Definition at line 1866 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int modules_free ( void  )

Definition at line 413 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int modules_hup ( CONF_SECTION modules)

Definition at line 1691 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int modules_init ( CONF_SECTION config)

Instantiate the modules.

Definition at line 2064 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static indexed_modcallable* new_sublist ( CONF_SECTION cs,
rbtree_t components,
rlm_components_t  comp,
int  idx 
)
static

Definition at line 873 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int pass2_cb ( UNUSED void *  ctx,
void *  data 
)
static

Definition at line 1341 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_accounting ( int  acct_type,
REQUEST request 
)

Definition at line 2123 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_authenticate ( int  auth_type,
REQUEST request 
)

Definition at line 2106 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_authorize ( int  autz_type,
REQUEST request 
)

Definition at line 2098 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int process_checksimul ( int  sess_type,
REQUEST request,
int  maxsimul 
)

Definition at line 2135 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_post_auth ( int  postauth_type,
REQUEST request 
)

Definition at line 2178 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_post_proxy ( int  type,
REQUEST request 
)

Definition at line 2169 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_pre_proxy ( int  type,
REQUEST request 
)

Definition at line 2161 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_recv_coa ( int  recv_coa_type,
REQUEST request 
)

Definition at line 2184 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

rlm_rcode_t process_send_coa ( int  send_coa_type,
REQUEST request 
)

Definition at line 2189 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int virtual_server_compile ( CONF_SECTION cs)
static

Definition at line 1174 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool virtual_server_define_types ( CONF_SECTION cs,
rlm_components_t  comp 
)
static

Definition at line 1391 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static virtual_server_t* virtual_server_find ( char const *  name)
static

Definition at line 286 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int virtual_servers_bootstrap ( CONF_SECTION config)

Definition at line 1457 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int virtual_servers_init ( CONF_SECTION config)

Definition at line 1577 of file modules.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

char const* ignored[MAX_IGNORED]
static

Definition at line 1021 of file modules.c.

int last_ignored = -1
static

Definition at line 1020 of file modules.c.

rbtree_t* module_tree = NULL
static

Definition at line 52 of file modules.c.

char const* radlib_dir = NULL

Path to search for modules in.

Definition at line 36 of file modules.c.

const section_type_value_t section_type_value[MOD_COUNT]
Initial value:
= {
{ "authenticate", "Auth-Type", PW_AUTH_TYPE },
{ "authorize", "Autz-Type", PW_AUTZ_TYPE },
{ "preacct", "Pre-Acct-Type", PW_PRE_ACCT_TYPE },
{ "accounting", "Acct-Type", PW_ACCT_TYPE },
{ "session", "Session-Type", PW_SESSION_TYPE },
{ "pre-proxy", "Pre-Proxy-Type", PW_PRE_PROXY_TYPE },
{ "post-proxy", "Post-Proxy-Type", PW_POST_PROXY_TYPE },
{ "post-auth", "Post-Auth-Type", PW_POST_AUTH_TYPE }
,
{ "recv-coa", "Recv-CoA-Type", PW_RECV_COA_TYPE },
{ "send-coa", "Send-CoA-Type", PW_SEND_COA_TYPE }
}

Mappings between section names, typenames and control attributes.

Defined in modules.c.

Definition at line 64 of file modules.c.

char const* unlang_keyword[]