![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Tokenizers and support functions for xlat expressions. More...
#include <freeradius-devel/server/base.h>#include <freeradius-devel/unlang/xlat_priv.h>#include <freeradius-devel/util/calc.h>#include <freeradius-devel/util/debug.h>#include <freeradius-devel/server/tmpl_dcursor.h>
Include dependency graph for xlat_expr.c:Go to the source code of this file.
Data Structures | |
| struct | xlat_exists_inst_t |
| struct | xlat_logical_inst_t |
| struct | xlat_logical_rctx_t |
| struct | xlat_rcode_inst_t |
| Holds the result of pre-parsing the rcode on startup. More... | |
| struct | xlat_regex_inst_t |
| struct | xlat_regex_rctx_t |
Macros | |
| #define | fr_sbuff_skip_whitespace(_x) |
| #define | P(_x, _y) (((_x) << 4) | (_y)) |
| #define | XLAT_BINARY_FUNC(_name, _op) |
| #define | XLAT_CMP_FUNC(_name, _op) |
| #define | XLAT_DEBUG(...) |
| #define | XLAT_REGEX_FUNC(_name, _op) |
| #define | XLAT_REGISTER_BINARY_CMP(_op, _name) |
| #define | XLAT_REGISTER_BINARY_OP(_op, _name) |
| #define | XLAT_REGISTER_BOOL(_xlat, _func, _arg, _ret_type) |
| #define | XLAT_REGISTER_NARY_OP(_op, _name, _func_name) |
| #define | XLAT_REGISTER_REGEX_OP(_op, _name) |
| #define | XLAT_REGISTER_UNARY(_op, _xlat, _func) |
Functions | |
| static xlat_exp_t * | expr_cast_alloc (TALLOC_CTX *ctx, fr_type_t type, xlat_exp_t *child) |
| Allocate a specific cast node. | |
| static fr_slen_t | expr_cast_from_substr (fr_type_t *cast, fr_sbuff_t *in) |
| static void | fr_value_box_init_zero (fr_value_box_t *vb, fr_type_t type) |
| static ssize_t | tokenize_expression (xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, fr_token_t prev, fr_sbuff_parse_rules_t const *bracket_rules, fr_sbuff_parse_rules_t const *input_rules, bool cond) |
| Tokenize a mathematical operation. | |
| static ssize_t | tokenize_field (xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, fr_sbuff_parse_rules_t const *bracket_rules, char *out_c, bool cond)) |
| static ssize_t | tokenize_rcode (xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in, fr_sbuff_term_t const *terminals) |
| static fr_slen_t | tokenize_regex_rhs (xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in, tmpl_rules_t const *t_rules, fr_sbuff_parse_rules_t const *bracket_rules) |
| static fr_slen_t | tokenize_unary (xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, fr_sbuff_parse_rules_t const *bracket_rules, char *out_c, bool cond)) |
| static bool | valid_type (xlat_exp_t *node) |
| static xlat_action_t | xlat_attr_exists (TALLOC_CTX *ctx, fr_dcursor_t *out, request_t *request, tmpl_t const *vpt, bool do_free) |
| static xlat_action_t | xlat_binary_op (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in, fr_token_t op, fr_type_t default_type, fr_dict_attr_t const *enumv) |
| static xlat_action_t | xlat_cmp_op (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *in, fr_token_t op) |
| static xlat_exp_t * | xlat_exists_alloc (TALLOC_CTX *ctx, xlat_exp_t *child) |
| Allocate a specific cast node. | |
| static int | xlat_expr_logical_purify (xlat_exp_t *node, void *instance, request_t *request) |
| If any argument resolves to inst->stop_on_match, the entire thing is a bool of inst->stop_on_match. | |
| static fr_slen_t | xlat_expr_print_binary (fr_sbuff_t *out, xlat_exp_t const *node, UNUSED void *inst, fr_sbuff_escape_rules_t const *e_rules) |
| static fr_slen_t | xlat_expr_print_exists (fr_sbuff_t *out, xlat_exp_t const *node, void *instance, fr_sbuff_escape_rules_t const *e_rules) |
| static fr_slen_t | xlat_expr_print_nary (fr_sbuff_t *out, xlat_exp_t const *node, void *instance, fr_sbuff_escape_rules_t const *e_rules) |
| static fr_slen_t | xlat_expr_print_rcode (fr_sbuff_t *out, xlat_exp_t const *node, void *instance, UNUSED fr_sbuff_escape_rules_t const *e_rules) |
| static fr_slen_t | xlat_expr_print_regex (fr_sbuff_t *out, xlat_exp_t const *node, void *instance, fr_sbuff_escape_rules_t const *e_rules) |
| static fr_slen_t | xlat_expr_print_unary (fr_sbuff_t *out, xlat_exp_t const *node, UNUSED void *inst, fr_sbuff_escape_rules_t const *e_rules) |
| static int | xlat_expr_resolve_binary (xlat_exp_t *node, UNUSED void *inst, xlat_res_rules_t const *xr_rules) |
| static void | xlat_func_append_arg (xlat_exp_t *head, xlat_exp_t *node, bool exists) |
| static xlat_action_t | xlat_func_exists (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in) |
| See if a named attribute exists. | |
| static xlat_action_t | xlat_func_expr_rcode (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args) |
| Match the passed rcode against request->rcode. | |
| static xlat_action_t | xlat_func_logical (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| Process logical &&, ||. | |
| static xlat_action_t | xlat_func_rcode (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *args) |
| Return the current rcode as a string. | |
| static xlat_action_t | xlat_func_regex_search (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| static xlat_action_t | xlat_func_unary_complement (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| static xlat_action_t | xlat_func_unary_minus (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| static xlat_action_t | xlat_func_unary_not (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *in) |
| static xlat_action_t | xlat_func_unary_op (TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in, fr_token_t op) |
| static int | xlat_instantiate_exists (xlat_inst_ctx_t const *xctx) |
| static int | xlat_instantiate_expr_rcode (xlat_inst_ctx_t const *xctx) |
| Convert static expr_rcode arguments into rcodes. | |
| static int | xlat_instantiate_logical (xlat_inst_ctx_t const *xctx) |
| static int | xlat_instantiate_regex (xlat_inst_ctx_t const *xctx) |
| bool | xlat_is_truthy (xlat_exp_head_t const *head, bool *out) |
| Allow callers to see if an xlat is truthy. | |
| static bool | xlat_logical_and (xlat_logical_rctx_t *rctx, fr_value_box_list_t const *in) |
| See if the input is truthy or not. | |
| static xlat_action_t | xlat_logical_and_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| static bool | xlat_logical_or (xlat_logical_rctx_t *rctx, fr_value_box_list_t const *in) |
| See if the input is truthy or not. | |
| static xlat_action_t | xlat_logical_or_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| static xlat_action_t | xlat_logical_process_arg (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in) |
| Process one argument of a logical operation. | |
| static bool | xlat_node_matches_bool (bool *result, xlat_exp_t *parent, xlat_exp_head_t *head, bool sense) |
| static xlat_action_t | xlat_regex_do_op (TALLOC_CTX *ctx, request_t *request, fr_value_box_list_t *in, regex_t **preg, fr_dcursor_t *out, fr_token_t op) |
| Perform a regular expressions comparison between two operands. | |
| static xlat_action_t | xlat_regex_op (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in, fr_token_t op) |
| static xlat_action_t | xlat_regex_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| int | xlat_register_expressions (void) |
| fr_slen_t | xlat_tokenize_condition (TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules) |
| fr_slen_t | xlat_tokenize_expression (TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules) |
| static fr_slen_t | xlat_tokenize_expression_internal (TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, bool cond) |
| static void | xlat_ungroup (xlat_exp_head_t *head) |
| Undo work which shouldn't have been done. | |
Tokenizers and support functions for xlat expressions.
Definition in file xlat_expr.c.
| struct xlat_exists_inst_t |
Definition at line 1697 of file xlat_expr.c.
Collaboration diagram for xlat_exists_inst_t:| Data Fields | ||
|---|---|---|
| tmpl_t const * | vpt | the attribute reference |
| struct xlat_logical_inst_t |
Definition at line 865 of file xlat_expr.c.
Collaboration diagram for xlat_logical_inst_t:| Data Fields | ||
|---|---|---|
| int | argc | |
| xlat_exp_head_t ** | argv | |
| xlat_func_t | callback | |
| bool | stop_on_match | |
| struct xlat_logical_rctx_t |
Definition at line 872 of file xlat_expr.c.
Collaboration diagram for xlat_logical_rctx_t:| Data Fields | ||
|---|---|---|
| fr_value_box_t * | box | output value-box |
| TALLOC_CTX * | ctx | |
| int | current | |
| unlang_result_t | last_result | |
| fr_value_box_list_t | list | |
| struct xlat_rcode_inst_t |
Holds the result of pre-parsing the rcode on startup.
Definition at line 1505 of file xlat_expr.c.
| Data Fields | ||
|---|---|---|
| rlm_rcode_t | rcode | The preparsed rcode. |
| struct xlat_regex_inst_t |
Definition at line 509 of file xlat_expr.c.
Collaboration diagram for xlat_regex_inst_t:| Data Fields | ||
|---|---|---|
| fr_token_t | op | |
| regex_t * | regex | precompiled regex |
| fr_regex_flags_t * | regex_flags | |
| xlat_exp_t * | xlat | to expand |
| struct xlat_regex_rctx_t |
Definition at line 516 of file xlat_expr.c.
Collaboration diagram for xlat_regex_rctx_t:| Data Fields | ||
|---|---|---|
| unlang_result_t | last_result | |
| fr_value_box_list_t | list | |
| #define fr_sbuff_skip_whitespace | ( | _x | ) |
Definition at line 2043 of file xlat_expr.c.
| #define P | ( | _x, | |
| _y | |||
| ) | (((_x) << 4) | (_y)) |
Definition at line 1987 of file xlat_expr.c.
| #define XLAT_BINARY_FUNC | ( | _name, | |
| _op | |||
| ) |
Definition at line 373 of file xlat_expr.c.
| #define XLAT_CMP_FUNC | ( | _name, | |
| _op | |||
| ) |
Definition at line 492 of file xlat_expr.c.
| #define XLAT_DEBUG | ( | ... | ) |
Definition at line 38 of file xlat_expr.c.
| #define XLAT_REGEX_FUNC | ( | _name, | |
| _op | |||
| ) |
Definition at line 825 of file xlat_expr.c.
| #define XLAT_REGISTER_BINARY_CMP | ( | _op, | |
| _name | |||
| ) |
Definition at line 1810 of file xlat_expr.c.
| #define XLAT_REGISTER_BINARY_OP | ( | _op, | |
| _name | |||
| ) |
Definition at line 1800 of file xlat_expr.c.
| #define XLAT_REGISTER_BOOL | ( | _xlat, | |
| _func, | |||
| _arg, | |||
| _ret_type | |||
| ) |
Definition at line 1842 of file xlat_expr.c.
| #define XLAT_REGISTER_NARY_OP | ( | _op, | |
| _name, | |||
| _func_name | |||
| ) |
Definition at line 1821 of file xlat_expr.c.
| #define XLAT_REGISTER_REGEX_OP | ( | _op, | |
| _name | |||
| ) |
Definition at line 1832 of file xlat_expr.c.
| #define XLAT_REGISTER_UNARY | ( | _op, | |
| _xlat, | |||
| _func | |||
| ) |
Definition at line 1849 of file xlat_expr.c.
|
static |
Allocate a specific cast node.
With the first argument being a UINT8 of the data type. See xlat_func_cast() for the implementation.
Definition at line 2186 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 2223 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 279 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Tokenize a mathematical operation.
(EXPR) !EXPR A OP B If "out" is NULL then the expression is added to "head". Otherwise, it's returned to the caller.
Definition at line 2758 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 2414 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 2357 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 2263 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 2083 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 2719 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1757 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
Allocate a specific cast node.
With the first argument being a UINT8 of the data type. See xlat_func_cast() for the implementation.
Definition at line 112 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
If any argument resolves to inst->stop_on_match, the entire thing is a bool of inst->stop_on_match.
If any argument resolves to !inst->stop_on_match, it is removed.
Definition at line 1002 of file xlat_expr.c.
Here is the call graph for this function:
|
static |
|
static |
Definition at line 1709 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Definition at line 1586 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
Definition at line 70 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Process logical &&, ||.
Definition at line 1383 of file xlat_expr.c.
Here is the call graph for this function:
|
static |
Definition at line 836 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1491 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1484 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1457 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1413 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1726 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Convert static expr_rcode arguments into rcodes.
This saves doing the lookup at runtime, which given how frequently this xlat is used could get quite expensive.
Definition at line 1514 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
| bool xlat_is_truthy | ( | xlat_exp_head_t const * | head, |
| bool * | out | ||
| ) |
Allow callers to see if an xlat is truthy.
So the caller can cache it, and needs to check fewer things at run time.
| [in] | head | of the xlat to check |
| [out] | out | truthiness of the box |
Definition at line 3208 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
See if the input is truthy or not.
| [in] | rctx | our ctx |
| [in] | in | list of value-boxes to check |
Empty lists are not truthy.
Definition at line 1265 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1312 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
See if the input is truthy or not.
| [in] | rctx | our ctx |
| [in] | in | list of value-boxes to check |
Empty lists are not truthy.
Definition at line 1166 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 1208 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Process one argument of a logical operation.
If we see a list in a truthy context, then we DON'T expand the list. Instead, we return a bool which indicates if the list was empty (or not). This prevents us from returning a whole mess of value-boxes when the user just wanted to see if the list existed.
Otherwise, we expand the xlat, and continue.
Definition at line 1129 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 928 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Perform a regular expressions comparison between two operands.
| [in] | ctx | to allocate resulting box in. |
| [in] | request | The current request. |
| [in] | in | list of item or items |
| [in,out] | preg | Pointer to pre-compiled or runtime-compiled regular expression. In the case of runtime-compiled the pattern may be stolen by the regex_sub_to_request function as the original pattern is needed to resolve capture groups. The caller should only free the regex_t * if it compiled it, and the pointer has not been set to NULL when this function returns. |
| [out] | out | Where result is written. |
| [in] | op | the operation to perform. |
Definition at line 663 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
Definition at line 752 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int xlat_register_expressions | ( | void | ) |
Definition at line 1858 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:| fr_slen_t xlat_tokenize_condition | ( | TALLOC_CTX * | ctx, |
| xlat_exp_head_t ** | out, | ||
| fr_sbuff_t * | in, | ||
| fr_sbuff_parse_rules_t const * | p_rules, | ||
| tmpl_rules_t const * | t_rules | ||
| ) |
Definition at line 3173 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:| fr_slen_t xlat_tokenize_expression | ( | TALLOC_CTX * | ctx, |
| xlat_exp_head_t ** | out, | ||
| fr_sbuff_t * | in, | ||
| fr_sbuff_parse_rules_t const * | p_rules, | ||
| tmpl_rules_t const * | t_rules | ||
| ) |
Definition at line 3145 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 3069 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Undo work which shouldn't have been done.
:(
Definition at line 976 of file xlat_expr.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 392 of file xlat_expr.c.
|
static |
Definition at line 296 of file xlat_expr.c.
|
static |
Definition at line 1931 of file xlat_expr.c.
|
static |
Definition at line 3044 of file xlat_expr.c.
|
static |
Definition at line 2685 of file xlat_expr.c.
|
static |
Definition at line 2717 of file xlat_expr.c.
|
static |
Definition at line 2061 of file xlat_expr.c.
|
static |
Definition at line 2067 of file xlat_expr.c.
|
static |
Definition at line 1963 of file xlat_expr.c.
|
static |
Definition at line 1976 of file xlat_expr.c.
|
static |
|
static |
Definition at line 1989 of file xlat_expr.c.
|
static |
Definition at line 629 of file xlat_expr.c.
|
static |
Definition at line 635 of file xlat_expr.c.
|
static |
Definition at line 1408 of file xlat_expr.c.
|
static |
Definition at line 1701 of file xlat_expr.c.
|
static |
Definition at line 1498 of file xlat_expr.c.
|
static |
Takes no arguments.
Definition at line 1664 of file xlat_expr.c.
1.9.8