The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions
edit.c File Reference
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/tmpl_dcursor.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/edit.h>
#include <freeradius-devel/util/calc.h>
#include <freeradius-devel/unlang/tmpl.h>
#include <freeradius-devel/unlang/edit.h>
#include <freeradius-devel/unlang/transaction.h>
#include <freeradius-devel/unlang/unlang_priv.h>
#include "edit_priv.h"
+ Include dependency graph for edit.c:

Go to the source code of this file.

Data Structures

struct  edit_map_s
 
struct  edit_result_t
 
struct  unlang_frame_state_edit_s
 State of an edit block. More...
 

Macros

#define DECLARE(_x)   static int _x(request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
#define MAP_INFO   cf_filename(map->ci), cf_lineno(map->ci)
 
#define XDEBUG(...)
 fr_pair_t editing More...
 

Typedefs

typedef struct edit_map_s edit_map_t
 
typedef int(* unlang_edit_expand_t) (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
typedef struct unlang_frame_state_edit_s unlang_frame_state_edit_t
 

Functions

static int apply_edits_to_leaf (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int apply_edits_to_list (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int check_lhs (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int check_lhs_nested (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int check_lhs_value (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int check_rhs (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
 DECLARE (check_lhs)
 
 DECLARE (check_lhs_nested)
 
 DECLARE (check_lhs_value)
 
 DECLARE (expand_lhs)
 
 DECLARE (expanded_lhs_attribute)
 
 DECLARE (expanded_lhs_value)
 
static int edit_create_lhs_vp (request_t *request, TALLOC_CTX *ctx, edit_map_t *current)
 
static void edit_debug_attr_list (request_t *request, fr_pair_list_t const *list, map_t const *map)
 
static void edit_debug_attr_vp (request_t *request, fr_pair_t *vp, map_t const *map)
 
static int edit_delete_lhs (request_t *request, edit_map_t *current, bool delete)
 
static fr_pair_tedit_list_pair_build (fr_pair_t *parent, fr_dcursor_t *cursor, fr_dict_attr_t const *da, void *uctx)
 Simple pair building callback for use with tmpl_dcursors. More...
 
static void edit_state_init_internal (request_t *request, unlang_frame_state_edit_t *state, fr_edit_list_t *el, map_list_t const *map_list)
 
static int expand_lhs (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int expand_rhs (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int expand_rhs_list (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int expanded_lhs_attribute (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int expanded_lhs_value (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)
 
static int next_map (UNUSED request_t *request, UNUSED unlang_frame_state_edit_t *state, edit_map_t *current)
 
static unlang_action_t process_edit (rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 Apply a map (recursively) to a request. More...
 
static int tmpl_attr_from_result (TALLOC_CTX *ctx, map_t const *map, edit_result_t *out, request_t *request)
 
static int tmpl_to_values (TALLOC_CTX *ctx, edit_result_t *out, request_t *request, tmpl_t const *vpt)
 
void unlang_edit_init (void)
 
int unlang_edit_push (request_t *request, bool *success, fr_edit_list_t *el, map_list_t const *map_list)
 Push a map onto the stack for edit evaluation. More...
 
static unlang_action_t unlang_edit_state_init (rlm_rcode_t *p_result, request_t *request, unlang_stack_frame_t *frame)
 Execute an update block. More...
 

Data Structure Documentation

◆ edit_map_s

struct edit_map_s

Definition at line 62 of file edit.c.

+ Collaboration diagram for edit_map_s:
Data Fields
unlang_edit_expand_t check_lhs for special cases
edit_map_t * child
TALLOC_CTX * ctx
fr_edit_list_t * el edit list
unlang_edit_expand_t expanded_lhs for special cases
unlang_edit_expand_t func for process state
edit_result_t lhs LHS child entries.
map_t const * map the map to evaluate
map_list_t const * map_list
edit_map_t * parent
edit_result_t rhs RHS child entries.
bool temporary_pair_list

◆ edit_result_t

struct edit_result_t

Definition at line 46 of file edit.c.

+ Collaboration diagram for edit_result_t:
Data Fields
bool create whether we need to create the VP
fr_pair_list_t pair_list for structural attributes
fr_value_box_list_t result result of expansion
tmpl_t * to_free tmpl to free.
fr_pair_t * vp VP referenced by tmpl.
fr_pair_t * vp_parent parent of the current VP
tmpl_t const * vpt expanded tmpl

◆ unlang_frame_state_edit_s

struct unlang_frame_state_edit_s

State of an edit block.

Definition at line 85 of file edit.c.

+ Collaboration diagram for unlang_frame_state_edit_s:
Data Fields
edit_map_t * current what we're currently doing.
fr_edit_list_t * el edit list
edit_map_t first
rindent_t indent
bool ours
bool * success whether or not the edit succeeded

Macro Definition Documentation

◆ DECLARE

#define DECLARE (   _x)    static int _x(request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)

Definition at line 899 of file edit.c.

◆ MAP_INFO

#define MAP_INFO   cf_filename(map->ci), cf_lineno(map->ci)

Definition at line 96 of file edit.c.

◆ XDEBUG

#define XDEBUG (   ...)

fr_pair_t editing

Id
d82ad41f0c69b280642e586db5436105185b427f

Definition at line 41 of file edit.c.

Typedef Documentation

◆ edit_map_t

typedef struct edit_map_s edit_map_t

Definition at line 1 of file edit.c.

◆ unlang_edit_expand_t

typedef int(* unlang_edit_expand_t) (request_t *request, unlang_frame_state_edit_t *state, edit_map_t *current)

Definition at line 60 of file edit.c.

◆ unlang_frame_state_edit_t

Definition at line 1 of file edit.c.

Function Documentation

◆ apply_edits_to_leaf()

static int apply_edits_to_leaf ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 590 of file edit.c.

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

◆ apply_edits_to_list()

static int apply_edits_to_list ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 264 of file edit.c.

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

◆ check_lhs()

static int check_lhs ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1301 of file edit.c.

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

◆ check_lhs_nested()

static int check_lhs_nested ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1261 of file edit.c.

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

◆ check_lhs_value()

static int check_lhs_value ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1115 of file edit.c.

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

◆ check_rhs()

static int check_rhs ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 934 of file edit.c.

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

◆ DECLARE() [1/6]

DECLARE ( check_lhs  )

◆ DECLARE() [2/6]

DECLARE ( check_lhs_nested  )

◆ DECLARE() [3/6]

DECLARE ( check_lhs_value  )

◆ DECLARE() [4/6]

DECLARE ( expand_lhs  )

◆ DECLARE() [5/6]

DECLARE ( expanded_lhs_attribute  )

◆ DECLARE() [6/6]

DECLARE ( expanded_lhs_value  )

◆ edit_create_lhs_vp()

static int edit_create_lhs_vp ( request_t request,
TALLOC_CTX *  ctx,
edit_map_t current 
)
static

Definition at line 233 of file edit.c.

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

◆ edit_debug_attr_list()

static void edit_debug_attr_list ( request_t request,
fr_pair_list_t const *  list,
map_t const *  map 
)
static

Definition at line 218 of file edit.c.

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

◆ edit_debug_attr_vp()

static void edit_debug_attr_vp ( request_t request,
fr_pair_t vp,
map_t const *  map 
)
static

Definition at line 183 of file edit.c.

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

◆ edit_delete_lhs()

static int edit_delete_lhs ( request_t request,
edit_map_t current,
bool  delete 
)
static

Definition at line 510 of file edit.c.

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

◆ edit_list_pair_build()

static fr_pair_t * edit_list_pair_build ( fr_pair_t parent,
fr_dcursor_t cursor,
fr_dict_attr_t const *  da,
void *  uctx 
)
static

Simple pair building callback for use with tmpl_dcursors.

Which always appends the new pair to the tail of the list since it is only called when no matching pairs were found when walking the list.

Note that this function is called for all intermediate nodes which are built!

Parameters
[in]parentto allocate new pair within.
[in,out]cursorto append new pair to.
[in]daof new pair.
[in]uctxunused.
Returns

Definition at line 866 of file edit.c.

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

◆ edit_state_init_internal()

static void edit_state_init_internal ( request_t request,
unlang_frame_state_edit_t state,
fr_edit_list_t el,
map_list_t const *  map_list 
)
static

Definition at line 1576 of file edit.c.

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

◆ expand_lhs()

static int expand_lhs ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1483 of file edit.c.

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

◆ expand_rhs()

static int expand_rhs ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1086 of file edit.c.

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

◆ expand_rhs_list()

static int expand_rhs_list ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1007 of file edit.c.

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

◆ expanded_lhs_attribute()

static int expanded_lhs_attribute ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1463 of file edit.c.

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

◆ expanded_lhs_value()

static int expanded_lhs_value ( request_t request,
unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 1181 of file edit.c.

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

◆ next_map()

static int next_map ( UNUSED request_t request,
UNUSED unlang_frame_state_edit_t state,
edit_map_t current 
)
static

Definition at line 911 of file edit.c.

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

◆ process_edit()

static unlang_action_t process_edit ( rlm_rcode_t p_result,
request_t request,
unlang_stack_frame_t frame 
)
static

Apply a map (recursively) to a request.

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 1514 of file edit.c.

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

◆ tmpl_attr_from_result()

static int tmpl_attr_from_result ( TALLOC_CTX *  ctx,
map_t const *  map,
edit_result_t out,
request_t request 
)
static

Definition at line 103 of file edit.c.

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

◆ tmpl_to_values()

static int tmpl_to_values ( TALLOC_CTX *  ctx,
edit_result_t out,
request_t request,
tmpl_t const *  vpt 
)
static

Definition at line 148 of file edit.c.

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

◆ unlang_edit_init()

void unlang_edit_init ( void  )

Definition at line 1700 of file edit.c.

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

◆ unlang_edit_push()

int unlang_edit_push ( request_t request,
bool success,
fr_edit_list_t el,
map_list_t const *  map_list 
)

Push a map onto the stack for edit evaluation.

If the "success" variable returns "false", the caller should call fr_edit_list_abort().

If the "success" variable returns "true", the caller can free the edit list (or rely on talloc to do that) and the transaction will be finalized.

Parameters
[in]requestThe current request.
[out]successWhether or not the edit succeeded
[in]elEdit list which can be used to apply multiple edits
[in]map_listThe map list to process

Definition at line 1651 of file edit.c.

+ Here is the call graph for this function:

◆ unlang_edit_state_init()

static unlang_action_t unlang_edit_state_init ( rlm_rcode_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 1623 of file edit.c.

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