The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Structures and prototypes for templates. More...
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/server/tmpl_escape.h>
#include <freeradius-devel/unlang/xlat.h>
#include <freeradius-devel/unlang/xlat_ctx.h>
#include <freeradius-devel/util/packet.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/regex.h>
Go to the source code of this file.
Data Structures | |
struct | tmpl_attr_extent_t |
Describes the current extents of a pair tree in relation to the tree described by a tmpl_t. More... | |
struct | tmpl_attr_filter_t |
union | tmpl_attr_filter_t.__unnamed81__ |
struct | tmpl_attr_rules_s |
Define entry and head types for tmpl request references. More... | |
struct | tmpl_attr_t |
An element in a list of nested attribute references. More... | |
union | tmpl_attr_t.__unnamed83__ |
struct | tmpl_attr_t.__unnamed83__.unknown |
struct | tmpl_attr_t.__unnamed83__.unresolved |
struct | tmpl_request_t |
Define manipulation functions for the attribute reference list. More... | |
struct | tmpl_res_rules_s |
Similar to tmpl_rules_t, but used to specify parameters that may change during subsequent resolution passes. More... | |
struct | tmpl_rules_s |
Optional arguments passed to vp_tmpl functions. More... | |
struct | tmpl_s |
A source or sink of value data. More... | |
union | tmpl_s.data |
struct | tmpl_s.data.__unnamed89__ |
union | tmpl_s.data.__unnamed89__.__unnamed91__ |
struct | tmpl_s.data.__unnamed89__.__unnamed91__.xlat |
struct | tmpl_s.data.attribute |
struct | tmpl_xlat_rules_s |
Typedefs | |
typedef struct tmpl_attr_rules_s | tmpl_attr_rules_t |
typedef struct tmpl_literal_rules_s | tmpl_literal_rules_t |
typedef enum requests_ref_e | tmpl_request_ref_t |
typedef struct tmpl_res_rules_s | tmpl_res_rules_t |
typedef struct tmpl_rules_s | tmpl_rules_t |
typedef struct tmpl_s | tmpl_t |
typedef enum tmpl_type_e | tmpl_type_t |
Types of tmpl_t. More... | |
typedef struct tmpl_xlat_rules_s | tmpl_xlat_rules_t |
Functions | |
int | tmpl_afrom_value_box (TALLOC_CTX *ctx, tmpl_t **out, fr_value_box_t *data, bool steal) |
Create a tmpl_t from a fr_value_box_t. More... | |
tmpl_t * | tmpl_alloc (TALLOC_CTX *ctx, tmpl_type_t type, fr_token_t quote, char const *name, ssize_t len) |
Create a new heap allocated tmpl_t. More... | |
bool | tmpl_async_required (tmpl_t const *vpt) |
Return whether or not async is required for this tmpl. More... | |
int | tmpl_attr_afrom_list (TALLOC_CTX *ctx, tmpl_t **out, tmpl_t const *list, fr_dict_attr_t const *da) |
Create a new tmpl from a list tmpl and a da. More... | |
int | tmpl_attr_copy (tmpl_t *dst, tmpl_t const *src) |
Copy a list of attribute and request references from one tmpl to another. More... | |
void | tmpl_attr_debug (tmpl_t const *vpt) |
fr_slen_t | tmpl_attr_list_from_substr (fr_dict_attr_t const **da_p, fr_sbuff_t *in) |
Parse one a single list reference. More... | |
void | tmpl_attr_ref_debug (const tmpl_attr_t *ar, int idx) |
void | tmpl_attr_ref_list_debug (FR_DLIST_HEAD(tmpl_attr_list) const *ar_head) |
void | tmpl_attr_rewrite_leaf_num (tmpl_t *vpt, int16_t num) |
Rewrite the leaf's instance number. More... | |
int | tmpl_attr_set_da (tmpl_t *vpt, fr_dict_attr_t const *da) |
Replace the current attribute reference. More... | |
int | tmpl_attr_set_leaf_da (tmpl_t *vpt, fr_dict_attr_t const *da) |
Replace the leaf attribute only. More... | |
void | tmpl_attr_set_list (tmpl_t *vpt, fr_dict_attr_t const *list) |
void | tmpl_attr_set_request_ref (tmpl_t *vpt, FR_DLIST_HEAD(tmpl_request_list) const *request_def) |
Set the request for an attribute ref. More... | |
void | tmpl_debug (tmpl_t const *vpt) |
int | tmpl_global_init (void) |
tmpl_t * | tmpl_init (tmpl_t *vpt, tmpl_type_t type, fr_token_t quote, char const *name, ssize_t len, tmpl_rules_t const *t_rules)) |
Initialise a tmpl using a literal string to create the name. More... | |
tmpl_t * | tmpl_init_printf (tmpl_t *vpt, tmpl_type_t type, fr_token_t quote, char const *fmt,...)) |
Initialise a tmpl using a format string to create the name. More... | |
tmpl_t * | tmpl_init_shallow (tmpl_t *vpt, tmpl_type_t type, fr_token_t quote, char const *name, ssize_t len, tmpl_rules_t const *t_rules)) |
Initialise a tmpl without copying the input name string. More... | |
static bool | tmpl_is_list (tmpl_t const *vpt) |
TALLOC_CTX * | tmpl_list_ctx (request_t *request, fr_dict_attr_t const *list) |
Return the correct TALLOC_CTX to alloc fr_pair_t in, for a list. More... | |
fr_pair_list_t * | tmpl_list_head (request_t *request, fr_dict_attr_t const *list) |
Resolve attribute fr_pair_list_t value to an attribute list. More... | |
static char const * | tmpl_list_name (fr_dict_attr_t const *list, char const *def) |
Return the name of a tmpl list or def if list not provided. More... | |
fr_packet_t * | tmpl_packet_ptr (request_t *request, fr_dict_attr_t const *list) |
Resolve a list to the fr_packet_t holding the HEAD pointer for a fr_pair_t list. More... | |
ssize_t | tmpl_preparse (char const **out, size_t *outlen, char const *in, size_t inlen, fr_token_t *type)) |
Preparse a string in preparation for passing it to tmpl_afrom_substr() More... | |
void | tmpl_rules_child_init (TALLOC_CTX *ctx, tmpl_rules_t *out, tmpl_rules_t const *parent, tmpl_t *vpt) |
Initialize a set of rules from a parent set of rules, and a parsed tmpl_t. More... | |
void | tmpl_rules_debug (tmpl_rules_t const *rules) |
void | tmpl_set_dict_def (tmpl_t *vpt, fr_dict_t const *dict) |
Change the default dictionary in the tmpl's resolution rules. More... | |
void | tmpl_set_escape (tmpl_t *vpt, tmpl_escape_t const *escape) |
Set escape parameters for the tmpl output. More... | |
void | tmpl_set_name (tmpl_t *vpt, fr_token_t quote, char const *name, ssize_t len) |
Set the name on a pre-initialised tmpl. More... | |
void | tmpl_set_name_printf (tmpl_t *vpt, fr_token_t quote, char const *fmt,...)) |
Set the name on a pre-initialised tmpl. More... | |
void | tmpl_set_name_shallow (tmpl_t *vpt, fr_token_t quote, char const *name, ssize_t len) |
Set the name on a pre-initialised tmpl. More... | |
void | tmpl_set_xlat (tmpl_t *vpt, xlat_exp_head_t *xlat) |
Change the default dictionary in the tmpl's resolution rules. More... | |
int | tmpl_value_list_insert_tail (fr_value_box_list_t *list, fr_value_box_t *vb, tmpl_t const *vpt) |
Insert a value-box to a list, with casting. More... | |
Variables | |
fr_table_num_ordered_t const | pair_list_table [] |
size_t | pair_list_table_len |
fr_table_num_sorted_t const | tmpl_request_ref_table [] |
Map keywords to tmpl_request_ref_t values. More... | |
size_t | tmpl_request_ref_table_len |
fr_table_num_ordered_t const | tmpl_type_table [] |
Map tmpl_type_t values to descriptive strings. More... | |
size_t | tmpl_type_table_len |
Field accessors for #TMPL_TYPE_ATTR, #TMPL_TYPE_ATTR_UNRESOLVED | |
static | FR_DLIST_HEAD (tmpl_request_list) tmpl_request_def_current |
Static default request ref list for the current request. More... | |
#define | tmpl_attr(_tmpl) &(_tmpl)->data.attribute.ar |
static bool | tmpl_attr_head_is_list (tmpl_t const *vpt) |
Return true if the head attribute reference is a list reference. More... | |
static bool | tmpl_attr_is_list_attr (tmpl_attr_t const *ar) |
Return true if the tmpl_attr is one of the list types. More... | |
static size_t | tmpl_attr_num_elements (tmpl_t const *vpt) |
The number of attribute references contained within a tmpl. More... | |
static tmpl_attr_t const * | tmpl_attr_tail (tmpl_t const *vpt) |
Return the last attribute reference. More... | |
static fr_dict_attr_t const * | tmpl_attr_tail_da (tmpl_t const *vpt) |
Return the last attribute reference da. More... | |
static bool | tmpl_attr_tail_da_is_leaf (tmpl_t const *vpt) |
Return true if the the last attribute reference is a leaf attribute. More... | |
static bool | tmpl_attr_tail_da_is_structural (tmpl_t const *vpt) |
Return true if the the last attribute reference is a structural attribute. More... | |
static bool | tmpl_attr_tail_is_normal (tmpl_t const *vpt) |
Return true if the last attribute reference is "normal". More... | |
static bool | tmpl_attr_tail_is_raw (tmpl_t const *vpt) |
Return true if the last attribute reference is "raw". More... | |
static bool | tmpl_attr_tail_is_unknown (tmpl_t const *vpt) |
Return true if the last attribute reference is "unknown". More... | |
static bool | tmpl_attr_tail_is_unresolved (tmpl_t const *vpt) |
Return true if the last attribute reference is "unresolved". More... | |
static bool | tmpl_attr_tail_is_unspecified (tmpl_t const *vpt) |
Return true if the last attribute reference is "unspecified". More... | |
static int16_t | tmpl_attr_tail_num (tmpl_t const *vpt) |
Return the last attribute reference's attribute number. More... | |
static fr_dict_attr_t const * | tmpl_attr_tail_unknown (tmpl_t const *vpt) |
Return the last attribute reference unknown da. More... | |
static char const * | tmpl_attr_tail_unresolved (tmpl_t const *vpt) |
Return the last attribute reference unresolved da. More... | |
static fr_dict_attr_t const * | tmpl_list (tmpl_t const *vpt) |
static size_t | tmpl_request_ref_count (tmpl_t const *vpt) |
The number of request references contained within a tmpl. More... | |
Field accessors for #TMPL_TYPE_XLAT | |
#define | tmpl_xlat(_tmpl) (_tmpl)->data.xlat.ex |
Field accessors for #TMPL_TYPE_DATA | |
#define | tmpl_rules_cast(_tmpl) (_tmpl)->rules.cast |
#define | tmpl_rules_enumv(_tmpl) (_tmpl)->rules.enumv |
#define | tmpl_value(_tmpl) (&(_tmpl)->data.literal) |
#define | tmpl_value_enumv(_tmpl) (_tmpl)->data.literal.enumv |
#define | tmpl_value_length(_tmpl) (_tmpl)->data.literal.vb_length |
#define | tmpl_value_type(_tmpl) (_tmpl)->data.literal.type |
Parse request qualifiers | |
int | tmpl_request_ptr (request_t **request, FR_DLIST_HEAD(tmpl_request_list) const *rql) |
Resolve a tmpl_request_ref_t to a request_t. More... | |
#define | tmpl_request_ref_is_current(_list) (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_current) == 0) |
Returns true if the specified qualifier list points to the current request. More... | |
#define | tmpl_request_ref_is_outer(_list) (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_outer) == 0) |
Returns true if the specified qualifier list points to the outer request. More... | |
#define | tmpl_request_ref_is_parent(_list) (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_parent) == 0) |
Returns true if the specified qualifier list points to the parent request. More... | |
fr_slen_t | tmpl_request_ref_list_afrom_substr (TALLOC_CTX *ctx, tmpl_attr_error_t *err, FR_DLIST_HEAD(tmpl_request_list) _CONST **out, fr_sbuff_t *in) |
int8_t | tmpl_request_ref_list_cmp (FR_DLIST_HEAD(tmpl_request_list) const *a, FR_DLIST_HEAD(tmpl_request_list) const *b) |
Compare a list of request qualifiers. More... | |
void | tmpl_request_ref_list_debug (FR_DLIST_HEAD(tmpl_request_list) const *rql) |
Dump a request list to stderr. More... | |
Functions for printing and parsing tmpl type names | |
static tmpl_type_t | tmpl_type_from_str (char const *type) |
Return the constant value representing a type. More... | |
static char const * | tmpl_type_to_str (tmpl_type_t type) |
Return a static string containing the type name. More... | |
Produce a #tmpl_t from a string or substring | |
ssize_t | tmpl_afrom_attr_str (TALLOC_CTX *ctx, tmpl_attr_error_t *err, tmpl_t **out, char const *name, tmpl_rules_t const *rules)) |
Parse a string into a TMPL_TYPE_ATTR_* type tmpl_t. More... | |
ssize_t | tmpl_afrom_attr_substr (TALLOC_CTX *ctx, tmpl_attr_error_t *err, tmpl_t **out, fr_sbuff_t *name, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules)) |
Parse a string into a TMPL_TYPE_ATTR_* type tmpl_t. More... | |
ssize_t | tmpl_afrom_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_token_t quote, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules)) |
Convert an arbitrary string into a tmpl_t. More... | |
ssize_t | tmpl_cast_from_substr (tmpl_rules_t *t_rules, fr_sbuff_t *in)) |
Parse a cast specifier. More... | |
static fr_type_t | tmpl_cast_get (tmpl_t *vpt) |
int | tmpl_cast_set (tmpl_t *vpt, fr_type_t type) |
Set a cast for a tmpl. More... | |
tmpl_t * | tmpl_copy (TALLOC_CTX *ctx, tmpl_t const *in) |
Copy a tmpl. More... | |
Change a #tmpl_t type, usually by casting or resolving a reference | |
int | tmpl_attr_tail_unresolved_add (fr_dict_t *dict, tmpl_t *vpt, fr_type_t type, fr_dict_attr_flags_t const *flags)) |
Add an unresolved fr_dict_attr_t specified by a tmpl_t to the main dictionary. More... | |
void | tmpl_attr_to_raw (tmpl_t *vpt) |
Convert the leaf attribute of a tmpl to a unknown/raw type. More... | |
int | tmpl_attr_to_xlat (TALLOC_CTX *ctx, tmpl_t **vpt_p) |
Convert an attribute reference to an xlat expansion. More... | |
int | tmpl_attr_unknown_add (tmpl_t *vpt) |
Add an unknown fr_dict_attr_t specified by a tmpl_t to the main dictionary. More... | |
int | tmpl_cast_in_place (tmpl_t *vpt, fr_type_t type, fr_dict_attr_t const *enumv)) |
Convert tmpl_t of type TMPL_TYPE_DATA_UNRESOLVED or TMPL_TYPE_DATA to TMPL_TYPE_DATA of type specified. More... | |
int | tmpl_resolve (tmpl_t *vpt, tmpl_res_rules_t const *tr_rules)) |
Attempt to resolve functions and attributes in xlats and attribute references. More... | |
void | tmpl_unresolve (tmpl_t *vpt) |
Reset the tmpl, leaving only the name in place. More... | |
Expand the tmpl, returning one or more values | |
ssize_t | _tmpl_to_atype (TALLOC_CTX *ctx, void *out, request_t *request, tmpl_t const *vpt, xlat_escape_legacy_t escape, void const *escape_ctx, fr_type_t dst_type)) |
Expand a template to a string, allocing a new buffer to hold the string. More... | |
ssize_t | _tmpl_to_type (void *out, uint8_t *buff, size_t outlen, request_t *request, tmpl_t const *vpt, xlat_escape_legacy_t escape, void const *escape_ctx, fr_type_t dst_type)) |
Expand a tmpl_t to a string writing the result to a buffer. More... | |
int | pair_append_by_tmpl_parent (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, tmpl_t const *vpt, bool skip_list)) |
Allocate and insert a leaf vp from a tmpl_t, building the parent vps if needed. More... | |
int | tmpl_copy_pair_children (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, tmpl_t const *vpt)) |
Copy children of pairs matching a tmpl_t in the current request_t. More... | |
int | tmpl_copy_pairs (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, tmpl_t const *vpt)) |
Copy pairs matching a tmpl_t in the current request_t. More... | |
int | tmpl_eval (TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *request, tmpl_t const *vpt) |
Gets the value of a tmpl. More... | |
int | tmpl_eval_cast_in_place (fr_value_box_list_t *out, request_t *request, tmpl_t const *vpt) |
Casts a value or list of values according to the tmpl. More... | |
int | tmpl_eval_pair (TALLOC_CTX *ctx, fr_value_box_list_t *out, request_t *request, tmpl_t const *vpt) |
Gets the value of a real or virtual attribute. More... | |
fr_type_t | tmpl_expanded_type (tmpl_t const *vpt) |
Return the native data type of the expression. More... | |
int | tmpl_extents_build_to_leaf_parent (fr_dlist_head_t *leaf, fr_dlist_head_t *interior, tmpl_t const *vpt) |
Allocate interior pairs. More... | |
void | tmpl_extents_debug (fr_dlist_head_t *head) |
int | tmpl_extents_find (TALLOC_CTX *ctx, fr_dlist_head_t *leaf, fr_dlist_head_t *interior, request_t *request, tmpl_t const *vpt)) |
Determines points where the reference list extends beyond the current pair tree. More... | |
int | tmpl_find_or_add_vp (fr_pair_t **out, request_t *request, tmpl_t const *vpt) |
Returns the first VP matching a tmpl_t, or if no VPs match, creates a new one. More... | |
int | tmpl_find_vp (fr_pair_t **out, request_t *request, tmpl_t const *vpt)) |
Returns the first VP matching a tmpl_t. More... | |
Structures and prototypes for templates.
These functions are used to work with tmpl_t structs.
tmpl_t (VPTs) specify either a data source, or a data sink.
Examples of sources are TMPL_TYPE_XLAT_UNRESOLVED, TMPL_TYPE_EXEC and TMPL_TYPE_ATTR. Examples of sinks are TMPL_TYPE_ATTR.
VPTs are used to gather values or attributes for evaluation, or copying, and to specify where values or fr_pair_t should be copied to.
To create new tmpl_t use one of the tmpl_*from_* functions. These parse strings into VPTs. The main parsing function is tmpl_afrom_substr, which can produce most types of VPTs. It uses the type of quoting (passed as an fr_token_t) to determine what type of VPT to parse the string as. For example a T_DOUBLE_QUOTED_STRING will produce either a TMPL_TYPE_XLAT_UNRESOLVED or a TMPL_TYPE_DATA_UNRESOLVED (depending if the string contained a non-literal expansion).
In the case of TMPL_TYPE_ATTR, there are special cursor overlay functions which can be used to iterate over only the fr_pair_t that match a tmpl_t in a given list.
Or for simplicity, there are functions which wrap the cursor functions, to copy or return the fr_pair_t that match the VPT.
If you just need the string value of whatever the VPT refers to, the tmpl_*expand functions may be used. These functions evaluate the VPT, execing, and xlat expanding as necessary. In the case of TMPL_TYPE_ATTR, and FR_TYPE_STRING or FR_TYPE_OCTETS tmpl_expand will return a pointer to the raw fr_pair_t buffer. This can be very useful when using the CONF_FLAG_TMPL type in conf_parser_t structs, as it allows the user to determine whether they want the module to sanitise the value using presentation format specific xlat_escape_legacy_t function, or to operate on the raw value.
Definition in file tmpl.h.
struct tmpl_attr_extent_t |
Describes the current extents of a pair tree in relation to the tree described by a tmpl_t.
Data Fields | ||
---|---|---|
tmpl_attr_t const * | ar |
Attribute representing the ar after the deepest node that was found in the existing pair tree when evaluating this path. If this is NULL, then all ars were evaluated. |
fr_dlist_t | entry | Entry in the dlist of extents. |
fr_pair_list_t * | list |
List that we tried to evaluate ar in and failed. Or if ar is NULL, the list that represents the deepest grouping or TLV attribute the chain of ars referenced. |
TALLOC_CTX * | list_ctx | Where to allocate new attributes if building out from the current extents of the tree. |
struct tmpl_attr_filter_t |
Data Fields | ||
---|---|---|
union tmpl_attr_filter_t | __unnamed__ | |
int16_t _CONST | num | For array references. |
tmpl_attr_filter_type_t _CONST | type | Type of filter this is. |
union tmpl_attr_filter_t.__unnamed81__ |
Data Fields | ||
---|---|---|
xlat_exp_head_t _CONST * | cond | xlat condition |
xlat_exp_head_t _CONST * | expr | xlat expression |
tmpl_t _CONST * | tmpl | tmpl |
union tmpl_attr_t.__unnamed83__ |
Data Fields | ||
---|---|---|
__unnamed83__ | unknown | |
__unnamed83__ | unresolved |
struct tmpl_attr_t.__unnamed83__.unknown |
Data Fields | ||
---|---|---|
fr_dict_attr_t *_CONST | da | Unknown dictionary attribute. |
struct tmpl_attr_t.__unnamed83__.unresolved |
struct tmpl_res_rules_s |
Similar to tmpl_rules_t, but used to specify parameters that may change during subsequent resolution passes.
When a tmpl is parsed initially the rules are stored in the tmpl_t.
During subsequent resolution phases where unresolved attributes are resolved to dictionary attributes the initial tmpl_rules_t is used to control resolution.
In some instances however (primarily policies), some rules may need change between initial parsing and subsequent resolution phases.
This structure holds rules which may override the tmpl_rules_s during subsequent resolution passes.
Data Fields | ||
---|---|---|
fr_dict_t const * | dict_def |
Alternative default dictionary to use if vpt->rules->dict_def is NULL. Will be written to vpt->rules->dict_def if used. |
fr_dict_attr_t const * | enumv | for resolving T_BARE_WORD |
bool | force_dict_def | Use supplied dict_def even if original vpt->rules->dict_def was not NULL. |
struct tmpl_rules_s |
Data Fields | ||
---|---|---|
bool | at_runtime |
Produce an ephemeral/runtime tmpl. Instantiated xlats are not added to the global trees, regexes are not JIT'd. |
tmpl_attr_rules_t | attr | Rules/data for parsing attribute references. |
fr_type_t | cast |
Whether there was an explicit cast. Used to determine if barewords or other values should be converted to an internal data type. |
fr_dict_attr_t const * | enumv | Enumeration attribute used to resolve enum values. |
tmpl_escape_t | escape | How escaping should be handled during evaluation. |
fr_value_box_safe_for_t | literals_safe_for | safe_for value assigned to literal values in xlats, execs, and data. |
tmpl_rules_t const * | parent | for parent / child relationships |
tmpl_xlat_rules_t | xlat | Rules/data for parsing xlats. |
struct tmpl_s |
A source or sink of value data.
Is used as both the RHS and LHS of a map (both update, and conditional types)
When used on the LHS it describes an attribute to create and should be one of these types:
When used on the RHS it describes the value to assign to the attribute being created and should be one of these types:
When used as part of a condition it may be any of the RHS side types, as well as:
Data Fields | ||
---|---|---|
union tmpl_s | data | |
size_t _CONST | len | Length of the raw string used to create the template. |
char const *_CONST | name |
Raw string used to create the template. this string will have any escape sequences left intact. |
fr_token_t _CONST | quote | What type of quoting was around the raw string. |
tmpl_rules_t _CONST | rules |
The rules that were used when creating the tmpl. These are useful for multiple resolution passes as they ensure the correct parsing rules are applied. |
tmpl_type_t _CONST | type | What type of value tmpl refers to. |
union tmpl_s.data |
Data Fields | ||
---|---|---|
data | __unnamed__ | |
data | attribute | |
fr_value_box_t | literal | Value data. |
char * | unescaped | Unescaped form of the name, used for TMPL_TYPE_DATA_UNRESOLVED and TMPL_TYPE_REGEX_UNCOMPILED. |
struct tmpl_s.data.__unnamed89__ |
Data Fields | ||
---|---|---|
__unnamed89__ | __unnamed__ | |
fr_regex_flags_t | reg_flags |
Flags for regular expressions. Used by:
|
union tmpl_s.data.__unnamed89__.__unnamed91__ |
Data Fields | ||
---|---|---|
__unnamed91__ | xlat |
struct tmpl_s.data.__unnamed89__.__unnamed91__.xlat |
Data Fields | ||
---|---|---|
xlat_exp_head_t * | ex | pre-parsed xlat expansion and expansion. |
struct tmpl_s.data.attribute |
struct tmpl_xlat_rules_s |
Data Fields | ||
---|---|---|
bool | new_functions | new function syntax |
fr_event_list_t * | runtime_el | The eventlist to use for runtime instantiation of xlats. |
#define ar_filter_is_cond | ( | _ar | ) | ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_CONDITION) |
#define ar_filter_is_expr | ( | _ar | ) | ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_EXPR) |
#define ar_filter_is_none | ( | _ar | ) | ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_NONE) |
#define ar_filter_is_num | ( | _ar | ) | ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_INDEX) |
#define ar_filter_is_tmpl | ( | _ar | ) | ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_TMPL) |
#define ar_filter_type filter.type |
#define ar_is_normal | ( | _ar | ) | ((_ar)->ar_type == TMPL_ATTR_TYPE_NORMAL) |
#define ar_is_unknown | ( | _ar | ) | ((_ar)->ar_type == TMPL_ATTR_TYPE_UNKNOWN) |
#define ar_is_unresolved | ( | _ar | ) | ((_ar)->ar_type == TMPL_ATTR_TYPE_UNRESOLVED) |
#define ar_is_unspecified | ( | _ar | ) | ((_ar)->ar_type == TMPL_ATTR_TYPE_UNSPEC) |
#define ar_unresolved unresolved.name |
#define FR_TYPE_FROM_PTR | ( | _ptr | ) |
Map ptr type to a boxed type.
#define tmpl_aexpand | ( | _ctx, | |
_out, | |||
_request, | |||
_vpt, | |||
_escape, | |||
_escape_ctx | |||
) | _tmpl_to_atype(_ctx, (void *)(_out), _request, _vpt, _escape, _escape_ctx, FR_TYPE_FROM_PTR(_out)) |
Expand a tmpl to a C type, allocing a new buffer to hold the string.
Expands a template using the _out ptr to determinate the cast type.
#define tmpl_aexpand_type | ( | _ctx, | |
_out, | |||
_type, | |||
_request, | |||
_vpt, | |||
_escape, | |||
_escape_ctx | |||
) | _tmpl_to_atype(_ctx, (void *)(_out), _request, _vpt, _escape, _escape_ctx, _type) |
Expand a tmpl to a C type, allocing a new buffer to hold the string.
Takes an explicit type which must match the ctype pointed to by out.
#define tmpl_assert_type | ( | _cond | ) |
Convenience macro for printing a meaningful assert message when we get a bad tmpl type.
#define tmpl_contains_attr | ( | vpt | ) | (vpt->type & TMPL_FLAG_ATTR) |
#define tmpl_contains_regex | ( | vpt | ) | (vpt->type & TMPL_FLAG_REGEX) |
#define tmpl_contains_xlat | ( | vpt | ) | (vpt->type & TMPL_FLAG_XLAT) |
#define tmpl_expand | ( | _out, | |
_buff, | |||
_buff_len, | |||
_request, | |||
_vpt, | |||
_escape, | |||
_escape_ctx | |||
) |
Expand a tmpl to a C type, using existing storage to hold variably sized types.
Expands a template using the _out ptr to determinate the cast type.
#define TMPL_FLAG_ATTR 0x01000000 |
#define TMPL_FLAG_REGEX 0x04000000 |
#define TMPL_FLAG_XLAT 0x02000000 |
#define tmpl_is_attr_unresolved | ( | vpt | ) | (vpt->type == TMPL_TYPE_ATTR_UNRESOLVED) |
#define tmpl_is_data_unresolved | ( | vpt | ) | (vpt->type == TMPL_TYPE_DATA_UNRESOLVED) |
#define tmpl_is_exec_unresolved | ( | vpt | ) | (vpt->type == TMPL_TYPE_EXEC_UNRESOLVED) |
#define tmpl_is_regex_uncompiled | ( | vpt | ) | (vpt->type == TMPL_TYPE_REGEX_UNCOMPILED) |
#define tmpl_is_regex_xlat | ( | vpt | ) | (vpt->type == TMPL_TYPE_REGEX_XLAT) |
#define tmpl_is_regex_xlat_unresolved | ( | vpt | ) | (vpt->type == TMPL_TYPE_REGEX_XLAT_UNRESOLVED) |
#define tmpl_is_uninitialised | ( | vpt | ) | (vpt->type == TMPL_TYPE_UNINITIALISED) |
#define tmpl_is_xlat_unresolved | ( | vpt | ) | (vpt->type == TMPL_TYPE_XLAT_UNRESOLVED) |
#define TMPL_MAX_REQUEST_REF_NESTING 10 |
#define tmpl_needs_resolving | ( | vpt | ) | (vpt->type & TMPL_FLAG_UNRESOLVED) |
#define tmpl_pair_list_and_ctx | ( | _ctx, | |
_head, | |||
_request, | |||
_ref, | |||
_list | |||
) |
Determine the correct context and list head.
Used in conjunction with the fr_dcursor functions to determine the correct list and TALLOC_CTX for inserting fr_pair_ts.
Example:
#define TMPL_POOL_DEF_HEADERS 4 |
#define TMPL_POOL_DEF_LEN (sizeof(tmpl_t) + 64 + sizeof(tmpl_attr_t) + sizeof(tmpl_request_t)) |
#define tmpl_request_ref_is_current | ( | _list | ) | (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_current) == 0) |
#define tmpl_request_ref_is_outer | ( | _list | ) | (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_outer) == 0) |
#define tmpl_request_ref_is_parent | ( | _list | ) | (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_parent) == 0) |
#define tmpl_value_enumv | ( | _tmpl | ) | (_tmpl)->data.literal.enumv |
#define tmpl_value_length | ( | _tmpl | ) | (_tmpl)->data.literal.vb_length |
#define tmpl_value_type | ( | _tmpl | ) | (_tmpl)->data.literal.type |
typedef struct tmpl_attr_rules_s tmpl_attr_rules_t |
typedef struct tmpl_literal_rules_s tmpl_literal_rules_t |
typedef enum requests_ref_e tmpl_request_ref_t |
typedef struct tmpl_res_rules_s tmpl_res_rules_t |
typedef struct tmpl_rules_s tmpl_rules_t |
typedef enum tmpl_type_e tmpl_type_t |
typedef struct tmpl_xlat_rules_s tmpl_xlat_rules_t |
enum requests_ref_e |
enum tmpl_attr_error_t |
Define entry and head types for attribute reference lists.
Different types of filter that can be applied to an attribute reference
enum tmpl_attr_prefix_t |
Specify whether attribute references require a prefix.
enum tmpl_attr_type_t |
enum tmpl_type_e |
Types of tmpl_t.
Types may be compound types made up of multiple other types.
Types which are used as part of compound types are:
ssize_t _tmpl_to_atype | ( | TALLOC_CTX * | ctx, |
void * | out, | ||
request_t * | request, | ||
tmpl_t const * | vpt, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx, | ||
fr_type_t | dst_type | ||
) |
Expand a template to a string, allocing a new buffer to hold the string.
The intended use of tmpl_expand and tmpl_aexpand is for modules to easily convert a tmpl_t provided by the conf parser, into a usable value. The value returned should be raw and undoctored for FR_TYPE_STRING and FR_TYPE_OCTETS types, and the printable (string) version of the data for all others.
This function will always duplicate values, whereas tmpl_expand may return a pointer to an existing buffer.
ctx | to allocate new buffer in. |
out | Where to write pointer to the new buffer. |
request | Current request. |
vpt | to expand. Must be one of the following types: |
escape | xlat escape function (only used for TMPL_TYPE_XLAT_UNRESOLVED_* types). |
escape_ctx | xlat escape function data (only used for TMPL_TYPE_XLAT_UNRESOLVED_* types). |
dst_type | FR_TYPE_* matching out pointer. |
Definition at line 563 of file tmpl_eval.c.
ssize_t _tmpl_to_type | ( | void * | out, |
uint8_t * | buff, | ||
size_t | bufflen, | ||
request_t * | request, | ||
tmpl_t const * | vpt, | ||
xlat_escape_legacy_t | escape, | ||
void const * | escape_ctx, | ||
fr_type_t | dst_type | ||
) |
Expand a tmpl_t to a string writing the result to a buffer.
The intended use of tmpl_expand and tmpl_aexpand is for modules to easily convert a tmpl_t provided by the conf parser, into a usable value. The value returned should be raw and undoctored for FR_TYPE_STRING and FR_TYPE_OCTETS types, and the printable (string) version of the data for all others.
Depending what arguments are passed, either copies the value to buff, or writes a pointer to a string buffer to out. This allows the most efficient access to the value resolved by the tmpl_t, avoiding unnecessary string copies.
[out] | out | Where to write a pointer to the string buffer. On return may point to buff if buff was used to store the value. Otherwise will point to a fr_value_box_t buffer, or the name of the template. Must not be NULL. |
[out] | buff | Expansion buffer, may be NULL except for the following types: |
[in] | bufflen | Length of expansion buffer. Must be >= 2. |
[in] | request | Current request. |
[in] | vpt | to expand. Must be one of the following types: |
[in] | escape | xlat escape function (only used for xlat types). |
[in] | escape_ctx | xlat escape function data. |
dst_type | FR_TYPE_* matching out pointer. |
Definition at line 284 of file tmpl_eval.c.
|
inlinestatic |
int pair_append_by_tmpl_parent | ( | TALLOC_CTX * | ctx, |
fr_pair_t ** | out, | ||
fr_pair_list_t * | list, | ||
tmpl_t const * | vpt, | ||
bool | skip_list | ||
) |
Allocate and insert a leaf vp from a tmpl_t, building the parent vps if needed.
This is the simple case - just add a vp at the first place where the parents exist, or create the parents, with no attempt to handle filters.
It is functionally equivalent to fr_pair_append_by_da_parent() but uses a tmpl_t to build the nested structure rather than a fr_dict_attr_t.
[in] | ctx | to allocate new pair(s) in |
[out] | out | Leaf pair we allocated. |
[in] | list | to insert into. |
[in] | vpt | tmpl representing the attribute to add. |
[in] | skip_list | skip list attr ref at the head of the tmpl. |
Definition at line 974 of file tmpl_eval.c.
ssize_t tmpl_afrom_attr_str | ( | TALLOC_CTX * | ctx, |
tmpl_attr_error_t * | err, | ||
tmpl_t ** | out, | ||
char const * | name, | ||
tmpl_rules_t const * | t_rules | ||
) |
Parse a string into a TMPL_TYPE_ATTR_* type tmpl_t.
[in,out] | ctx | to allocate tmpl_t in. |
[out] | err | May be NULL. Provides the exact error that the parser hit when processing the attribute ref. |
[out] | out | Where to write pointer to new tmpl_t. |
[in] | name | of attribute including tmpl_request_ref_t and fr_pair_list_t qualifiers. |
[in] | t_rules | Rules which control parsing. See tmpl_afrom_attr_substr() for details. |
Definition at line 2475 of file tmpl_tokenize.c.
ssize_t tmpl_afrom_attr_substr | ( | TALLOC_CTX * | ctx, |
tmpl_attr_error_t * | err, | ||
tmpl_t ** | out, | ||
fr_sbuff_t * | name, | ||
fr_sbuff_parse_rules_t const * | p_rules, | ||
tmpl_rules_t const * | t_rules | ||
) |
Parse a string into a TMPL_TYPE_ATTR_* type tmpl_t.
[in,out] | ctx | to allocate tmpl_t in. |
[out] | err | May be NULL. Provides the exact error that the parser hit when processing the attribute ref. |
[out] | out | Where to write pointer to new tmpl_t. |
[in] | name | of attribute including tmpl_request_ref_t and fr_pair_list_t qualifiers. |
[in] | p_rules | Formatting rules used to check for trailing garbage. |
[in] | t_rules | Rules which control parsing:
|
Definition at line 2211 of file tmpl_tokenize.c.
ssize_t tmpl_afrom_substr | ( | TALLOC_CTX * | ctx, |
tmpl_t ** | out, | ||
fr_sbuff_t * | in, | ||
fr_token_t | quote, | ||
fr_sbuff_parse_rules_t const * | p_rules, | ||
tmpl_rules_t const * | t_rules | ||
) |
Convert an arbitrary string into a tmpl_t.
[in,out] | ctx | To allocate tmpl_t in. |
[out] | out | Where to write the pointer to the new tmpl_t. |
[in] | in | String to parse. |
[in] | quote | Quoting around the tmpl. Determines what we attempt to parse the string as. |
[in] | p_rules | Formatting rules for the tmpl. |
[in] | t_rules | Validation rules for attribute references. |
Definition at line 3177 of file tmpl_tokenize.c.
int tmpl_afrom_value_box | ( | TALLOC_CTX * | ctx, |
tmpl_t ** | out, | ||
fr_value_box_t * | data, | ||
bool | steal | ||
) |
Create a tmpl_t from a fr_value_box_t.
[in,out] | ctx | to allocate tmpl_t in. |
[out] | out | Where to write pointer to new tmpl_t. |
[in] | data | to convert. |
[in] | steal | If true, any buffers are moved to the new ctx instead of being duplicated. |
Definition at line 1006 of file tmpl_tokenize.c.
tmpl_t* tmpl_alloc | ( | TALLOC_CTX * | ctx, |
tmpl_type_t | type, | ||
fr_token_t | quote, | ||
char const * | name, | ||
ssize_t | len | ||
) |
Create a new heap allocated tmpl_t.
[in,out] | ctx | to allocate in. |
[in] | type | to set in the tmpl_t. |
[in] | name | of the tmpl_t (will be copied to a new talloc buffer parented by the tmpl_t). |
[in] | len | The length of the buffer (or a substring of the buffer) pointed to by name. If < 0 strlen will be used to determine the length. |
[in] | quote | The type of quoting around the template name. |
Definition at line 949 of file tmpl_tokenize.c.
|
inlinestatic |
|
inlinestatic |
Return whether or not async is required for this tmpl.
If the tmpl is needs_async, then it is async If the tmpl is not needs_async, then it will not yield If the tmpl yields, then async is required.
Definition at line 5751 of file tmpl_tokenize.c.
int tmpl_attr_afrom_list | ( | TALLOC_CTX * | ctx, |
tmpl_t ** | out, | ||
tmpl_t const * | list, | ||
fr_dict_attr_t const * | da | ||
) |
Create a new tmpl from a list tmpl and a da.
Definition at line 1239 of file tmpl_tokenize.c.
|
inlinestatic |
Copy a list of attribute and request references from one tmpl to another.
Definition at line 1036 of file tmpl_tokenize.c.
void tmpl_attr_debug | ( | tmpl_t const * | vpt | ) |
Definition at line 273 of file tmpl_tokenize.c.
|
inlinestatic |
fr_slen_t tmpl_attr_list_from_substr | ( | fr_dict_attr_t const ** | da_p, |
fr_sbuff_t * | in | ||
) |
Parse one a single list reference.
[out] | da_p | attribute representing a list. |
[in] | in | Sbuff to read request references from. |
Definition at line 401 of file tmpl_tokenize.c.
static fr_slen_t rql fr_slen_t tmpl_attr_print | ( | fr_sbuff_t * | out, |
tmpl_t const * | vpt, | ||
tmpl_attr_prefix_t | ar_prefix | ||
) |
Print an attribute or list tmpl_t to a string.
This function is the direct counterpart to tmpl_afrom_attr_substr.
[in] | out | Where to write the presentation format tmpl_t string. |
[in] | vpt | to print. |
[in] | ar_prefix | Whether to print the '&' at the beginning of attribute references.
|
Definition at line 4625 of file tmpl_tokenize.c.
void tmpl_attr_ref_debug | ( | const tmpl_attr_t * | ar, |
int | idx | ||
) |
Definition at line 198 of file tmpl_tokenize.c.
void tmpl_attr_ref_list_debug | ( | FR_DLIST_HEAD(tmpl_attr_list) const * | ar_head | ) |
Definition at line 258 of file tmpl_tokenize.c.
void tmpl_attr_rewrite_leaf_num | ( | tmpl_t * | vpt, |
int16_t | to | ||
) |
Rewrite the leaf's instance number.
This function is only called from the compiler, for "update" and "foreach" keywords. In those cases, the user historically did "&foo-bar", but really meant "&foo-bar[*]". We silently update that for "update" sections, and complain about it in "foreach" sections.
As the server now supports multiple types of leaf references, we do the rewrite only from "none" (no filter), OR where it's a numerical index, AND the index hasn't been specified.
Definition at line 1187 of file tmpl_tokenize.c.
int tmpl_attr_set_da | ( | tmpl_t * | vpt, |
fr_dict_attr_t const * | da | ||
) |
Replace the current attribute reference.
Definition at line 1087 of file tmpl_tokenize.c.
int tmpl_attr_set_leaf_da | ( | tmpl_t * | vpt, |
fr_dict_attr_t const * | da | ||
) |
Replace the leaf attribute only.
Definition at line 1120 of file tmpl_tokenize.c.
void tmpl_attr_set_list | ( | tmpl_t * | vpt, |
fr_dict_attr_t const * | list | ||
) |
Definition at line 1228 of file tmpl_tokenize.c.
void tmpl_attr_set_request_ref | ( | tmpl_t * | vpt, |
FR_DLIST_HEAD(tmpl_request_list) const * | request_def | ||
) |
Set the request for an attribute ref.
Definition at line 1214 of file tmpl_tokenize.c.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
int tmpl_attr_tail_unresolved_add | ( | fr_dict_t * | dict_def, |
tmpl_t * | vpt, | ||
fr_type_t | type, | ||
fr_dict_attr_flags_t const * | flags | ||
) |
Add an unresolved fr_dict_attr_t specified by a tmpl_t to the main dictionary.
[in] | dict_def | Default dictionary to use if none is specified by the tmpl_attr_tail_unresolved. |
[in] | vpt | specifying unresolved attribute to add. tmpl_attr_tail_da pointer will be updated to point to the fr_dict_attr_t inserted into the dictionary. Lists and requests will be preserved. |
[in] | type | to define unresolved attribute as. |
[in] | flags | to define unresolved attribute with. |
Definition at line 4519 of file tmpl_tokenize.c.
void tmpl_attr_to_raw | ( | tmpl_t * | vpt | ) |
Convert the leaf attribute of a tmpl to a unknown/raw type.
Definition at line 4403 of file tmpl_tokenize.c.
int tmpl_attr_to_xlat | ( | TALLOC_CTX * | ctx, |
tmpl_t ** | vpt_p | ||
) |
Convert an attribute reference to an xlat expansion.
This is where a user attempts to use an attribute reference which is actually a virtual attribute.
[in] | ctx | to convert new tmpl in. |
[in,out] | vpt_p | pointer to tmpl_t of TMPL_TYPE_ATTR | TMPL_TYPE_ATTR_UNPARSED. |
Definition at line 4343 of file tmpl_tokenize.c.
int tmpl_attr_unknown_add | ( | tmpl_t * | vpt | ) |
Add an unknown fr_dict_attr_t specified by a tmpl_t to the main dictionary.
vpt | to add. tmpl_attr_tail_da pointer will be updated to point to the fr_dict_attr_t inserted into the dictionary. |
Definition at line 4417 of file tmpl_tokenize.c.
ssize_t tmpl_cast_from_substr | ( | tmpl_rules_t * | rules, |
fr_sbuff_t * | in | ||
) |
Parse a cast specifier.
Note that casts are
(foo)
and NOT
( foo )
Not for any particular reason, but to emphasize a bit that they're not mathematical expressions.
[out] | rules | to set the cast type in. |
[in] | in | String containing the cast marker. |
Definition at line 3622 of file tmpl_tokenize.c.
int tmpl_cast_in_place | ( | tmpl_t * | vpt, |
fr_type_t | type, | ||
fr_dict_attr_t const * | enumv | ||
) |
Convert tmpl_t of type TMPL_TYPE_DATA_UNRESOLVED or TMPL_TYPE_DATA to TMPL_TYPE_DATA of type specified.
[in,out] | vpt | The template to modify. Must be of type TMPL_TYPE_DATA_UNRESOLVED or TMPL_TYPE_DATA. |
[in] | type | to cast to. |
[in] | enumv | Enumerated dictionary values associated with a fr_dict_attr_t. |
Definition at line 3855 of file tmpl_tokenize.c.
Set a cast for a tmpl.
[in,out] | vpt | to set cast for. |
[in] | dst_type | to set. |
Definition at line 3668 of file tmpl_tokenize.c.
Copy a tmpl.
Fully duplicates the contents of a tmpl including any nested attribute references.
[in] | ctx | to perform allocations under. |
[in] | in | tmpl to duplicate. |
Definition at line 3541 of file tmpl_tokenize.c.
int tmpl_copy_pair_children | ( | TALLOC_CTX * | ctx, |
fr_pair_list_t * | out, | ||
request_t * | request, | ||
tmpl_t const * | vpt | ||
) |
Copy children of pairs matching a tmpl_t in the current request_t.
ctx | to allocate new fr_pair_t in. |
out | Where to write the copied fr_pair_t (s). |
request | The current request_t. |
vpt | specifying the fr_pair_t type or list to copy. Must be one of the following types: |
Definition at line 841 of file tmpl_eval.c.
int tmpl_copy_pairs | ( | TALLOC_CTX * | ctx, |
fr_pair_list_t * | out, | ||
request_t * | request, | ||
tmpl_t const * | vpt | ||
) |
Copy pairs matching a tmpl_t in the current request_t.
ctx | to allocate new fr_pair_t in. |
out | Where to write the copied fr_pair_t (s). |
request | The current request_t. |
vpt | specifying the fr_pair_t type or list to copy. Must be one of the following types: |
Definition at line 798 of file tmpl_eval.c.
void tmpl_debug | ( | tmpl_t const * | vpt | ) |
Definition at line 312 of file tmpl_tokenize.c.
int tmpl_eval | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t * | out, | ||
request_t * | request, | ||
tmpl_t const * | vpt | ||
) |
Gets the value of a tmpl.
The result is returned "raw". The caller must do any escaping it desires.
[in] | ctx | to allocate boxed value, and buffers in. |
[out] | out | Where to write the boxed value. |
[in] | request | The current request. |
[in] | vpt | Representing the tmpl |
Definition at line 1221 of file tmpl_eval.c.
Casts a value or list of values according to the tmpl.
[in,out] | list | Where to write the boxed value. |
[in] | request | The current request. |
[in] | vpt | Representing the attribute. |
Definition at line 1349 of file tmpl_eval.c.
int tmpl_eval_pair | ( | TALLOC_CTX * | ctx, |
fr_value_box_list_t * | out, | ||
request_t * | request, | ||
tmpl_t const * | vpt | ||
) |
Gets the value of a real or virtual attribute.
[in] | ctx | to allocate boxed value, and buffers in. |
[out] | out | Where to write the boxed value. |
[in] | request | The current request. |
[in] | vpt | Representing the attribute. |
Definition at line 1077 of file tmpl_eval.c.
Return the native data type of the expression.
[in] | vpt | to determine the type of. |
Definition at line 209 of file tmpl_eval.c.
int tmpl_extents_build_to_leaf_parent | ( | fr_dlist_head_t * | existing, |
fr_dlist_head_t * | to_build, | ||
tmpl_t const * | vpt | ||
) |
Allocate interior pairs.
Builds out the pair tree to the point where leaf attributes can be added
[out] | existing | List to add built out attributes to. |
[in] | to_build | List to remove attributes from. |
[in] | vpt | We are evaluating. |
Definition at line 695 of file tmpl_dcursor.c.
void tmpl_extents_debug | ( | fr_dlist_head_t * | head | ) |
int tmpl_extents_find | ( | TALLOC_CTX * | ctx, |
fr_dlist_head_t * | existing, | ||
fr_dlist_head_t * | to_build, | ||
request_t * | request, | ||
tmpl_t const * | vpt | ||
) |
Determines points where the reference list extends beyond the current pair tree.
If a particular branch in the VP hierarchy is incomplete, i.e. the chain of attribute refers to nodes deeper than the nodes currently in the tree, then we return the deepest point node in the tree which matched, and the ar that we failed to evaluate.
If the reference list resolves to one or more structural pairs, return those as well.
This function can be used for a number of different operations, but it's most useful for determining insertion points for new attributes, or determining which attributes need to be updated.
[in] | ctx | to allocate. It's recommended to pass a pool with space for at least five extent structures. |
[out] | existing | List of extents we discovered by evaluating all attribute references. May be NULL. |
[out] | to_build | List of extents that need building out, i.e. references extend beyond pairs. May be NULL. |
[in] | request | The current request_t. |
[in] | vpt | specifying the fr_pair_t type to retrieve or create. Must be TMPL_TYPE_ATTR. |
Definition at line 569 of file tmpl_dcursor.c.
Returns the first VP matching a tmpl_t, or if no VPs match, creates a new one.
[out] | out | where to write the retrieved or created vp. |
[in] | request | The current request_t. |
[in] | vpt | specifying the fr_pair_t type to retrieve or create. Must be TMPL_TYPE_ATTR. |
Definition at line 918 of file tmpl_eval.c.
Returns the first VP matching a tmpl_t.
[out] | out | where to write the retrieved vp. |
[in] | request | The current request_t. |
[in] | vpt | specifying the fr_pair_t type to find. Must be one of the following types: |
Definition at line 889 of file tmpl_eval.c.
int tmpl_global_init | ( | void | ) |
Definition at line 1485 of file tmpl_eval.c.
tmpl_t* tmpl_init | ( | tmpl_t * | vpt, |
tmpl_type_t | type, | ||
fr_token_t | quote, | ||
char const * | name, | ||
ssize_t | len, | ||
tmpl_rules_t const * | t_rules | ||
) |
Initialise a tmpl using a literal string to create the name.
[in] | vpt | to initialise. |
[in] | type | of tmpl to initialise. |
[in] | quote | Original quoting around the name. |
[in] | name | to set for the tmpl. |
[in] | len | Name length. If < 0 strlen will be used to determine the name. |
[in] | t_rules | used during parsing. |
Definition at line 905 of file tmpl_tokenize.c.
tmpl_t* tmpl_init_printf | ( | tmpl_t * | vpt, |
tmpl_type_t | type, | ||
fr_token_t | quote, | ||
char const * | fmt, | ||
... | |||
) |
Initialise a tmpl using a format string to create the name.
[in] | vpt | to initialise. |
[in] | type | of tmpl to initialise. |
[in] | quote | Original quoting around the name. |
[in] | fmt | string. |
[in] | ... | format arguments. |
Definition at line 853 of file tmpl_tokenize.c.
tmpl_t* tmpl_init_shallow | ( | tmpl_t * | vpt, |
tmpl_type_t | type, | ||
fr_token_t | quote, | ||
char const * | name, | ||
ssize_t | len, | ||
tmpl_rules_t const * | t_rules | ||
) |
Initialise a tmpl without copying the input name string.
[out] | vpt | to initialise. |
[in] | type | to set in the tmpl_t. |
[in] | quote | The type of quoting around the template name. |
[in] | name | of the tmpl_t. |
[in] | len | The length of the buffer (or a substring of the buffer) pointed to by name. If < 0 strlen will be used to determine the length. |
[in] | t_rules | used during parsing. |
Definition at line 883 of file tmpl_tokenize.c.
|
inlinestatic |
TALLOC_CTX* tmpl_list_ctx | ( | request_t * | request, |
fr_dict_attr_t const * | list | ||
) |
Return the correct TALLOC_CTX to alloc fr_pair_t in, for a list.
Allocating new fr_pair_t in the context of a request_t is usually wrong. fr_pair_t should be allocated in the context of a fr_packet_t, so that if the fr_packet_t is freed before the request_t, the associated fr_pair_t lists are freed too.
[in] | request | containing the target lists. |
[in] | list | fr_pair_list_t value to resolve to TALLOC_CTX. |
Definition at line 116 of file tmpl_eval.c.
fr_pair_list_t* tmpl_list_head | ( | request_t * | request, |
fr_dict_attr_t const * | list | ||
) |
Resolve attribute fr_pair_list_t value to an attribute list.
The value returned is a pointer to the pointer of the HEAD of a fr_pair_t list in the request_t. If the head of the list changes, the pointer will still be valid.
[in] | request | containing the target lists. |
[in] | list | fr_pair_list_t value to resolve to fr_pair_t list. Will be NULL if list name couldn't be resolved. |
Definition at line 76 of file tmpl_eval.c.
|
inlinestatic |
fr_packet_t* tmpl_packet_ptr | ( | request_t * | request, |
fr_dict_attr_t const * | list | ||
) |
Resolve a list to the fr_packet_t holding the HEAD pointer for a fr_pair_t list.
Returns a pointer to the fr_packet_t that holds the HEAD pointer of a given list, for the current request_t.
[in] | request | To resolve list in. |
[in] | list | fr_pair_list_t value to resolve to fr_packet_t. |
Definition at line 146 of file tmpl_eval.c.
ssize_t tmpl_preparse | ( | char const ** | out, |
size_t * | outlen, | ||
char const * | in, | ||
size_t | inlen, | ||
fr_token_t * | type | ||
) |
Preparse a string in preparation for passing it to tmpl_afrom_substr()
Note that the input string is not modified, which means that the tmpl_afrom_substr() function MUST un-escape it.
The caller should pass 'out' and 'outlen' to tmpl_afrom_substr() as 'in' and 'inlen'. The caller should also pass 'type'. The caller should also pass do_unescape=true.
[out] | out | start of the string to parse |
[out] | outlen | length of the string to parse |
in | where we start looking for the string | |
inlen | length of the input string | |
[out] | type | token type of the string. |
Definition at line 5348 of file tmpl_tokenize.c.
static fr_slen_t ar_prefix fr_slen_t tmpl_print | ( | fr_sbuff_t * | out, |
tmpl_t const * | vpt, | ||
tmpl_attr_prefix_t | ar_prefix, | ||
fr_sbuff_escape_rules_t const * | e_rules | ||
) |
Print a tmpl_t to a string.
This function should primarily be used for regenerating vpt->name when the contents of the tmpl_t is changed programmatically, or when the tmpl_t is being serialized in some non-standard way, i.e. as a value for a field in a database.
This function is the direct counterpart to tmpl_afrom_substr.
[out] | out | Where to write the presentation format tmpl_t string. |
[in] | vpt | to print. |
[in] | ar_prefix | Whether to print the '&' at the beginning of attribute references.
|
[in] | e_rules | Escaping rules used to print strings. |
Definition at line 237 of file merged_model.c.
static fr_slen_t e_rules fr_slen_t tmpl_print_quoted | ( | fr_sbuff_t * | out, |
tmpl_t const * | vpt, | ||
tmpl_attr_prefix_t | ar_prefix | ||
) |
Print a tmpl_t to a string with quotes.
This function should be used when the tmpl is embedded in some other construct in the server's configuration.
It adds standard quoting around tmpl's used as operands in expressions and applies the correct escaping rules.
[out] | out | Where to write the presentation format tmpl_t string. |
[in] | vpt | to print. |
[in] | ar_prefix | Whether to print the '&' at the beginning of attribute references.
|
Definition at line 4915 of file tmpl_tokenize.c.
int tmpl_request_ptr | ( | request_t ** | context, |
FR_DLIST_HEAD(tmpl_request_list) const * | rql | ||
) |
Resolve a tmpl_request_ref_t to a request_t.
Sometimes request_t structs may be chained to each other, as is the case when internally proxying EAP. This function resolves a tmpl_request_ref_t to a request_t higher in the chain than the current request_t.
[in,out] | context | request_t to start resolving from, and where to write a pointer to the resolved request_t back to. |
[in] | rql | list of request qualifiers to follow. |
Definition at line 169 of file tmpl_eval.c.
fr_slen_t tmpl_request_ref_list_afrom_substr | ( | TALLOC_CTX * | ctx, |
tmpl_attr_error_t * | err, | ||
FR_DLIST_HEAD(tmpl_request_list) _CONST ** | out, | ||
fr_sbuff_t * | in | ||
) |
|
inlinestatic |
int8_t tmpl_request_ref_list_cmp | ( | FR_DLIST_HEAD(tmpl_request_list) const * | a, |
FR_DLIST_HEAD(tmpl_request_list) const * | b | ||
) |
Compare a list of request qualifiers.
[in] | a | first list. If NULL tmpl_request_def_current will be used. |
[in] | b | second list. If NULL tmpl_request_def_current will be used. |
Definition at line 485 of file tmpl_tokenize.c.
void tmpl_request_ref_list_debug | ( | FR_DLIST_HEAD(tmpl_request_list) const * | rql | ) |
Dump a request list to stderr.
Definition at line 465 of file tmpl_tokenize.c.
fr_slen_t tmpl_request_ref_list_print | ( | fr_sbuff_t * | out, |
FR_DLIST_HEAD(tmpl_request_list) const * | rql | ||
) |
Definition at line 4591 of file tmpl_tokenize.c.
int tmpl_resolve | ( | tmpl_t * | vpt, |
tmpl_res_rules_t const * | tr_rules | ||
) |
Attempt to resolve functions and attributes in xlats and attribute references.
[in,out] | vpt | to resolve. Should be of type TMPL_TYPE_XLAT_UNRESOLVED or TMPL_TYPE_ATTR_UNRESOLVED. All other types will be noops. |
[in] | tr_rules | Combined with the original parse rules for additional resolution passes. |
Definition at line 4163 of file tmpl_tokenize.c.
void tmpl_rules_child_init | ( | TALLOC_CTX * | ctx, |
tmpl_rules_t * | out, | ||
tmpl_rules_t const * | parent, | ||
tmpl_t * | vpt | ||
) |
Initialize a set of rules from a parent set of rules, and a parsed tmpl_t.
Definition at line 5773 of file tmpl_tokenize.c.
void tmpl_rules_debug | ( | tmpl_rules_t const * | rules | ) |
Change the default dictionary in the tmpl's resolution rules.
[in] | vpt | to alter. |
[in] | dict | to set. |
Definition at line 816 of file tmpl_tokenize.c.
void tmpl_set_escape | ( | tmpl_t * | vpt, |
tmpl_escape_t const * | escape | ||
) |
Set escape parameters for the tmpl output.
[in] | vpt | to alter. |
[in] | escape | to set. |
Definition at line 826 of file tmpl_tokenize.c.
void tmpl_set_name | ( | tmpl_t * | vpt, |
fr_token_t | quote, | ||
char const * | name, | ||
ssize_t | len | ||
) |
Set the name on a pre-initialised tmpl.
[in] | vpt | to set the name for. |
[in] | quote | Original quoting around the name. |
[in] | name | of the tmpl_t. |
[in] | len | The length of the buffer (or a substring of the buffer) pointed to by name. If < 0 strlen will be used to determine the length. |
Definition at line 800 of file tmpl_tokenize.c.
void tmpl_set_name_printf | ( | tmpl_t * | vpt, |
fr_token_t | quote, | ||
char const * | fmt, | ||
... | |||
) |
Set the name on a pre-initialised tmpl.
[in] | vpt | to set the name for. |
[in] | quote | Original quoting around the name. |
[in] | fmt | string. |
[in] | ... | format arguments. |
Definition at line 759 of file tmpl_tokenize.c.
void tmpl_set_name_shallow | ( | tmpl_t * | vpt, |
fr_token_t | quote, | ||
char const * | name, | ||
ssize_t | len | ||
) |
Set the name on a pre-initialised tmpl.
[in] | vpt | to set the name for. |
[in] | quote | Original quoting around the name. |
[in] | name | of the tmpl_t. |
[in] | len | The length of the buffer (or a substring of the buffer) pointed to by name. If < 0 strlen will be used to determine the length. |
Definition at line 783 of file tmpl_tokenize.c.
void tmpl_set_xlat | ( | tmpl_t * | vpt, |
xlat_exp_head_t * | xlat | ||
) |
Change the default dictionary in the tmpl's resolution rules.
[in] | vpt | to alter. |
[in] | xlat | to set. |
Definition at line 836 of file tmpl_tokenize.c.
|
inlinestatic |
|
inlinestatic |
void tmpl_unresolve | ( | tmpl_t * | vpt | ) |
Reset the tmpl, leaving only the name in place.
After calling this function, the tmpl type will revert to TMPL_TYPE_DATA_UNRESOLVED and only the name and quoting will be preserved.
[in] | vpt | to reset. |
Definition at line 4278 of file tmpl_tokenize.c.
int tmpl_value_list_insert_tail | ( | fr_value_box_list_t * | list, |
fr_value_box_t * | box, | ||
tmpl_t const * | vpt | ||
) |
Insert a value-box to a list, with casting.
list | to append to |
box | box to cast / append |
vpt | tmpl with cast. |
Definition at line 1052 of file tmpl_eval.c.
|
extern |
|
extern |
|
extern |
Map keywords to tmpl_request_ref_t values.
Definition at line 147 of file tmpl_tokenize.c.
|
extern |
Definition at line 152 of file tmpl_tokenize.c.
|
extern |
Map tmpl_type_t values to descriptive strings.
Definition at line 112 of file tmpl_tokenize.c.
|
extern |
Definition at line 133 of file tmpl_tokenize.c.