The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
map.c File Reference
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/map.h>
#include <freeradius-devel/unlang/tmpl.h>
#include <freeradius-devel/unlang/map.h>
#include "map_priv.h"
+ Include dependency graph for map.c:

Go to the source code of this file.

Data Structures

struct  unlang_frame_state_map_proc_t
 State of a map block. More...
 
struct  unlang_frame_state_update_t
 State of an update block. More...
 

Macros

#define MAP_CTX(_mod_inst, _map_inst, _rctx)   &(map_ctx_t){ .moi = _mod_inst, .mpi = _map_inst, .rctx = _rctx }
 Wrapper to create a map_ctx_t as a compound literal.
 

Enumerations

enum  unlang_update_state_t {
  UNLANG_UPDATE_MAP_INIT = 0 ,
  UNLANG_UPDATE_MAP_EXPANDED_LHS ,
  UNLANG_UPDATE_MAP_EXPANDED_RHS
}
 map and unlang integration. More...
 

Functions

static unlang_action_t list_mod_apply (unlang_result_t *p_result, request_t *request)
 Apply a list of modifications on one or more fr_pair_t lists.
 
static unlang_action_t list_mod_create (unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 Create a list of modifications to apply to one or more fr_pair_t lists.
 
static unlang_action_t map_proc_apply (unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 
static unlang_action_t map_proc_resume (unlang_result_t *p_result, request_t *request, UNUSED unlang_stack_frame_t *frame)
 
void unlang_map_init (void)
 
static unlang_action_t unlang_map_state_init (unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 
unlang_action_t unlang_map_yield (request_t *request, map_proc_func_t resume, unlang_map_signal_t signal, fr_signal_t sigmask, void *rctx)
 Yield a request back to the interpreter from within a module.
 
static unlang_action_t unlang_update_state_init (unlang_result_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 Execute an update block.
 

Data Structure Documentation

◆ unlang_frame_state_map_proc_t

struct unlang_frame_state_map_proc_t

State of a map block.

Definition at line 60 of file map.c.

+ Collaboration diagram for unlang_frame_state_map_proc_t:
Data Fields
void * rctx for resume / signal
map_proc_func_t resume resumption handler
fr_signal_t sigmask Signals to block.
unlang_map_signal_t signal for signal handlers
fr_value_box_list_t src_result Result of expanding the map source.

◆ unlang_frame_state_update_t

struct unlang_frame_state_update_t

State of an update block.

Definition at line 46 of file map.c.

+ Collaboration diagram for unlang_frame_state_update_t:
Data Fields
fr_value_box_list_t lhs_result Result of expanding the LHS.
fr_dcursor_t maps Cursor of maps to evaluate.
fr_value_box_list_t rhs_result Result of expanding the RHS.
unlang_update_state_t state What we're currently doing.
fr_dlist_head_t vlm_head Head of list of VP List Mod.

Macro Definition Documentation

◆ MAP_CTX

#define MAP_CTX (   _mod_inst,
  _map_inst,
  _rctx 
)    &(map_ctx_t){ .moi = _mod_inst, .mpi = _map_inst, .rctx = _rctx }

Wrapper to create a map_ctx_t as a compound literal.

Parameters
[in]_mod_instof the module being called.
[in]_map_instof the map being called.
[in]_rctxResume ctx (if any).

Definition at line 80 of file map.c.

Enumeration Type Documentation

◆ unlang_update_state_t

map and unlang integration.

Id
8ccab42c2be9ec5be9bfba24747f1d43c27881e8

Unlang "map" keyword evaluation.

Enumerator
UNLANG_UPDATE_MAP_INIT 

Start processing a map.

UNLANG_UPDATE_MAP_EXPANDED_LHS 

Expand the LHS xlat or exec (if needed).

UNLANG_UPDATE_MAP_EXPANDED_RHS 

Expand the RHS xlat or exec (if needed).

Definition at line 37 of file map.c.

Function Documentation

◆ list_mod_apply()

static unlang_action_t list_mod_apply ( unlang_result_t p_result,
request_t request 
)
static

Apply a list of modifications on one or more fr_pair_t lists.

Parameters
[in]requestThe current request.
[out]p_resultThe rcode indicating what the result of the operation was.
Returns
  • UNLANG_ACTION_CALCULATE_RESULT changes were applied.
  • UNLANG_ACTION_PUSHED_CHILD async execution of an expansion is required.

Definition at line 91 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ list_mod_create()

static unlang_action_t list_mod_create ( unlang_result_t p_result,
request_t request,
unlang_stack_frame_t frame 
)
static

Create a list of modifications to apply to one or more fr_pair_t lists.

Parameters
[out]p_resultThe rcode indicating what the result of the operation was.
[in]requestThe current request.
[in]frameCurrent stack frame.
Returns
  • UNLANG_ACTION_CALCULATE_RESULT changes were applied.
  • UNLANG_ACTION_PUSHED_CHILD async execution of an expansion is required.

Definition at line 135 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ map_proc_apply()

static unlang_action_t map_proc_apply ( unlang_result_t p_result,
request_t request,
unlang_stack_frame_t frame 
)
static

Definition at line 368 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ map_proc_resume()

static unlang_action_t map_proc_resume ( unlang_result_t p_result,
request_t request,
UNUSED unlang_stack_frame_t frame 
)
static

Definition at line 296 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_map_init()

void unlang_map_init ( void  )

Definition at line 447 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_map_state_init()

static unlang_action_t unlang_map_state_init ( unlang_result_t p_result,
request_t request,
unlang_stack_frame_t frame 
)
static

Definition at line 385 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_map_yield()

unlang_action_t unlang_map_yield ( request_t request,
map_proc_func_t  resume,
unlang_map_signal_t  signal,
fr_signal_t  sigmask,
void *  rctx 
)

Yield a request back to the interpreter from within a module.

This passes control of the request back to the unlang interpreter, setting callbacks to execute when the request is 'signalled' asynchronously, or whatever timer or I/O event the module was waiting for occurs.

Note
The module function which calls unlang_module_yield should return control of the C stack to the unlang interpreter immediately after calling unlang_module_yield. A common pattern is to use return unlang_module_yield(...).
Parameters
[in]requestThe current request.
[in]resumeCalled on unlang_interpret_mark_runnable().
[in]signalCalled on unlang_action().
[in]sigmaskSet of signals to block.
[in]rctxto pass to the callbacks.
Returns
  • UNLANG_ACTION_YIELD.

Definition at line 344 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unlang_update_state_init()

static unlang_action_t unlang_update_state_init ( unlang_result_t p_result,
request_t request,
unlang_stack_frame_t frame 
)
static

Execute an update block.

Update blocks execute in two phases, first there's an evaluation phase where each input map is evaluated, outputting one or more modification maps. The modification maps detail a change that should be made to a list in the current request. The request is not modified during this phase.

The second phase applies those modification maps to the current request. This re-enables the atomic functionality of update blocks provided in v2.x.x. If one map fails in the evaluation phase, no more maps are processed, and the current result is discarded.

Definition at line 270 of file map.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: