The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
xlat expansion parsing and evaluation API. More...
#include <freeradius-devel/util/retry.h>
#include <freeradius-devel/server/request.h>
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/signal.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/util/heap.h>
#include <freeradius-devel/util/pair.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/time.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/unlang/call_env.h>
#include <freeradius-devel/unlang/xlat_ctx.h>
Go to the source code of this file.
Data Structures | |
struct | xlat_arg_parser_t |
Definition for a single argument consumend by an xlat function. More... | |
struct | xlat_flags_t |
Flags that control resolution and evaluation. More... | |
struct | xlat_inst_s |
Instance data for an xlat expansion node. More... | |
struct | xlat_res_rules_t |
struct | xlat_thread_inst_s |
Thread specific instance data for xlat expansion node. More... | |
Macros | |
#define | _XLAT_ARGS_X(XLAT_ARGS_N, _list, ...) XLAT_ARGS_N(_list, __VA_ARGS__) |
Trampoline macro for selecting which XLAT_ARGS_<num> macro to expand. | |
#define | XLAT_ARG_PARSER_TERMINATOR |
#define | XLAT_ARGS(_list, ...) _XLAT_ARGS_X(JOIN(XLAT_ARGS_, VA_NARG(__VA_ARGS__)), _list, __VA_ARGS__) |
Populate local variables with value boxes from the input list. | |
#define | XLAT_ARGS_1(_list, _a) *(_a) = fr_value_box_list_head(_list) |
#define | XLAT_ARGS_2(_list, _a, _b) |
#define | XLAT_ARGS_3(_list, _a, _b, _c) |
#define | XLAT_ARGS_4(_list, _a, _b, _c, _d) |
#define | XLAT_ARGS_5(_list, _a, _b, _c, _d, _e) |
#define | XLAT_ARGS_6(_list, _a, _b, _c, _d, _e, _f) |
#define | XLAT_ARGS_7(_list, _a, _b, _c, _d, _e, _f, _g) |
#define | XLAT_ARGS_8(_list, _a, _b, _c, _d, _e, _f, _g, _h) |
#define | XLAT_ARGS_NEXT(_list, _prev, _curr) *(_curr) = likely(*(_prev) != NULL) ? fr_value_box_list_next(_list, *(_prev)) : NULL |
Set the next argument to the next item in the input list or NULL. | |
#define | xlat_copy(_ctx, _out, _in) _xlat_copy(NDEBUG_LOCATION_EXP _ctx, _out, _in) |
#define | XLAT_HEAD_VERIFY(_head) |
#define | XLAT_VERIFY(_node) |
Typedefs | |
typedef void(* | fr_unlang_xlat_fd_event_t) (xlat_ctx_t const *xctx, request_t *request, int fd) |
A callback when the FD is ready for reading. | |
typedef void(* | fr_unlang_xlat_retry_t) (xlat_ctx_t const *xctx, request_t *request, fr_retry_t const *retry) |
A callback when the the timeout occurs. | |
typedef void(* | fr_unlang_xlat_timeout_t) (xlat_ctx_t const *xctx, request_t *request, fr_time_t fired) |
A callback when the the timeout occurs. | |
typedef struct unlang_interpret_s | unlang_interpret_t |
typedef int(* | xlat_detach_t) (xlat_inst_ctx_t const *xctx) |
xlat detach callback | |
typedef int(* | xlat_escape_func_t) (request_t *request, fr_value_box_t *vb, void *uctx) |
A function used to escape an argument passed to an xlat. | |
typedef ssize_t(* | xlat_escape_legacy_t) (request_t *request, char *out, size_t outlen, char const *in, void *arg) |
typedef void(* | xlat_func_signal_t) (xlat_ctx_t const *xctx, request_t *request, fr_signal_t action) |
A callback when the request gets a fr_signal_t. | |
typedef xlat_action_t(* | xlat_func_t) (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
xlat callback function | |
typedef struct xlat_inst_s | xlat_inst_t |
typedef int(* | xlat_instantiate_t) (xlat_inst_ctx_t const *xctx) |
Allocate new instance data for an xlat instance. | |
typedef struct xlat_s | xlat_t |
typedef int(* | xlat_thread_detach_t) (xlat_thread_inst_ctx_t const *xctx) |
xlat thread detach callback | |
typedef struct xlat_thread_inst_s | xlat_thread_inst_t |
typedef int(* | xlat_thread_instantiate_t) (xlat_thread_inst_ctx_t const *xctx) |
Allocate new thread instance data for an xlat instance. | |
Enumerations | |
enum | xlat_action_t { XLAT_ACTION_PUSH_CHILD = 1 , XLAT_ACTION_PUSH_UNLANG , XLAT_ACTION_YIELD , XLAT_ACTION_DONE , XLAT_ACTION_FAIL } |
enum | xlat_arg_parser_variadic_t { XLAT_ARG_VARIADIC_DISABLED = 0 , XLAT_ARG_VARIADIC_EMPTY_SQUASH = 1 , XLAT_ARG_VARIADIC_EMPTY_KEEP = 2 } |
enum | xlat_input_type_t { XLAT_INPUT_UNPROCESSED , XLAT_INPUT_ARGS } |
Functions | |
int | _xlat_copy (NDEBUG_LOCATION_ARGS TALLOC_CTX *ctx, xlat_exp_head_t *out, xlat_exp_head_t const *in) |
int | unlang_xlat_eval (TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *request, xlat_exp_head_t const *head) |
Evaluate a "pure" (or not impure) xlat. | |
int | unlang_xlat_eval_type (TALLOC_CTX *ctx, fr_value_box_t *out, fr_type_t type, fr_dict_attr_t const *enumv, request_t *request, xlat_exp_head_t const *head) |
Evaluate a "pure" (or not impure) xlat. | |
int | unlang_xlat_push (TALLOC_CTX *ctx, bool *p_success, fr_value_box_list_t *out, request_t *request, xlat_exp_head_t const *head, bool top_frame) |
Push a pre-compiled xlat onto the stack for evaluation. | |
int | unlang_xlat_timeout_add (request_t *request, fr_unlang_xlat_timeout_t callback, void const *rctx, fr_time_t when) |
Add a timeout for an xlat handler. | |
xlat_action_t | unlang_xlat_yield (request_t *request, xlat_func_t callback, xlat_func_signal_t signal, fr_signal_t sigmask, void *rctx) |
Yield a request back to the interpreter from within a module. | |
xlat_action_t | unlang_xlat_yield_to_retry (request_t *request, xlat_func_t resume, fr_unlang_xlat_retry_t retry, xlat_func_signal_t signal, fr_signal_t sigmask, void *rctx, fr_retry_config_t const *retry_cfg) |
Yield a request back to the interpreter, with retries. | |
ssize_t | xlat_aeval (TALLOC_CTX *ctx, char **out, request_t *request, char const *fmt, xlat_escape_legacy_t escape, void const *escape_ctx)) |
ssize_t | xlat_aeval_compiled (TALLOC_CTX *ctx, char **out, request_t *request, xlat_exp_head_t const *head, xlat_escape_legacy_t escape, void const *escape_ctx)) |
int | xlat_aeval_compiled_argv (TALLOC_CTX *ctx, char ***argv, request_t *request, xlat_exp_head_t const *head, xlat_escape_legacy_t escape, void const *escape_ctx) |
Synchronous compile xlat_tokenize_argv() into argv[] array. | |
static fr_slen_t | xlat_aprint (TALLOC_CTX *ctx, char **out, xlat_exp_head_t const *head, fr_sbuff_escape_rules_t const *e_rules) 1(xlat_print |
void | xlat_debug (xlat_exp_t const *node) |
void | xlat_debug_attr_list (request_t *request, fr_pair_list_t const *list) |
void | xlat_debug_attr_vp (request_t *request, fr_pair_t *vp, tmpl_t const *vpt) |
void | xlat_debug_head (xlat_exp_head_t const *head) |
ssize_t | xlat_eval (char *out, size_t outlen, request_t *request, char const *fmt, xlat_escape_legacy_t escape, void const *escape_ctx)) |
ssize_t | xlat_eval_compiled (char *out, size_t outlen, request_t *request, xlat_exp_head_t const *head, xlat_escape_legacy_t escape, void const *escape_ctx)) |
int | xlat_finalize (xlat_exp_head_t *head, fr_event_list_t *runtime_el) |
Bootstrap static xlats, or instantiate ephemeral ones. | |
int | xlat_flatten_compiled_argv (TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head) |
Turn xlat_tokenize_argv() into an argv[] array, and nuke the input list. | |
int | xlat_from_tmpl_attr (TALLOC_CTX *ctx, xlat_exp_head_t **head, tmpl_t **vpt_p) |
Convert attr tmpl to an xlat for &attr[*]. | |
void | xlat_global_free (void) |
int | xlat_global_init (void) |
bool | xlat_impure_func (xlat_exp_head_t const *head) |
int | xlat_instance_register_func (xlat_exp_t *node) |
Callback for creating "permanent" instance data for a xlat_exp_t. | |
int | xlat_instance_unregister_func (xlat_exp_t *node) |
Remove a node from the list of xlat instance data. | |
void | xlat_instances_free (void) |
Walk over all registered instance data and free them explicitly. | |
int | xlat_instantiate (void) |
Call instantiation functions for all registered, "permanent" xlats. | |
bool | xlat_is_literal (xlat_exp_head_t const *head) |
Check to see if the expansion consists entirely of value-box elements. | |
static fr_slen_t e_rules bool | xlat_is_truthy (xlat_exp_head_t const *head, bool *out) |
Allow callers to see if an xlat is truthy. | |
bool | xlat_needs_resolving (xlat_exp_head_t const *head) |
Check to see if the expansion needs resolving. | |
fr_slen_t | xlat_print (fr_sbuff_t *in, xlat_exp_head_t const *node, fr_sbuff_escape_rules_t const *e_rules) |
Reconstitute an xlat expression from its constituent nodes. | |
int | xlat_protocols_register (void) |
Register xlats for any loaded dictionaries. | |
int | xlat_purify (xlat_exp_head_t *head, unlang_interpret_t *intp) |
Purify an xlat. | |
int | xlat_purify_op (TALLOC_CTX *ctx, xlat_exp_t **out, xlat_exp_t *lhs, fr_token_t op, xlat_exp_t *rhs) |
int | xlat_resolve (xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules) |
Walk over an xlat tree recursively, resolving any unresolved functions or references. | |
void | xlat_thread_detach (void) |
Destroy any thread specific xlat instances. | |
xlat_thread_inst_t * | xlat_thread_instance_find (xlat_exp_t const *node) |
Retrieve xlat/thread specific instance data. | |
int | xlat_thread_instantiate (TALLOC_CTX *ctx, fr_event_list_t *el) |
Create thread specific instance tree and create thread instances. | |
bool | xlat_to_string (TALLOC_CTX *ctx, char **str, xlat_exp_head_t **head) |
Convert an xlat node to an unescaped literal string and free the original node. | |
tmpl_t * | xlat_to_tmpl_attr (TALLOC_CTX *ctx, xlat_exp_head_t *xlat) |
Try to convert an xlat to a tmpl for efficiency. | |
fr_slen_t | xlat_tokenize (TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, fr_value_box_safe_for_t literals_safe_for) |
Tokenize an xlat expansion. | |
fr_slen_t | xlat_tokenize_argv (TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in, xlat_t const *xlat, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, bool comma, bool allow_attr) |
Tokenize an xlat expansion into a series of XLAT_TYPE_CHILD arguments. | |
fr_slen_t | xlat_tokenize_condition (TALLOC_CTX *ctx, xlat_exp_head_t **head, 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 **head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules) |
xlat_action_t | xlat_transparent (UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out, UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args) |
fr_slen_t | xlat_validate_function_args (xlat_exp_t *node) |
Variables | |
static fr_slen_t | head |
fr_table_num_sorted_t const | xlat_action_table [] |
size_t | xlat_action_table_len |
xlat expansion parsing and evaluation API.
Definition in file xlat.h.
struct xlat_arg_parser_t |
Definition for a single argument consumend by an xlat function.
Data Fields | ||
---|---|---|
bool | always_escape | Pass all arguments to escape function not just tainted ones. |
bool | concat | Concat boxes together. |
xlat_escape_func_t | func | Function to handle tainted values. |
bool | required | Argument must be present, and non-empty. |
fr_value_box_safe_for_t | safe_for | Escaped value to set for boxes processed by this escape function. |
bool | single | Argument must only contain a single box. |
fr_type_t | type | Type to cast argument to. |
void * | uctx | Argument to pass to escape callback. |
xlat_arg_parser_variadic_t | variadic | All additional boxes should be processed using this definition. |
struct xlat_flags_t |
Data Fields | ||
---|---|---|
bool | can_purify | if the xlat has a pure function with pure arguments. |
bool | constant | xlat is just tmpl_attr_tail_data, or XLAT_BOX |
bool | impure_func | xlat contains an impure function |
bool | needs_resolving | Needs pass2 resolution. |
bool | pure | has no external side effects, true for BOX, LITERAL, and some functions |
bool | xlat | it's an xlat wrapper |
struct xlat_inst_s |
Data Fields | ||
---|---|---|
call_env_t const * | call_env | Per call environment. |
void * | data | xlat node specific instance data. |
fr_heap_index_t | idx |
Entry in heap of xlat instances. Identical instances are used for global instance data and thread-specific instance data. |
xlat_exp_t * | node | Node this data relates to. |
struct xlat_res_rules_t |
Data Fields | ||
---|---|---|
bool | allow_unresolved |
If false, all resolution steps must be completed. this round, otherwise an error will be produced. |
tmpl_res_rules_t const * | tr_rules | tmpl resolution rules. |
struct xlat_thread_inst_s |
Data Fields | ||
---|---|---|
uint64_t | active_callers | total number of times we've been called |
void * | data | Thread specific instance data. |
fr_event_list_t * | el | Event list associated with this thread. |
fr_heap_index_t | idx |
Entry in heap of xlat thread instances. Identical instances are used for global instance data and thread-specific instance data. |
module_ctx_t const * | mctx | A synthesised module calling ctx containing module global and thread instance data. |
xlat_exp_t const * | node | Node this data relates to. |
uint64_t | total_calls |
#define _XLAT_ARGS_X | ( | XLAT_ARGS_N, | |
_list, | |||
... | |||
) | XLAT_ARGS_N(_list, __VA_ARGS__) |
Trampoline macro for selecting which XLAT_ARGS_<num>
macro to expand.
[in] | XLAT_ARGS_N | the name of the macro to expand. Created by concatenating XLAT_ARGS_ + <number of variadic arguments> . |
[in] | _list | The input list of value boxes. |
[in] | ... | The variadic arguments themselves. |
#define XLAT_ARG_PARSER_TERMINATOR |
#define XLAT_ARGS | ( | _list, | |
... | |||
) | _XLAT_ARGS_X(JOIN(XLAT_ARGS_, VA_NARG(__VA_ARGS__)), _list, __VA_ARGS__) |
Populate local variables with value boxes from the input list.
[in] | _list | input list to pull arguments from. |
[in] | ... | 1-8 output boxes pointers fr_value_box_t ** e.g. XLAT_ARGS(in, &arg0, &arg1, &argN) `. |
#define XLAT_ARGS_1 | ( | _list, | |
_a | |||
) | *(_a) = fr_value_box_list_head(_list) |
#define XLAT_ARGS_2 | ( | _list, | |
_a, | |||
_b | |||
) |
#define XLAT_ARGS_3 | ( | _list, | |
_a, | |||
_b, | |||
_c | |||
) |
#define XLAT_ARGS_4 | ( | _list, | |
_a, | |||
_b, | |||
_c, | |||
_d | |||
) |
#define XLAT_ARGS_5 | ( | _list, | |
_a, | |||
_b, | |||
_c, | |||
_d, | |||
_e | |||
) |
#define XLAT_ARGS_6 | ( | _list, | |
_a, | |||
_b, | |||
_c, | |||
_d, | |||
_e, | |||
_f | |||
) |
#define XLAT_ARGS_7 | ( | _list, | |
_a, | |||
_b, | |||
_c, | |||
_d, | |||
_e, | |||
_f, | |||
_g | |||
) |
#define XLAT_ARGS_8 | ( | _list, | |
_a, | |||
_b, | |||
_c, | |||
_d, | |||
_e, | |||
_f, | |||
_g, | |||
_h | |||
) |
#define XLAT_ARGS_NEXT | ( | _list, | |
_prev, | |||
_curr | |||
) | *(_curr) = likely(*(_prev) != NULL) ? fr_value_box_list_next(_list, *(_prev)) : NULL |
#define xlat_copy | ( | _ctx, | |
_out, | |||
_in | |||
) | _xlat_copy(NDEBUG_LOCATION_EXP _ctx, _out, _in) |
typedef void(* fr_unlang_xlat_fd_event_t) (xlat_ctx_t const *xctx, request_t *request, int fd) |
A callback when the FD is ready for reading.
Used when a xlat needs to read from an FD. Typically the callback is set, and then the xlat returns unlang_xlat_yield().
[in] | xctx | xlat calling ctx. Contains all instance data. |
[in] | request | the current request. |
[in] | fd | the file descriptor. |
typedef void(* fr_unlang_xlat_retry_t) (xlat_ctx_t const *xctx, request_t *request, fr_retry_t const *retry) |
A callback when the the timeout occurs.
Used when a xlat needs wait for an event. Typically the callback is set, and then the xlat returns unlang_xlat_yield().
[in] | xctx | xlat calling ctx. Contains all instance data. |
[in] | request | the request. |
[in] | retry | retry status. "now" is in retry->updated |
typedef void(* fr_unlang_xlat_timeout_t) (xlat_ctx_t const *xctx, request_t *request, fr_time_t fired) |
A callback when the the timeout occurs.
Used when a xlat needs wait for an event. Typically the callback is set, and then the xlat returns unlang_xlat_yield().
[in] | xctx | xlat calling ctx. Contains all instance data. |
[in] | request | the request. |
[in] | fired | the time the timeout event actually fired. |
typedef struct unlang_interpret_s unlang_interpret_t |
typedef int(* xlat_detach_t) (xlat_inst_ctx_t const *xctx) |
xlat detach callback
Is called whenever an xlat_node_t is freed.
Detach should close all handles associated with the xlat instance, and free any memory allocated during instantiate.
[in] | xctx | instantiate/detach calling ctx. |
typedef int(* xlat_escape_func_t) (request_t *request, fr_value_box_t *vb, void *uctx) |
typedef void(* xlat_func_signal_t) (xlat_ctx_t const *xctx, request_t *request, fr_signal_t action) |
A callback when the request gets a fr_signal_t.
[in] | request | The current request. |
[in] | xctx | xlat calling ctx. Contains all instance data. |
[in] | action | which is signalling the request. |
typedef xlat_action_t(* xlat_func_t) (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
xlat callback function
Ingests a list of value boxes as arguments.
[in] | ctx | to allocate any fr_value_box_t in. |
[out] | out | Where to append fr_value_box_t containing the output of this function. |
[in] | xctx | xlat calling ctx. Contains all instance data and the resume ctx if this function is being resumed. |
[in] | request | The current request. |
[in] | in | Input arguments. |
typedef struct xlat_inst_s xlat_inst_t |
typedef int(* xlat_instantiate_t) (xlat_inst_ctx_t const *xctx) |
typedef int(* xlat_thread_detach_t) (xlat_thread_inst_ctx_t const *xctx) |
xlat thread detach callback
Is called whenever an xlat_node_t is freed (if ephemeral), or when a thread exits.
Detach should close all handles associated with the xlat instance, and free any memory allocated during instantiate.
[in] | xctx | thread instantiate/detach calling ctx. |
typedef struct xlat_thread_inst_s xlat_thread_inst_t |
typedef int(* xlat_thread_instantiate_t) (xlat_thread_inst_ctx_t const *xctx) |
enum xlat_action_t |
enum xlat_input_type_t |
int _xlat_copy | ( | NDEBUG_LOCATION_ARGS TALLOC_CTX * | ctx, |
xlat_exp_head_t * | out, | ||
xlat_exp_head_t const * | in | ||
) |
int unlang_xlat_eval | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t * | out, | ||
request_t * | request, | ||
xlat_exp_head_t const * | xlat | ||
) |
Evaluate a "pure" (or not impure) xlat.
[in] | ctx | To allocate value boxes and values in. |
[out] | out | Where to write the result of the expansion. |
[in] | request | to push xlat onto. |
[in] | xlat | to evaluate. |
Definition at line 739 of file xlat.c.
int unlang_xlat_eval_type | ( | TALLOC_CTX * | ctx, |
fr_value_box_t * | vb, | ||
fr_type_t | type, | ||
fr_dict_attr_t const * | enumv, | ||
request_t * | request, | ||
xlat_exp_head_t const * | xlat | ||
) |
Evaluate a "pure" (or not impure) xlat.
[in] | ctx | To allocate value boxes and values in. |
[out] | vb | output value-box |
[in] | type | expected type |
[in] | enumv | enum for type |
[in] | request | to push xlat onto. |
[in] | xlat | to evaluate. |
Definition at line 769 of file xlat.c.
int unlang_xlat_push | ( | TALLOC_CTX * | ctx, |
bool * | p_success, | ||
fr_value_box_list_t * | out, | ||
request_t * | request, | ||
xlat_exp_head_t const * | xlat, | ||
bool | top_frame | ||
) |
Push a pre-compiled xlat onto the stack for evaluation.
[in] | ctx | To allocate value boxes and values in. |
[out] | p_success | If set, and execution succeeds, true will be written here. If execution fails, false will be written. |
[out] | out | Where to write the result of the expansion. |
[in] | request | to push xlat onto. |
[in] | xlat | to evaluate. |
[in] | top_frame | Set to UNLANG_TOP_FRAME if the interpreter should return. Set to UNLANG_SUB_FRAME if the interprer should continue. |
Definition at line 286 of file xlat.c.
int unlang_xlat_timeout_add | ( | request_t * | request, |
fr_unlang_xlat_timeout_t | callback, | ||
void const * | rctx, | ||
fr_time_t | when | ||
) |
Add a timeout for an xlat handler.
[in] | request | the request |
[in] | callback | to run when the timeout hits |
[in] | rctx | passed to the callback |
[in] | when | when the timeout fires |
Definition at line 152 of file xlat.c.
xlat_action_t unlang_xlat_yield | ( | request_t * | request, |
xlat_func_t | resume, | ||
xlat_func_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.
return unlang_xlat_yield(...)
.[in] | request | The current request. |
[in] | resume | Called on unlang_interpret_mark_runnable(). |
[in] | signal | Called on unlang_action(). |
[in] | sigmask | Signals to block. |
[in] | rctx | to pass to the callbacks. |
Definition at line 573 of file xlat.c.
xlat_action_t unlang_xlat_yield_to_retry | ( | request_t * | request, |
xlat_func_t | resume, | ||
fr_unlang_xlat_retry_t | retry, | ||
xlat_func_signal_t | signal, | ||
fr_signal_t | sigmask, | ||
void * | rctx, | ||
fr_retry_config_t const * | retry_cfg | ||
) |
Yield a request back to the interpreter, with retries.
This passes control of the request back to the unlang interpreter, setting callbacks to execute when the request is 'signalled' asynchronously, or when the retry timer hits.
return unlang_module_yield_to_retry(...)
.[in] | request | The current request. |
[in] | resume | Called on unlang_interpret_mark_runnable(). |
[in] | retry | Called on when a retry timer hits |
[in] | signal | Called on unlang_action(). |
[in] | sigmask | Set of signals to block. |
[in] | rctx | to pass to the callbacks. |
[in] | retry_cfg | to set up the retries |
Definition at line 691 of file xlat.c.
ssize_t xlat_aeval | ( | TALLOC_CTX * | ctx, |
char ** | out, | ||
request_t * | request, | ||
char const * | fmt, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Definition at line 1554 of file xlat_eval.c.
ssize_t xlat_aeval_compiled | ( | TALLOC_CTX * | ctx, |
char ** | out, | ||
request_t * | request, | ||
xlat_exp_head_t const * | head, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Definition at line 1563 of file xlat_eval.c.
int xlat_aeval_compiled_argv | ( | TALLOC_CTX * | ctx, |
char *** | argv, | ||
request_t * | request, | ||
xlat_exp_head_t const * | head, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Synchronous compile xlat_tokenize_argv() into argv[] array.
This is mostly for synchronous evaluation.
ctx | The talloc_ctx | |
[out] | argv | the argv array of resulting strings, size is argc + 1 |
request | the request | |
head | from xlat_tokenize_argv() | |
escape | escape function | |
escape_ctx | context for escape function |
Definition at line 1587 of file xlat_eval.c.
|
inlinestatic |
void xlat_debug | ( | xlat_exp_t const * | node | ) |
void xlat_debug_attr_list | ( | request_t * | request, |
fr_pair_list_t const * | list | ||
) |
Definition at line 221 of file xlat_builtin.c.
Definition at line 123 of file xlat_builtin.c.
void xlat_debug_head | ( | xlat_exp_head_t const * | head | ) |
Definition at line 1055 of file xlat_tokenize.c.
ssize_t xlat_eval | ( | char * | out, |
size_t | outlen, | ||
request_t * | request, | ||
char const * | fmt, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Definition at line 215 of file merged_model.c.
ssize_t xlat_eval_compiled | ( | char * | out, |
size_t | outlen, | ||
request_t * | request, | ||
xlat_exp_head_t const * | head, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx | ||
) |
Definition at line 1546 of file xlat_eval.c.
int xlat_finalize | ( | xlat_exp_head_t * | head, |
fr_event_list_t * | runtime_el | ||
) |
Bootstrap static xlats, or instantiate ephemeral ones.
[in] | head | of xlat tree to create instance data for. |
[in] | runtime_el | determines whether we do ephemeral or static instantiation. If NULL, we perform static instantiation, otherwise will perform ephemeral instantiation passing the el to the instantiation functions. |
Definition at line 695 of file xlat_inst.c.
int xlat_flatten_compiled_argv | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t *** | argv, | ||
xlat_exp_head_t * | head | ||
) |
Turn xlat_tokenize_argv() into an argv[] array, and nuke the input list.
This is mostly for async use.
Definition at line 1622 of file xlat_eval.c.
int xlat_from_tmpl_attr | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t ** | out, | ||
tmpl_t ** | vpt_p | ||
) |
Convert attr tmpl to an xlat for &attr[*].
[in] | ctx | to allocate new expansion in. |
[out] | out | Where to write new xlat node. |
[in,out] | vpt_p | to convert to xlat expansion. Will be set to NULL on completion |
Definition at line 1829 of file xlat_tokenize.c.
void xlat_global_free | ( | void | ) |
int xlat_global_init | ( | void | ) |
Definition at line 4241 of file xlat_builtin.c.
bool xlat_impure_func | ( | xlat_exp_head_t const * | head | ) |
int xlat_instance_register_func | ( | xlat_exp_t * | node | ) |
Callback for creating "permanent" instance data for a xlat_exp_t.
This function records the xlat_exp_t requiring instantiation but does not call the instantiation function. This is to allow for a clear separation between the module instantiation phase and the xlat instantiation phase.
[in] | node | to create "permanent" instance data for. |
Definition at line 595 of file xlat_inst.c.
int xlat_instance_unregister_func | ( | xlat_exp_t * | node | ) |
Remove a node from the list of xlat instance data.
[in] | node | to remove instance data for. |
Definition at line 550 of file xlat_inst.c.
void xlat_instances_free | ( | void | ) |
Walk over all registered instance data and free them explicitly.
This must be called before any modules or xlats are deregistered/unloaded and before the mainconfig is freed, as the xlat_t need to still exist in order to call the detach functions within them.
Definition at line 709 of file xlat_inst.c.
int xlat_instantiate | ( | void | ) |
Call instantiation functions for all registered, "permanent" xlats.
Should be called after all the permanent xlats have been tokenised/bootstrapped.
Definition at line 513 of file xlat_inst.c.
bool xlat_is_literal | ( | xlat_exp_head_t const * | head | ) |
Check to see if the expansion consists entirely of value-box elements.
[in] | head | to check. |
Definition at line 1547 of file xlat_tokenize.c.
static fr_slen_t e_rules 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 3188 of file xlat_expr.c.
bool xlat_needs_resolving | ( | xlat_exp_head_t const * | head | ) |
Check to see if the expansion needs resolving.
[in] | head | to check. |
Definition at line 1563 of file xlat_tokenize.c.
fr_slen_t xlat_print | ( | fr_sbuff_t * | out, |
xlat_exp_head_t const * | head, | ||
fr_sbuff_escape_rules_t const * | e_rules | ||
) |
Reconstitute an xlat expression from its constituent nodes.
[in] | out | Where to write the output string. |
[in] | head | First node to print. |
[in] | e_rules | Specifying how to escape literal values. |
Definition at line 1239 of file xlat_tokenize.c.
int xlat_protocols_register | ( | void | ) |
Register xlats for any loaded dictionaries.
Definition at line 4038 of file xlat_builtin.c.
int xlat_purify | ( | xlat_exp_head_t * | head, |
unlang_interpret_t * | intp | ||
) |
Purify an xlat.
head | the xlat to be purified |
intp | the interpreter to use. |
Definition at line 194 of file xlat_purify.c.
int xlat_purify_op | ( | TALLOC_CTX * | ctx, |
xlat_exp_t ** | out, | ||
xlat_exp_t * | lhs, | ||
fr_token_t | op, | ||
xlat_exp_t * | rhs | ||
) |
Definition at line 425 of file xlat_purify.c.
int xlat_resolve | ( | xlat_exp_head_t * | head, |
xlat_res_rules_t const * | xr_rules | ||
) |
Walk over an xlat tree recursively, resolving any unresolved functions or references.
[in,out] | head | of xlat tree to resolve. |
[in] | xr_rules | Specifies rules to use for resolution passes after initial tokenization. |
Definition at line 1618 of file xlat_tokenize.c.
void xlat_thread_detach | ( | void | ) |
Destroy any thread specific xlat instances.
Definition at line 489 of file xlat_inst.c.
xlat_thread_inst_t * xlat_thread_instance_find | ( | xlat_exp_t const * | node | ) |
Retrieve xlat/thread specific instance data.
[in] | node | to find thread specific data for. |
Definition at line 407 of file xlat_inst.c.
int xlat_thread_instantiate | ( | TALLOC_CTX * | ctx, |
fr_event_list_t * | el | ||
) |
Create thread specific instance tree and create thread instances.
This should be called directly after the modules_thread_instantiate() function.
Memory will be freed automatically when the thread exits.
[in] | ctx | to bind instance tree lifetime to. Must not be shared between multiple threads. |
[in] | el | Event list to pass to all thread instantiation functions. |
Definition at line 444 of file xlat_inst.c.
bool xlat_to_string | ( | TALLOC_CTX * | ctx, |
char ** | str, | ||
xlat_exp_head_t ** | head | ||
) |
Convert an xlat node to an unescaped literal string and free the original node.
This is really "unparse the xlat nodes, and convert back to their original string".
[in] | ctx | to allocate the new string in. |
[out] | str | a duplicate of the node's fmt string. |
[in,out] | head | to convert. |
Definition at line 1579 of file xlat_tokenize.c.
tmpl_t * xlat_to_tmpl_attr | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t * | head | ||
) |
Try to convert an xlat to a tmpl for efficiency.
ctx | to allocate new tmpl_t in. |
head | to convert. |
Definition at line 1796 of file xlat_tokenize.c.
fr_slen_t xlat_tokenize | ( | 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_value_box_safe_for_t | literals_safe_for | ||
) |
Tokenize an xlat expansion.
[in] | ctx | to allocate dynamic buffers in. |
[out] | out | the head of the xlat list / tree structure. |
[in] | in | the format string to expand. |
[in] | p_rules | controlling how the string containing the xlat expansions should be parsed. |
[in] | t_rules | controlling how attribute references are parsed. Do NOT alter this function to take tmpl_rules_t as this provides another value for literals_safe_for and this gets very confusing. |
[in] | literals_safe_for | the safe_for value to assign to any literals occurring at the top level of the expansion. |
Definition at line 1509 of file xlat_tokenize.c.
fr_slen_t xlat_tokenize_argv | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t ** | out, | ||
fr_sbuff_t * | in, | ||
xlat_t const * | xlat, | ||
fr_sbuff_parse_rules_t const * | p_rules, | ||
tmpl_rules_t const * | t_rules, | ||
bool | comma, | ||
bool | allow_attr | ||
) |
Tokenize an xlat expansion into a series of XLAT_TYPE_CHILD arguments.
[in] | ctx | to allocate nodes in. Note: All nodes will be allocated in the same ctx. This is to allow manipulation by xlat instantiation functions later. |
[out] | out | the head of the xlat list / tree structure. |
[in] | in | the format string to expand. |
[in] | xlat | we're tokenizing arguments for. |
[in] | p_rules | controlling how to parse the string outside of any expansions. |
[in] | t_rules | controlling how attribute references are parsed. |
[in] | comma | whether the arguments are delimited by commas |
[in] | allow_attr | allow attribute references as arguments |
Definition at line 1274 of file xlat_tokenize.c.
fr_slen_t xlat_tokenize_condition | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t ** | head, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_parse_rules_t const * | p_rules, | ||
tmpl_rules_t const * | t_rules | ||
) |
Definition at line 3171 of file xlat_expr.c.
fr_slen_t xlat_tokenize_expression | ( | TALLOC_CTX * | ctx, |
xlat_exp_head_t ** | head, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_parse_rules_t const * | p_rules, | ||
tmpl_rules_t const * | t_rules | ||
) |
Definition at line 3165 of file xlat_expr.c.
xlat_action_t xlat_transparent | ( | UNUSED TALLOC_CTX * | ctx, |
fr_dcursor_t * | out, | ||
UNUSED xlat_ctx_t const * | xctx, | ||
request_t * | request, | ||
fr_value_box_list_t * | args | ||
) |
fr_slen_t xlat_validate_function_args | ( | xlat_exp_t * | node | ) |
Definition at line 230 of file xlat_tokenize.c.
|
extern |
Definition at line 83 of file xlat_eval.c.
|
extern |
Definition at line 89 of file xlat_eval.c.