The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
fr_pair_t template functions More...
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/base16.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/value.h>
#include <ctype.h>
Go to the source code of this file.
Macros | |
#define | _TMPL_PRIVATE 1 |
#define | DEFAULT_RULES tmpl_rules_t const default_rules = { .attr = { .list_def = request_attr_request }} |
Default parser rules. | |
#define | RESOLVED_SET(_flags) (*(_flags) = (*(_flags) & ~TMPL_FLAG_UNRESOLVED)) |
#define | return_P(_x) fr_strerror_const(_x);goto return_p |
#define | TMPL_REQUEST_REF_DEF(_name, _ref) |
Define a global variable for specifying a default request reference. | |
#define | UNRESOLVED_SET(_flags) (*(_flags) = (*(_flags) | TMPL_FLAG_UNRESOLVED)) |
Functions | |
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. | |
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. | |
static fr_slen_t | tmpl_afrom_bool_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
Parse a truth value. | |
static ssize_t | tmpl_afrom_enum (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules) |
static ssize_t | tmpl_afrom_ether_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
Try and parse signed or unsigned integers. | |
static ssize_t | tmpl_afrom_float_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
static fr_slen_t | tmpl_afrom_integer_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
Try and parse signed or unsigned integers. | |
static fr_slen_t | tmpl_afrom_ipv4_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
Parse bareword as an IPv4 address or prefix. | |
static fr_slen_t | tmpl_afrom_ipv6_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
Parse bareword as an IPv6 address or prefix. | |
static fr_slen_t | tmpl_afrom_octets_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
Parse bareword as an octet string. | |
fr_slen_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. | |
static ssize_t | tmpl_afrom_time_delta (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
static fr_slen_t | tmpl_afrom_value_substr (TALLOC_CTX *ctx, tmpl_t **out, fr_sbuff_t *in, fr_token_t quote, tmpl_rules_t const *t_rules, bool allow_enum, fr_sbuff_parse_rules_t const *p_rules) |
Create TMPL_TYPE_DATA from a string. | |
bool | tmpl_async_required (tmpl_t const *vpt) |
Return whether or not async is required for this tmpl. | |
static int | tmpl_attr_afrom_attr_substr (TALLOC_CTX *ctx, tmpl_attr_error_t *err, tmpl_t *vpt, fr_dict_attr_t const *parent, fr_dict_attr_t const *namespace, fr_sbuff_t *name, fr_sbuff_parse_rules_t const *p_rules, tmpl_attr_rules_t const *at_rules, unsigned int depth) |
Parse an attribute reference, either an OID or attribute name. | |
void | tmpl_attr_debug (tmpl_t const *vpt) |
static void | tmpl_attr_insert (tmpl_t *vpt, tmpl_attr_t *ar) |
Insert an attribute reference into a tmpl. | |
static fr_slen_t | tmpl_attr_parse_filter (tmpl_attr_error_t *err, tmpl_attr_t *ar, fr_sbuff_t *name, tmpl_attr_rules_t const *at_rules) |
Parse array subscript and in future other filters. | |
static fr_slen_t | tmpl_attr_ref_afrom_unresolved_substr (TALLOC_CTX *ctx, tmpl_attr_error_t *err, tmpl_t *vpt, fr_dict_attr_t const *parent, fr_dict_attr_t const *namespace, fr_sbuff_t *name, tmpl_attr_rules_t const *at_rules) |
Parse an unresolved attribute, i.e. | |
void | tmpl_attr_ref_debug (const tmpl_attr_t *ar, int i) |
static void | tmpl_attr_ref_fixup (TALLOC_CTX *ctx, tmpl_t *vpt, fr_dict_attr_t const *da, fr_dict_attr_t const *parent) |
static fr_slen_t | tmpl_attr_ref_from_unspecified_substr (tmpl_attr_t *ar, tmpl_attr_error_t *err, tmpl_t *vpt, fr_sbuff_t *name, tmpl_attr_rules_t const *at_rules) |
void | tmpl_attr_ref_list_debug (FR_DLIST_HEAD(tmpl_attr_list) const *ar_head) |
static void | tmpl_attr_rules_debug (tmpl_attr_rules_t const *at_rules) |
ssize_t | tmpl_cast_from_substr (tmpl_rules_t *rules, fr_sbuff_t *in) |
Parse a cast specifier. | |
int | tmpl_cast_set (tmpl_t *vpt, fr_type_t dst_type) |
Set a cast for a tmpl. | |
tmpl_t * | tmpl_copy (TALLOC_CTX *ctx, tmpl_t const *in) |
Copy a tmpl. | |
void | tmpl_debug (tmpl_t const *vpt) |
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() | |
TMPL_REQUEST_REF_DEF (tmpl_request_def_current, REQUEST_CURRENT) | |
Use the current request as the default. | |
TMPL_REQUEST_REF_DEF (tmpl_request_def_outer, REQUEST_OUTER) | |
Use the outer request as the default. | |
TMPL_REQUEST_REF_DEF (tmpl_request_def_parent, REQUEST_PARENT) | |
Use the parent request as the default. | |
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. | |
void | tmpl_rules_debug (tmpl_rules_t const *rules) |
static bool | tmpl_substr_terminal_check (fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules) |
Verify, after skipping whitespace, that a substring ends in a terminal char, or ends without further chars. | |
Variables | |
static fr_table_num_sorted_t const | attr_num_table [] |
Special attribute reference indexes. | |
static size_t | attr_num_table_len = NUM_ELEMENTS(attr_num_table) |
static fr_table_num_ordered_t const | attr_table [] |
Attr ref types. | |
static size_t | attr_table_len = NUM_ELEMENTS(attr_table) |
fr_dict_attr_t const * | tmpl_attr_unspec |
Placeholder attribute for uses of unspecified attribute references. | |
fr_table_num_sorted_t const | tmpl_request_ref_table [] |
Map keywords to tmpl_request_ref_t values. | |
size_t | tmpl_request_ref_table_len = NUM_ELEMENTS(tmpl_request_ref_table) |
bool | tmpl_require_enum_prefix = false |
fr_table_num_ordered_t const | tmpl_type_table [] |
Map tmpl_type_t values to descriptive strings. | |
size_t | tmpl_type_table_len = NUM_ELEMENTS(tmpl_type_table) |
Change a #tmpl_t type, usually by casting or resolving a reference | |
tmpl_cast_in_place can be used to convert TMPL_TYPE_DATA_UNRESOLVED to a TMPL_TYPE_DATA of a specified fr_type_t. tmpl_attr_unknown_add converts a TMPL_TYPE_ATTR with an unknown fr_dict_attr_t to a TMPL_TYPE_ATTR with a known fr_dict_attr_t, by adding the unknown fr_dict_attr_t to the main dictionary, and updating the | |
static void | attr_to_raw (tmpl_t *vpt, tmpl_attr_t *ref) |
static int | tmpl_attr_resolve (tmpl_t *vpt, tmpl_res_rules_t const *tr_rules) |
Resolve an unresolved attribute. | |
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. | |
void | tmpl_attr_to_raw (tmpl_t *vpt) |
Convert the leaf attribute of a tmpl to a unknown/raw type. | |
int | tmpl_attr_to_xlat (TALLOC_CTX *ctx, tmpl_t **vpt_p) |
Convert an attribute reference to an xlat expansion. | |
int | tmpl_attr_unknown_add (tmpl_t *vpt) |
Add an unknown fr_dict_attr_t specified by a tmpl_t to the main dictionary. | |
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. | |
static fr_token_t | tmpl_cast_quote (fr_token_t existing_quote, fr_type_t type, fr_dict_attr_t const *enumv, char const *unescaped, size_t unescaped_len) |
Determine the correct quoting after a cast. | |
int | tmpl_resolve (tmpl_t *vpt, tmpl_res_rules_t const *tr_rules) |
Attempt to resolve functions and attributes in xlats and attribute references. | |
void | tmpl_unresolve (tmpl_t *vpt) |
Reset the tmpl, leaving only the name in place. | |
static int | tmpl_xlat_resolve (tmpl_t *vpt, tmpl_res_rules_t const *tr_rules) |
Resolve an unresolved xlat, i.e. | |
Parse list and request qualifiers to #fr_pair_list_t and #tmpl_request_ref_t values | |
These functions also resolve fr_pair_list_t and tmpl_request_ref_t values to request_t structs and the head of fr_pair_t lists in those structs. For adding new fr_pair_t to the lists, the tmpl_list_ctx function can be used to obtain the appropriate TALLOC_CTX pointer.
| |
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. | |
static void | tmpl_request_ref_list_acopy (TALLOC_CTX *ctx, FR_DLIST_HEAD(tmpl_request_list) **out, FR_DLIST_HEAD(tmpl_request_list) const *in) |
Allocate a new request reference list and copy request references into it. | |
fr_slen_t | tmpl_request_ref_list_afrom_substr (TALLOC_CTX *ctx, tmpl_attr_error_t *err, FR_DLIST_HEAD(tmpl_request_list) **out, fr_sbuff_t *in) |
Parse one or more request references, allocing a new list and adding the references to it. | |
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. | |
static void | tmpl_request_ref_list_copy (TALLOC_CTX *ctx, FR_DLIST_HEAD(tmpl_request_list) *out, FR_DLIST_HEAD(tmpl_request_list) const *in) |
Allocate a new request reference and add it to the end of the attribute reference list. | |
void | tmpl_request_ref_list_debug (FR_DLIST_HEAD(tmpl_request_list) const *rql) |
Dump a request list to stderr. | |
static fr_slen_t | tmpl_request_ref_list_from_substr (TALLOC_CTX *ctx, tmpl_attr_error_t *err, FR_DLIST_HEAD(tmpl_request_list) *out, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, fr_dict_attr_t const **namespace) |
Parse one or more request references, writing the list to out. | |
Alloc or initialise #tmpl_t | |
| |
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. | |
static tmpl_t * | tmpl_alloc_null (TALLOC_CTX *ctx) |
Create a new heap allocated tmpl_t. | |
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. | |
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. | |
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. | |
void | tmpl_set_dict_def (tmpl_t *vpt, fr_dict_t const *dict) |
Change the default dictionary in the tmpl's resolution rules. | |
void | tmpl_set_escape (tmpl_t *vpt, tmpl_escape_t const *escape) |
Set escape parameters for the tmpl output. | |
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. | |
void | tmpl_set_name_printf (tmpl_t *vpt, fr_token_t quote, char const *fmt,...) |
Set the name on a pre-initialised tmpl. | |
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. | |
void | tmpl_set_xlat (tmpl_t *vpt, xlat_exp_head_t *xlat) |
Change the default dictionary in the tmpl's resolution rules. | |
static void | tmpl_type_init (tmpl_t *vpt, tmpl_type_t type) |
Initialise fields inside a tmpl depending on its type. | |
Create new #tmpl_t from a string | |
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. | |
static tmpl_attr_t * | tmpl_attr_add (tmpl_t *vpt, tmpl_attr_type_t type) |
Allocate a new attribute reference and add it to the end of the attribute reference list. | |
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. | |
int | tmpl_attr_copy (tmpl_t *dst, tmpl_t const *src) |
Copy a list of attribute and request references from one tmpl to another. | |
void | tmpl_attr_rewrite_leaf_num (tmpl_t *vpt, int16_t to) |
Rewrite the leaf's instance number. | |
int | tmpl_attr_set_da (tmpl_t *vpt, fr_dict_attr_t const *da) |
Replace the current attribute reference. | |
int | tmpl_attr_set_leaf_da (tmpl_t *vpt, fr_dict_attr_t const *da) |
Replace the leaf attribute only. | |
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. | |
Print the contents of a #tmpl_t | |
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. | |
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. | |
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. | |
fr_slen_t | tmpl_request_ref_list_print (fr_sbuff_t *out, FR_DLIST_HEAD(tmpl_request_list) const *rql) |
fr_pair_t template functions
Definition in file tmpl_tokenize.c.
#define _TMPL_PRIVATE 1 |
Definition at line 29 of file tmpl_tokenize.c.
#define DEFAULT_RULES tmpl_rules_t const default_rules = { .attr = { .list_def = request_attr_request }} |
Default parser rules.
Because this is getting to be a ridiculous number of parsing rules to pass in via arguments.
Defaults are used if a NULL rules pointer is passed to the parsing function.
Definition at line 106 of file tmpl_tokenize.c.
#define RESOLVED_SET | ( | _flags | ) | (*(_flags) = (*(_flags) & ~TMPL_FLAG_UNRESOLVED)) |
Definition at line 172 of file tmpl_tokenize.c.
#define return_P | ( | _x | ) | fr_strerror_const(_x);goto return_p |
Definition at line 5328 of file tmpl_tokenize.c.
#define TMPL_REQUEST_REF_DEF | ( | _name, | |
_ref | |||
) |
Define a global variable for specifying a default request reference.
[in] | _name | what the global variable should be called. |
[in] | _ref | one of the values of tmpl_request_ref_t
|
Definition at line 60 of file tmpl_tokenize.c.
#define UNRESOLVED_SET | ( | _flags | ) | (*(_flags) = (*(_flags) | TMPL_FLAG_UNRESOLVED)) |
Definition at line 171 of file tmpl_tokenize.c.
|
static |
Definition at line 4370 of file tmpl_tokenize.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.
|
static |
Parse a truth value.
[in] | ctx | to allocate tmpl to. |
[out] | out | where to write tmpl. |
[in] | in | sbuff to parse. |
[in] | p_rules | formatting rules. |
Definition at line 2564 of file tmpl_tokenize.c.
|
static |
Definition at line 3063 of file tmpl_tokenize.c.
|
static |
Try and parse signed or unsigned integers.
[in] | ctx | to allocate tmpl to. |
[out] | out | where to write tmpl. |
[in] | in | sbuff to parse. |
[in] | p_rules | formatting rules. |
Definition at line 2847 of file tmpl_tokenize.c.
|
static |
Definition at line 2990 of file tmpl_tokenize.c.
|
static |
Try and parse signed or unsigned integers.
[in] | ctx | to allocate tmpl to. |
[out] | out | where to write tmpl. |
[in] | in | sbuff to parse. |
[in] | p_rules | formatting rules. |
Definition at line 2914 of file tmpl_tokenize.c.
|
static |
Parse bareword as an IPv4 address or prefix.
[in] | ctx | to allocate tmpl to. |
[out] | out | where to write tmpl. |
[in] | in | sbuff to parse. |
[in] | p_rules | formatting rules. |
Definition at line 2661 of file tmpl_tokenize.c.
|
static |
Parse bareword as an IPv6 address or prefix.
[in] | ctx | to allocate tmpl to. |
[out] | out | where to write tmpl. |
[in] | in | sbuff to parse. |
[in] | p_rules | formatting rules. |
Definition at line 2729 of file tmpl_tokenize.c.
|
static |
Parse bareword as an octet string.
[in] | ctx | to allocate tmpl to. |
[out] | out | where to write tmpl. |
[in] | in | sbuff to parse. |
[in] | p_rules | formatting rules. |
Definition at line 2602 of file tmpl_tokenize.c.
fr_slen_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.
|
static |
Definition at line 3018 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.
|
static |
Create TMPL_TYPE_DATA from a string.
[in] | ctx | to allocate tmpl to. |
[out] | out | where to write tmpl. |
[in] | in | sbuff to parse. |
[in] | quote | surrounding the operand to parse. |
[in] | t_rules | specifying the cast and any enumeration values. |
[in] | allow_enum | Whether parsing the value as an enum should be allowed. |
[in] | p_rules | formatting rules. |
Definition at line 2514 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 |
Create a new heap allocated tmpl_t.
Must be later initialised with a tmpl_init_* function.
This function is provided to allow tmpls to be pre-allocated for talloc purposes before their name is known.
Definition at line 923 of file tmpl_tokenize.c.
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.
|
static |
Allocate a new attribute reference and add it to the end of the attribute reference list.
Definition at line 971 of file tmpl_tokenize.c.
|
inlinestatic |
Parse an attribute reference, either an OID or attribute name.
[in] | ctx | to allocate new attribute reference in. |
[out] | err | Parse error. |
[in,out] | vpt | to append this reference to. |
[in] | parent | Parent where the attribute will be placed (group, struct, tlv, etc). |
[in] | namespace | Where the child attribute will be parsed from (dict root, struct member, TLV child, etc) |
[in] | name | to parse. |
[in] | p_rules | Formatting rules used to check for trailing garbage. |
[in] | at_rules | which places constraints on attribute reference parsing. Rules interpreted by this function is:
|
[in] | depth | How deep we are. Used to check for maximum nesting level. |
Definition at line 1762 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.
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 |
Insert an attribute reference into a tmpl.
Not all attribute references can be used to create new attributes, for example those accessing instance > 0 or those that resolve to special indexes.
We mark up these references and their parents as resolve only meaning that if any code needs to use a reference chain to build out a pair tree, it bails out early.
[in] | vpt | containing the reference list. |
[in] | ar | to insert and check. |
Definition at line 1303 of file tmpl_tokenize.c.
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 |
Parse array subscript and in future other filters.
[out] | err | Parse error code. |
[in] | ar | to populate filter for. |
[in] | name | containing more attribute ref data. |
[in] | at_rules | see tmpl_attr_afrom_attr_substr. |
Definition at line 1333 of file tmpl_tokenize.c.
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.
|
inlinestatic |
Parse an unresolved attribute, i.e.
one which can't be found in the current dictionary
This function calls itself recursively to process additional OID components once we've failed to resolve one component.
[in] | ctx | to allocate new attribute reference in. |
[out] | err | Parse error. |
[in,out] | vpt | to append this reference to. |
[in] | parent | Last known parent. |
[in] | namespace | in which the attribute will be resolved. |
[in] | name | to parse. |
[in] | at_rules | see tmpl_attr_afrom_attr_substr. |
Definition at line 1641 of file tmpl_tokenize.c.
void tmpl_attr_ref_debug | ( | const tmpl_attr_t * | ar, |
int | i | ||
) |
Definition at line 198 of file tmpl_tokenize.c.
|
static |
Definition at line 1717 of file tmpl_tokenize.c.
|
inlinestatic |
Definition at line 1588 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.
|
inlinestatic |
Resolve an unresolved attribute.
Multi-pass parsing fixups for attribute references.
[in] | vpt | to resolve. |
[in] | tr_rules | Combined with the original parse rules for additional resolution passes. |
Definition at line 3969 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.
|
static |
Definition at line 5829 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.
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.
|
inlinestatic |
Determine the correct quoting after a cast.
[in] | existing_quote | Exiting quotation type. |
[in] | type | Cast type. |
[in] | enumv | Enumeration values. |
[in] | unescaped | The unescaped value of an enumeration. |
[in] | unescaped_len | Length of unescaped. |
Definition at line 3817 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.
void tmpl_debug | ( | tmpl_t const * | vpt | ) |
Definition at line 312 of file tmpl_tokenize.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.
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.
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 4833 of file tmpl_tokenize.c.
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.
TMPL_REQUEST_REF_DEF | ( | tmpl_request_def_current | , |
REQUEST_CURRENT | |||
) |
Use the current request as the default.
Used as .attr.request_def = &tmpl_request_def_current;
TMPL_REQUEST_REF_DEF | ( | tmpl_request_def_outer | , |
REQUEST_OUTER | |||
) |
Use the outer request as the default.
Used as .attr.request_def = &tmpl_request_def_outer;
TMPL_REQUEST_REF_DEF | ( | tmpl_request_def_parent | , |
REQUEST_PARENT | |||
) |
Use the parent request as the default.
Used as .attr.request_def = &tmpl_request_def_parent;
|
inlinestatic |
Allocate a new request reference list and copy request references into it.
Definition at line 449 of file tmpl_tokenize.c.
fr_slen_t tmpl_request_ref_list_afrom_substr | ( | TALLOC_CTX * | ctx, |
tmpl_attr_error_t * | err, | ||
FR_DLIST_HEAD(tmpl_request_list) ** | out, | ||
fr_sbuff_t * | in | ||
) |
Parse one or more request references, allocing a new list and adding the references to it.
This can be used to create request ref lists for rules and for tmpls.
[in] | ctx | to allocate request refs in. |
[out] | err | If !NULL where to write the parsing error. |
[out] | out | The new list. |
[in] | in | Sbuff to read request references from. |
Definition at line 694 of file tmpl_tokenize.c.
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.
|
inlinestatic |
Allocate a new request reference and add it to the end of the attribute reference list.
Definition at line 426 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.
|
static |
Parse one or more request references, writing the list to out.
[in] | ctx | to allocate request refs in. |
[out] | err | If !NULL where to write the parsing error. |
[in] | out | The list to write to. |
[in] | in | Sbuff to read request references from. |
[in] | p_rules | Parse rules. |
[in] | t_rules | Default list and other rules. |
[out] | namespace | the namespace to use |
Definition at line 527 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 | ||
) |
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 |
Verify, after skipping whitespace, that a substring ends in a terminal char, or ends without further chars.
[in] | in | the sbuff to check. |
[in] | p_rules | to use terminals from. |
Definition at line 182 of file tmpl_tokenize.c.
|
inlinestatic |
Initialise fields inside a tmpl depending on its type.
Definition at line 727 of file tmpl_tokenize.c.
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.
|
inlinestatic |
Resolve an unresolved xlat, i.e.
one containing unresolved attribute references or xlat functions
Multi-pass parsing fixups for attribute references.
Works for base types:
[in] | vpt | Containing the xlat expansion to resolve. |
[in] | tr_rules | Combined with the original parse rules for additional resolution passes. |
Definition at line 4133 of file tmpl_tokenize.c.
|
static |
Special attribute reference indexes.
Definition at line 157 of file tmpl_tokenize.c.
|
static |
Definition at line 163 of file tmpl_tokenize.c.
|
static |
Attr ref types.
Definition at line 137 of file tmpl_tokenize.c.
|
static |
Definition at line 143 of file tmpl_tokenize.c.
|
extern |
Placeholder attribute for uses of unspecified attribute references.
Definition at line 61 of file tmpl_eval.c.
fr_table_num_sorted_t const tmpl_request_ref_table[] |
Map keywords to tmpl_request_ref_t values.
Definition at line 147 of file tmpl_tokenize.c.
size_t tmpl_request_ref_table_len = NUM_ELEMENTS(tmpl_request_ref_table) |
Definition at line 152 of file tmpl_tokenize.c.
bool tmpl_require_enum_prefix = false |
Definition at line 49 of file tmpl_tokenize.c.
fr_table_num_ordered_t const tmpl_type_table[] |
Map tmpl_type_t values to descriptive strings.
Definition at line 112 of file tmpl_tokenize.c.
size_t tmpl_type_table_len = NUM_ELEMENTS(tmpl_type_table) |
Definition at line 133 of file tmpl_tokenize.c.