The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
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/server/section.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"
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... | |
Macros | |
#define | CALL_ENV_DEBUG(_ci, ...) |
Functions | |
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, call_env_ctx_t const *cec) |
Given a call_env_method, parse all call_env_pair_t in the context of a specific call to an xlat or module method. | |
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. | |
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. | |
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. | |
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. | |
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, call_env_ctx_t const *cec, call_env_parser_t const *rule) |
Parse per call env. | |
int | call_env_parse_pair (TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules, CONF_ITEM *ci, UNUSED call_env_ctx_t const *cec, UNUSED call_env_parser_t const *rule) |
Standard function we use for parsing call env pairs. | |
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. | |
static call_env_parsed_t * | call_env_parsed_alloc (TALLOC_CTX *ctx, call_env_parser_t const *rule) |
Allocates a new call env parsed struct. | |
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. | |
void | call_env_parsed_set_data (call_env_parsed_t *parsed, void const *data) |
Assign data to a call_env_parsed_t. | |
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. | |
void | call_env_parsed_set_tmpl (call_env_parsed_t *parsed, tmpl_t const *tmpl) |
Assign a tmpl to a call_env_parsed_t. | |
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. | |
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. | |
Call environment parsing functions.
Definition in file call_env.c.
struct call_env_parsed_s |
Definition at line 42 of file call_env.c.
Data Fields | ||
---|---|---|
size_t | count | Number of CONF_PAIRs found, matching the call_env_parser_t. |
union call_env_parsed_s.data | 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. |
union call_env_parsed_s.data |
Definition at line 45 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. |
struct call_env_rctx_t |
Context to keep track of expansion of call environments.
Definition at line 123 of file call_env.c.
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. |
#define CALL_ENV_DEBUG | ( | _ci, | |
... | |||
) |
Definition at line 60 of file call_env.c.
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, | ||
call_env_ctx_t const * | cec | ||
) |
Given a call_env_method, parse all call_env_pair_t in the context of a specific call to an xlat or module method.
[in] | ctx | to allocate the call_env_t in. |
[in] | name | Module name for error messages. |
[in] | call_env_method | containing the call_env_pair_t to evaluate against the specified CONF_SECTION. |
[in] | t_rules | that control how call_env_pair_t are parsed. |
[in] | cs | to parse in the context of the call. |
[in] | cec | information about how the call is being made. |
Definition at line 736 of file call_env.c.
|
static |
Perform a quick assessment of how many parsed call env will be produced.
[in,out] | names_len | Where 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] | cs | Conf section to search for pairs. |
[in] | call_env | to parse. |
Definition at line 583 of file call_env.c.
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.
[in] | ctx | in which to allocate destination structure for resulting value boxes. |
[in] | request | Current request. |
[out] | env_result | Where to write the result of the callenv expansion. May be NULL |
[in,out] | env_data | Where the destination structure should be created. |
[in] | call_env | Call environment being expanded. |
Definition at line 295 of file call_env.c.
|
static |
|
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 242 of file call_env.c.
|
static |
Start the expansion of a call environment tmpl.
Definition at line 136 of file call_env.c.
|
static |
Parse per call env.
Used for config options which must be parsed in the context in which the module is being called.
[in] | ctx | To allocate parsed environment in. |
[out] | parsed | Where to write parsed environment. |
[in] | name | Module name for error messages. |
[in] | t_rules | controlling how the call env is parsed. |
[in] | cs | Module config. |
[in] | cec | information about the call. |
[in] | rule | to parse. |
Definition at line 411 of file call_env.c.
int call_env_parse_pair | ( | TALLOC_CTX * | ctx, |
void * | out, | ||
tmpl_rules_t const * | t_rules, | ||
CONF_ITEM * | ci, | ||
UNUSED call_env_ctx_t const * | cec, | ||
UNUSED call_env_parser_t const * | rule | ||
) |
Standard function we use for parsing call env pairs.
[in] | ctx | to allocate any data in. |
[out] | out | Where to write the result of parsing. |
[in] | t_rules | we're parsing attributes with. Contains the default dictionary and nested 'caller' tmpl_rules_t. |
[in] | ci | The CONF_SECTION or CONF_PAIR to parse. |
[in] | cec | information about the call. |
[in] | rule | Parse rules - How the CONF_PAIR or CONF_SECTION should be converted. |
Definition at line 375 of file call_env.c.
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.
[in] | ctx | to allocate the new call_env_parsed_t in. |
[out] | head | to add the new call_env_parsed_t to. |
[in] | rule | to 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. |
Definition at line 631 of file call_env.c.
|
inlinestatic |
Allocates a new call env parsed struct.
Definition at line 317 of file call_env.c.
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.
[in] | parsed | to remove parsed data from. |
[in] | ptr | to remove. |
Definition at line 718 of file call_env.c.
void call_env_parsed_set_data | ( | call_env_parsed_t * | parsed, |
void const * | data | ||
) |
Assign data to a call_env_parsed_t.
[in] | parsed | to assign the tmpl to. |
[in] | data | to assign. |
Definition at line 688 of file call_env.c.
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.
[in] | parsed | to modify metadata of. |
[in] | count | to assign. |
[in] | index | to assign. |
Definition at line 703 of file call_env.c.
void call_env_parsed_set_tmpl | ( | call_env_parsed_t * | parsed, |
tmpl_t const * | tmpl | ||
) |
Assign a tmpl to a call_env_parsed_t.
[in] | parsed | to assign the tmpl to. |
[in] | tmpl | to assign. |
Definition at line 660 of file call_env.c.
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.
[in] | parsed | to assign the tmpl to. |
[in] | vb | to assign. |
Definition at line 674 of file call_env.c.
|
inlinestatic |
Definition at line 330 of file call_env.c.
|
inlinestatic |
Parse the result of call_env tmpl expansion.
Definition at line 66 of file call_env.c.