The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Macros | Functions
tmpl_dcursor.c File Reference

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>
+ Include dependency graph for tmpl_dcursor.c:

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

Detailed Description

fr_pair_t template functions

Id
5ddd1f4992dbee561d8ff327dcb300a12e484a69

Definition in file tmpl_dcursor.c.

Macro Definition Documentation

◆ EXTENT_ADD

#define EXTENT_ADD (   _out,
  _ar,
  _list_ctx,
  _list 
)
Value:
do { \
tmpl_attr_extent_t *_extent; \
MEM(_extent = talloc(ctx, tmpl_attr_extent_t)); \
*_extent = (tmpl_attr_extent_t){ \
.ar = _ar, \
.list_ctx = _list_ctx, \
.list = _list \
}; \
fr_dlist_insert_tail(_out, _extent); \
} while (0)
Describes the current extents of a pair tree in relation to the tree described by a tmpl_t.
Definition: tmpl.h:596

Definition at line 455 of file tmpl_dcursor.c.

Function Documentation

◆ _tmpl_cursor_child_next()

static void* _tmpl_cursor_child_next ( fr_dlist_head_t list,
void *  curr,
void *  uctx 
)
static

Traverse a list of attributes.

A dcursor iterator function for matching attributes

Parameters
[in]listbeing traversed.
[in]curritem in the list to start tests from.
[in]uctxContext for evaluation - in this instance a tmpl_dcursor_nested_t
Returns
  • the next matching attribute
  • NULL if none found

Definition at line 55 of file tmpl_dcursor.c.

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

◆ _tmpl_cursor_eval()

static fr_pair_t* _tmpl_cursor_eval ( fr_pair_t curr,
tmpl_dcursor_ctx_t cc 
)
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.

Parameters
[in]currThe pair to evaluate.
[in]ccTracks state between cursor calls.
Returns
the vp evaluated.

Definition at line 125 of file tmpl_dcursor.c.

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

◆ _tmpl_cursor_next()

static void* _tmpl_cursor_next ( UNUSED fr_dlist_head_t list,
void *  curr,
void *  uctx 
)
static

Definition at line 199 of file tmpl_dcursor.c.

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

◆ _tmpl_cursor_pair_init()

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

Initialise the evaluation context for traversing a group attribute.

Definition at line 83 of file tmpl_dcursor.c.

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

◆ _tmpl_cursor_pool_init()

static void _tmpl_cursor_pool_init ( tmpl_dcursor_ctx_t cc)
inlinestatic

Definition at line 39 of file tmpl_dcursor.c.

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

◆ _tmpl_dcursor_init()

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.

Parameters
[out]errMay be NULL if no error code is required. Will be set to:
  • 0 on success.
  • -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).
[in]ctxto make temporary allocations under.
[in]ccto initialise. Tracks evaluation state. Must be explicitly cleared with tmpl_cursor_state_clear otherwise we will leak memory.
[in]cursorto store iterator position.
[in]requestThe current request_t.
[in]vptspecifying the fr_pair_t type or list to iterate over.
[in]buildCallback to build missing pairs.
[in]uctxfor building new pairs.
Returns
See also
tmpl_cursor_next

Definition at line 393 of file tmpl_dcursor.c.

+ Here is the call graph for this function:

◆ tmpl_cursor_nested_pop()

static void tmpl_cursor_nested_pop ( tmpl_dcursor_ctx_t cc)
inlinestatic

Definition at line 72 of file tmpl_dcursor.c.

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

◆ tmpl_cursor_nested_push()

static void tmpl_cursor_nested_push ( tmpl_dcursor_ctx_t cc,
tmpl_dcursor_nested_t ns 
)
inlinestatic

Definition at line 67 of file tmpl_dcursor.c.

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

◆ tmpl_dcursor_clear()

void tmpl_dcursor_clear ( tmpl_dcursor_ctx_t cc)

Clear any temporary state allocations.

Definition at line 419 of file tmpl_dcursor.c.

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

◆ tmpl_dcursor_init_relative()

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.

Parameters
[out]errMay be NULL if no error code is required. Will be set to:
  • 0 on success.
  • -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).
[in]ctxto make temporary allocations under.
[in]ccto initialise. Tracks evaluation state. Must be explicitly cleared with tmpl_cursor_state_clear otherwise we will leak memory.
[in]cursorto store iterator position.
[in]requestthe current request.
[in]lista nested list to start evaluating from. May be the child list of a pair in the request's pair tree.
[in]vptspecifying the fr_pair_t type or list to iterate over.
[in]buildCallback to build missing pairs.
[in]uctxto pass to build.
Returns
See also
tmpl_cursor_next

Definition at line 309 of file tmpl_dcursor.c.

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

◆ tmpl_dcursor_pair_build()

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.

Parameters
[in]parentto allocate new pair within.
[in,out]cursorto append new pair to.
[in]daof new pair.
[in]uctxunused.
Returns

Definition at line 447 of file tmpl_dcursor.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: