70 RCSIDH(tmpl_h,
"$Id: 356109420969b970e97049ee2b134f5ac6f410b4 $")
76 #include <freeradius-devel/util/table.h>
77 #include <freeradius-devel/util/dlist.h>
78 #include <freeradius-devel/util/value.h>
80 #include <freeradius-devel/server/tmpl_escape.h>
85 #define TMPL_MAX_REQUEST_REF_NESTING 10
106 #define TMPL_FLAG_ATTR 0x01000000
111 #define TMPL_FLAG_XLAT 0x02000000
116 #define TMPL_FLAG_REGEX 0x04000000
121 #define TMPL_FLAG_UNRESOLVED 0x08000000
208 #define tmpl_is_uninitialised(vpt) (vpt->type == TMPL_TYPE_UNINITIALISED)
210 #define tmpl_is_null(vpt) (vpt->type == TMPL_TYPE_NULL)
211 #define tmpl_is_data(vpt) (vpt->type == TMPL_TYPE_DATA)
213 #define tmpl_is_attr(vpt) (vpt->type == TMPL_TYPE_ATTR)
215 #define tmpl_is_xlat(vpt) (vpt->type == TMPL_TYPE_XLAT)
216 #define tmpl_is_exec(vpt) (vpt->type == TMPL_TYPE_EXEC)
218 #define tmpl_is_regex(vpt) (vpt->type == TMPL_TYPE_REGEX)
219 #define tmpl_is_regex_uncompiled(vpt) (vpt->type == TMPL_TYPE_REGEX_UNCOMPILED)
220 #define tmpl_is_regex_xlat(vpt) (vpt->type == TMPL_TYPE_REGEX_XLAT)
222 #define tmpl_is_data_unresolved(vpt) (vpt->type == TMPL_TYPE_DATA_UNRESOLVED)
223 #define tmpl_is_exec_unresolved(vpt) (vpt->type == TMPL_TYPE_EXEC_UNRESOLVED)
224 #define tmpl_is_attr_unresolved(vpt) (vpt->type == TMPL_TYPE_ATTR_UNRESOLVED)
225 #define tmpl_is_xlat_unresolved(vpt) (vpt->type == TMPL_TYPE_XLAT_UNRESOLVED)
226 #define tmpl_is_regex_xlat_unresolved(vpt) (vpt->type == TMPL_TYPE_REGEX_XLAT_UNRESOLVED)
228 #define tmpl_needs_resolving(vpt) (vpt->type & TMPL_FLAG_UNRESOLVED)
229 #define tmpl_contains_attr(vpt) (vpt->type & TMPL_FLAG_ATTR)
230 #define tmpl_contains_regex(vpt) (vpt->type & TMPL_FLAG_REGEX)
231 #define tmpl_contains_xlat(vpt) (vpt->type & TMPL_FLAG_XLAT)
243 #include <freeradius-devel/unlang/xlat.h>
244 #include <freeradius-devel/unlang/xlat_ctx.h>
245 #include <freeradius-devel/util/packet.h>
246 #include <freeradius-devel/util/proto.h>
247 #include <freeradius-devel/util/regex.h>
253 # error _CONST can only be defined in the local header
255 #ifndef _TMPL_PRIVATE
256 # define _CONST const
399 #define NUM_UNSPEC INT16_MIN
400 #define NUM_ALL (INT16_MIN + 1)
401 #define NUM_COUNT (INT16_MIN + 2)
402 #define NUM_LAST (INT16_MIN + 3)
495 #define TMPL_POOL_DEF_HEADERS 4
500 #define TMPL_POOL_DEF_LEN (sizeof(tmpl_t) + 64 + sizeof(tmpl_attr_t) + sizeof(tmpl_request_t))
507 #define ar_depth depth
509 #define ar_parent parent
510 #define ar_unknown unknown.da
511 #define ar_unresolved unresolved.name
512 #define ar_unresolved_namespace unresolved.namespace
514 #define ar_is_normal(_ar) ((_ar)->ar_type == TMPL_ATTR_TYPE_NORMAL)
515 #define ar_is_unspecified(_ar) ((_ar)->ar_type == TMPL_ATTR_TYPE_UNSPEC)
516 #define ar_is_unknown(_ar) ((_ar)->ar_type == TMPL_ATTR_TYPE_UNKNOWN)
517 #define ar_is_unresolved(_ar) ((_ar)->ar_type == TMPL_ATTR_TYPE_UNRESOLVED)
518 #define ar_is_raw(_ar) ((_ar)->is_raw)
520 #define ar_num filter.num
521 #define ar_cond filter.cond
522 #define ar_tmpl filter.tmpl
523 #define ar_expr filter.expr
524 #define ar_filter_type filter.type
526 #define ar_filter_is_none(_ar) ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_NONE)
527 #define ar_filter_is_num(_ar) ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_INDEX)
528 #define ar_filter_is_cond(_ar) ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_CONDITION)
529 #define ar_filter_is_tmpl(_ar) ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_TMPL)
530 #define ar_filter_is_expr(_ar) ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_EXPR)
595 fr_regex_flags_t reg_flags;
631 #define tmpl_assert_type(_cond) \
632 fr_assert_msg(_cond, "Unexpected tmpl type '%s'", \
633 tmpl_type_to_str(vpt->type))
665 #define tmpl_attr(_tmpl) &(_tmpl)->data.attribute.ar
672 return &
vpt->data.attribute.rr;
683 return tmpl_request_list_num_elements(&
vpt->data.attribute.rr);
819 if (!ar)
return NULL;
835 if (!ar)
return false;
853 if (!ar)
return false;
871 if (!ar)
return NULL;
873 return ar->ar_unknown;
887 if (!ar)
return NULL;
889 return ar->ar_unresolved;
928 return (list ? list->name : def);
941 #define tmpl_xlat(_tmpl) (_tmpl)->data.xlat.ex
948 #define tmpl_value(_tmpl) (&(_tmpl)->data.literal)
949 #define tmpl_value_length(_tmpl) (_tmpl)->data.literal.vb_length
950 #define tmpl_value_type(_tmpl) (_tmpl)->data.literal.type
951 #define tmpl_value_enumv(_tmpl) (_tmpl)->data.literal.enumv
953 #define tmpl_rules_cast(_tmpl) (_tmpl)->rules.cast
954 #define tmpl_rules_enumv(_tmpl) (_tmpl)->rules.enumv
962 # define tmpl_regex(_tmpl) (_tmpl)->data.reg.ex
963 # define tmpl_regex_flags(_tmpl) (&(_tmpl)->data.reg_flags)
967 #ifndef WITH_VERIFY_PTR
968 # define TMPL_ATTR_VERIFY(_vpt)
969 # define TMPL_VERIFY(_vpt)
971 # define TMPL_ATTR_VERIFY(_vpt) tmpl_attr_verify(__FILE__, __LINE__, _vpt)
972 # define TMPL_VERIFY(_vpt) tmpl_verify(__FILE__, __LINE__, _vpt)
1001 #define tmpl_pair_list_and_ctx(_ctx, _head, _request, _ref, _list) \
1003 request_t *_rctx = _request; \
1004 if ((tmpl_request_ptr(&_rctx, _ref) < 0) || \
1005 !(_head = tmpl_list_head(_rctx, _list)) || \
1006 !(_ctx = tmpl_list_ctx(_rctx, _list))) {\
1041 #define FR_TYPE_FROM_PTR(_ptr) \
1043 char **: FR_TYPE_STRING, \
1044 char const **: FR_TYPE_STRING, \
1045 uint8_t **: FR_TYPE_OCTETS, \
1046 uint8_t const **: FR_TYPE_OCTETS, \
1047 uint8_t *: FR_TYPE_UINT8, \
1048 uint16_t *: FR_TYPE_UINT16, \
1049 uint32_t *: FR_TYPE_UINT32, \
1050 uint64_t *: FR_TYPE_UINT64, \
1051 fr_value_box_t **: FR_TYPE_VALUE_BOX, \
1052 fr_value_box_t const **: FR_TYPE_VALUE_BOX)
1060 #define tmpl_expand(_out, _buff, _buff_len, _request, _vpt, _escape, _escape_ctx) \
1061 _tmpl_to_type((void *)(_out), (uint8_t *)_buff, _buff_len, \
1062 _request, _vpt, _escape, _escape_ctx, FR_TYPE_FROM_PTR(_out))
1070 #define tmpl_aexpand(_ctx, _out, _request, _vpt, _escape, _escape_ctx) \
1071 _tmpl_to_atype(_ctx, (void *)(_out), _request, _vpt, _escape, _escape_ctx, FR_TYPE_FROM_PTR(_out))
1079 #define tmpl_aexpand_type(_ctx, _out, _type, _request, _vpt, _escape, _escape_ctx) \
1080 _tmpl_to_atype(_ctx, (void *)(_out), _request, _vpt, _escape, _escape_ctx, _type)
1112 extern
FR_DLIST_HEAD(tmpl_request_list) tmpl_request_def_current;
1118 extern
FR_DLIST_HEAD(tmpl_request_list) tmpl_request_def_outer;
1124 extern
FR_DLIST_HEAD(tmpl_request_list) tmpl_request_def_parent;
1140 #define tmpl_request_ref_is_current(_list) (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_current) == 0)
1149 #define tmpl_request_ref_is_parent(_list) (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_parent) == 0)
1158 #define tmpl_request_ref_is_outer(_list) (tmpl_request_ref_list_cmp(_list, &tmpl_request_def_outer) == 0)
1207 fr_sbuff_parse_rules_t const *p_rules,
1217 fr_sbuff_parse_rules_t const *p_rules,
1228 return vpt->rules.cast;
static int const char * fmt
Values of the encryption flags.
#define FR_DLIST_TYPES(_name)
Define type specific wrapper structs for dlists.
#define FR_DLIST_FUNCS(_name, _element_type, _element_entry)
Define type specific wrapper functions for dlists.
Head of a doubly linked list.
Entry in a doubly linked list.
Stores all information relating to an event list.
size_t(* xlat_escape_legacy_t)(request_t *request, char *out, size_t outlen, char const *in, void *arg)
fr_dict_attr_t const * request_attr_request
fr_dict_attr_t const * request_attr_control
fr_dict_attr_t const * request_attr_local
fr_dict_attr_t const * request_attr_state
fr_dict_attr_t const * request_attr_reply
#define SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(_func,...)
Set of terminal elements.
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.
int tmpl_find_vp(fr_pair_t **out, request_t *request, tmpl_t const *vpt))
Returns the first VP matching a tmpl_t.
static fr_slen_t tmpl_attr_aprint(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix) 1(tmpl_attr_print
void tmpl_request_ref_list_debug(FR_DLIST_HEAD(tmpl_request_list) const *rql)
Dump a request list to stderr.
static fr_slen_t ar_prefix
static int16_t tmpl_attr_tail_num(tmpl_t const *vpt)
Return the last attribute reference's attribute number.
void tmpl_attr_set_list(tmpl_t *vpt, fr_dict_attr_t const *list)
tmpl_attr_prefix_t
Specify whether attribute references require a prefix.
@ TMPL_ATTR_REF_PREFIX_NO
Attribute refs have no '&' prefix.
@ TMPL_ATTR_REF_PREFIX_AUTO
Attribute refs may have a '&' prefix.
@ TMPL_ATTR_REF_PREFIX_YES
Attribute refs must have '&' prefix.
#define ar_is_unspecified(_ar)
void tmpl_unresolve(tmpl_t *vpt)
Reset the tmpl, leaving only the name in place.
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.
#define tmpl_is_attr_unresolved(vpt)
enum requests_ref_e tmpl_request_ref_t
void tmpl_set_name_printf(tmpl_t *vpt, fr_token_t quote, char const *fmt,...))
Set the name on a pre-initialised tmpl.
static bool tmpl_attr_tail_is_unspecified(tmpl_t const *vpt)
Return true if the last attribute reference is "unspecified".
void tmpl_set_xlat(tmpl_t *vpt, xlat_exp_head_t *xlat)
Change the default dictionary in the tmpl's resolution rules.
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.
int tmpl_attr_set_da(tmpl_t *vpt, fr_dict_attr_t const *da)
Replace the current attribute reference.
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.
static fr_slen_t tmpl_aprint(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix, fr_sbuff_escape_rules_t const *e_rules) 1(tmpl_print
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.
tmpl_escape_t escape
How escaping should be handled during evaluation.
static bool tmpl_attr_tail_is_normal(tmpl_t const *vpt)
Return true if the last attribute reference is "normal".
int tmpl_resolve(tmpl_t *vpt, tmpl_res_rules_t const *tr_rules))
Attempt to resolve functions and attributes in xlats and attribute references.
TALLOC_CTX * list_ctx
Where to allocate new attributes if building out from the current extents of the tree.
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.
fr_table_num_sorted_t const tmpl_request_ref_table[]
Map keywords to tmpl_request_ref_t values.
#define TMPL_FLAG_ATTR
Base data type is an attribute reference.
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.
#define ar_is_unknown(_ar)
int tmpl_attr_unknown_add(tmpl_t *vpt)
Add an unknown fr_dict_attr_t specified by a tmpl_t to the main dictionary.
static bool tmpl_attr_tail_is_unknown(tmpl_t const *vpt)
Return true if the last attribute reference is "unknown".
static fr_dict_attr_t const * tmpl_attr_tail_da(tmpl_t const *vpt)
Return the last attribute reference da.
int tmpl_extents_build_to_leaf_parent(fr_dlist_head_t *leaf, fr_dlist_head_t *interior, tmpl_t const *vpt)
Allocate interior pairs.
static tmpl_type_t tmpl_type_from_str(char const *type)
Return the constant value representing a type.
void tmpl_attr_ref_debug(const tmpl_attr_t *ar, int idx)
fr_value_box_safe_for_t literals_safe_for
safe_for value assigned to literal values in xlats, execs, and data.
void tmpl_set_escape(tmpl_t *vpt, tmpl_escape_t const *escape)
Set escape parameters for the tmpl output.
#define TMPL_FLAG_UNRESOLVED
Needs resolution.
size_t pair_list_table_len
#define tmpl_is_attr(vpt)
bool tmpl_async_required(tmpl_t const *vpt)
Return whether or not async is required for this tmpl.
fr_dict_attr_t const * enumv
Enumeration attribute used to resolve enum values.
tmpl_rules_t const * parent
for parent / child relationships
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.
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.
int16_t _CONST num
For array references.
static fr_dict_attr_t const * tmpl_attr_tail_unknown(tmpl_t const *vpt)
Return the last attribute reference unknown da.
static bool tmpl_attr_is_list_attr(tmpl_attr_t const *ar)
Return true if the tmpl_attr is one of the list types.
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.
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.
static fr_slen_t tmpl_request_ref_list_aprint(TALLOC_CTX *ctx, char **out, FR_DLIST_HEAD(tmpl_request_list) const *rql) 1(tmpl_request_ref_list_print
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.
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.
tmpl_type_e
Types of tmpl_t.
@ TMPL_TYPE_REGEX_UNCOMPILED
Regex where compilation is possible but hasn't been performed yet.
@ TMPL_TYPE_MAX
Marker for the last tmpl type.
@ TMPL_TYPE_ATTR_UNRESOLVED
An attribute reference that we couldn't resolve but looked valid.
@ TMPL_TYPE_ATTR
Reference to one or more attributes.
@ TMPL_TYPE_XLAT
Pre-parsed xlat expansion.
@ TMPL_TYPE_NULL
Has no value.
@ TMPL_TYPE_EXEC
Callout to an external script or program.
@ TMPL_TYPE_REGEX_XLAT_UNRESOLVED
A regular expression with unresolved xlat functions or attribute references.
@ TMPL_TYPE_DATA
Value in native boxed format.
@ TMPL_TYPE_REGEX
Compiled (and possibly JIT'd) regular expression.
@ TMPL_TYPE_DATA_UNRESOLVED
Unparsed literal string.
@ TMPL_TYPE_XLAT_UNRESOLVED
A xlat expansion with unresolved xlat functions or attribute references.
@ TMPL_TYPE_REGEX_XLAT
A regex containing xlat expansions.
@ TMPL_TYPE_EXEC_UNRESOLVED
An exec with unresolved xlat function or attribute references.
@ TMPL_TYPE_UNINITIALISED
Uninitialised.
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.
void tmpl_attr_to_raw(tmpl_t *vpt)
Convert the leaf attribute of a tmpl to a unknown/raw type.
static bool tmpl_attr_tail_da_is_leaf(tmpl_t const *vpt)
Return true if the the last attribute reference is a leaf attribute.
#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)
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.
static bool tmpl_attr_tail_da_is_structural(tmpl_t const *vpt)
Return true if the the last attribute reference is a structural attribute.
tmpl_t * tmpl_copy(TALLOC_CTX *ctx, tmpl_t const *in)
Copy a tmpl.
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.
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.
#define TMPL_FLAG_REGEX
Is a type of regular expression.
static size_t tmpl_request_ref_count(tmpl_t const *vpt)
The number of request references contained within a tmpl.
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.
tmpl_rules_t _CONST rules
The rules that were used when creating the tmpl.
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.
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.
fr_dlist_t entry
Entry in the dlist of extents.
int tmpl_global_init(void)
tmpl_xlat_rules_t xlat
Rules/data for parsing xlats.
bool at_runtime
Produce an ephemeral/runtime tmpl.
static bool tmpl_is_list(tmpl_t const *vpt)
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.
static fr_slen_t tmpl_aprint_quoted(TALLOC_CTX *ctx, char **out, tmpl_t const *vpt, tmpl_attr_prefix_t ar_prefix) 1(tmpl_print_quoted
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.
bool new_functions
new function syntax
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.
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.
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.
static FR_DLIST_HEAD(tmpl_request_list) const *tmpl_request(tmpl_t const *vpt)
Static default request ref list for the current request.
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 specifie...
bool force_dict_def
Use supplied dict_def even if original vpt->rules->dict_def was not NULL.
void tmpl_debug(tmpl_t const *vpt)
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.
fr_dict_t const * dict_def
Alternative default dictionary to use if vpt->rules->dict_def is NULL.
static bool tmpl_attr_tail_is_unresolved(tmpl_t const *vpt)
Return true if the last attribute reference is "unresolved".
tmpl_type_t _CONST type
What type of value tmpl refers to.
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()
static size_t tmpl_attr_num_elements(tmpl_t const *vpt)
The number of attribute references contained within a tmpl.
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.
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)
fr_table_num_ordered_t const pair_list_table[]
void tmpl_attr_rewrite_leaf_num(tmpl_t *vpt, int16_t num)
Rewrite the leaf's instance number.
void tmpl_attr_ref_list_debug(FR_DLIST_HEAD(tmpl_attr_list) const *ar_head)
static fr_type_t tmpl_cast_get(tmpl_t *vpt)
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.
char const *_CONST name
Raw string used to create the template.
@ TMPL_ATTR_ERROR_INVALID_ARRAY_INDEX
Invalid array index.
@ TMPL_ATTR_ERROR_LIST_NOT_ALLOWED
List qualifier is not allowed here.
@ TMPL_ATTR_ERROR_INTERNAL_NOT_ALLOWED
Attribute resolved to an internal attribute which is disallowed.
@ TMPL_ATTR_ERROR_UNRESOLVED_NOT_ALLOWED
Attribute couldn't be found in the dictionaries.
@ TMPL_ATTR_ERROR_INVALID_FILTER
Invalid filter.
@ TMPL_ATTR_ERROR_BAD_CAST
Specified cast was invalid.
@ TMPL_ATTR_ERROR_INVALID_NAME
Attribute ref length is zero, or longer than the maximum.
@ TMPL_ATTR_ERROR_UNQUALIFIED_NOT_ALLOWED
Attribute must be qualified to be used here.
@ TMPL_ATTR_ERROR_MISSING_TERMINATOR
Unexpected text found after attribute reference.
@ TMPL_ATTR_ERROR_LIST_MISSING
List qualifier is required, but missing.
@ TMPL_ATTR_ERROR_NONE
No error.
@ TMPL_ATTR_ERROR_FOREIGN_NOT_ALLOWED
Attribute resolved in a dictionary different to the one specified.
@ TMPL_ATTR_ERROR_UNKNOWN_NOT_ALLOWED
Attribute specified as OID, could not be found in the dictionaries, and is disallowed because 'disall...
@ TMPL_ATTR_ERROR_FILTER_NOT_ALLOWED
Filters disallowed by rules.
@ TMPL_ATTR_ERROR_EMPTY
Attribute ref contains no data.
@ TMPL_ATTR_ERROR_NESTING_TOO_DEEP
Too many levels of nesting.
@ TMPL_ATTR_ERROR_BAD_PREFIX
Missing '&' or has '&' when it shouldn't.
fr_type_t cast
Whether there was an explicit cast.
tmpl_attr_rules_t attr
Rules/data for parsing attribute references.
void tmpl_rules_debug(tmpl_rules_t const *rules)
int tmpl_attr_copy(tmpl_t *dst, tmpl_t const *src)
Copy a list of attribute and request references from one tmpl to another.
fr_pair_list_t * list
List that we tried to evaluate ar in and failed.
static char const * tmpl_attr_tail_unresolved(tmpl_t const *vpt)
Return the last attribute reference unresolved da.
static tmpl_attr_t const * tmpl_attr_tail(tmpl_t const *vpt)
Return the last attribute reference.
tmpl_attr_list_presence_t
Specify whether attribute references can have a list (or parent) reference.
@ TMPL_ATTR_LIST_REQUIRE
Attribute refs are required to have a list.
@ TMPL_ATTR_LIST_ALLOW
Attribute refs are allowed to have a list.
@ TMPL_ATTR_LIST_FORBID
Attribute refs are forbidden from having a list.
void tmpl_extents_debug(fr_dlist_head_t *head)
#define ar_is_unresolved(_ar)
static bool tmpl_attr_head_is_list(tmpl_t const *vpt)
Return true if the head attribute reference is a list reference.
enum tmpl_type_e tmpl_type_t
Types of tmpl_t.
size_t tmpl_type_table_len
struct tmpl_literal_rules_s tmpl_literal_rules_t
#define ar_is_normal(_ar)
int tmpl_attr_set_leaf_da(tmpl_t *vpt, fr_dict_attr_t const *da)
Replace the leaf attribute only.
static bool tmpl_attr_tail_is_raw(tmpl_t const *vpt)
Return true if the last attribute reference is "raw".
@ REQUEST_OUTER
request_t containing the outer layer of the EAP conversation.
@ REQUEST_PARENT
Parent (whatever it is).
@ REQUEST_UNKNOWN
Unknown request.
@ REQUEST_CURRENT
The current request (default).
fr_slen_t tmpl_request_ref_list_print(fr_sbuff_t *out, FR_DLIST_HEAD(tmpl_request_list) const *rql))
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.
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.
static fr_dict_attr_t const * tmpl_list(tmpl_t const *vpt)
void tmpl_set_dict_def(tmpl_t *vpt, fr_dict_t const *dict)
Change the default dictionary in the tmpl's resolution rules.
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.
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.
fr_dict_attr_t const * enumv
for resolving T_BARE_WORD
size_t _CONST len
Length of the raw string used to create the template.
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.
ssize_t tmpl_cast_from_substr(tmpl_rules_t *t_rules, fr_sbuff_t *in))
Parse a cast specifier.
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.
@ TMPL_ATTR_TYPE_UNSPEC
No attribute was specified as this level only a filter.
@ TMPL_ATTR_TYPE_NORMAL
Normal, resolved, attribute ref.
@ TMPL_ATTR_TYPE_UNKNOWN
We have an attribute number but it doesn't match anything in the dictionary, or isn't a child of the ...
@ TMPL_ATTR_TYPE_UNRESOLVED
We have a name, but nothing else to identify the attribute.
#define TMPL_FLAG_XLAT
Base data type is an xlat expansion.
tmpl_attr_t const * ar
Attribute representing the ar after the deepest node that was found in the existing pair tree when ev...
int tmpl_attr_to_xlat(TALLOC_CTX *ctx, tmpl_t **vpt_p)
Convert an attribute reference to an xlat expansion.
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.
tmpl_attr_filter_type_t
Define entry and head types for attribute reference lists.
@ TMPL_ATTR_FILTER_TYPE_TMPL
Filter is a tmpl.
@ TMPL_ATTR_FILTER_TYPE_INDEX
Filter is an index type.
@ TMPL_ATTR_FILTER_TYPE_CONDITION
Filter is a condition.
@ TMPL_ATTR_FILTER_TYPE_NONE
No filter present.
@ TMPL_ATTR_FILTER_TYPE_EXPR
Filter is an expression.
fr_event_list_t * runtime_el
The eventlist to use for runtime instantiation of xlats.
fr_table_num_ordered_t const tmpl_type_table[]
Map tmpl_type_t values to descriptive strings.
int tmpl_cast_set(tmpl_t *vpt, fr_type_t type)
Set a cast for a tmpl.
fr_token_t _CONST quote
What type of quoting was around the raw string.
void tmpl_attr_debug(tmpl_t const *vpt)
fr_type_t tmpl_expanded_type(tmpl_t const *vpt)
Return the native data type of the expression.
tmpl_attr_filter_type_t _CONST type
Type of filter this is.
size_t tmpl_request_ref_table_len
static char const * tmpl_type_to_str(tmpl_type_t type)
Return a static string containing the type name.
Describes the current extents of a pair tree in relation to the tree described by a tmpl_t.
Similar to tmpl_rules_t, but used to specify parameters that may change during subsequent resolution ...
Optional arguments passed to vp_tmpl functions.
A source or sink of value data.
static char buff[sizeof("18446744073709551615")+3]
fr_aka_sim_id_type_t type
Define entry and head types for tmpl request references.
tmpl_attr_list_presence_t list_presence
Whether the attribute reference can have a list, forbid it, or require it.
fr_dict_attr_t const * list_def
Default list to use with unqualified attribute reference.
uint8_t disallow_filters
disallow filters.
uint8_t allow_unresolved
Allow attributes that look valid but were not found in the dictionaries.
uint8_t allow_foreign
Allow arguments not found in dict_def.
fr_dict_t const * dict_def
Default dictionary to use with unqualified attribute references.
FR_DLIST_HEAD(tmpl_request_list) _CONST *request_def
< Point in dictionary tree to resume parsing from.
uint8_t allow_wildcard
Allow the special case of .
uint8_t allow_unknown
Allow unknown attributes i.e.
tmpl_attr_prefix_t prefix
Whether the attribute reference requires a prefix.
An element in a list of nested attribute references.
unsigned int _CONST resolve_only
This reference and those before it.
unsigned int _CONST is_raw
fr_dict_attr_t const *_CONST da
Resolved dictionary attribute.
fr_dict_attr_t const *_CONST parent
The parent we used when trying to resolve the attribute originally.
FR_DLIST_ENTRY(tmpl_attr_list) _CONST entry
Entry in the doubly linked list of attribute references.
tmpl_attr_filter_t _CONST filter
Filter associated with the attribute reference.
tmpl_attr_type_t _CONST type
is a raw reference
Define manipulation functions for the attribute reference list.
FR_DLIST_ENTRY(tmpl_request_list) _CONST entry
Entry in the doubly linked list of request references.
tmpl_request_ref_t _CONST request
Stores an attribute, a value and various bits of other data.
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
An element in an arbitrarily ordered array of name to num mappings.
An element in a lexicographically sorted array of name to num mappings.
Escaping rules for tmpls.
#define fr_type_is_structural(_x)
#define fr_type_is_leaf(_x)
static size_t char fr_sbuff_t size_t inlen
uintptr_t fr_value_box_safe_for_t
Escaping that's been applied to a value box.
static size_t char ** out