The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions
tmpl_dcursor.h File Reference
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/util/dcursor.h>
+ Include dependency graph for tmpl_dcursor.h:

Go to the source code of this file.

Data Structures

struct  tmpl_dcursor_ctx_s
 Maintains state between cursor calls. More...
 
struct  tmpl_dcursor_nested_s
 State for traversing an attribute reference. More...
 

Macros

#define tmpl_dcursor_build_init(_err, _ctx, _cc, _cursor, _request, _vpt, _build, _uctx)    _tmpl_dcursor_init(_err, _ctx, _cc, _cursor, _request, _vpt, _build, _uctx)
 
#define tmpl_dcursor_init(_err, _ctx, _cc, _cursor, _request, _vpt)    _tmpl_dcursor_init(_err, _ctx, _cc, _cursor, _request, _vpt, NULL, NULL)
 

Typedefs

typedef fr_pair_t *(* tmpl_dcursor_build_t) (fr_pair_t *parent, fr_dcursor_t *cursor, fr_dict_attr_t const *da, void *uctx)
 Callback function for populating missing pair. More...
 
typedef struct tmpl_dcursor_ctx_s tmpl_dcursor_ctx_t
 
typedef struct tmpl_dcursor_nested_s tmpl_dcursor_nested_t
 

Functions

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...
 
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...
 
ssize_t tmpl_dcursor_print (fr_sbuff_t *out, tmpl_dcursor_ctx_t const *cc)
 

Data Structure Documentation

◆ tmpl_dcursor_ctx_s

struct tmpl_dcursor_ctx_s

Maintains state between cursor calls.

Definition at line 62 of file tmpl_dcursor.h.

+ Collaboration diagram for tmpl_dcursor_ctx_s:
Data Fields
tmpl_dcursor_build_t build Callback to build missing pairs.
TALLOC_CTX * ctx Temporary allocations go here.
tmpl_dcursor_nested_t leaf Pre-allocated leaf state.

We always need one of these so it doesn't make sense to allocate it later.

fr_pair_list_t * list List within the request.
fr_dlist_head_t nested Nested state.

These are allocated when we need to maintain state between multiple cursor calls for a particular attribute reference. This forms a stack of tmpl_dcursor_nested_t and tracks where we are in evaluation at all levels.

TALLOC_CTX * pool Temporary pool.
request_t * request Result of following the request references.
void * uctx Context for building new pairs.
tmpl_t const * vpt tmpl we're evaluating.

◆ tmpl_dcursor_nested_s

struct tmpl_dcursor_nested_s

State for traversing an attribute reference.

Definition at line 44 of file tmpl_dcursor.h.

+ Collaboration diagram for tmpl_dcursor_nested_s:
Data Fields
tmpl_attr_t const * ar Attribute reference this state entry is associated with.

Mainly for debugging.

fr_dcursor_t cursor Cursor to track where we are in the list in case we're doing counts.
fr_dlist_t entry Entry in the dlist that forms the evaluation stack.
TALLOC_CTX * list_ctx Track where we should be allocating attributes.
size_t num which attribute number we are looking at
bool seen Whether we've seen an attribute at this level of evaluation already.

This is mainly used where the build cursor is used.

Macro Definition Documentation

◆ tmpl_dcursor_build_init

#define tmpl_dcursor_build_init (   _err,
  _ctx,
  _cc,
  _cursor,
  _request,
  _vpt,
  _build,
  _uctx 
)     _tmpl_dcursor_init(_err, _ctx, _cc, _cursor, _request, _vpt, _build, _uctx)

Definition at line 103 of file tmpl_dcursor.h.

◆ tmpl_dcursor_init

#define tmpl_dcursor_init (   _err,
  _ctx,
  _cc,
  _cursor,
  _request,
  _vpt 
)     _tmpl_dcursor_init(_err, _ctx, _cc, _cursor, _request, _vpt, NULL, NULL)

Definition at line 100 of file tmpl_dcursor.h.

Typedef Documentation

◆ tmpl_dcursor_build_t

typedef fr_pair_t*(* tmpl_dcursor_build_t) (fr_pair_t *parent, fr_dcursor_t *cursor, fr_dict_attr_t const *da, void *uctx)

Callback function for populating missing pair.

Parameters
[in]parentto allocate the new pair in.
[in]cursorto append the pair to.
[in]daof the attribute to create.
[in]uctxcontext data.
Returns
newly allocated pair.

Definition at line 39 of file tmpl_dcursor.h.

◆ tmpl_dcursor_ctx_t

Definition at line 1 of file tmpl_dcursor.h.

◆ tmpl_dcursor_nested_t

Definition at line 1 of file tmpl_dcursor.h.

Function Documentation

◆ _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 469 of file tmpl_dcursor.c.

+ Here is the call graph for this function:

◆ tmpl_dcursor_clear()

void tmpl_dcursor_clear ( tmpl_dcursor_ctx_t cc)

Clear any temporary state allocations.

Definition at line 495 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 385 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 523 of file tmpl_dcursor.c.

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

◆ tmpl_dcursor_print()

ssize_t tmpl_dcursor_print ( fr_sbuff_t out,
tmpl_dcursor_ctx_t const *  cc 
)

Definition at line 781 of file tmpl_dcursor.c.

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