All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
modcall.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/map_proc.h>
#include <freeradius-devel/rad_assert.h>
+ Include dependency graph for modcall.c:

Go to the source code of this file.

Data Structures

struct  modcall_stack_entry_t
 
struct  modcallable
 
struct  modgroup
 
struct  modref
 
struct  modsingle
 
struct  modxlat
 

Macros

#define dump_tree(a, b)
 
#define MOD_ACTION_REJECT   (-2)
 
#define MOD_ACTION_RETURN   (-1)
 
#define MOD_LOG_CLOSE_BRACE   RDEBUG2("} # %s = %s", c->debug_name, fr_int2str(mod_rcode_table, result, "<invalid>"))
 
#define MOD_LOG_OPEN_BRACE   RDEBUG2("%s {", c->debug_name)
 
#define MODCALL_STACK_MAX   (32)
 
#define safe_lock(foo)
 
#define safe_unlock(foo)
 

Typedefs

typedef struct
modcall_stack_entry_t 
modcall_stack_entry_t
 

Enumerations

enum  mod_type_t {
  MOD_SINGLE = 1,
  MOD_GROUP,
  MOD_LOAD_BALANCE,
  MOD_REDUNDANT_LOAD_BALANCE,
  MOD_IF,
  MOD_ELSE,
  MOD_ELSIF,
  MOD_UPDATE,
  MOD_SWITCH,
  MOD_CASE,
  MOD_FOREACH,
  MOD_BREAK,
  MOD_RETURN,
  MOD_MAP,
  MOD_POLICY,
  MOD_REFERENCE,
  MOD_XLAT
}
 Types of modcallable_t nodes. More...
 

Functions

static void add_child (modgroup *g, modcallable *c)
 
void add_to_modcallable (modcallable *parent, modcallable *this)
 
static int all_children_are_modules (CONF_SECTION *cs, char const *name)
 
static rlm_rcode_t CC_HINT (nonnull)
 
static int compile_action (modcallable *c, CONF_PAIR *cp)
 
modcallablecompile_modgroup (modcallable *parent, rlm_components_t component, CONF_SECTION *cs)
 
modcallablecompile_modsingle (TALLOC_CTX *ctx, modcallable **parent, rlm_components_t component, CONF_ITEM *ci, char const **modname)
 
static modcallabledo_compile_modbreak (modcallable *parent, rlm_components_t component, CONF_ITEM const *ci)
 
static modcallabledo_compile_modcase (modcallable *parent, rlm_components_t component, CONF_SECTION *cs)
 
static modcallabledo_compile_modforeach (modcallable *parent, rlm_components_t component, CONF_SECTION *cs)
 
static modcallabledo_compile_modgroup (modcallable *, rlm_components_t, CONF_SECTION *, int, int, int)
 
static modcallabledo_compile_modmap (modcallable *parent, rlm_components_t component, CONF_SECTION *cs, char const *name2, int grouptype)
 
static modcallabledo_compile_modserver (modcallable *parent, rlm_components_t component, CONF_ITEM *ci, char const *name, CONF_SECTION *cs, char const *server)
 
static modcallabledo_compile_modsingle (modcallable *parent, rlm_components_t component, CONF_ITEM *ci, int grouptype, char const **modname)
 
static modcallabledo_compile_modswitch (modcallable *parent, rlm_components_t component, CONF_SECTION *cs)
 
static modcallabledo_compile_modupdate (modcallable *parent, rlm_components_t component, CONF_SECTION *cs, char const *name2)
 
static modcallabledo_compile_modxlat (modcallable *parent, rlm_components_t component, char const *fmt)
 
static modgroupmod_callabletogroup (modcallable *p)
 
static modrefmod_callabletoref (modcallable *p)
 
static modsinglemod_callabletosingle (modcallable *p)
 
static modxlatmod_callabletoxlat (modcallable *p)
 
static modcallablemod_grouptocallable (modgroup *p)
 
static modcallablemod_reftocallable (modref *p)
 
static modcallablemod_singletocallable (modsingle *p)
 
static modcallablemod_xlattocallable (modxlat *p)
 
int modcall (rlm_components_t component, modcallable *c, REQUEST *request)
 Call a module, iteratively, with a local stack, rather than recursively. More...
 
static void modcall_child (REQUEST *request, rlm_components_t component, int depth, modcall_stack_entry_t *entry, modcallable *c, rlm_rcode_t *result, bool do_next_sibling)
 
void modcall_debug (modcallable *mc, int depth)
 
static int modcall_fixup_map (vp_map_t *map, UNUSED void *ctx)
 Validate and fixup a map that's part of an map section. More...
 
int modcall_fixup_update (vp_map_t *map, UNUSED void *ctx)
 Validate and fixup a map that's part of an update section. More...
 
bool modcall_pass2 (modcallable *mc)
 
static bool modcall_recurse (REQUEST *request, rlm_components_t component, int depth, modcall_stack_entry_t *entry, bool do_next_sibling)
 
static bool pass2_callback (void *ctx, fr_cond_t *c)
 
static bool pass2_fixup_undefined (CONF_ITEM const *ci, vp_tmpl_t *vpt)
 
static bool pass2_map_compile (modgroup *g)
 
static bool pass2_update_compile (modgroup *g)
 
static bool pass2_xlat_compile (CONF_ITEM const *ci, vp_tmpl_t **pvpt, bool convert, fr_dict_attr_t const *da)
 
static CONF_SECTIONvirtual_module_find_cs (rlm_components_t *pcomponent, char const *real_name, char const *virtual_name, char const *method_name)
 Load a named module from "instantiate" or "policy". More...
 

Variables

static const int authtype_actions [GROUPTYPE_COUNT][RLM_MODULE_NUMCODES]
 
static char const *const comp2str []
 
static int default_component_results [MOD_COUNT]
 
static const int defaultactions [MOD_COUNT][GROUPTYPE_COUNT][RLM_MODULE_NUMCODES]
 
const FR_NAME_NUMBER mod_rcode_table []
 
static char const modcall_spaces [] = " "
 
char const * unlang_keyword []
 

Data Structure Documentation

struct modcall_stack_entry_t

Definition at line 400 of file modcall.c.

+ Collaboration diagram for modcall_stack_entry_t:
Data Fields
modcallable * c
int priority
rlm_rcode_t result
int unwind
struct modcallable

Definition at line 74 of file modcall.c.

+ Collaboration diagram for modcallable:
Data Fields
int actions[RLM_MODULE_NUMCODES]
char const * debug_name
rlm_components_t method
char const * name
struct modcallable * next
modcallable * parent
mod_type_t type
struct modgroup

Definition at line 88 of file modcall.c.

+ Collaboration diagram for modgroup:
Data Fields
__unnamed__
Data Fields
modcallable * children
fr_cond_t * cond MOD_IF, MOD_ELSIF.
CONF_SECTION * cs
bool done_pass2
enum modgroup grouptype After mc.
vp_map_t * map MOD_UPDATE, MOD_MAP.
modcallable mc Self.
map_proc_inst_t * proc_inst Instantiation data for MOD_MAP.
modcallable * tail of the children list.
vp_tmpl_t * vpt MOD_SWITCH, MOD_MAP.
struct modref

Definition at line 112 of file modcall.c.

+ Collaboration diagram for modref:
Data Fields
modcallable mc
CONF_SECTION * ref_cs
char const * ref_name
struct modsingle

Definition at line 107 of file modcall.c.

+ Collaboration diagram for modsingle:
Data Fields
modcallable mc
module_instance_t * modinst
struct modxlat

Definition at line 118 of file modcall.c.

+ Collaboration diagram for modxlat:
Data Fields
int exec
modcallable mc
char * xlat_name

Macro Definition Documentation

#define dump_tree (   a,
 
)

Definition at line 1237 of file modcall.c.

#define MOD_ACTION_REJECT   (-2)

Definition at line 44 of file modcall.c.

#define MOD_ACTION_RETURN   (-1)

Definition at line 43 of file modcall.c.

#define MOD_LOG_CLOSE_BRACE   RDEBUG2("} # %s = %s", c->debug_name, fr_int2str(mod_rcode_table, result, "<invalid>"))

Definition at line 86 of file modcall.c.

#define MOD_LOG_OPEN_BRACE   RDEBUG2("%s {", c->debug_name)

Definition at line 84 of file modcall.c.

#define MODCALL_STACK_MAX   (32)

Definition at line 394 of file modcall.c.

#define safe_lock (   foo)

Definition at line 296 of file modcall.c.

#define safe_unlock (   foo)

Definition at line 297 of file modcall.c.

Typedef Documentation

Enumeration Type Documentation

enum mod_type_t

Types of modcallable_t nodes.

Here are our basic types: modcallable, modgroup, and modsingle. For an explanation of what they are all about, see doc/configurable_failover.rst

Enumerator
MOD_SINGLE 

Module method.

MOD_GROUP 

Grouping section.

MOD_LOAD_BALANCE 

Load balance section.

MOD_REDUNDANT_LOAD_BALANCE 

Redundant load balance section.

MOD_IF 

Condition.

MOD_ELSE 

!Condition.

MOD_ELSIF 

!Condition && Condition.

MOD_UPDATE 

Update block.

MOD_SWITCH 

Switch section.

MOD_CASE 

Case section (within a MOD_SWITCH).

MOD_FOREACH 

Foreach section.

MOD_BREAK 

Break statement (within a MOD_FOREACH).

MOD_RETURN 

Return statement.

MOD_MAP 

Mapping section (like MOD_UPDATE, but uses values from a map_proc_t call).

MOD_POLICY 

Policy section.

MOD_REFERENCE 

Virtual server.

MOD_XLAT 

Bare xlat statement.

Definition at line 51 of file modcall.c.

Function Documentation

static void add_child ( modgroup g,
modcallable c 
)
static

Definition at line 167 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void add_to_modcallable ( modcallable parent,
modcallable this 
)

Definition at line 3261 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int all_children_are_modules ( CONF_SECTION cs,
char const *  name 
)
static

Definition at line 2351 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static rlm_rcode_t CC_HINT ( nonnull  )
static

Definition at line 300 of file modcall.c.

static int compile_action ( modcallable c,
CONF_PAIR cp 
)
static

Definition at line 203 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

modcallable* compile_modgroup ( modcallable parent,
rlm_components_t  component,
CONF_SECTION cs 
)

Definition at line 3247 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

modcallable* compile_modsingle ( TALLOC_CTX *  ctx,
modcallable **  parent,
rlm_components_t  component,
CONF_ITEM ci,
char const **  modname 
)

Definition at line 2953 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modbreak ( modcallable parent,
rlm_components_t  component,
CONF_ITEM const *  ci 
)
static

Definition at line 2258 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modcase ( modcallable parent,
rlm_components_t  component,
CONF_SECTION cs 
)
static

Definition at line 2100 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modforeach ( modcallable parent,
rlm_components_t  component,
CONF_SECTION cs 
)
static

Definition at line 2180 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable * do_compile_modgroup ( modcallable parent,
rlm_components_t  component,
CONF_SECTION cs,
int  grouptype,
int  parentgrouptype,
int  mod_type 
)
static

Definition at line 2998 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modmap ( modcallable parent,
rlm_components_t  component,
CONF_SECTION cs,
char const *  name2,
int  grouptype 
)
static

Definition at line 1806 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modserver ( modcallable parent,
rlm_components_t  component,
CONF_ITEM ci,
char const *  name,
CONF_SECTION cs,
char const *  server 
)
static

Definition at line 2282 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modsingle ( modcallable parent,
rlm_components_t  component,
CONF_ITEM ci,
int  grouptype,
char const **  modname 
)
static

Definition at line 2489 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modswitch ( modcallable parent,
rlm_components_t  component,
CONF_SECTION cs 
)
static

Definition at line 1995 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modupdate ( modcallable parent,
rlm_components_t  component,
CONF_SECTION cs,
char const *  name2 
)
static

Definition at line 1946 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modcallable* do_compile_modxlat ( modcallable parent,
rlm_components_t  component,
char const *  fmt 
)
static

Definition at line 2317 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static modgroup* mod_callabletogroup ( modcallable p)
static

Definition at line 131 of file modcall.c.

+ Here is the caller graph for this function:

static modref* mod_callabletoref ( modcallable p)
static

Definition at line 146 of file modcall.c.

+ Here is the caller graph for this function:

static modsingle* mod_callabletosingle ( modcallable p)
static

Definition at line 126 of file modcall.c.

+ Here is the caller graph for this function:

static modxlat* mod_callabletoxlat ( modcallable p)
static

Definition at line 156 of file modcall.c.

+ Here is the caller graph for this function:

static modcallable* mod_grouptocallable ( modgroup p)
static

Definition at line 141 of file modcall.c.

+ Here is the caller graph for this function:

static modcallable* mod_reftocallable ( modref p)
static

Definition at line 151 of file modcall.c.

+ Here is the caller graph for this function:

static modcallable* mod_singletocallable ( modsingle p)
static

Definition at line 137 of file modcall.c.

+ Here is the caller graph for this function:

static modcallable* mod_xlattocallable ( modxlat p)
static

Definition at line 161 of file modcall.c.

+ Here is the caller graph for this function:

int modcall ( rlm_components_t  component,
modcallable c,
REQUEST request 
)

Call a module, iteratively, with a local stack, rather than recursively.

What did Paul Graham say about Lisp...?

Definition at line 1161 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void modcall_child ( REQUEST request,
rlm_components_t  component,
int  depth,
modcall_stack_entry_t entry,
modcallable c,
rlm_rcode_t result,
bool  do_next_sibling 
)
static

Definition at line 414 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void modcall_debug ( modcallable mc,
int  depth 
)

Definition at line 4178 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int modcall_fixup_map ( vp_map_t map,
UNUSED void *  ctx 
)
static

Validate and fixup a map that's part of an map section.

Parameters
mapto validate.
ctxdata to pass to fixup function (currently unused).
Returns
0 if valid else -1.

Definition at line 1556 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int modcall_fixup_update ( vp_map_t map,
UNUSED void *  ctx 
)

Validate and fixup a map that's part of an update section.

Parameters
mapto validate.
ctxdata to pass to fixup function (currently unused).
Returns
  • 0 if valid.
  • -1 not valid.

Definition at line 1622 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool modcall_pass2 ( modcallable mc)

Definition at line 3814 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool modcall_recurse ( REQUEST request,
rlm_components_t  component,
int  depth,
modcall_stack_entry_t entry,
bool  do_next_sibling 
)
static

Definition at line 456 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool pass2_callback ( void *  ctx,
fr_cond_t c 
)
static

Definition at line 3425 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool pass2_fixup_undefined ( CONF_ITEM const *  ci,
vp_tmpl_t vpt 
)
static

Definition at line 3408 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool pass2_map_compile ( modgroup g)
static

Definition at line 3779 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool pass2_update_compile ( modgroup g)
static

Definition at line 3742 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool pass2_xlat_compile ( CONF_ITEM const *  ci,
vp_tmpl_t **  pvpt,
bool  convert,
fr_dict_attr_t const *  da 
)
static

Definition at line 3275 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static CONF_SECTION* virtual_module_find_cs ( rlm_components_t pcomponent,
char const *  real_name,
char const *  virtual_name,
char const *  method_name 
)
static

Load a named module from "instantiate" or "policy".

If it's "foo.method", look for "foo", and return "method" as the method we wish to use, instead of the input component.

Parameters
[out]pcomponentWhere to write the method we found, if any. If no method is specified will be set to MOD_COUNT.
[in]real_nameComplete name string e.g. foo.authorize.
[in]virtual_nameVirtual module name e.g. foo.
[in]method_nameMethod override (may be NULL) or the method name e.g. authorize.
Returns
the CONF_SECTION specifying the virtual module.

Definition at line 2407 of file modcall.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const int authtype_actions[GROUPTYPE_COUNT][RLM_MODULE_NUMCODES]
static
char const* const comp2str[]
static
Initial value:
= {
"authenticate",
"authorize",
"preacct",
"accounting",
"session",
"pre-proxy",
"post-proxy",
"post-auth"
,
"recv-coa",
"send-coa"
}

Definition at line 258 of file modcall.c.

int default_component_results[MOD_COUNT]
static
Initial value:
= {
,
RLM_MODULE_NOOP
}
Immediately reject the request.
Definition: radiusd.h:89
Module succeeded without doing anything.
Definition: radiusd.h:96
Module failed, don't reply.
Definition: radiusd.h:90
User not found.
Definition: radiusd.h:95

Definition at line 349 of file modcall.c.

const int defaultactions[MOD_COUNT][GROUPTYPE_COUNT][RLM_MODULE_NUMCODES]
static

Definition at line 1244 of file modcall.c.

const FR_NAME_NUMBER mod_rcode_table[]
Initial value:
= {
{ "reject", RLM_MODULE_REJECT },
{ "fail", RLM_MODULE_FAIL },
{ "ok", RLM_MODULE_OK },
{ "handled", RLM_MODULE_HANDLED },
{ "invalid", RLM_MODULE_INVALID },
{ "userlock", RLM_MODULE_USERLOCK },
{ "notfound", RLM_MODULE_NOTFOUND },
{ "noop", RLM_MODULE_NOOP },
{ "updated", RLM_MODULE_UPDATED },
{ NULL, 0 }
}
The module is OK, continue.
Definition: radiusd.h:91
The module considers the request invalid.
Definition: radiusd.h:93
Reject the request (user is locked out).
Definition: radiusd.h:94
Immediately reject the request.
Definition: radiusd.h:89
Module succeeded without doing anything.
Definition: radiusd.h:96
Module failed, don't reply.
Definition: radiusd.h:90
User not found.
Definition: radiusd.h:95
OK (pairs modified).
Definition: radiusd.h:97
The module handled the request, so stop.
Definition: radiusd.h:92

Definition at line 186 of file modcall.c.

char const modcall_spaces[] = " "
static

Definition at line 392 of file modcall.c.

char const * unlang_keyword
Initial value:
= {
"",
"single",
"group",
"load-balance group",
"redundant-load-balance group",
"if",
"else",
"elsif",
"update",
"switch",
"case",
"foreach",
"break",
"return",
"map",
"policy",
"reference",
"xlat",
NULL
}

Definition at line 368 of file modcall.c.