The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
fr_pair_t template functions More...
#include <freeradius-devel/server/exec.h>
#include <freeradius-devel/server/exec_legacy.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/server/tmpl_dcursor.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/edit.h>
Go to the source code of this file.
Macros | |
#define | EXTENT_ADD(_out, _ar, _list_ctx, _list) |
Functions | |
static void * | _tmpl_cursor_child_next (fr_dlist_head_t *list, void *curr, void *uctx) |
Traverse a list of attributes. More... | |
static fr_pair_t * | _tmpl_cursor_eval (fr_pair_t *curr, tmpl_dcursor_ctx_t *cc) |
Evaluates, then, sometimes, pops evaluation contexts from the tmpl stack. More... | |
static void * | _tmpl_cursor_next (UNUSED fr_dlist_head_t *list, void *curr, void *uctx) |
static void | _tmpl_cursor_pair_init (TALLOC_CTX *list_ctx, fr_pair_list_t *list, tmpl_attr_t const *ar, tmpl_dcursor_ctx_t *cc) |
Initialise the evaluation context for traversing a group attribute. More... | |
static void | _tmpl_cursor_pool_init (tmpl_dcursor_ctx_t *cc) |
fr_pair_t * | _tmpl_dcursor_init (int *err, TALLOC_CTX *ctx, tmpl_dcursor_ctx_t *cc, fr_dcursor_t *cursor, request_t *request, tmpl_t const *vpt, tmpl_dcursor_build_t build, void *uctx) |
Initialise a fr_dcursor_t to the fr_pair_t specified by a tmpl_t. More... | |
static void | tmpl_cursor_nested_pop (tmpl_dcursor_ctx_t *cc) |
static void | tmpl_cursor_nested_push (tmpl_dcursor_ctx_t *cc, tmpl_dcursor_nested_t *ns) |
void | tmpl_dcursor_clear (tmpl_dcursor_ctx_t *cc) |
Clear any temporary state allocations. More... | |
fr_pair_t * | tmpl_dcursor_init_relative (int *err, TALLOC_CTX *ctx, tmpl_dcursor_ctx_t *cc, fr_dcursor_t *cursor, request_t *request, fr_pair_t *list, tmpl_t const *vpt, tmpl_dcursor_build_t build, void *uctx) |
Initialise a fr_dcursor_t at the specified point in a pair tree. More... | |
fr_pair_t * | tmpl_dcursor_pair_build (fr_pair_t *parent, fr_dcursor_t *cursor, fr_dict_attr_t const *da, UNUSED void *uctx) |
Simple pair building callback for use with tmpl_dcursors. More... | |
ssize_t | tmpl_dcursor_print (fr_sbuff_t *out, tmpl_dcursor_ctx_t const *cc) |
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. More... | |
void | tmpl_extents_debug (fr_dlist_head_t *head) |
int | tmpl_extents_find (TALLOC_CTX *ctx, fr_dlist_head_t *existing, fr_dlist_head_t *to_build, request_t *request, tmpl_t const *vpt) |
Determines points where the reference list extends beyond the current pair tree. More... | |
fr_pair_t template functions
Definition in file tmpl_dcursor.c.
#define EXTENT_ADD | ( | _out, | |
_ar, | |||
_list_ctx, | |||
_list | |||
) |
Definition at line 531 of file tmpl_dcursor.c.
|
static |
Traverse a list of attributes.
A dcursor iterator function for matching attributes
[in] | list | being traversed. |
[in] | curr | item in the list to start tests from. |
[in] | uctx | Context for evaluation - in this instance a tmpl_dcursor_nested_t |
Definition at line 55 of file tmpl_dcursor.c.
|
inlinestatic |
Evaluates, then, sometimes, pops evaluation contexts from the tmpl stack.
To pop or not to pop is determined by whether evaluating the context again would/should/could produce another fr_pair_t.
[in] | curr | The pair to evaluate. |
[in] | cc | Tracks state between cursor calls. |
Definition at line 125 of file tmpl_dcursor.c.
|
static |
Definition at line 275 of file tmpl_dcursor.c.
|
inlinestatic |
Initialise the evaluation context for traversing a group attribute.
Definition at line 83 of file tmpl_dcursor.c.
|
inlinestatic |
Definition at line 39 of file tmpl_dcursor.c.
fr_pair_t* _tmpl_dcursor_init | ( | int * | err, |
TALLOC_CTX * | ctx, | ||
tmpl_dcursor_ctx_t * | cc, | ||
fr_dcursor_t * | cursor, | ||
request_t * | request, | ||
tmpl_t const * | vpt, | ||
tmpl_dcursor_build_t | build, | ||
void * | uctx | ||
) |
Initialise a fr_dcursor_t to the fr_pair_t specified by a tmpl_t.
This makes iterating over the one or more fr_pair_t specified by a tmpl_t significantly easier.
[out] | err | May be NULL if no error code is required. Will be set to: |
[in] | ctx | to make temporary allocations under. |
[in] | cc | to initialise. Tracks evaluation state. Must be explicitly cleared with tmpl_cursor_state_clear otherwise we will leak memory. |
[in] | cursor | to store iterator position. |
[in] | request | The current request_t. |
[in] | vpt | specifying the fr_pair_t type or list to iterate over. |
[in] | build | Callback to build missing pairs. |
[in] | uctx | for building new pairs. |
Definition at line 469 of file tmpl_dcursor.c.
|
inlinestatic |
Definition at line 72 of file tmpl_dcursor.c.
|
inlinestatic |
Definition at line 67 of file tmpl_dcursor.c.
void tmpl_dcursor_clear | ( | tmpl_dcursor_ctx_t * | cc | ) |
Clear any temporary state allocations.
Definition at line 495 of file tmpl_dcursor.c.
fr_pair_t* tmpl_dcursor_init_relative | ( | int * | err, |
TALLOC_CTX * | ctx, | ||
tmpl_dcursor_ctx_t * | cc, | ||
fr_dcursor_t * | cursor, | ||
request_t * | request, | ||
fr_pair_t * | list, | ||
tmpl_t const * | vpt, | ||
tmpl_dcursor_build_t | build, | ||
void * | uctx | ||
) |
Initialise a fr_dcursor_t at the specified point in a pair tree.
This makes iterating over the one or more fr_pair_t specified by a tmpl_t significantly easier.
[out] | err | May be NULL if no error code is required. Will be set to: |
[in] | ctx | to make temporary allocations under. |
[in] | cc | to initialise. Tracks evaluation state. Must be explicitly cleared with tmpl_cursor_state_clear otherwise we will leak memory. |
[in] | cursor | to store iterator position. |
[in] | request | the current request. |
[in] | list | a nested list to start evaluating from. May be the child list of a pair in the request's pair tree. |
[in] | vpt | specifying the fr_pair_t type or list to iterate over. |
[in] | build | Callback to build missing pairs. |
[in] | uctx | to pass to build. |
Definition at line 385 of file tmpl_dcursor.c.
fr_pair_t* tmpl_dcursor_pair_build | ( | fr_pair_t * | parent, |
fr_dcursor_t * | cursor, | ||
fr_dict_attr_t const * | da, | ||
UNUSED void * | uctx | ||
) |
Simple pair building callback for use with tmpl_dcursors.
Which always appends the new pair to the tail of the list since it is only called when no matching pairs were found when walking the list.
[in] | parent | to allocate new pair within. |
[in,out] | cursor | to append new pair to. |
[in] | da | of new pair. |
[in] | uctx | unused. |
Definition at line 523 of file tmpl_dcursor.c.
ssize_t tmpl_dcursor_print | ( | fr_sbuff_t * | out, |
tmpl_dcursor_ctx_t const * | cc | ||
) |
Definition at line 781 of file tmpl_dcursor.c.
int tmpl_extents_build_to_leaf_parent | ( | fr_dlist_head_t * | existing, |
fr_dlist_head_t * | to_build, | ||
tmpl_t const * | vpt | ||
) |
Allocate interior pairs.
Builds out the pair tree to the point where leaf attributes can be added
[out] | existing | List to add built out attributes to. |
[in] | to_build | List to remove attributes from. |
[in] | vpt | We are evaluating. |
Definition at line 695 of file tmpl_dcursor.c.
void tmpl_extents_debug | ( | fr_dlist_head_t * | head | ) |
int tmpl_extents_find | ( | TALLOC_CTX * | ctx, |
fr_dlist_head_t * | existing, | ||
fr_dlist_head_t * | to_build, | ||
request_t * | request, | ||
tmpl_t const * | vpt | ||
) |
Determines points where the reference list extends beyond the current pair tree.
If a particular branch in the VP hierarchy is incomplete, i.e. the chain of attribute refers to nodes deeper than the nodes currently in the tree, then we return the deepest point node in the tree which matched, and the ar that we failed to evaluate.
If the reference list resolves to one or more structural pairs, return those as well.
This function can be used for a number of different operations, but it's most useful for determining insertion points for new attributes, or determining which attributes need to be updated.
[in] | ctx | to allocate. It's recommended to pass a pool with space for at least five extent structures. |
[out] | existing | List of extents we discovered by evaluating all attribute references. May be NULL. |
[out] | to_build | List of extents that need building out, i.e. references extend beyond pairs. May be NULL. |
[in] | request | The current request_t. |
[in] | vpt | specifying the fr_pair_t type to retrieve or create. Must be TMPL_TYPE_ATTR. |
Definition at line 569 of file tmpl_dcursor.c.