The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Functions
call_env.c File Reference

Call environment parsing functions. More...

#include <freeradius-devel/server/log.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/unlang/tmpl.h>
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/interpret.h>
#include <freeradius-devel/unlang/call_env.h>
#include <freeradius-devel/util/token.h>
#include <talloc.h>
#include "call_env.h"
+ Include dependency graph for call_env.c:

Go to the source code of this file.

Data Structures

struct  call_env_parsed_s
 
union  call_env_parsed_s.data
 
struct  call_env_rctx_t
 Context to keep track of expansion of call environments. More...
 

Functions

call_env_tcall_env_alloc (TALLOC_CTX *ctx, char const *name, call_env_method_t const *call_env_method, tmpl_rules_t const *t_rules, CONF_SECTION *cs, char const *section_name1, char const *section_name2, void const *data)
 Given a call_env_method, parse all call_env_pair_t in the context of a specific call to an xlat or module method. More...
 
static size_t call_env_count (size_t *names_len, CONF_SECTION const *cs, call_env_parser_t const *call_env)
 Perform a quick assessment of how many parsed call env will be produced. More...
 
unlang_action_t call_env_expand (TALLOC_CTX *ctx, request_t *request, call_env_result_t *env_result, void **env_data, call_env_t const *call_env)
 Initialise the expansion of a call environment. More...
 
static unlang_action_t call_env_expand_repeat (rlm_rcode_t *p_result, int *priority, request_t *request, void *uctx)
 
static unlang_action_t call_env_expand_repeat (UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
 Extract expanded call environment tmpl and store in env_data. More...
 
static unlang_action_t call_env_expand_start (UNUSED rlm_rcode_t *p_result, UNUSED int *priority, request_t *request, void *uctx)
 Start the expansion of a call environment tmpl. More...
 
static int call_env_parse (TALLOC_CTX *ctx, call_env_parsed_head_t *parsed, char const *name, tmpl_rules_t const *t_rules, CONF_SECTION const *cs, char const *section_name1, char const *section_name2, void const *data, call_env_parser_t const *rule)
 Parse per call env. More...
 
int call_env_parse_pair (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED char const *section_name1, UNUSED char const *section_name2, UNUSED void const *data, UNUSED call_env_parser_t const *rule)
 Standard function we use for parsing call env pairs. More...
 
call_env_parsed_tcall_env_parsed_add (TALLOC_CTX *ctx, call_env_parsed_head_t *head, call_env_parser_t const *rule)
 Allocate a new call_env_parsed_t structure and add it to the list of parsed call envs. More...
 
static call_env_parsed_tcall_env_parsed_alloc (TALLOC_CTX *ctx, call_env_parser_t const *rule)
 Allocates a new call env parsed struct. More...
 
void call_env_parsed_free (call_env_parsed_head_t *parsed, call_env_parsed_t *ptr)
 Remove a call_env_parsed_t from the list of parsed call envs. More...
 
void call_env_parsed_set_data (call_env_parsed_t *parsed, void const *data)
 Assign data to a call_env_parsed_t. More...
 
void call_env_parsed_set_multi_index (call_env_parsed_t *parsed, size_t count, size_t index)
 Assign a count and index to a call_env_parsed_t. More...
 
void call_env_parsed_set_tmpl (call_env_parsed_t *parsed, tmpl_t const *tmpl)
 Assign a tmpl to a call_env_parsed_t. More...
 
void call_env_parsed_set_value (call_env_parsed_t *parsed, fr_value_box_t const *vb)
 Assign a value box to a call_env_parsed_t. More...
 
static int call_env_parsed_valid (call_env_parsed_t const *parsed, CONF_ITEM const *ci, call_env_parser_t const *rule)
 
static call_env_result_t call_env_result (TALLOC_CTX *ctx, request_t *request, void *out, void **tmpl_out, call_env_parsed_t const *env, fr_value_box_list_t *tmpl_expanded)
 Parse the result of call_env tmpl expansion. More...
 

Detailed Description

Call environment parsing functions.

Id
dd133e4e4fc0ee397918678950e22a89519121d6

Definition in file call_env.c.


Data Structure Documentation

◆ call_env_parsed_s

struct call_env_parsed_s

Definition at line 41 of file call_env.c.

+ Collaboration diagram for call_env_parsed_s:
Data Fields
size_t count Number of CONF_PAIRs found, matching the call_env_parser_t.
union call_env_parsed_s data
call_env_parsed_entry_t entry Entry in list of parsed call_env_parsers.
size_t multi_index Array index for this instance.
call_env_parser_t const * rule Used to produce this.

◆ call_env_parsed_s.data

union call_env_parsed_s.data

Definition at line 44 of file call_env.c.

Data Fields
void const * ptr Data produced from parsing conf pair.
tmpl_t const * tmpl Tmpl produced from parsing conf pair.
fr_value_box_t const * vb Value box produced from parsing conf pair.

◆ call_env_rctx_t

struct call_env_rctx_t

Context to keep track of expansion of call environments.

Definition at line 116 of file call_env.c.

+ Collaboration diagram for call_env_rctx_t:
Data Fields
call_env_t const * call_env Call env being expanded.
void ** data Final destination structure for value boxes.
call_env_parsed_t const * last_expanded The last expanded tmpl.
call_env_result_t * result Where to write the return code of callenv expansion.
fr_value_box_list_t tmpl_expanded List to write value boxes to as tmpls are expanded.

Function Documentation

◆ call_env_alloc()

call_env_t* call_env_alloc ( TALLOC_CTX *  ctx,
char const *  name,
call_env_method_t const *  call_env_method,
tmpl_rules_t const *  t_rules,
CONF_SECTION cs,
char const *  section_name1,
char const *  section_name2,
void const *  data 
)

Given a call_env_method, parse all call_env_pair_t in the context of a specific call to an xlat or module method.

Parameters
[in]ctxto allocate the call_env_t in.
[in]nameModule name for error messages.
[in]call_env_methodcontaining the call_env_pair_t to evaluate against the specified CONF_SECTION.
[in]t_rulesthat control how call_env_pair_t are parsed.
[in]csto parse in the context of the call.
[in]datamodule / xlat instance data of the module / xlat allocating this call_env
Returns
  • A new call_env_t on success.
    • NULL on failure.

Definition at line 718 of file call_env.c.

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

◆ call_env_count()

static size_t call_env_count ( size_t names_len,
CONF_SECTION const *  cs,
call_env_parser_t const *  call_env 
)
static

Perform a quick assessment of how many parsed call env will be produced.

Parameters
[in,out]names_lenWhere to write the sum of bytes required to represent the strings which will be parsed as tmpls. This is required to pre-allocate space for the tmpl name buffers.
[in]csConf section to search for pairs.
[in]call_envto parse.
Returns
Number of parsed_call_env expected to be required.

Definition at line 565 of file call_env.c.

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

◆ call_env_expand()

unlang_action_t call_env_expand ( TALLOC_CTX *  ctx,
request_t request,
call_env_result_t env_result,
void **  env_data,
call_env_t const *  call_env 
)

Initialise the expansion of a call environment.

Parameters
[in]ctxin which to allocate destination structure for resulting value boxes.
[in]requestCurrent request.
[out]env_resultWhere to write the result of the callenv expansion. May be NULL
[in,out]env_dataWhere the destination structure should be created.
[in]call_envCall environment being expanded.

Definition at line 287 of file call_env.c.

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

◆ call_env_expand_repeat() [1/2]

static unlang_action_t call_env_expand_repeat ( rlm_rcode_t p_result,
int *  priority,
request_t request,
void *  uctx 
)
static
+ Here is the caller graph for this function:

◆ call_env_expand_repeat() [2/2]

static unlang_action_t call_env_expand_repeat ( UNUSED rlm_rcode_t p_result,
UNUSED int *  priority,
request_t request,
void *  uctx 
)
static

Extract expanded call environment tmpl and store in env_data.

If there are more tmpls to expand, push the next expansion.

Definition at line 235 of file call_env.c.

+ Here is the call graph for this function:

◆ call_env_expand_start()

static unlang_action_t call_env_expand_start ( UNUSED rlm_rcode_t p_result,
UNUSED int *  priority,
request_t request,
void *  uctx 
)
static

Start the expansion of a call environment tmpl.

Definition at line 129 of file call_env.c.

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

◆ call_env_parse()

static int call_env_parse ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  parsed,
char const *  name,
tmpl_rules_t const *  t_rules,
CONF_SECTION const *  cs,
char const *  section_name1,
char const *  section_name2,
void const *  data,
call_env_parser_t const *  rule 
)
static

Parse per call env.

Used for config options which must be parsed in the context in which the module is being called.

Parameters
[in]ctxTo allocate parsed environment in.
[out]parsedWhere to write parsed environment.
[in]nameModule name for error messages.
[in]t_rulescontrolling how the call env is parsed.
[in]csModule config.
[in]section_name1Name 1 from calling section for module calls
[in]section_name2Name 2 from calling section for module calls
[in]datamodule / xlat instance data of the module / xlat allocating this call_env
[in]ruleto parse.
Returns
  • 0 on success;
  • <0 on failure;

Definition at line 405 of file call_env.c.

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

◆ call_env_parse_pair()

int call_env_parse_pair ( TALLOC_CTX *  ctx,
void *  out,
tmpl_rules_t const *  t_rules,
CONF_ITEM ci,
UNUSED char const *  section_name1,
UNUSED char const *  section_name2,
UNUSED void const *  data,
UNUSED call_env_parser_t const *  rule 
)

Standard function we use for parsing call env pairs.

Note
This is called where no custom pair parsing function is provided, but may be called by custom functions to avoid duplicating the standard parsing code.
Parameters
[in]ctxto allocate any data in.
[out]outWhere to write the result of parsing.
[in]t_ruleswe're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t.
[in]ciThe CONF_SECTION or CONF_PAIR to parse.
[in]datamodule / xlat instance data of the module / xlat allocating this call_env
[in]ruleParse rules - How the CONF_PAIR or CONF_SECTION should be converted.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 367 of file call_env.c.

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

◆ call_env_parsed_add()

call_env_parsed_t* call_env_parsed_add ( TALLOC_CTX *  ctx,
call_env_parsed_head_t *  head,
call_env_parser_t const *  rule 
)

Allocate a new call_env_parsed_t structure and add it to the list of parsed call envs.

Note
tmpl_t and void * should be allocated in the context of the call_env_parsed_t
Parameters
[in]ctxto allocate the new call_env_parsed_t in.
[out]headto add the new call_env_parsed_t to.
[in]ruleto base call_env_parsed_t around. MUST NOT BE THE RULE PASSED TO THE CALLBACK. The rule passed to the callback describes how to parse a subsection, but the subsection callback is adding rules describing how to parse its children.
Returns
The new call_env_parsed_t.

Definition at line 613 of file call_env.c.

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

◆ call_env_parsed_alloc()

static call_env_parsed_t* call_env_parsed_alloc ( TALLOC_CTX *  ctx,
call_env_parser_t const *  rule 
)
inlinestatic

Allocates a new call env parsed struct.

Definition at line 309 of file call_env.c.

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

◆ call_env_parsed_free()

void call_env_parsed_free ( call_env_parsed_head_t *  parsed,
call_env_parsed_t ptr 
)

Remove a call_env_parsed_t from the list of parsed call envs.

Note
Intended to be used by subsection callbacks to remove a call_env_parsed_t from the list of parsed call envs (typically on error).
Parameters
[in]parsedto remove parsed data from.
[in]ptrto remove.

Definition at line 700 of file call_env.c.

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

◆ call_env_parsed_set_data()

void call_env_parsed_set_data ( call_env_parsed_t parsed,
void const *  data 
)

Assign data to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to set arbitrary data to be written out to the result structure.
Parameters
[in]parsedto assign the tmpl to.
[in]datato assign.

Definition at line 670 of file call_env.c.

+ Here is the caller graph for this function:

◆ call_env_parsed_set_multi_index()

void call_env_parsed_set_multi_index ( call_env_parsed_t parsed,
size_t  count,
size_t  index 
)

Assign a count and index to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to indicate related call_env_parsed_t.
Parameters
[in]parsedto modify metadata of.
[in]countto assign.
[in]indexto assign.

Definition at line 685 of file call_env.c.

+ Here is the caller graph for this function:

◆ call_env_parsed_set_tmpl()

void call_env_parsed_set_tmpl ( call_env_parsed_t parsed,
tmpl_t const *  tmpl 
)

Assign a tmpl to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to add a tmpl to be evaluated during the call.
Parameters
[in]parsedto assign the tmpl to.
[in]tmplto assign.

Definition at line 642 of file call_env.c.

+ Here is the caller graph for this function:

◆ call_env_parsed_set_value()

void call_env_parsed_set_value ( call_env_parsed_t parsed,
fr_value_box_t const *  vb 
)

Assign a value box to a call_env_parsed_t.

Note
Intended to be used by subsection callbacks to set a static boxed value to be written out to the result structure.
Parameters
[in]parsedto assign the tmpl to.
[in]vbto assign.

Definition at line 656 of file call_env.c.

+ Here is the caller graph for this function:

◆ call_env_parsed_valid()

static int call_env_parsed_valid ( call_env_parsed_t const *  parsed,
CONF_ITEM const *  ci,
call_env_parser_t const *  rule 
)
inlinestatic

Definition at line 322 of file call_env.c.

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

◆ call_env_result()

static call_env_result_t call_env_result ( TALLOC_CTX *  ctx,
request_t request,
void *  out,
void **  tmpl_out,
call_env_parsed_t const *  env,
fr_value_box_list_t *  tmpl_expanded 
)
inlinestatic

Parse the result of call_env tmpl expansion.

Definition at line 59 of file call_env.c.

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