The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
tmpl.h File Reference

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>
+ Include dependency graph for tmpl.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
 
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.__unnamed79__
 
struct  tmpl_attr_t.__unnamed79__.unknown
 
struct  tmpl_attr_t.__unnamed79__.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.__unnamed85__
 
union  tmpl_s.data.__unnamed85__.__unnamed87__
 
struct  tmpl_s.data.__unnamed85__.__unnamed87__.xlat
 
struct  tmpl_s.data.attribute
 
struct  tmpl_xlat_rules_s
 

Macros

#define _CONST   const
 
#define FR_TYPE_FROM_PTR(_ptr)
 Map ptr type to a boxed type. More...
 
#define NUM_ALL   (INT16_MIN + 1)
 
#define NUM_COUNT   (INT16_MIN + 2)
 
#define NUM_LAST   (INT16_MIN + 3)
 
#define NUM_UNSPEC   INT16_MIN
 
#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. More...
 
#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. More...
 
#define tmpl_assert_type(_cond)
 Convenience macro for printing a meaningful assert message when we get a bad tmpl type. More...
 
#define TMPL_ATTR_VERIFY(_vpt)
 
#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. More...
 
#define TMPL_FLAG_ATTR   0x01000000
 Base data type is an attribute reference. More...
 
#define TMPL_FLAG_REGEX   0x04000000
 Is a type of regular expression. More...
 
#define TMPL_FLAG_UNRESOLVED   0x08000000
 Needs resolution. More...
 
#define TMPL_FLAG_XLAT   0x02000000
 Base data type is an xlat expansion. More...
 
#define tmpl_is_attr(vpt)   (vpt->type == TMPL_TYPE_ATTR)
 
#define tmpl_is_attr_unresolved(vpt)   (vpt->type == TMPL_TYPE_ATTR_UNRESOLVED)
 
#define tmpl_is_data(vpt)   (vpt->type == TMPL_TYPE_DATA)
 
#define tmpl_is_data_unresolved(vpt)   (vpt->type == TMPL_TYPE_DATA_UNRESOLVED)
 
#define tmpl_is_exec(vpt)   (vpt->type == TMPL_TYPE_EXEC)
 
#define tmpl_is_exec_unresolved(vpt)   (vpt->type == TMPL_TYPE_EXEC_UNRESOLVED)
 
#define tmpl_is_null(vpt)   (vpt->type == TMPL_TYPE_NULL)
 
#define tmpl_is_regex(vpt)   (vpt->type == TMPL_TYPE_REGEX)
 
#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)
 Helpers to verify the type of tmpl_t. More...
 
#define tmpl_is_xlat(vpt)   (vpt->type == TMPL_TYPE_XLAT)
 
#define tmpl_is_xlat_unresolved(vpt)   (vpt->type == TMPL_TYPE_XLAT_UNRESOLVED)
 
#define TMPL_MAX_REQUEST_REF_NESTING   10
 The maximum number of request references allowed. More...
 
#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. More...
 
#define TMPL_POOL_DEF_HEADERS   4
 Define manipulation functions for the attribute reference list. More...
 
#define TMPL_POOL_DEF_LEN   (sizeof(tmpl_t) + 64 + sizeof(tmpl_attr_t) + sizeof(tmpl_request_t))
 How many additional bytes to allocate in a pool for a tmpl_t. More...
 
#define TMPL_VERIFY(_vpt)
 

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
 

Enumerations

enum  requests_ref_e {
  REQUEST_CURRENT = 0 ,
  REQUEST_OUTER ,
  REQUEST_PARENT ,
  REQUEST_UNKNOWN
}
 
enum  tmpl_attr_error_t {
  TMPL_ATTR_ERROR_NONE = 0 ,
  TMPL_ATTR_ERROR_EMPTY ,
  TMPL_ATTR_ERROR_BAD_PREFIX ,
  TMPL_ATTR_ERROR_LIST_NOT_ALLOWED ,
  TMPL_ATTR_ERROR_LIST_MISSING ,
  TMPL_ATTR_ERROR_UNKNOWN_NOT_ALLOWED ,
  TMPL_ATTR_ERROR_UNRESOLVED_NOT_ALLOWED ,
  TMPL_ATTR_ERROR_UNQUALIFIED_NOT_ALLOWED ,
  TMPL_ATTR_ERROR_INVALID_NAME ,
  TMPL_ATTR_ERROR_INTERNAL_NOT_ALLOWED ,
  TMPL_ATTR_ERROR_FOREIGN_NOT_ALLOWED ,
  TMPL_ATTR_ERROR_FILTER_NOT_ALLOWED ,
  TMPL_ATTR_ERROR_INVALID_ARRAY_INDEX ,
  TMPL_ATTR_ERROR_INVALID_FILTER ,
  TMPL_ATTR_ERROR_NESTING_TOO_DEEP ,
  TMPL_ATTR_ERROR_MISSING_TERMINATOR ,
  TMPL_ATTR_ERROR_BAD_CAST
}
 
enum  tmpl_attr_filter_type_t {
  TMPL_ATTR_FILTER_TYPE_NONE = 0 ,
  TMPL_ATTR_FILTER_TYPE_INDEX ,
  TMPL_ATTR_FILTER_TYPE_CONDITION
}
 Define entry and head types for attribute reference lists. More...
 
enum  tmpl_attr_list_presence_t {
  TMPL_ATTR_LIST_ALLOW = 0 ,
  TMPL_ATTR_LIST_FORBID ,
  TMPL_ATTR_LIST_REQUIRE
}
 Specify whether attribute references can have a list (or parent) reference. More...
 
enum  tmpl_attr_prefix_t {
  TMPL_ATTR_REF_PREFIX_YES = 0 ,
  TMPL_ATTR_REF_PREFIX_NO ,
  TMPL_ATTR_REF_PREFIX_AUTO ,
  TMPL_ATTR_REF_PREFIX_YES = 0 ,
  TMPL_ATTR_REF_PREFIX_NO ,
  TMPL_ATTR_REF_PREFIX_AUTO
}
 Specify whether attribute references require a prefix. More...
 
enum  tmpl_attr_type_t {
  TMPL_ATTR_TYPE_NORMAL = 0 ,
  TMPL_ATTR_TYPE_UNSPEC ,
  TMPL_ATTR_TYPE_UNKNOWN ,
  TMPL_ATTR_TYPE_UNRESOLVED
}
 
enum  tmpl_type_e {
  TMPL_TYPE_UNINITIALISED = 0x0000 ,
  TMPL_TYPE_NULL = 0x0001 ,
  TMPL_TYPE_DATA = 0x0002 ,
  TMPL_TYPE_ATTR = 0x0008 | TMPL_FLAG_ATTR ,
  TMPL_TYPE_XLAT = 0x0010 | TMPL_FLAG_XLAT ,
  TMPL_TYPE_EXEC = 0x0020 | TMPL_FLAG_XLAT ,
  TMPL_TYPE_REGEX = 0x0040 | TMPL_FLAG_REGEX ,
  TMPL_TYPE_REGEX_UNCOMPILED = 0x0080 | TMPL_FLAG_REGEX ,
  TMPL_TYPE_REGEX_XLAT = 0x0100 | TMPL_FLAG_REGEX | TMPL_FLAG_XLAT ,
  TMPL_TYPE_DATA_UNRESOLVED = TMPL_TYPE_DATA | TMPL_FLAG_UNRESOLVED ,
  TMPL_TYPE_ATTR_UNRESOLVED = TMPL_TYPE_ATTR | TMPL_FLAG_UNRESOLVED ,
  TMPL_TYPE_EXEC_UNRESOLVED = TMPL_TYPE_EXEC | TMPL_FLAG_UNRESOLVED ,
  TMPL_TYPE_XLAT_UNRESOLVED = TMPL_TYPE_XLAT | TMPL_FLAG_UNRESOLVED ,
  TMPL_TYPE_REGEX_XLAT_UNRESOLVED = TMPL_TYPE_REGEX_XLAT | TMPL_FLAG_UNRESOLVED ,
  TMPL_TYPE_MAX
}
 Types of tmpl_t. More...
 

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_ttmpl_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 from, int16_t to)
 Rewrite the leaf's instance number. More...
 
void tmpl_attr_rewrite_num (tmpl_t *vpt, int16_t from, int16_t to)
 Rewrite all instances of an array 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_leaf_num (tmpl_t *vpt, int16_t num)
 
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)
 
void tmpl_global_free (void)
 
int tmpl_global_init (void)
 
tmpl_ttmpl_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_ttmpl_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_ttmpl_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_ttmpl_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_ttmpl_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, fr_dict_attr_t const **castda, bool require_regex, bool allow_xlat))
 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 attribute references

#define ar_cond   filter.cond
 
#define ar_da   da
 
#define ar_depth   depth
 
#define ar_filter_is_cond(_ar)   ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_CONDITION)
 
#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_type   filter.type
 
#define ar_is_normal(_ar)   ((_ar)->ar_type == TMPL_ATTR_TYPE_NORMAL)
 
#define ar_is_raw(_ar)   ((_ar)->is_raw)
 
#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_num   filter.num
 
#define ar_parent   parent
 
#define ar_type   type
 
#define ar_unknown   unknown.da
 
#define ar_unresolved   unresolved.name
 
#define ar_unresolved_namespace   unresolved.namespace
 

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...
 

Print the contents of a #tmpl_t

static fr_slen_t ar_prefix
 
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
 
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
 
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
 
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. More...
 
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. More...
 
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. More...
 
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
 
fr_slen_t tmpl_request_ref_list_print (fr_sbuff_t *out, FR_DLIST_HEAD(tmpl_request_list) const *rql))
 
static fr_slen_t vpt
 

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_ttmpl_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...
 

Detailed Description

Structures and prototypes for templates.

Id
5104a0071413c011e1d4bda01d057536b1e69dc7

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).

See also
tmpl_afrom_substr
tmpl_afrom_attr_str

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.

See also
tmpl_dcursor_init
tmpl_cursor_next

Or for simplicity, there are functions which wrap the cursor functions, to copy or return the fr_pair_t that match the VPT.

See also
tmpl_copy_pairs
tmpl_find_vp

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.

See also
tmpl_expand
tmpl_aexpand

Definition in file tmpl.h.


Data Structure Documentation

◆ tmpl_attr_extent_t

struct tmpl_attr_extent_t

Describes the current extents of a pair tree in relation to the tree described by a tmpl_t.

Definition at line 596 of file tmpl.h.

+ Collaboration diagram for tmpl_attr_extent_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.

◆ tmpl_attr_filter_t

struct tmpl_attr_filter_t

Definition at line 418 of file tmpl.h.

+ Collaboration diagram for tmpl_attr_filter_t:
Data Fields
xlat_exp_head_t _CONST * cond xlat condition
int16_t _CONST num For array references.
tmpl_attr_filter_type_t _CONST type Type of filter this is.

◆ tmpl_attr_t.__unnamed79__

union tmpl_attr_t.__unnamed79__

Definition at line 433 of file tmpl.h.

Data Fields
__unnamed79__ unknown
__unnamed79__ unresolved

◆ tmpl_attr_t.__unnamed79__.unknown

struct tmpl_attr_t.__unnamed79__.unknown

Definition at line 434 of file tmpl.h.

Data Fields
fr_dict_attr_t *_CONST da Unknown dictionary attribute.

◆ tmpl_attr_t.__unnamed79__.unresolved

struct tmpl_attr_t.__unnamed79__.unresolved

Definition at line 438 of file tmpl.h.

Data Fields
char *_CONST name Undefined reference type.

◆ tmpl_res_rules_s

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.

Definition at line 373 of file tmpl.h.

+ Collaboration diagram for tmpl_res_rules_s:
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.

◆ tmpl_rules_s

struct tmpl_rules_s

Optional arguments passed to vp_tmpl functions.

Definition at line 341 of file tmpl.h.

+ Collaboration diagram for 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.

◆ tmpl_s

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)

Use in update map_t

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:

Use in conditional map_t

When used as part of a condition it may be any of the RHS side types, as well as:

See also
map_t

Definition at line 540 of file tmpl.h.

+ Collaboration diagram for tmpl_s:
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.

◆ tmpl_s.data

union tmpl_s.data

Definition at line 548 of file tmpl.h.

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.

◆ tmpl_s.data.__unnamed85__

struct tmpl_s.data.__unnamed85__

Definition at line 564 of file tmpl.h.

Data Fields
__unnamed85__ __unnamed__
fr_regex_flags_t reg_flags Flags for regular expressions.

Used by:

  • TMPL_TYPE_REGEX_XLAT
  • TMPL_TYPE_REGEX_UNCOMPILED
  • TMPL_TYPE_REGEX
  • TMPL_TYPE_REGEX_XLAT_UNRESOLVED

◆ tmpl_s.data.__unnamed85__.__unnamed87__

union tmpl_s.data.__unnamed85__.__unnamed87__

Definition at line 565 of file tmpl.h.

Data Fields
__unnamed87__ xlat

◆ tmpl_s.data.__unnamed85__.__unnamed87__.xlat

struct tmpl_s.data.__unnamed85__.__unnamed87__.xlat

Definition at line 566 of file tmpl.h.

Data Fields
xlat_exp_head_t * ex pre-parsed xlat expansion and expansion.

◆ tmpl_s.data.attribute

struct tmpl_s.data.attribute

Definition at line 552 of file tmpl.h.

Data Fields
bool ref_prefix true if the reference was prefixed with a '&'.

◆ tmpl_xlat_rules_s

struct tmpl_xlat_rules_s

Definition at line 332 of file tmpl.h.

+ Collaboration diagram for 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.

Macro Definition Documentation

◆ _CONST

#define _CONST   const

Definition at line 256 of file tmpl.h.

◆ ar_cond

#define ar_cond   filter.cond

Definition at line 509 of file tmpl.h.

◆ ar_da

#define ar_da   da

Definition at line 496 of file tmpl.h.

◆ ar_depth

#define ar_depth   depth

Definition at line 495 of file tmpl.h.

◆ ar_filter_is_cond

#define ar_filter_is_cond (   _ar)    ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_CONDITION)

Definition at line 514 of file tmpl.h.

◆ ar_filter_is_none

#define ar_filter_is_none (   _ar)    ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_NONE)

Definition at line 512 of file tmpl.h.

◆ ar_filter_is_num

#define ar_filter_is_num (   _ar)    ((_ar)->ar_filter_type == TMPL_ATTR_FILTER_TYPE_INDEX)

Definition at line 513 of file tmpl.h.

◆ ar_filter_type

#define ar_filter_type   filter.type

Definition at line 510 of file tmpl.h.

◆ ar_is_normal

#define ar_is_normal (   _ar)    ((_ar)->ar_type == TMPL_ATTR_TYPE_NORMAL)

Definition at line 502 of file tmpl.h.

◆ ar_is_raw

#define ar_is_raw (   _ar)    ((_ar)->is_raw)

Definition at line 506 of file tmpl.h.

◆ ar_is_unknown

#define ar_is_unknown (   _ar)    ((_ar)->ar_type == TMPL_ATTR_TYPE_UNKNOWN)

Definition at line 504 of file tmpl.h.

◆ ar_is_unresolved

#define ar_is_unresolved (   _ar)    ((_ar)->ar_type == TMPL_ATTR_TYPE_UNRESOLVED)

Definition at line 505 of file tmpl.h.

◆ ar_is_unspecified

#define ar_is_unspecified (   _ar)    ((_ar)->ar_type == TMPL_ATTR_TYPE_UNSPEC)

Definition at line 503 of file tmpl.h.

◆ ar_num

#define ar_num   filter.num

Definition at line 508 of file tmpl.h.

◆ ar_parent

#define ar_parent   parent

Definition at line 497 of file tmpl.h.

◆ ar_type

#define ar_type   type

Definition at line 494 of file tmpl.h.

◆ ar_unknown

#define ar_unknown   unknown.da

Definition at line 498 of file tmpl.h.

◆ ar_unresolved

#define ar_unresolved   unresolved.name

Definition at line 499 of file tmpl.h.

◆ ar_unresolved_namespace

#define ar_unresolved_namespace   unresolved.namespace

Definition at line 500 of file tmpl.h.

◆ FR_TYPE_FROM_PTR

#define FR_TYPE_FROM_PTR (   _ptr)
Value:
_Generic((_ptr), \
char **: FR_TYPE_STRING, \
char const **: FR_TYPE_STRING, \
uint8_t const **: FR_TYPE_OCTETS, \
uint64_t *: FR_TYPE_UINT64, \
unsigned short uint16_t
Definition: merged_model.c:31
@ FR_TYPE_STRING
String of printable characters.
Definition: merged_model.c:83
@ FR_TYPE_UINT16
16 Bit unsigned integer.
Definition: merged_model.c:98
@ FR_TYPE_VALUE_BOX
A boxed value.
Definition: merged_model.c:125
@ FR_TYPE_UINT8
8 Bit unsigned integer.
Definition: merged_model.c:97
@ FR_TYPE_UINT32
32 Bit unsigned integer.
Definition: merged_model.c:99
@ FR_TYPE_UINT64
64 Bit unsigned integer.
Definition: merged_model.c:100
@ FR_TYPE_OCTETS
Raw octets.
Definition: merged_model.c:84
unsigned int uint32_t
Definition: merged_model.c:33
unsigned char uint8_t
Definition: merged_model.c:30

Map ptr type to a boxed type.

Definition at line 1025 of file tmpl.h.

◆ NUM_ALL

#define NUM_ALL   (INT16_MIN + 1)

Definition at line 400 of file tmpl.h.

◆ NUM_COUNT

#define NUM_COUNT   (INT16_MIN + 2)

Definition at line 401 of file tmpl.h.

◆ NUM_LAST

#define NUM_LAST   (INT16_MIN + 3)

Definition at line 402 of file tmpl.h.

◆ NUM_UNSPEC

#define NUM_UNSPEC   INT16_MIN

Definition at line 399 of file tmpl.h.

◆ tmpl_aexpand

#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.

See also
_tmpl_to_atype

Definition at line 1054 of file tmpl.h.

◆ tmpl_aexpand_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.

See also
_tmpl_to_atype

Definition at line 1063 of file tmpl.h.

◆ tmpl_assert_type

#define tmpl_assert_type (   _cond)
Value:
fr_assert_msg(_cond, "Unexpected tmpl type '%s'", \
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
Definition: debug.h:208
static fr_slen_t vpt
Definition: tmpl.h:1260
static char const * tmpl_type_to_str(tmpl_type_t type)
Return a static string containing the type name.
Definition: tmpl.h:629

Convenience macro for printing a meaningful assert message when we get a bad tmpl type.

Definition at line 615 of file tmpl.h.

◆ tmpl_attr

#define tmpl_attr (   _tmpl)    &(_tmpl)->data.attribute.ar

Definition at line 649 of file tmpl.h.

◆ TMPL_ATTR_VERIFY

#define TMPL_ATTR_VERIFY (   _vpt)

Definition at line 952 of file tmpl.h.

◆ tmpl_contains_attr

#define tmpl_contains_attr (   vpt)    (vpt->type & TMPL_FLAG_ATTR)

Definition at line 229 of file tmpl.h.

◆ tmpl_contains_regex

#define tmpl_contains_regex (   vpt)    (vpt->type & TMPL_FLAG_REGEX)

Definition at line 230 of file tmpl.h.

◆ tmpl_contains_xlat

#define tmpl_contains_xlat (   vpt)    (vpt->type & TMPL_FLAG_XLAT)

Definition at line 231 of file tmpl.h.

◆ tmpl_expand

#define tmpl_expand (   _out,
  _buff,
  _buff_len,
  _request,
  _vpt,
  _escape,
  _escape_ctx 
)
Value:
_tmpl_to_type((void *)(_out), (uint8_t *)_buff, _buff_len, \
_request, _vpt, _escape, _escape_ctx, FR_TYPE_FROM_PTR(_out))
#define FR_TYPE_FROM_PTR(_ptr)
Map ptr type to a boxed type.
Definition: tmpl.h:1025
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.
Definition: tmpl_eval.c:282

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.

See also
_tmpl_to_type

Definition at line 1044 of file tmpl.h.

◆ TMPL_FLAG_ATTR

#define TMPL_FLAG_ATTR   0x01000000

Base data type is an attribute reference.

Definition at line 106 of file tmpl.h.

◆ TMPL_FLAG_REGEX

#define TMPL_FLAG_REGEX   0x04000000

Is a type of regular expression.

Definition at line 116 of file tmpl.h.

◆ TMPL_FLAG_UNRESOLVED

#define TMPL_FLAG_UNRESOLVED   0x08000000

Needs resolution.

Definition at line 121 of file tmpl.h.

◆ TMPL_FLAG_XLAT

#define TMPL_FLAG_XLAT   0x02000000

Base data type is an xlat expansion.

Definition at line 111 of file tmpl.h.

◆ tmpl_is_attr

#define tmpl_is_attr (   vpt)    (vpt->type == TMPL_TYPE_ATTR)

Definition at line 213 of file tmpl.h.

◆ tmpl_is_attr_unresolved

#define tmpl_is_attr_unresolved (   vpt)    (vpt->type == TMPL_TYPE_ATTR_UNRESOLVED)

Definition at line 224 of file tmpl.h.

◆ tmpl_is_data

#define tmpl_is_data (   vpt)    (vpt->type == TMPL_TYPE_DATA)

Definition at line 211 of file tmpl.h.

◆ tmpl_is_data_unresolved

#define tmpl_is_data_unresolved (   vpt)    (vpt->type == TMPL_TYPE_DATA_UNRESOLVED)

Definition at line 222 of file tmpl.h.

◆ tmpl_is_exec

#define tmpl_is_exec (   vpt)    (vpt->type == TMPL_TYPE_EXEC)

Definition at line 216 of file tmpl.h.

◆ tmpl_is_exec_unresolved

#define tmpl_is_exec_unresolved (   vpt)    (vpt->type == TMPL_TYPE_EXEC_UNRESOLVED)

Definition at line 223 of file tmpl.h.

◆ tmpl_is_null

#define tmpl_is_null (   vpt)    (vpt->type == TMPL_TYPE_NULL)

Definition at line 210 of file tmpl.h.

◆ tmpl_is_regex

#define tmpl_is_regex (   vpt)    (vpt->type == TMPL_TYPE_REGEX)

Definition at line 218 of file tmpl.h.

◆ tmpl_is_regex_uncompiled

#define tmpl_is_regex_uncompiled (   vpt)    (vpt->type == TMPL_TYPE_REGEX_UNCOMPILED)

Definition at line 219 of file tmpl.h.

◆ tmpl_is_regex_xlat

#define tmpl_is_regex_xlat (   vpt)    (vpt->type == TMPL_TYPE_REGEX_XLAT)

Definition at line 220 of file tmpl.h.

◆ tmpl_is_regex_xlat_unresolved

#define tmpl_is_regex_xlat_unresolved (   vpt)    (vpt->type == TMPL_TYPE_REGEX_XLAT_UNRESOLVED)

Definition at line 226 of file tmpl.h.

◆ tmpl_is_uninitialised

#define tmpl_is_uninitialised (   vpt)    (vpt->type == TMPL_TYPE_UNINITIALISED)

Helpers to verify the type of tmpl_t.

Definition at line 208 of file tmpl.h.

◆ tmpl_is_xlat

#define tmpl_is_xlat (   vpt)    (vpt->type == TMPL_TYPE_XLAT)

Definition at line 215 of file tmpl.h.

◆ tmpl_is_xlat_unresolved

#define tmpl_is_xlat_unresolved (   vpt)    (vpt->type == TMPL_TYPE_XLAT_UNRESOLVED)

Definition at line 225 of file tmpl.h.

◆ TMPL_MAX_REQUEST_REF_NESTING

#define TMPL_MAX_REQUEST_REF_NESTING   10

The maximum number of request references allowed.

Definition at line 85 of file tmpl.h.

◆ tmpl_needs_resolving

#define tmpl_needs_resolving (   vpt)    (vpt->type & TMPL_FLAG_UNRESOLVED)

Definition at line 228 of file tmpl.h.

◆ tmpl_pair_list_and_ctx

#define tmpl_pair_list_and_ctx (   _ctx,
  _head,
  _request,
  _ref,
  _list 
)
Value:
do {\
request_t *_rctx = _request; \
if ((tmpl_request_ptr(&_rctx, _ref) < 0) || \
!(_head = tmpl_list_head(_rctx, _list)) || \
!(_ctx = tmpl_list_ctx(_rctx, _list))) {\
_ctx = NULL; \
_head = NULL; \
}\
} while (0)
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.
Definition: tmpl_eval.c:114
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.
Definition: tmpl_eval.c:74
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.
Definition: tmpl_eval.c:167

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:

TALLOC_CTX *ctx;
tmpl_pair_list_and_ctx(ctx, head, request, CURRENT_REQUEST, request_attr_request);
if (!list) return -1; // error
value.strvalue = talloc_typed_strdup(NULL, "my new username");
value.length = talloc_array_length(value.strvalue) - 1;
Test enumeration values.
Definition: dict_test.h:92
fr_dict_attr_t const * request_attr_request
Definition: request.c:41
#define tmpl_pair_list_and_ctx(_ctx, _head, _request, _ref, _list)
Determine the correct context and list head.
Definition: tmpl.h:985
char * talloc_typed_strdup(TALLOC_CTX *ctx, char const *p)
Call talloc_strdup, setting the type on the new chunk correctly.
Definition: talloc.c:333
static fr_slen_t head
Definition: xlat.h:408
Parameters
_ctxnew fr_pair_t s should be allocated in for the specified list.
_headof the fr_pair_t list.
_requestThe current request.
_refto resolve.
_listto resolve.

Definition at line 985 of file tmpl.h.

◆ TMPL_POOL_DEF_HEADERS

#define TMPL_POOL_DEF_HEADERS   4

Define manipulation functions for the attribute reference list.

How many additional headers to allocate in a pool for a tmpl_t

Definition at line 483 of file tmpl.h.

◆ TMPL_POOL_DEF_LEN

#define TMPL_POOL_DEF_LEN   (sizeof(tmpl_t) + 64 + sizeof(tmpl_attr_t) + sizeof(tmpl_request_t))

How many additional bytes to allocate in a pool for a tmpl_t.

Definition at line 488 of file tmpl.h.

◆ tmpl_request_ref_is_current

#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.

Parameters
[in]_listto check.
Returns
  • true if the list only contains a current request qualifier.
  • false otherwise.

Definition at line 1124 of file tmpl.h.

◆ tmpl_request_ref_is_outer

#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.

Parameters
[in]_listto check.
Returns
  • true if the list only contains a outer request qualifier.
  • false otherwise.

Definition at line 1142 of file tmpl.h.

◆ tmpl_request_ref_is_parent

#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.

Parameters
[in]_listto check.
Returns
  • true if the list only contains a parent request qualifier.
  • false otherwise.

Definition at line 1133 of file tmpl.h.

◆ tmpl_rules_cast

#define tmpl_rules_cast (   _tmpl)    (_tmpl)->rules.cast

Definition at line 937 of file tmpl.h.

◆ tmpl_rules_enumv

#define tmpl_rules_enumv (   _tmpl)    (_tmpl)->rules.enumv

Definition at line 938 of file tmpl.h.

◆ tmpl_value

#define tmpl_value (   _tmpl)    (&(_tmpl)->data.literal)

Definition at line 932 of file tmpl.h.

◆ tmpl_value_enumv

#define tmpl_value_enumv (   _tmpl)    (_tmpl)->data.literal.enumv

Definition at line 935 of file tmpl.h.

◆ tmpl_value_length

#define tmpl_value_length (   _tmpl)    (_tmpl)->data.literal.vb_length

Definition at line 933 of file tmpl.h.

◆ tmpl_value_type

#define tmpl_value_type (   _tmpl)    (_tmpl)->data.literal.type

Definition at line 934 of file tmpl.h.

◆ TMPL_VERIFY

#define TMPL_VERIFY (   _vpt)

Definition at line 953 of file tmpl.h.

◆ tmpl_xlat

#define tmpl_xlat (   _tmpl)    (_tmpl)->data.xlat.ex

Definition at line 925 of file tmpl.h.

Typedef Documentation

◆ tmpl_attr_rules_t

Definition at line 234 of file tmpl.h.

◆ tmpl_literal_rules_t

typedef struct tmpl_literal_rules_s tmpl_literal_rules_t

Definition at line 234 of file tmpl.h.

◆ tmpl_request_ref_t

◆ tmpl_res_rules_t

Definition at line 234 of file tmpl.h.

◆ tmpl_rules_t

typedef struct tmpl_rules_s tmpl_rules_t

Definition at line 234 of file tmpl.h.

◆ tmpl_t

typedef struct tmpl_s tmpl_t

Definition at line 234 of file tmpl.h.

◆ tmpl_type_t

typedef enum tmpl_type_e tmpl_type_t

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:

  • XLAT_TYPE_XLAT - tmpl_t contains xlat expansion.
  • XLAT_TYPE_UNRESOLVED - tmpl_t contains unresolved elements such as xlat functions or other expansions.

◆ tmpl_xlat_rules_t

Definition at line 234 of file tmpl.h.

Enumeration Type Documentation

◆ requests_ref_e

Enumerator
REQUEST_CURRENT 

The current request (default).

REQUEST_OUTER 

request_t containing the outer layer of the EAP conversation.

Usually the RADIUS request sent by the NAS.

REQUEST_PARENT 

Parent (whatever it is).

REQUEST_UNKNOWN 

Unknown request.

Definition at line 90 of file tmpl.h.

◆ tmpl_attr_error_t

Enumerator
TMPL_ATTR_ERROR_NONE 

No error.

TMPL_ATTR_ERROR_EMPTY 

Attribute ref contains no data.

TMPL_ATTR_ERROR_BAD_PREFIX 

Missing '&' or has '&' when it shouldn't.

TMPL_ATTR_ERROR_LIST_NOT_ALLOWED 

List qualifier is not allowed here.

TMPL_ATTR_ERROR_LIST_MISSING 

List qualifier is required, but missing.

TMPL_ATTR_ERROR_UNKNOWN_NOT_ALLOWED 

Attribute specified as OID, could not be found in the dictionaries, and is disallowed because 'disallow_internal' in tmpl_rules_t is trie.

TMPL_ATTR_ERROR_UNRESOLVED_NOT_ALLOWED 

Attribute couldn't be found in the dictionaries.

TMPL_ATTR_ERROR_UNQUALIFIED_NOT_ALLOWED 

Attribute must be qualified to be used here.

TMPL_ATTR_ERROR_INVALID_NAME 

Attribute ref length is zero, or longer than the maximum.

TMPL_ATTR_ERROR_INTERNAL_NOT_ALLOWED 

Attribute resolved to an internal attribute which is disallowed.

TMPL_ATTR_ERROR_FOREIGN_NOT_ALLOWED 

Attribute resolved in a dictionary different to the one specified.

TMPL_ATTR_ERROR_FILTER_NOT_ALLOWED 

Filters disallowed by rules.

TMPL_ATTR_ERROR_INVALID_ARRAY_INDEX 

Invalid array index.

TMPL_ATTR_ERROR_INVALID_FILTER 

Invalid filter.

TMPL_ATTR_ERROR_NESTING_TOO_DEEP 

Too many levels of nesting.

TMPL_ATTR_ERROR_MISSING_TERMINATOR 

Unexpected text found after attribute reference.

TMPL_ATTR_ERROR_BAD_CAST 

Specified cast was invalid.

Definition at line 996 of file tmpl.h.

◆ tmpl_attr_filter_type_t

Define entry and head types for attribute reference lists.

Different types of filter that can be applied to an attribute reference

Enumerator
TMPL_ATTR_FILTER_TYPE_NONE 

No filter present.

TMPL_ATTR_FILTER_TYPE_INDEX 

Filter is an index type.

TMPL_ATTR_FILTER_TYPE_CONDITION 

Filter is a condition.

Definition at line 412 of file tmpl.h.

◆ tmpl_attr_list_presence_t

Specify whether attribute references can have a list (or parent) reference.

Enumerator
TMPL_ATTR_LIST_ALLOW 

Attribute refs are allowed to have a list.

TMPL_ATTR_LIST_FORBID 

Attribute refs are forbidden from having a list.

TMPL_ATTR_LIST_REQUIRE 

Attribute refs are required to have a list.

Definition at line 273 of file tmpl.h.

◆ tmpl_attr_prefix_t

Specify whether attribute references require a prefix.

Enumerator
TMPL_ATTR_REF_PREFIX_YES 

Attribute refs must have '&' 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.

TMPL_ATTR_REF_PREFIX_NO 

Attribute refs have no '&' prefix.

TMPL_ATTR_REF_PREFIX_AUTO 

Attribute refs may have a '&' prefix.

Definition at line 264 of file tmpl.h.

◆ tmpl_attr_type_t

Enumerator
TMPL_ATTR_TYPE_NORMAL 

Normal, resolved, attribute ref.

TMPL_ATTR_TYPE_UNSPEC 

No attribute was specified as this level only a filter.

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 previous ref.

May be resolved later.

TMPL_ATTR_TYPE_UNRESOLVED 

We have a name, but nothing else to identify the attribute.

may be resolved later.

Definition at line 385 of file tmpl.h.

◆ 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:

  • XLAT_TYPE_XLAT - tmpl_t contains xlat expansion.
  • XLAT_TYPE_UNRESOLVED - tmpl_t contains unresolved elements such as xlat functions or other expansions.
Enumerator
TMPL_TYPE_UNINITIALISED 

Uninitialised.

TMPL_TYPE_NULL 

Has no value.

Usually a placeholder in a binary expression that's really a unary expression

TMPL_TYPE_DATA 

Value in native boxed format.

TMPL_TYPE_ATTR 

Reference to one or more attributes.

TMPL_TYPE_XLAT 

Pre-parsed xlat expansion.

TMPL_TYPE_EXEC 

Callout to an external script or program.

TMPL_TYPE_REGEX 

Compiled (and possibly JIT'd) regular expression.

TMPL_TYPE_REGEX_UNCOMPILED 

Regex where compilation is possible but hasn't been performed yet.

TMPL_TYPE_REGEX_XLAT 

A regex containing xlat expansions.

Cannot be pre-compiled

TMPL_TYPE_DATA_UNRESOLVED 

Unparsed literal string.

   May be an intermediary phase where the tmpl is created as a
   temporary structure during parsing.  The value here MUST be raw
   data, and cannot be anything else.
TMPL_TYPE_ATTR_UNRESOLVED 

An attribute reference that we couldn't resolve but looked valid.

   May be resolvable later once more attributes are defined.
TMPL_TYPE_EXEC_UNRESOLVED 

An exec with unresolved xlat function or attribute references.

TMPL_TYPE_XLAT_UNRESOLVED 

A xlat expansion with unresolved xlat functions or attribute references.

TMPL_TYPE_REGEX_XLAT_UNRESOLVED 

A regular expression with unresolved xlat functions or attribute references.

TMPL_TYPE_MAX 

Marker for the last tmpl type.

Definition at line 131 of file tmpl.h.

Function Documentation

◆ _tmpl_to_atype()

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.

Note
This function is used where raw string values are needed, which may mean the string returned may be binary data or contain unprintable chars. fr_snprint or fr_asprint should be used before using these values in debug statements. is_printable can be used to check if the string only contains printable chars.
The type (char or uint8_t) can be obtained with talloc_get_type, and may be used as a hint as to how to process or print the data.
Parameters
ctxto allocate new buffer in.
outWhere to write pointer to the new buffer.
requestCurrent request.
vptto expand. Must be one of the following types:
escapexlat escape function (only used for TMPL_TYPE_XLAT_UNRESOLVED_* types).
escape_ctxxlat escape function data (only used for TMPL_TYPE_XLAT_UNRESOLVED_* types).
dst_typeFR_TYPE_* matching out pointer.
See also
tmpl_aexpand.
Returns
  • -1 on failure.
  • The length of data written to buff, or pointed to by out.

Definition at line 561 of file tmpl_eval.c.

+ Here is the call graph for this function:

◆ _tmpl_to_type()

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.

Note
This function is used where raw string values are needed, which may mean the string returned may be binary data or contain unprintable chars. fr_snprint or fr_asprint should be used before using these values in debug statements. is_printable can be used to check if the string only contains printable chars.
Parameters
[out]outWhere 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]buffExpansion buffer, may be NULL except for the following types:
[in]bufflenLength of expansion buffer. Must be >= 2.
[in]requestCurrent request.
[in]vptto expand. Must be one of the following types:
[in]escapexlat escape function (only used for xlat types).
[in]escape_ctxxlat escape function data.
dst_typeFR_TYPE_* matching out pointer.
See also
tmpl_expand.
Returns
  • -1 on failure.
  • The length of data written out.

Definition at line 282 of file tmpl_eval.c.

+ Here is the call graph for this function:

◆ FR_DLIST_HEAD()

FR_DLIST_HEAD ( tmpl_request_list  )
inlinestatic

Static default request ref list for the current request.

Static default request ref list for the parent request.

Static default request ref list for the outer request.

Passed as request_def in tmpl_attr_rules_t.

Definition at line 651 of file tmpl.h.

◆ pair_append_by_tmpl_parent()

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.

Parameters
[in]ctxto allocate new pair(s) in
[out]outLeaf pair we allocated.
[in]listto insert into.
[in]vpttmpl representing the attribute to add.
[in]skip_listskip list attr ref at the head of the tmpl.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 972 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_afrom_attr_str()

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.

Parameters
[in,out]ctxto allocate tmpl_t in.
[out]errMay be NULL. Provides the exact error that the parser hit when processing the attribute ref.
[out]outWhere to write pointer to new tmpl_t.
[in]nameof attribute including tmpl_request_ref_t and fr_pair_list_t qualifiers.
[in]t_rulesRules which control parsing. See tmpl_afrom_attr_substr() for details.
Note
Unlike tmpl_afrom_attr_substr this function will error out if the entire name string isn't parsed.

Definition at line 2354 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_afrom_attr_substr()

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.

Parameters
[in,out]ctxto allocate tmpl_t in.
[out]errMay be NULL. Provides the exact error that the parser hit when processing the attribute ref.
[out]outWhere to write pointer to new tmpl_t.
[in]nameof attribute including tmpl_request_ref_t and fr_pair_list_t qualifiers.
[in]p_rulesFormatting rules used to check for trailing garbage.
[in]t_rulesRules which control parsing:
  • dict_def The default dictionary to use if attributes are unqualified.
  • request_def The default request_t to set if no tmpl_request_ref_t qualifiers are found in name.
  • list_def The default list to set if no fr_pair_list_t qualifiers are found in the name.
  • allow_unknown If true attributes in the format accepted by fr_dict_unknown_afrom_oid_substr will be allowed, even if they're not in the main dictionaries. If an unknown attribute is found a TMPL_TYPE_ATTR tmpl_t will be produced. If tmpl_afrom_attr_substr is being called on startup, the tmpl_t may be passed to tmpl_attr_unknown_add to add the unknown attribute to the main dictionary. If the unknown attribute is not added to the main dictionary the tmpl_t cannot be used to search for a fr_pair_t in a request_t.
  • allow_unresolved If true, we don't generate a parse error on unknown attributes. If an unknown attribute is found a TMPL_TYPE_ATTR_UNRESOLVED tmpl_t will be produced.
  • allow_foreign If true, allow attribute names to be qualified with a protocol outside of the passed dict_def.
  • disallow_filters
See also
REMARKER to produce pretty error markers from the return value.
Returns
  • <= 0 on error (offset as negative integer)
  • > 0 on success (number of bytes parsed).

Definition at line 2095 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_afrom_substr()

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.

Note
Unlike tmpl_afrom_attr_str return code 0 doesn't necessarily indicate failure, may just mean a 0 length string was parsed. Check to see if the function emitted a tmpl_t in *out.
xlats and regexes are left uncompiled. This is to support the two pass parsing done by the modcall code. Compilation on pass1 of that code could fail, as attributes or xlat functions registered by modules may not be available (yet).
For details of attribute parsing see tmpl_afrom_attr_substr.
Parameters
[in,out]ctxTo allocate tmpl_t in.
[out]outWhere to write the pointer to the new tmpl_t.
[in]inString to parse.
[in]quoteQuoting around the tmpl. Determines what we attempt to parse the string as.
[in]p_rulesFormatting rules for the tmpl.
[in]t_rulesValidation rules for attribute references.
Returns
  • < 0 on error (offset as negative integer)
  • >= 0 on success (number of bytes parsed).
See also
REMARKER to produce pretty error markers from the return value.
tmpl_afrom_attr_substr

Definition at line 3049 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_afrom_value_box()

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.

Parameters
[in,out]ctxto allocate tmpl_t in.
[out]outWhere to write pointer to new tmpl_t.
[in]datato convert.
[in]stealIf true, any buffers are moved to the new ctx instead of being duplicated.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 998 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_alloc()

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.

Parameters
[in,out]ctxto allocate in.
[in]typeto set in the tmpl_t.
[in]nameof the tmpl_t (will be copied to a new talloc buffer parented by the tmpl_t).
[in]lenThe 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]quoteThe type of quoting around the template name.
Returns
the newly allocated tmpl_t.

Definition at line 942 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_aprint()

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 
)
inlinestatic

◆ tmpl_aprint_quoted()

static fr_slen_t tmpl_aprint_quoted ( TALLOC_CTX *  ctx,
char **  out,
tmpl_t const *  vpt,
tmpl_attr_prefix_t  ar_prefix 
)
inlinestatic

◆ tmpl_async_required()

bool tmpl_async_required ( tmpl_t const *  vpt)

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 5653 of file tmpl_tokenize.c.

+ Here is the caller graph for this function:

◆ tmpl_attr_afrom_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.

Definition at line 1240 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_aprint()

static fr_slen_t tmpl_attr_aprint ( TALLOC_CTX *  ctx,
char **  out,
tmpl_t const *  vpt,
tmpl_attr_prefix_t  ar_prefix 
)
inlinestatic

◆ tmpl_attr_copy()

int tmpl_attr_copy ( tmpl_t dst,
tmpl_t const *  src 
)

Copy a list of attribute and request references from one tmpl to another.

Definition at line 1028 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_debug()

void tmpl_attr_debug ( tmpl_t const *  vpt)

Definition at line 266 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_head_is_list()

static bool tmpl_attr_head_is_list ( tmpl_t const *  vpt)
inlinestatic

Return true if the head attribute reference is a list reference.

Definition at line 689 of file tmpl.h.

+ Here is the call graph for this function:

◆ tmpl_attr_is_list_attr()

static bool tmpl_attr_is_list_attr ( tmpl_attr_t const *  ar)
inlinestatic

Return true if the tmpl_attr is one of the list types.

Definition at line 674 of file tmpl.h.

◆ tmpl_attr_list_from_substr()

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.

Parameters
[out]da_pattribute representing a list.
[in]inSbuff to read request references from.
Returns
  • > 0 the number of bytes parsed.
  • 0 no list qualifier found.

Definition at line 394 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_num_elements()

static size_t tmpl_attr_num_elements ( tmpl_t const *  vpt)
inlinestatic

The number of attribute references contained within a tmpl.

Definition at line 891 of file tmpl.h.

+ Here is the caller graph for this function:

◆ tmpl_attr_print()

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.

Parameters
[in]outWhere to write the presentation format tmpl_t string.
[in]vptto print.
[in]ar_prefixWhether to print the '&' at the beginning of attribute references.
  • TMPL_ATTR_REF_PREFIX_YES - always print.
  • TMPL_ATTR_REF_PREFIX_NO - never print.
  • TMPL_ATTR_REF_PREFIX_AUTO - print if the original tmpl was prefixed.
Returns
  • >0 the number of bytes written to the out buffer.
  • 0 invalid argument.
  • <0 the number of bytes we would have needed to complete the print.

Definition at line 4478 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_ref_debug()

void tmpl_attr_ref_debug ( const tmpl_attr_t ar,
int  idx 
)

Definition at line 191 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_ref_list_debug()

void tmpl_attr_ref_list_debug ( FR_DLIST_HEAD(tmpl_attr_list) const *  ar_head)

Definition at line 251 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_rewrite_leaf_num()

void tmpl_attr_rewrite_leaf_num ( tmpl_t vpt,
int16_t  from,
int16_t  to 
)

Rewrite the leaf's instance number.

Definition at line 1184 of file tmpl_tokenize.c.

+ Here is the caller graph for this function:

◆ tmpl_attr_rewrite_num()

void tmpl_attr_rewrite_num ( tmpl_t vpt,
int16_t  from,
int16_t  to 
)

Rewrite all instances of an array number.

Definition at line 1201 of file tmpl_tokenize.c.

◆ tmpl_attr_set_da()

int tmpl_attr_set_da ( tmpl_t vpt,
fr_dict_attr_t const *  da 
)

Replace the current attribute reference.

Definition at line 1079 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_set_leaf_da()

int tmpl_attr_set_leaf_da ( tmpl_t vpt,
fr_dict_attr_t const *  da 
)

Replace the leaf attribute only.

Definition at line 1112 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_set_leaf_num()

void tmpl_attr_set_leaf_num ( tmpl_t vpt,
int16_t  num 
)

Definition at line 1164 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_set_list()

void tmpl_attr_set_list ( tmpl_t vpt,
fr_dict_attr_t const *  list 
)

Definition at line 1229 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_set_request_ref()

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 1215 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_tail()

static tmpl_attr_t const* tmpl_attr_tail ( tmpl_t const *  vpt)
inlinestatic

Return the last attribute reference.

Definition at line 785 of file tmpl.h.

◆ tmpl_attr_tail_da()

static fr_dict_attr_t const* tmpl_attr_tail_da ( tmpl_t const *  vpt)
inlinestatic

Return the last attribute reference da.

Definition at line 796 of file tmpl.h.

◆ tmpl_attr_tail_da_is_leaf()

static bool tmpl_attr_tail_da_is_leaf ( tmpl_t const *  vpt)
inlinestatic

Return true if the the last attribute reference is a leaf attribute.

Definition at line 812 of file tmpl.h.

+ Here is the call graph for this function:

◆ tmpl_attr_tail_da_is_structural()

static bool tmpl_attr_tail_da_is_structural ( tmpl_t const *  vpt)
inlinestatic

Return true if the the last attribute reference is a structural attribute.

Definition at line 830 of file tmpl.h.

+ Here is the call graph for this function:

◆ tmpl_attr_tail_is_normal()

static bool tmpl_attr_tail_is_normal ( tmpl_t const *  vpt)
inlinestatic

Return true if the last attribute reference is "normal".

Definition at line 705 of file tmpl.h.

◆ tmpl_attr_tail_is_raw()

static bool tmpl_attr_tail_is_raw ( tmpl_t const *  vpt)
inlinestatic

Return true if the last attribute reference is "raw".

Definition at line 769 of file tmpl.h.

◆ tmpl_attr_tail_is_unknown()

static bool tmpl_attr_tail_is_unknown ( tmpl_t const *  vpt)
inlinestatic

Return true if the last attribute reference is "unknown".

Definition at line 737 of file tmpl.h.

◆ tmpl_attr_tail_is_unresolved()

static bool tmpl_attr_tail_is_unresolved ( tmpl_t const *  vpt)
inlinestatic

Return true if the last attribute reference is "unresolved".

Definition at line 753 of file tmpl.h.

◆ tmpl_attr_tail_is_unspecified()

static bool tmpl_attr_tail_is_unspecified ( tmpl_t const *  vpt)
inlinestatic

Return true if the last attribute reference is "unspecified".

Definition at line 721 of file tmpl.h.

◆ tmpl_attr_tail_num()

static int16_t tmpl_attr_tail_num ( tmpl_t const *  vpt)
inlinestatic

Return the last attribute reference's attribute number.

Definition at line 880 of file tmpl.h.

◆ tmpl_attr_tail_unknown()

static fr_dict_attr_t const* tmpl_attr_tail_unknown ( tmpl_t const *  vpt)
inlinestatic

Return the last attribute reference unknown da.

Definition at line 848 of file tmpl.h.

◆ tmpl_attr_tail_unresolved()

static char const* tmpl_attr_tail_unresolved ( tmpl_t const *  vpt)
inlinestatic

Return the last attribute reference unresolved da.

Definition at line 864 of file tmpl.h.

◆ tmpl_attr_tail_unresolved_add()

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.

Note
fr_dict_attr_add will not return an error if the attribute already exists meaning that multiple tmpl_t specifying the same attribute can be passed to this function to be fixed up, so long as the type and flags are identical.
Parameters
[in]dict_defDefault dictionary to use if none is specified by the tmpl_attr_tail_unresolved.
[in]vptspecifying 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]typeto define unresolved attribute as.
[in]flagsto define unresolved attribute with.
Returns
  • 1 noop (did nothing) - Not possible to convert tmpl.
  • 0 on success.
  • -1 on failure.

Definition at line 4375 of file tmpl_tokenize.c.

+ Here is the call graph for this function:

◆ tmpl_attr_to_raw()

void tmpl_attr_to_raw ( tmpl_t vpt)

Convert the leaf attribute of a tmpl to a unknown/raw type.

Definition at line 4259 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_attr_to_xlat()

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.

Parameters
[in]ctxto convert new tmpl in.
[in,out]vpt_ppointer to tmpl_t of TMPL_TYPE_ATTR | TMPL_TYPE_ATTR_UNPARSED.

Definition at line 4199 of file tmpl_tokenize.c.

+ Here is the call graph for this function:

◆ tmpl_attr_unknown_add()

int tmpl_attr_unknown_add ( tmpl_t vpt)

Add an unknown fr_dict_attr_t specified by a tmpl_t to the main dictionary.

Parameters
vptto add. tmpl_attr_tail_da pointer will be updated to point to the fr_dict_attr_t inserted into the dictionary.
Returns
  • 1 noop (did nothing) - Not possible to convert tmpl.
  • 0 on success.
  • -1 on failure.

Definition at line 4273 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_cast_from_substr()

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.

Parameters
[out]rulesto set the cast type in.
[in]inString containing the cast marker.
Returns
  • 0 no cast specifier found.
  • >0 the number of bytes parsed.
  • <0 offset of parse error.

Definition at line 3494 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_cast_get()

static fr_type_t tmpl_cast_get ( tmpl_t vpt)
inlinestatic

Definition at line 1214 of file tmpl.h.

+ Here is the caller graph for this function:

◆ tmpl_cast_in_place()

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.

Note
Conversion is done in place.
Irrespective of whether the tmpl_t was TMPL_TYPE_DATA_UNRESOLVED or TMPL_TYPE_DATA, on successful cast it will be TMPL_TYPE_DATA.
Parameters
[in,out]vptThe template to modify. Must be of type TMPL_TYPE_DATA_UNRESOLVED or TMPL_TYPE_DATA.
[in]typeto cast to.
[in]enumvEnumerated dictionary values associated with a fr_dict_attr_t.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3712 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_cast_set()

int tmpl_cast_set ( tmpl_t vpt,
fr_type_t  dst_type 
)

Set a cast for a tmpl.

Parameters
[in,out]vptto set cast for.
[in]dst_typeto set.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3543 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_copy()

tmpl_t* tmpl_copy ( TALLOC_CTX *  ctx,
tmpl_t const *  in 
)

Copy a tmpl.

Fully duplicates the contents of a tmpl including any nested attribute references.

Parameters
[in]ctxto perform allocations under.
[in]intmpl to duplicate.
Returns
  • NULL on error.
  • A new tmpl on success.

Definition at line 3413 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_copy_pair_children()

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.

Parameters
ctxto allocate new fr_pair_t in.
outWhere to write the copied fr_pair_t (s).
requestThe current request_t.
vptspecifying the fr_pair_t type or list to copy. Must be one of the following types:
Returns
  • -1 if no matching fr_pair_t could be found.
  • -2 if list could not be found (doesn't exist in current request_t).
  • -3 if context could not be found (no parent request_t available).
  • -4 on memory allocation error.

Definition at line 839 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_copy_pairs()

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.

Parameters
ctxto allocate new fr_pair_t in.
outWhere to write the copied fr_pair_t (s).
requestThe current request_t.
vptspecifying the fr_pair_t type or list to copy. Must be one of the following types:
Returns
  • -1 if no matching fr_pair_t could be found.
  • -2 if list could not be found (doesn't exist in current request_t).
  • -3 if context could not be found (no parent request_t available).
  • -4 on memory allocation error.

Definition at line 796 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_debug()

void tmpl_debug ( tmpl_t const *  vpt)

Definition at line 305 of file tmpl_tokenize.c.

+ Here is the call graph for this function:

◆ tmpl_eval()

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.

Parameters
[in]ctxto allocate boxed value, and buffers in.
[out]outWhere to write the boxed value.
[in]requestThe current request.
[in]vptRepresenting the tmpl
Returns
  • <0 we failed getting a value for the tmpl
  • 0 we successfully evaluated the tmpl

Definition at line 1216 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_eval_cast_in_place()

int tmpl_eval_cast_in_place ( fr_value_box_list_t *  list,
request_t request,
tmpl_t const *  vpt 
)

Casts a value or list of values according to the tmpl.

Parameters
[in,out]listWhere to write the boxed value.
[in]requestThe current request.
[in]vptRepresenting the attribute.
Returns
  • <0 the cast failed
  • 0 we successfully evaluated the tmpl

Definition at line 1344 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_eval_pair()

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.

Parameters
[in]ctxto allocate boxed value, and buffers in.
[out]outWhere to write the boxed value.
[in]requestThe current request.
[in]vptRepresenting the attribute.
Returns
  • <0 we failed getting a value for the attribute.
  • 0 we successfully evaluated the tmpl

Definition at line 1075 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_expanded_type()

fr_type_t tmpl_expanded_type ( tmpl_t const *  vpt)

Return the native data type of the expression.

Parameters
[in]vptto determine the type of.
Returns
  • FR_TYPE_NULL if the type of the tmpl_t can't be determined.
  • The data type we'd expect the tmpl_t to produce at runtime when expanded.

Definition at line 207 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_extents_build_to_leaf_parent()

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

Parameters
[out]existingList to add built out attributes to.
[in]to_buildList to remove attributes from.
[in]vptWe are evaluating.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 619 of file tmpl_dcursor.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_extents_debug()

void tmpl_extents_debug ( fr_dlist_head_t head)

Definition at line 669 of file tmpl_dcursor.c.

+ Here is the call graph for this function:

◆ tmpl_extents_find()

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.

Parameters
[in]ctxto allocate. It's recommended to pass a pool with space for at least five extent structures.
[out]existingList of extents we discovered by evaluating all attribute references. May be NULL.
[out]to_buildList of extents that need building out, i.e. references extend beyond pairs. May be NULL.
[in]requestThe current request_t.
[in]vptspecifying the fr_pair_t type to retrieve or create. Must be TMPL_TYPE_ATTR.
Returns
  • 0 on success a pair was found.
  • -2 if list could not be found (doesn't exist in current request_t).
  • -3 if context could not be found (no parent request_t available).

Definition at line 493 of file tmpl_dcursor.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_find_or_add_vp()

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.

Parameters
[out]outwhere to write the retrieved or created vp.
[in]requestThe current request_t.
[in]vptspecifying the fr_pair_t type to retrieve or create. Must be TMPL_TYPE_ATTR.
Returns
  • 1 on success a pair was created.
  • 0 on success a pair was found.
  • -1 if a new fr_pair_t couldn't be found or created.
  • -2 if list could not be found (doesn't exist in current request_t).
  • -3 if context could not be found (no parent request_t available).

Definition at line 916 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_find_vp()

int tmpl_find_vp ( fr_pair_t **  out,
request_t request,
tmpl_t const *  vpt 
)

Returns the first VP matching a tmpl_t.

Parameters
[out]outwhere to write the retrieved vp.
[in]requestThe current request_t.
[in]vptspecifying the fr_pair_t type to find. Must be one of the following types:
Returns
  • 0 on success (found matching fr_pair_t).
  • -1 if no matching fr_pair_t could be found.
  • -2 if list could not be found (doesn't exist in current request_t).
  • -3 if context could not be found (no parent request_t available).

Definition at line 887 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_global_free()

void tmpl_global_free ( void  )

Definition at line 1471 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_global_init()

int tmpl_global_init ( void  )

Definition at line 1453 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_init()

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.

Parameters
[in]vptto initialise.
[in]typeof tmpl to initialise.
[in]quoteOriginal quoting around the name.
[in]nameto set for the tmpl.
[in]lenName length. If < 0 strlen will be used to determine the name.
[in]t_rulesused during parsing.
Returns
A pointer to the newly initialised tmpl.

Definition at line 898 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_init_printf()

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.

Parameters
[in]vptto initialise.
[in]typeof tmpl to initialise.
[in]quoteOriginal quoting around the name.
[in]fmtstring.
[in]...format arguments.
Returns
A pointer to the newly initialised tmpl.

Definition at line 846 of file tmpl_tokenize.c.

+ Here is the call graph for this function:

◆ tmpl_init_shallow()

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.

Note
Name is not talloc_strdup'd or memcpy'd so must be available, and must not change for the lifetime of the tmpl_t.
Parameters
[out]vptto initialise.
[in]typeto set in the tmpl_t.
[in]quoteThe type of quoting around the template name.
[in]nameof the tmpl_t.
[in]lenThe 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_rulesused during parsing.
Returns
a pointer to the initialised tmpl_t. The same value as vpt.

Definition at line 876 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_is_list()

static bool tmpl_is_list ( tmpl_t const *  vpt)
inlinestatic

Definition at line 915 of file tmpl.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_list()

static fr_dict_attr_t const* tmpl_list ( tmpl_t const *  vpt)
inlinestatic

Definition at line 899 of file tmpl.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_list_ctx()

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.

Parameters
[in]requestcontaining the target lists.
[in]listfr_pair_list_t value to resolve to TALLOC_CTX.
Returns
  • TALLOC_CTX on success.
  • NULL on failure.
See also
tmpl_pair_list

Definition at line 114 of file tmpl_eval.c.

+ Here is the caller graph for this function:

◆ tmpl_list_head()

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.

Parameters
[in]requestcontaining the target lists.
[in]listfr_pair_list_t value to resolve to fr_pair_t list. Will be NULL if list name couldn't be resolved.
Returns
a pointer to the HEAD of a list in the request_t.
See also
tmpl_dcursor_init

Definition at line 74 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_list_name()

static char const* tmpl_list_name ( fr_dict_attr_t const *  list,
char const *  def 
)
inlinestatic

Return the name of a tmpl list or def if list not provided.

Definition at line 910 of file tmpl.h.

+ Here is the caller graph for this function:

◆ tmpl_packet_ptr()

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.

Parameters
[in]requestTo resolve list in.
[in]listfr_pair_list_t value to resolve to fr_packet_t.
Returns
See also
tmpl_pair_list

Definition at line 144 of file tmpl_eval.c.

◆ tmpl_preparse()

ssize_t tmpl_preparse ( char const **  out,
size_t outlen,
char const *  in,
size_t  inlen,
fr_token_t type,
fr_dict_attr_t const **  castda,
bool  require_regex,
bool  allow_xlat 
)

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.

Parameters
[out]outstart of the string to parse
[out]outlenlength of the string to parse
inwhere we start looking for the string
inlenlength of the input string
[out]typetoken type of the string.
[out]castdaNULL if casting is not allowed, otherwise the cast
require_regexwhether or not to require regular expressions
allow_xlatwhether or not "bare" xlat's are allowed
Returns
  • > 0, amount of parsed string to skip, to get to the next token
  • <=0, -offset in 'start' where the parse error was located

Definition at line 5204 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_print()

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.

Note
Does not print flags for regular expressions, as the quoting char is needed to separate the elements of the expression. Call regex_flags_print to write the flags values to the output buffer.
Parameters
[out]outWhere to write the presentation format tmpl_t string.
[in]vptto print.
[in]ar_prefixWhether to print the '&' at the beginning of attribute references.
  • TMPL_ATTR_REF_PREFIX_YES - always print.
  • TMPL_ATTR_REF_PREFIX_NO - never print.
  • TMPL_ATTR_REF_PREFIX_AUTO - print if the original tmpl was prefixed.
[in]e_rulesEscaping rules used to print strings.
Returns
  • >0 the number of bytes written to the out buffer.
  • 0 invalid argument.
  • <0 the number of bytes we would have needed to complete the print.

Definition at line 237 of file merged_model.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_print_quoted()

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.

Parameters
[out]outWhere to write the presentation format tmpl_t string.
[in]vptto print.
[in]ar_prefixWhether to print the '&' at the beginning of attribute references.
  • TMPL_ATTR_REF_PREFIX_YES - always print.
  • TMPL_ATTR_REF_PREFIX_NO - never print.
  • TMPL_ATTR_REF_PREFIX_AUTO - print if the original tmpl was prefixed.
Returns
  • >0 the number of bytes written to the out buffer.
  • 0 invalid argument.
  • <0 the number of bytes we would have needed to complete the print.

Definition at line 4768 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_request_ptr()

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.

See also
tmpl_pair_list
Parameters
[in,out]contextrequest_t to start resolving from, and where to write a pointer to the resolved request_t back to.
[in]rqllist of request qualifiers to follow.
Returns
  • 0 if request is valid in this context.
  • -1 if request is not valid in this context.

Definition at line 167 of file tmpl_eval.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_request_ref_count()

static size_t tmpl_request_ref_count ( tmpl_t const *  vpt)
inlinestatic

The number of request references contained within a tmpl.

Definition at line 662 of file tmpl.h.

◆ tmpl_request_ref_list_afrom_substr()

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 
)
+ Here is the caller graph for this function:

◆ tmpl_request_ref_list_aprint()

static fr_slen_t tmpl_request_ref_list_aprint ( TALLOC_CTX *  ctx,
char **  out,
FR_DLIST_HEAD(tmpl_request_list) const *  rql 
)
inlinestatic
+ Here is the caller graph for this function:

◆ tmpl_request_ref_list_cmp()

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.

Parameters
[in]afirst list. If NULL tmpl_request_def_current will be used.
[in]bsecond list. If NULL tmpl_request_def_current will be used.
Returns
  • >0 a > b
  • 0 a == b
  • <0 a < b

Definition at line 478 of file tmpl_tokenize.c.

+ Here is the caller graph for this function:

◆ tmpl_request_ref_list_debug()

void tmpl_request_ref_list_debug ( FR_DLIST_HEAD(tmpl_request_list) const *  rql)

Dump a request list to stderr.

Definition at line 458 of file tmpl_tokenize.c.

◆ tmpl_request_ref_list_print()

fr_slen_t tmpl_request_ref_list_print ( fr_sbuff_t out,
FR_DLIST_HEAD(tmpl_request_list) const *  rql 
)

Definition at line 4444 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_resolve()

int tmpl_resolve ( tmpl_t vpt,
tmpl_res_rules_t const *  tr_rules 
)

Attempt to resolve functions and attributes in xlats and attribute references.

Note
If resolution is successful, the rules->attr.dict_def field will be modified to reflect the dictionary resolution was successful in.
Parameters
[in,out]vptto resolve. Should be of type TMPL_TYPE_XLAT_UNRESOLVED or TMPL_TYPE_ATTR_UNRESOLVED. All other types will be noops.
[in]tr_rulesCombined with the original parse rules for additional resolution passes.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4019 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_rules_child_init()

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 5675 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_rules_debug()

void tmpl_rules_debug ( tmpl_rules_t const *  rules)

Definition at line 5746 of file tmpl_tokenize.c.

+ Here is the call graph for this function:

◆ tmpl_set_dict_def()

void tmpl_set_dict_def ( tmpl_t vpt,
fr_dict_t const *  dict 
)

Change the default dictionary in the tmpl's resolution rules.

Parameters
[in]vptto alter.
[in]dictto set.

Definition at line 809 of file tmpl_tokenize.c.

+ Here is the caller graph for this function:

◆ tmpl_set_escape()

void tmpl_set_escape ( tmpl_t vpt,
tmpl_escape_t const *  escape 
)

Set escape parameters for the tmpl output.

Parameters
[in]vptto alter.
[in]escapeto set.

Definition at line 819 of file tmpl_tokenize.c.

◆ tmpl_set_name()

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.

Parameters
[in]vptto set the name for.
[in]quoteOriginal quoting around the name.
[in]nameof the tmpl_t.
[in]lenThe 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 793 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_set_name_printf()

void tmpl_set_name_printf ( tmpl_t vpt,
fr_token_t  quote,
char const *  fmt,
  ... 
)

Set the name on a pre-initialised tmpl.

Parameters
[in]vptto set the name for.
[in]quoteOriginal quoting around the name.
[in]fmtstring.
[in]...format arguments.

Definition at line 752 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_set_name_shallow()

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.

Parameters
[in]vptto set the name for.
[in]quoteOriginal quoting around the name.
[in]nameof the tmpl_t.
[in]lenThe 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 776 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_set_xlat()

void tmpl_set_xlat ( tmpl_t vpt,
xlat_exp_head_t xlat 
)

Change the default dictionary in the tmpl's resolution rules.

Parameters
[in]vptto alter.
[in]xlatto set.

Definition at line 829 of file tmpl_tokenize.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmpl_type_from_str()

static tmpl_type_t tmpl_type_from_str ( char const *  type)
inlinestatic

Return the constant value representing a type.

Parameters
[in]typeto return the constant value for.
Returns
The constant type value or TMPL_TYPE_UNINITIALISED if no type matches.

Definition at line 639 of file tmpl.h.

◆ tmpl_type_to_str()

static char const* tmpl_type_to_str ( tmpl_type_t  type)
inlinestatic

Return a static string containing the type name.

Parameters
[in]typeto return name for.
Returns
name of the type

Definition at line 629 of file tmpl.h.

+ Here is the caller graph for this function:

◆ tmpl_unresolve()

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.

Parameters
[in]vptto reset.

Definition at line 4134 of file tmpl_tokenize.c.

+ Here is the call graph for this function:

◆ tmpl_value_list_insert_tail()

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.

Parameters
listto append to
boxbox to cast / append
vpttmpl with cast.
Returns
  • <0 for "cast failed"
  • 0 for success

Definition at line 1050 of file tmpl_eval.c.

+ Here is the call graph for this function:

Variable Documentation

◆ ar_prefix

fr_slen_t ar_prefix

Definition at line 1267 of file tmpl.h.

◆ pair_list_table

fr_table_num_ordered_t const pair_list_table[]
extern

◆ pair_list_table_len

size_t pair_list_table_len
extern

◆ tmpl_request_ref_table

fr_table_num_sorted_t const tmpl_request_ref_table[]
extern

Map keywords to tmpl_request_ref_t values.

Definition at line 140 of file tmpl_tokenize.c.

◆ tmpl_request_ref_table_len

size_t tmpl_request_ref_table_len
extern

Definition at line 145 of file tmpl_tokenize.c.

◆ tmpl_type_table

fr_table_num_ordered_t const tmpl_type_table[]
extern

Map tmpl_type_t values to descriptive strings.

Definition at line 105 of file tmpl_tokenize.c.

◆ tmpl_type_table_len

size_t tmpl_type_table_len
extern

Definition at line 126 of file tmpl_tokenize.c.

◆ vpt

static fr_slen_t vpt

Definition at line 1260 of file tmpl.h.