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

AVP manipulation and search API. More...

#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/pair.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/regex.h>
#include <freeradius-devel/util/pair_inline.c>
+ Include dependency graph for pair.c:

Go to the source code of this file.

Macros

#define _PAIR_INLINE   1
 
#define _PAIR_PRIVATE   1
 
#define IN_A_LIST_MSG   "Pair %pV is already in a list, and cannot be moved"
 
#define NOT_IN_THIS_LIST_MSG   "Pair %pV is not in the given list"
 

Functions

fr_pair_t_fr_pair_dcursor_by_ancestor_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dict_attr_t const *da, bool is_const)
 Initialise a cursor that will return only attributes descended from the specified fr_dict_attr_t. More...
 
fr_pair_t_fr_pair_dcursor_by_da_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dict_attr_t const *da, bool is_const)
 Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t. More...
 
fr_pair_t_fr_pair_dcursor_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, bool is_const)
 Initialises a special dcursor with callbacks that will maintain the attr sublists correctly. More...
 
fr_pair_t_fr_pair_dcursor_iter_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dcursor_iter_t iter, void const *uctx, bool is_const)
 Initialises a special dcursor with callbacks that will maintain the attr sublists correctly. More...
 
static int _fr_pair_free (fr_pair_t *vp)
 Free a fr_pair_t. More...
 
static void * _fr_pair_iter_next_dcursor_value (UNUSED fr_dlist_head_t *list, void *current, void *uctx)
 Iterate over pairs. More...
 
static void * _fr_pair_iter_next_value (fr_dlist_head_t *list, void *current, UNUSED void *uctx)
 Iterate over pairs. More...
 
static int _pair_list_dcursor_insert (fr_dlist_head_t *list, void *to_insert, UNUSED void *uctx)
 Keep attr tree and sublists synced on cursor insert. More...
 
static int _pair_list_dcursor_remove (NDEBUG_UNUSED fr_dlist_head_t *list, void *to_remove, UNUSED void *uctx)
 Keep attr tree and sublists synced on cursor removal. More...
 
static void fprintf_pair_list (FILE *fp, fr_pair_list_t const *list, int depth)
 
void fr_fprintf_pair (FILE *fp, char const *msg, fr_pair_t const *vp)
 
void fr_fprintf_pair_list (FILE *fp, fr_pair_list_t const *list)
 
fr_pair_tfr_pair_afrom_child_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
 Create a new valuepair. More...
 
fr_pair_tfr_pair_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da)
 Dynamically allocate a new attribute and assign a fr_dict_attr_t. More...
 
fr_pair_tfr_pair_afrom_da_depth_nested (TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da, int start)
 Create a pair (and all intermediate parents), and append it to the list. More...
 
fr_pair_tfr_pair_afrom_da_nested (TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da)
 Create a pair (and all intermediate parents), and append it to the list. More...
 
fr_pair_tfr_pair_alloc_null (TALLOC_CTX *ctx)
 Dynamically allocate a new attribute with no fr_dict_attr_t assigned. More...
 
int fr_pair_append (fr_pair_list_t *list, fr_pair_t *to_add)
 Add a VP to the end of the list. More...
 
int fr_pair_append_by_da (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da)
 Alloc a new fr_pair_t (and append) More...
 
int fr_pair_append_by_da_parent (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da)
 Alloc a new fr_pair_t, adding the parent attributes if required. More...
 
fr_pair_list_tfr_pair_children (fr_pair_t *vp)
 Get the child list of a group. More...
 
int fr_pair_cmp (fr_pair_t const *a, fr_pair_t const *b)
 Compare two pairs, using the operator from "a". More...
 
int8_t fr_pair_cmp_by_da (void const *a, void const *b)
 Order attributes by their da, and tag. More...
 
int8_t fr_pair_cmp_by_parent_num (void const *a, void const *b)
 Order attributes by their parent(s), attribute number, and tag. More...
 
fr_pair_tfr_pair_copy (TALLOC_CTX *ctx, fr_pair_t const *vp)
 Copy a single valuepair. More...
 
unsigned int fr_pair_count_by_da (fr_pair_list_t const *list, fr_dict_attr_t const *da)
 Return the number of instances of a given da in the specified list. More...
 
fr_value_box_tfr_pair_dcursor_nested_init (fr_dcursor_t *cursor, fr_dcursor_t *parent)
 Initialises a special dcursor over another cursor which returns fr_pair_t, but we return fr_value_box_t. More...
 
fr_value_box_tfr_pair_dcursor_value_init (fr_dcursor_t *cursor)
 Initialises a special dcursor over a fr_pair_list_t, but which returns fr_value_box_t. More...
 
fr_pair_tfr_pair_delete (fr_pair_list_t *list, fr_pair_t *vp)
 Remove fr_pair_t from a list and free. More...
 
int fr_pair_delete_by_child_num (fr_pair_list_t *list, fr_dict_attr_t const *parent, unsigned int attr)
 Delete matching pairs from the specified list. More...
 
int fr_pair_delete_by_da (fr_pair_list_t *list, fr_dict_attr_t const *da)
 Delete matching pairs from the specified list. More...
 
int fr_pair_delete_by_da_nested (fr_pair_list_t *list, fr_dict_attr_t const *da)
 Delete matching pairs from the specified list, and prune any empty branches. More...
 
fr_pair_tfr_pair_find_by_child_num (fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *parent, unsigned int attr)
 Find the pair with the matching child attribute. More...
 
fr_pair_tfr_pair_find_by_child_num_idx (fr_pair_list_t const *list, fr_dict_attr_t const *parent, unsigned int attr, unsigned int idx)
 Find the pair with the matching child attribute at a given index. More...
 
fr_pair_tfr_pair_find_by_da (fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
 Find the first pair with a matching da. More...
 
fr_pair_tfr_pair_find_by_da_idx (fr_pair_list_t const *list, fr_dict_attr_t const *da, unsigned int idx)
 Find a pair with a matching da at a given index. More...
 
fr_pair_tfr_pair_find_by_da_nested (fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
 Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree. More...
 
fr_pair_tfr_pair_find_last_by_da (fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
 Find the last pair with a matching da. More...
 
bool fr_pair_immutable (fr_pair_t const *vp)
 
void fr_pair_init_null (fr_pair_t *vp)
 Initialise fields in an fr_pair_t without assigning a da. More...
 
int fr_pair_insert_after (fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_add)
 Add a VP after another VP. More...
 
int fr_pair_insert_before (fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_add)
 Add a VP before another VP. More...
 
static void * fr_pair_iter_next_by_ancestor (fr_dlist_head_t *list, void *current, void *uctx)
 Iterate over pairs which are decedents of the specified da. More...
 
static void * fr_pair_iter_next_by_da (fr_dlist_head_t *list, void *current, void *uctx)
 Iterate over pairs with a specified da. More...
 
void fr_pair_list_afrom_box (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict, fr_value_box_t *box)
 Parse a list of VPs from a value box. More...
 
fr_pair_list_tfr_pair_list_alloc (TALLOC_CTX *ctx)
 Allocate a new pair list on the heap. More...
 
int fr_pair_list_cmp (fr_pair_list_t const *a, fr_pair_list_t const *b)
 Determine equality of two lists. More...
 
int fr_pair_list_copy (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
 Duplicate a list of pairs. More...
 
int fr_pair_list_copy_by_ancestor (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from, fr_dict_attr_t const *parent_da)
 Duplicate pairs in a list where the da is a descendant of parent_da. More...
 
int fr_pair_list_copy_by_da (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from, fr_dict_attr_t const *da, unsigned int count)
 Duplicate pairs in a list matching the specified da. More...
 
int fr_pair_list_copy_to_box (fr_value_box_t *dst, fr_pair_list_t *from)
 Copy the contents of a pair list to a set of value-boxes. More...
 
void fr_pair_list_init (fr_pair_list_t *list)
 Initialise a pair list header. More...
 
fr_pair_tfr_pair_list_iter_leaf (fr_pair_list_t *list, fr_pair_t *vp)
 Iterates over the leaves of a list. More...
 
fr_pair_tfr_pair_list_parent (fr_pair_list_t const *list)
 Return a pointer to the parent pair which contains this list. More...
 
void fr_pair_list_steal (TALLOC_CTX *ctx, fr_pair_list_t *list)
 Steal a list of pairs to a new context. More...
 
void fr_pair_list_tainted (fr_pair_list_t *list)
 Mark up a list of VPs as tainted. More...
 
bool fr_pair_matches_da (void const *item, void const *uctx)
 Evaluation function for matching if vp matches a given da. More...
 
fr_pair_tfr_pair_parent (fr_pair_t const *vp)
 Return a pointer to the parent pair. More...
 
fr_pair_list_tfr_pair_parent_list (fr_pair_t const *vp)
 Return a pointer to the parent pair list. More...
 
int fr_pair_prepend (fr_pair_list_t *list, fr_pair_t *to_add)
 Add a VP to the start of the list. More...
 
int fr_pair_prepend_by_da (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da)
 Alloc a new fr_pair_t (and prepend) More...
 
int fr_pair_raw_afrom_pair (fr_pair_t *vp, uint8_t const *data, size_t data_len)
 Mark malformed attribute as raw. More...
 
int fr_pair_reinit_from_da (fr_pair_list_t *list, fr_pair_t *vp, fr_dict_attr_t const *da)
 Re-initialise an attribute with a different da. More...
 
void fr_pair_replace (fr_pair_list_t *list, fr_pair_t *to_replace, fr_pair_t *vp)
 Replace a given VP. More...
 
fr_pair_tfr_pair_root_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da)
 A special allocation function which disables child autofree. More...
 
int fr_pair_steal (TALLOC_CTX *ctx, fr_pair_t *vp)
 Steal one VP. More...
 
int fr_pair_steal_append (TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp)
 Change a vp's talloc ctx and insert it into a new list. More...
 
int fr_pair_steal_prepend (TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp)
 Change a vp's talloc ctx and insert it into a new list. More...
 
int fr_pair_sublist_copy (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from, fr_pair_t const *start, unsigned int count)
 Duplicate a list of pairs starting at a particular item. More...
 
int fr_pair_update_by_da_parent (fr_pair_t *parent, fr_pair_t **out, fr_dict_attr_t const *da)
 Return the first fr_pair_t matching the fr_dict_attr_t or alloc a new fr_pair_t and its subtree (and append) More...
 
bool fr_pair_validate (fr_pair_t const *failed[2], fr_pair_list_t *filter, fr_pair_list_t *list)
 Uses fr_pair_cmp to verify all fr_pair_ts in list match the filter defined by check. More...
 
void fr_pair_validate_debug (fr_pair_t const *failed[2])
 Write an error to the library errorbuff detailing the mismatch. More...
 
bool fr_pair_validate_relaxed (fr_pair_t const *failed[2], fr_pair_list_t *filter, fr_pair_list_t *list)
 Uses fr_pair_cmp to verify all fr_pair_ts in list match the filter defined by check. More...
 
int fr_pair_value_aprintf (fr_pair_t *vp, char const *fmt,...)
 Print data into an "string" data type. More...
 
int fr_pair_value_bstr_alloc (fr_pair_t *vp, char **out, size_t size, bool tainted)
 Pre-allocate a memory buffer for a "string" type value pair. More...
 
int fr_pair_value_bstr_append_buffer (fr_pair_t *vp, char const *src, bool tainted)
 Append a talloced buffer to an existing "string" type value pair. More...
 
int fr_pair_value_bstr_realloc (fr_pair_t *vp, char **out, size_t size)
 Change the length of a buffer for a "string" type value pair. More...
 
int fr_pair_value_bstrdup_buffer (fr_pair_t *vp, char const *src, bool tainted)
 Copy a nul terminated talloced buffer a "string" type value pair. More...
 
int fr_pair_value_bstrdup_buffer_shallow (fr_pair_t *vp, char const *src, bool tainted)
 Assign a string to a "string" type value pair. More...
 
int fr_pair_value_bstrn_append (fr_pair_t *vp, char const *src, size_t len, bool tainted)
 Append bytes from a buffer to an existing "string" type value pair. More...
 
int fr_pair_value_bstrndup (fr_pair_t *vp, char const *src, size_t len, bool tainted)
 Copy data into a "string" type value pair. More...
 
int fr_pair_value_bstrndup_shallow (fr_pair_t *vp, char const *src, size_t len, bool tainted)
 Assign a string to a "string" type value pair. More...
 
void fr_pair_value_clear (fr_pair_t *vp)
 Free/zero out value (or children) of a given VP. More...
 
int fr_pair_value_copy (fr_pair_t *dst, fr_pair_t *src)
 Copy the value from one pair to another. More...
 
char const * fr_pair_value_enum (fr_pair_t const *vp, char buff[20])
 Return a const buffer for an enum type attribute. More...
 
int fr_pair_value_enum_box (fr_value_box_t const **out, fr_pair_t *vp)
 Get value box of a VP, optionally prefer enum value. More...
 
int fr_pair_value_from_str (fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, bool tainted)
 Convert string value to native attribute value. More...
 
int fr_pair_value_mem_alloc (fr_pair_t *vp, uint8_t **out, size_t size, bool tainted)
 Pre-allocate a memory buffer for a "octets" type value pair. More...
 
int fr_pair_value_mem_append (fr_pair_t *vp, uint8_t *src, size_t len, bool tainted)
 Append bytes from a buffer to an existing "octets" type value pair. More...
 
int fr_pair_value_mem_append_buffer (fr_pair_t *vp, uint8_t *src, bool tainted)
 Append a talloced buffer to an existing "octets" type value pair. More...
 
int fr_pair_value_mem_realloc (fr_pair_t *vp, uint8_t **out, size_t size)
 Change the length of a buffer for a "octets" type value pair. More...
 
int fr_pair_value_memdup (fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
 Copy data into an "octets" data type. More...
 
int fr_pair_value_memdup_buffer (fr_pair_t *vp, uint8_t const *src, bool tainted)
 Copy data from a talloced buffer into an "octets" data type. More...
 
int fr_pair_value_memdup_buffer_shallow (fr_pair_t *vp, uint8_t const *src, bool tainted)
 Assign a talloced buffer to a "octets" type value pair. More...
 
int fr_pair_value_memdup_shallow (fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
 Assign a buffer to a "octets" type value pair. More...
 
int fr_pair_value_strdup (fr_pair_t *vp, char const *src, bool tainted)
 Copy data into an "string" data type. More...
 
int fr_pair_value_strdup_shallow (fr_pair_t *vp, char const *src, bool tainted)
 Assign a buffer containing a nul terminated string to a vp, but don't copy it. More...
 
int fr_pair_value_strtrim (fr_pair_t *vp)
 Trim the length of the string buffer to match the length of the C string. More...
 
static fr_pair_tpair_alloc_parent (fr_pair_t *in, fr_pair_t *item, fr_dict_attr_t const *da)
 Find or allocate a parent attribute. More...
 
static int8_t pair_cmp_by_num (void const *a, void const *b)
 Order attributes by their attribute number, and tag. More...
 
static void pair_init_from_da (fr_pair_t *vp, fr_dict_attr_t const *da)
 Continue initialising an fr_pair_t assigning a da. More...
 
static void pair_init_null (fr_pair_t *vp)
 Initialise fields in an fr_pair_t without assigning a da. More...
 

Variables

static const char spaces [] = " "
 
static fr_dlist_head_t value_dlist
 

Detailed Description

AVP manipulation and search API.

Definition in file pair.c.

Macro Definition Documentation

◆ _PAIR_INLINE

#define _PAIR_INLINE   1

Definition at line 27 of file pair.c.

◆ _PAIR_PRIVATE

#define _PAIR_PRIVATE   1

Definition at line 26 of file pair.c.

◆ IN_A_LIST_MSG

#define IN_A_LIST_MSG   "Pair %pV is already in a list, and cannot be moved"

Definition at line 529 of file pair.c.

◆ NOT_IN_THIS_LIST_MSG

#define NOT_IN_THIS_LIST_MSG   "Pair %pV is not in the given list"

Definition at line 530 of file pair.c.

Function Documentation

◆ _fr_pair_dcursor_by_ancestor_init()

fr_pair_t* _fr_pair_dcursor_by_ancestor_init ( fr_dcursor_t cursor,
fr_pair_list_t const *  list,
fr_dict_attr_t const *  da,
bool  is_const 
)

Initialise a cursor that will return only attributes descended from the specified fr_dict_attr_t.

Parameters
[in]cursorto initialise.
[in]listto iterate over.
[in]dawho's decentness to search for.
[in]is_constwhether the fr_pair_list_t is const.
Returns
  • The first matching pair.
  • NULL if no pairs match.

Definition at line 1157 of file pair.c.

+ Here is the call graph for this function:

◆ _fr_pair_dcursor_by_da_init()

fr_pair_t* _fr_pair_dcursor_by_da_init ( fr_dcursor_t cursor,
fr_pair_list_t const *  list,
fr_dict_attr_t const *  da,
bool  is_const 
)

Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t.

Parameters
[in]cursorto initialise.
[in]listto iterate over.
[in]dato search for.
[in]is_constwhether the fr_pair_list_t is const.
Returns
  • The first matching pair.
  • NULL if no pairs match.

Definition at line 1138 of file pair.c.

+ Here is the call graph for this function:

◆ _fr_pair_dcursor_init()

fr_pair_t* _fr_pair_dcursor_init ( fr_dcursor_t cursor,
fr_pair_list_t const *  list,
bool  is_const 
)

Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.

Filters can be applied later with fr_dcursor_filter_set.

Note
This is the only way to use a dcursor in non-const mode with fr_pair_list_t.
Parameters
[out]cursorto initialise.
[in]listto iterate over.
[in]is_constwhether the fr_pair_list_t is const.
Returns
  • NULL if src does not point to any items.
  • The first pair in the list.

Definition at line 1120 of file pair.c.

+ Here is the call graph for this function:

◆ _fr_pair_dcursor_iter_init()

fr_pair_t* _fr_pair_dcursor_iter_init ( fr_dcursor_t cursor,
fr_pair_list_t const *  list,
fr_dcursor_iter_t  iter,
void const *  uctx,
bool  is_const 
)

Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.

Filters can be applied later with fr_dcursor_filter_set.

Note
This is the only way to use a dcursor in non-const mode with fr_pair_list_t.
Parameters
[out]cursorto initialise.
[in]listto iterate over.
[in]iterIterator to use when filtering pairs.
[in]uctxTo pass to iterator.
[in]is_constwhether the fr_pair_list_t is const.
Returns
  • NULL if src does not point to any items.
  • The first pair in the list.

Definition at line 1098 of file pair.c.

+ Here is the call graph for this function:

◆ _fr_pair_free()

static int _fr_pair_free ( fr_pair_t vp)
static

Free a fr_pair_t.

Note
Do not call directly, use talloc_free instead.
Parameters
vpto free.
Returns
0

Definition at line 69 of file pair.c.

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

◆ _fr_pair_iter_next_dcursor_value()

static void* _fr_pair_iter_next_dcursor_value ( UNUSED fr_dlist_head_t list,
void *  current,
void *  uctx 
)
static

Iterate over pairs.

Parameters
[in]listto iterate over.
[in]currentThe fr_value_box_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t.
[in]uctxThe parent dcursor
Returns
  • Next matching fr_pair_t.
  • NULL if not more matching fr_pair_ts could be found.

Definition at line 1259 of file pair.c.

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

◆ _fr_pair_iter_next_value()

static void* _fr_pair_iter_next_value ( fr_dlist_head_t list,
void *  current,
UNUSED void *  uctx 
)
static

Iterate over pairs.

Parameters
[in]listto iterate over.
[in]currentThe fr_value_box_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t.
[in]uctxunused
Returns
  • Next matching fr_pair_t.
  • NULL if not more matching fr_pair_ts could be found.

Definition at line 1195 of file pair.c.

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

◆ _pair_list_dcursor_insert()

static int _pair_list_dcursor_insert ( fr_dlist_head_t list,
void *  to_insert,
UNUSED void *  uctx 
)
static

Keep attr tree and sublists synced on cursor insert.

Parameters
[in]listUnderlying order list from the fr_pair_list_t.
[in]to_insertfr_pair_t being inserted.
[in]uctxfr_pair_list_t containing the order list.
Returns
  • 0 on success.

Definition at line 968 of file pair.c.

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

◆ _pair_list_dcursor_remove()

static int _pair_list_dcursor_remove ( NDEBUG_UNUSED fr_dlist_head_t list,
void *  to_remove,
UNUSED void *  uctx 
)
static

Keep attr tree and sublists synced on cursor removal.

Parameters
[in]listUnderlying order list from the fr_pair_list_t.
[in]to_removefr_pair_t being removed.
[in]uctxfr_pair_list_t containing the order list.
Returns
  • 0 on success.

Definition at line 993 of file pair.c.

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

◆ fprintf_pair_list()

static void fprintf_pair_list ( FILE *  fp,
fr_pair_list_t const *  list,
int  depth 
)
static

Definition at line 3601 of file pair.c.

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

◆ fr_fprintf_pair()

void fr_fprintf_pair ( FILE *  fp,
char const *  msg,
fr_pair_t const *  vp 
)

Definition at line 3625 of file pair.c.

+ Here is the call graph for this function:

◆ fr_fprintf_pair_list()

void fr_fprintf_pair_list ( FILE *  fp,
fr_pair_list_t const *  list 
)

Definition at line 3617 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_afrom_child_num()

fr_pair_t* fr_pair_afrom_child_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  attr 
)

Create a new valuepair.

If attr and vendor match a dictionary entry then a VP with that fr_dict_attr_t will be returned.

If attr or vendor are unknown will call dict_attruknown to create a dynamic fr_dict_attr_t of FR_TYPE_OCTETS.

Which type of fr_dict_attr_t the fr_pair_t was created with can be determined by checking

vp->da->flags.is_unknown 

.

Parameters
[in]ctxfor allocated memory, usually a pointer to a fr_packet_t.
[in]parentof the attribute being allocated (usually a dictionary or vendor).
[in]attrnumber.
Returns

Definition at line 366 of file pair.c.

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

◆ fr_pair_afrom_da()

fr_pair_t* fr_pair_afrom_da ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  da 
)

Dynamically allocate a new attribute and assign a fr_dict_attr_t.

Note
Will duplicate any unknown attributes passed as the da.
Parameters
[in]ctxfor allocated memory, usually a pointer to a fr_packet_t
[in]daSpecifies the dictionary attribute to build the fr_pair_t from. If unknown, will be duplicated, with the memory being bound to the pair.
Returns
  • A new fr_pair_t.
  • NULL if an error occurred.

Definition at line 278 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_afrom_da_depth_nested()

fr_pair_t* fr_pair_afrom_da_depth_nested ( TALLOC_CTX *  ctx,
fr_pair_list_t list,
fr_dict_attr_t const *  da,
int  start 
)

Create a pair (and all intermediate parents), and append it to the list.

Unlike fr_pair_afrom_da_nested(), this function starts off at an intermediate ctx and list.

Parameters
[in]ctxfor allocated memory, usually a pointer to a fr_packet_t.
[out]listwhere the created pair is supposed to go.
[in]dathe da for the pair to create
[in]startthe starting depth. If start != 0, we must have ctx==vp at that depth, and list==&vp->vp_group
Returns

Definition at line 403 of file pair.c.

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

◆ fr_pair_afrom_da_nested()

fr_pair_t* fr_pair_afrom_da_nested ( TALLOC_CTX *  ctx,
fr_pair_list_t list,
fr_dict_attr_t const *  da 
)

Create a pair (and all intermediate parents), and append it to the list.

If the relevant leaf pair already exists, then a new one is created.

This function is similar to fr_pair_update_by_da_parent(), except that function requires a parent pair, and this one takes a separate talloc ctx and pair list.

Parameters
[in]ctxfor allocated memory, usually a pointer to a fr_packet_t.
[out]listwhere the created pair is supposed to go.
[in]dathe da for the pair to create
Returns

Definition at line 462 of file pair.c.

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

◆ fr_pair_alloc_null()

fr_pair_t* fr_pair_alloc_null ( TALLOC_CTX *  ctx)

Dynamically allocate a new attribute with no fr_dict_attr_t assigned.

This is not the function you're looking for (unless you're binding unknown attributes to pairs, and need to pre-allocate the memory). You probably want fr_pair_afrom_da instead.

Note
You must assign a fr_dict_attr_t before freeing this fr_pair_t.
Parameters
[in]ctxto allocate the pair list in.
Returns
  • A new fr_pair_t.
  • NULL if an error occurred.

Definition at line 167 of file pair.c.

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

◆ fr_pair_append()

int fr_pair_append ( fr_pair_list_t list,
fr_pair_t to_add 
)

Add a VP to the end of the list.

Links an additional VP 'to_add' at the end of a list.

Parameters
[in]listVP in linked list. Will add new VP to this list.
[in]to_addVP to add to list.
Returns
  • 0 on success.
  • -1 on failure (pair already in list).

Definition at line 1340 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_append_by_da()

int fr_pair_append_by_da ( TALLOC_CTX *  ctx,
fr_pair_t **  out,
fr_pair_list_t list,
fr_dict_attr_t const *  da 
)

Alloc a new fr_pair_t (and append)

Parameters
[in]ctxto allocate new fr_pair_t in.
[out]outPair we allocated. May be NULL if the caller doesn't care about manipulating the fr_pair_t.
[in,out]listin search and insert into.
[in]daof attribute to update.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1461 of file pair.c.

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

◆ fr_pair_append_by_da_parent()

int fr_pair_append_by_da_parent ( TALLOC_CTX *  ctx,
fr_pair_t **  out,
fr_pair_list_t list,
fr_dict_attr_t const *  da 
)

Alloc a new fr_pair_t, adding the parent attributes if required.

A child pair will be added to the first available matching parent found.

Parameters
[in]ctxto allocate new fr_pair_t in
[out]outPair we allocated. May be NULL if the caller doesn't care about manipulating the fr_pair_t.
[in]listin which to insert the pair.
[in]daof the attribute to create.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1518 of file pair.c.

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

◆ fr_pair_children()

fr_pair_list_t* fr_pair_children ( fr_pair_t vp)

Get the child list of a group.

Parameters
[in]vpwhich MUST be of a type that can contain children.
Returns
  • NULL on error
  • pointer to head of the child list.

Definition at line 912 of file pair.c.

◆ fr_pair_cmp()

int fr_pair_cmp ( fr_pair_t const *  a,
fr_pair_t const *  b 
)

Compare two pairs, using the operator from "a".

i.e. given two attributes, it does:

(b->data) (a->operator) (a->data)

e.g. "foo" != "bar"
Parameters
[in]athe head attribute
[in]bthe second attribute
Returns
  • 1 if true.
  • 0 if false.
  • -1 on failure.

Definition at line 1966 of file pair.c.

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

◆ fr_pair_cmp_by_da()

int8_t fr_pair_cmp_by_da ( void const *  a,
void const *  b 
)

Order attributes by their da, and tag.

Useful where attributes need to be aggregated, but not necessarily ordered by attribute number.

Parameters
[in]afirst dict_attr_t.
[in]bsecond dict_attr_t.
Returns
  • +1 if a > b
  • 0 if a == b
  • -1 if a < b

Definition at line 1841 of file pair.c.

+ Here is the caller graph for this function:

◆ fr_pair_cmp_by_parent_num()

int8_t fr_pair_cmp_by_parent_num ( void const *  a,
void const *  b 
)

Order attributes by their parent(s), attribute number, and tag.

Useful for some protocols where attributes of the same number should by aggregated within a packet or container TLV.

Parameters
[in]afirst dict_attr_t.
[in]bsecond dict_attr_t.
Returns
  • +1 if a > b
  • 0 if a == b
  • -1 if a < b

Definition at line 1918 of file pair.c.

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

◆ fr_pair_copy()

fr_pair_t* fr_pair_copy ( TALLOC_CTX *  ctx,
fr_pair_t const *  vp 
)

Copy a single valuepair.

Allocate a new valuepair and copy the da from the old vp.

Parameters
[in]ctxfor talloc
[in]vpto copy.
Returns
  • A copy of the input VP.
  • NULL on error.

Definition at line 484 of file pair.c.

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

◆ fr_pair_count_by_da()

unsigned int fr_pair_count_by_da ( fr_pair_list_t const *  list,
fr_dict_attr_t const *  da 
)

Return the number of instances of a given da in the specified list.

Parameters
[in]listto search in.
[in]dato look for in the list.
Returns
  • 0 if no instances exist.
  • >0 the number of instance of a given attribute.

Definition at line 665 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_dcursor_nested_init()

fr_value_box_t* fr_pair_dcursor_nested_init ( fr_dcursor_t cursor,
fr_dcursor_t parent 
)

Initialises a special dcursor over another cursor which returns fr_pair_t, but we return fr_value_box_t.

Filters can be applied later with fr_dcursor_filter_set.

Note
- the list cannot be modified, and structural attributes are not returned.
Parameters
[out]cursorto initialise.
[in]parentto iterate over
Returns
  • NULL if src does not point to any items.
  • The first pair in the list.

Definition at line 1293 of file pair.c.

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

◆ fr_pair_dcursor_value_init()

fr_value_box_t* fr_pair_dcursor_value_init ( fr_dcursor_t cursor)

Initialises a special dcursor over a fr_pair_list_t, but which returns fr_value_box_t.

Filters can be applied later with fr_dcursor_filter_set.

Note
This is the only way to use a dcursor in non-const mode with fr_pair_list_t.
- the list cannot be modified, and structural attributes are not returned.
Parameters
[out]cursorto initialise.
Returns
  • NULL if src does not point to any items.
  • The first pair in the list.

Definition at line 1243 of file pair.c.

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

◆ fr_pair_delete()

fr_pair_t* fr_pair_delete ( fr_pair_list_t list,
fr_pair_t vp 
)

Remove fr_pair_t from a list and free.

Parameters
[in]listof value pairs to remove VP from.
[in]vpto remove
Returns
previous item in the list to the one being removed.

Definition at line 1819 of file pair.c.

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

◆ fr_pair_delete_by_child_num()

int fr_pair_delete_by_child_num ( fr_pair_list_t list,
fr_dict_attr_t const *  parent,
unsigned int  attr 
)

Delete matching pairs from the specified list.

Parameters
[in]listto delete attributes from.
[in]parentto match.
[in]attrto match.
Returns
  • >0 the number of pairs deleted.
  • 0 if no pairs were delete.
  • -1 if we couldn't resolve the attribute number.

Definition at line 1803 of file pair.c.

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

◆ fr_pair_delete_by_da()

int fr_pair_delete_by_da ( fr_pair_list_t list,
fr_dict_attr_t const *  da 
)

Delete matching pairs from the specified list.

Parameters
[in,out]listto search for attributes in or delete attributes from.
[in]dato match.
Returns
  • >0 the number of pairs deleted.
  • 0 if no pairs were deleted.

Definition at line 1684 of file pair.c.

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

◆ fr_pair_delete_by_da_nested()

int fr_pair_delete_by_da_nested ( fr_pair_list_t list,
fr_dict_attr_t const *  da 
)

Delete matching pairs from the specified list, and prune any empty branches.

Parameters
[in,out]listto search for attributes in or delete attributes from.
[in]dato match.
Returns
  • >0 the number of pairs deleted.
  • 0 if no pairs were deleted.

Definition at line 1708 of file pair.c.

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

◆ fr_pair_find_by_child_num()

fr_pair_t* fr_pair_find_by_child_num ( fr_pair_list_t const *  list,
fr_pair_t const *  prev,
fr_dict_attr_t const *  parent,
unsigned int  attr 
)

Find the pair with the matching child attribute.

Parameters
[in]listin which to search.
[in]prevattribute to start search from.
[in]parentattribute in which to lookup child.
[in]attrid of child.
Returns
  • first matching value pair.
  • NULL if no pair found.

Definition at line 862 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_find_by_child_num_idx()

fr_pair_t* fr_pair_find_by_child_num_idx ( fr_pair_list_t const *  list,
fr_dict_attr_t const *  parent,
unsigned int  attr,
unsigned int  idx 
)

Find the pair with the matching child attribute at a given index.

Parameters
[in]listin which to search.
[in]parentattribute in which to lookup child.
[in]attrid of child.
[in]idxInstance of the attribute to return.
Returns
  • first matching value pair.
  • NULL if no pair found.

Definition at line 888 of file pair.c.

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

◆ fr_pair_find_by_da()

fr_pair_t* fr_pair_find_by_da ( fr_pair_list_t const *  list,
fr_pair_t const *  prev,
fr_dict_attr_t const *  da 
)

Find the first pair with a matching da.

Parameters
[in]listto search in.
[in]prevthe previous attribute in the list.
[in]dathe next da to find.
Returns
  • first matching fr_pair_t.
  • NULL if no fr_pair_ts match.

Definition at line 688 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_find_by_da_idx()

fr_pair_t* fr_pair_find_by_da_idx ( fr_pair_list_t const *  list,
fr_dict_attr_t const *  da,
unsigned int  idx 
)

Find a pair with a matching da at a given index.

Parameters
[in]listto search in.
[in]dato look for in the list.
[in]idxInstance of the attribute to return.
Returns
  • first matching fr_pair_t.
  • NULL if no fr_pair_ts match.

Definition at line 736 of file pair.c.

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

◆ fr_pair_find_by_da_nested()

fr_pair_t* fr_pair_find_by_da_nested ( fr_pair_list_t const *  list,
fr_pair_t const *  prev,
fr_dict_attr_t const *  da 
)

Find a pair with a matching fr_dict_attr_t, by walking the nested fr_dict_attr_t tree.

The list should be the one containing the top level attributes.

Parameters
[in]listto search in.
[in]prevpair to start searching from.
[in]dathe next da to find.
Returns
  • first matching fr_pair_t.
  • NULL if no fr_pair_ts match.

Definition at line 765 of file pair.c.

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

◆ fr_pair_find_last_by_da()

fr_pair_t* fr_pair_find_last_by_da ( fr_pair_list_t const *  list,
fr_pair_t const *  prev,
fr_dict_attr_t const *  da 
)

Find the last pair with a matching da.

Parameters
[in]listto search in.
[in]prevthe previous attribute in the list.
[in]dathe previous da to find.
Returns
  • first matching fr_pair_t.
  • NULL if no fr_pair_ts match.

Definition at line 712 of file pair.c.

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

◆ fr_pair_immutable()

bool fr_pair_immutable ( fr_pair_t const *  vp)
Parameters
[in]vpthe pair to check
Returns
  • true the pair is immutable, or has an immutable child
  • false the pair is not immutable, or has no immutable children.

Definition at line 2277 of file pair.c.

+ Here is the caller graph for this function:

◆ fr_pair_init_null()

void fr_pair_init_null ( fr_pair_t vp)

Initialise fields in an fr_pair_t without assigning a da.

Used only for temporary value-pairs which are not placed in any list.

Definition at line 147 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_insert_after()

int fr_pair_insert_after ( fr_pair_list_t list,
fr_pair_t pos,
fr_pair_t to_add 
)

Add a VP after another VP.

Parameters
[in]listVP in linked list. Will add new VP to this list.
[in]posto insert pair after.
[in]to_addVP to add to list.
Returns
  • 0 on success.
  • -1 on failure (pair already in list).

Definition at line 1368 of file pair.c.

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

◆ fr_pair_insert_before()

int fr_pair_insert_before ( fr_pair_list_t list,
fr_pair_t pos,
fr_pair_t to_add 
)

Add a VP before another VP.

Parameters
[in]listVP in linked list. Will add new VP to this list.
[in]posto insert pair after.
[in]to_addVP to add to list.
Returns
  • 0 on success.
  • -1 on failure (pair already in list).

Definition at line 1401 of file pair.c.

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

◆ fr_pair_iter_next_by_ancestor()

static void* fr_pair_iter_next_by_ancestor ( fr_dlist_head_t list,
void *  current,
void *  uctx 
)
static

Iterate over pairs which are decedents of the specified da.

Parameters
[in]listto iterate over.
[in]currentThe fr_pair_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t.
[in]uctxThe fr_dict_attr_t to search for.
Returns
  • Next matching fr_pair_t.
  • NULL if not more matching fr_pair_ts could be found.

Definition at line 644 of file pair.c.

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

◆ fr_pair_iter_next_by_da()

static void* fr_pair_iter_next_by_da ( fr_dlist_head_t list,
void *  current,
void *  uctx 
)
static

Iterate over pairs with a specified da.

Parameters
[in]listto iterate over.
[in]currentThe fr_pair_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t.
[in]uctxThe fr_dict_attr_t to search for.
Returns
  • Next matching fr_pair_t.
  • NULL if not more matching fr_pair_ts could be found.

Definition at line 621 of file pair.c.

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

◆ fr_pair_list_afrom_box()

void fr_pair_list_afrom_box ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_dict_t const *  dict,
fr_value_box_t box 
)

Parse a list of VPs from a value box.

Parameters
[in]ctxto allocate new VPs in
[out]outlist to add new pairs to
[in]dictto use in parsing
[in]boxwhose value is to be parsed

Definition at line 3579 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_list_alloc()

fr_pair_list_t* fr_pair_list_alloc ( TALLOC_CTX *  ctx)

Allocate a new pair list on the heap.

Parameters
[in]ctxto allocate the pair list in.
Returns

Definition at line 117 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_list_cmp()

int fr_pair_list_cmp ( fr_pair_list_t const *  a,
fr_pair_list_t const *  b 
)

Determine equality of two lists.

This is useful for comparing lists of attributes inserted into a binary tree.

Parameters
ahead list of fr_pair_t.
bsecond list of fr_pair_t.
Returns
  • -1 if a < b.
  • 0 if the two lists are equal.
  • 1 if a > b.
  • -2 on error.

Definition at line 2044 of file pair.c.

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

◆ fr_pair_list_copy()

int fr_pair_list_copy ( TALLOC_CTX *  ctx,
fr_pair_list_t to,
fr_pair_list_t const *  from 
)

Duplicate a list of pairs.

Copy all pairs from 'from' regardless of tag, attribute or vendor.

Parameters
[in]ctxfor new fr_pair_t (s) to be allocated in.
[in]towhere to copy attributes to.
[in]fromwhence to copy fr_pair_t (s).
Returns
  • >0 the number of attributes copied.
  • 0 if no attributes copied.
  • -1 on error.

Definition at line 2316 of file pair.c.

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

◆ fr_pair_list_copy_by_ancestor()

int fr_pair_list_copy_by_ancestor ( TALLOC_CTX *  ctx,
fr_pair_list_t to,
fr_pair_list_t const *  from,
fr_dict_attr_t const *  parent_da 
)

Duplicate pairs in a list where the da is a descendant of parent_da.

Copy all pairs from 'from' which are descendants of the specified 'parent_da'. This is particularly useful for copying attributes of a particular vendor, where the vendor da is passed as parent_da.

Parameters
[in]ctxfor new fr_pair_t (s) to be allocated in.
[in]towhere to copy attributes to.
[in]fromwhence to copy fr_pair_t (s).
[in]parent_dato match.
Returns
  • >0 one or more attributes were copied
  • 0 if no attributes copied.
  • -1 on error.

Definition at line 2452 of file pair.c.

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

◆ fr_pair_list_copy_by_da()

int fr_pair_list_copy_by_da ( TALLOC_CTX *  ctx,
fr_pair_list_t to,
fr_pair_list_t const *  from,
fr_dict_attr_t const *  da,
unsigned int  count 
)

Duplicate pairs in a list matching the specified da.

Copy all pairs from 'from' matching the specified da.

Parameters
[in]ctxfor new fr_pair_t (s) to be allocated in.
[in]towhere to copy attributes to.
[in]fromwhence to copy fr_pair_t (s).
[in]dato match.
[in]countHow many instances to copy. Use 0 for all attributes.
Returns
  • >0 the number of attributes copied.
  • 0 if no attributes copied.
  • -1 on error.

Definition at line 2403 of file pair.c.

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

◆ fr_pair_list_copy_to_box()

int fr_pair_list_copy_to_box ( fr_value_box_t dst,
fr_pair_list_t from 
)

Copy the contents of a pair list to a set of value-boxes.

This function should be removed when the xlats use dcursors of copying all of the boxes.

Parameters
[in]dstwhere boxes will be created
[in]fromwhence to copy fr_pair_t (s).
Returns
  • >0 the number of boxes copied.
  • 0 if no boxes copied.
  • -1 on error.

Definition at line 2351 of file pair.c.

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

◆ fr_pair_list_init()

void fr_pair_list_init ( fr_pair_list_t list)

Initialise a pair list header.

Parameters
[in,out]listto initialise

Definition at line 46 of file pair.c.

◆ fr_pair_list_iter_leaf()

fr_pair_t* fr_pair_list_iter_leaf ( fr_pair_list_t list,
fr_pair_t vp 
)

Iterates over the leaves of a list.

Parameters
[in]listto iterate over.
[in]vpthe current CVP
Returns
  • NULL when done
  • vp - a leaf pair

Definition at line 1033 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_list_parent()

fr_pair_t* fr_pair_list_parent ( fr_pair_list_t const *  list)

Return a pointer to the parent pair which contains this list.

Definition at line 951 of file pair.c.

+ Here is the caller graph for this function:

◆ fr_pair_list_steal()

void fr_pair_list_steal ( TALLOC_CTX *  ctx,
fr_pair_list_t list 
)

Steal a list of pairs to a new context.

Definition at line 2297 of file pair.c.

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

◆ fr_pair_list_tainted()

void fr_pair_list_tainted ( fr_pair_list_t list)

Mark up a list of VPs as tainted.

Definition at line 3454 of file pair.c.

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

◆ fr_pair_matches_da()

bool fr_pair_matches_da ( void const *  item,
void const *  uctx 
)

Evaluation function for matching if vp matches a given da.

Can be used as a filter function for fr_dcursor_filter_next()

Parameters
itempointer to a fr_pair_t
uctxda to match
Returns
true if the pair matches the da

Definition at line 3483 of file pair.c.

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

◆ fr_pair_parent()

fr_pair_t* fr_pair_parent ( fr_pair_t const *  vp)

Return a pointer to the parent pair.

Definition at line 937 of file pair.c.

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

◆ fr_pair_parent_list()

fr_pair_list_t* fr_pair_parent_list ( fr_pair_t const *  vp)

Return a pointer to the parent pair list.

Definition at line 922 of file pair.c.

+ Here is the caller graph for this function:

◆ fr_pair_prepend()

int fr_pair_prepend ( fr_pair_list_t list,
fr_pair_t to_add 
)

Add a VP to the start of the list.

Links an additional VP 'add' at the beginning a list.

Parameters
[in]listVP in linked list. Will add new VP to this list.
[in]to_addVP to add to list.
Returns
  • 0 on success.
  • -1 on failure (pair already in list).

Definition at line 1309 of file pair.c.

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

◆ fr_pair_prepend_by_da()

int fr_pair_prepend_by_da ( TALLOC_CTX *  ctx,
fr_pair_t **  out,
fr_pair_list_t list,
fr_dict_attr_t const *  da 
)

Alloc a new fr_pair_t (and prepend)

Parameters
[in]ctxto allocate new fr_pair_t in.
[out]outPair we allocated. May be NULL if the caller doesn't care about manipulating the fr_pair_t.
[in,out]listin search and insert into.
[in]daof attribute to update.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1488 of file pair.c.

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

◆ fr_pair_raw_afrom_pair()

int fr_pair_raw_afrom_pair ( fr_pair_t vp,
uint8_t const *  data,
size_t  data_len 
)

Mark malformed attribute as raw.

Parameters
[in]vpto mark as raw.
[in]datato parse.
[in]data_lenof data to parse.
Returns
  • 0 on success
  • -1 on failure.

Definition at line 588 of file pair.c.

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

◆ fr_pair_reinit_from_da()

int fr_pair_reinit_from_da ( fr_pair_list_t list,
fr_pair_t vp,
fr_dict_attr_t const *  da 
)

Re-initialise an attribute with a different da.

If the new da has a different type to the old da, we'll attempt to cast the current value in place.

Definition at line 309 of file pair.c.

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

◆ fr_pair_replace()

void fr_pair_replace ( fr_pair_list_t list,
fr_pair_t to_replace,
fr_pair_t vp 
)

Replace a given VP.

Note
Memory used by the VP being replaced will be freed.
Parameters
[in,out]listpair list
[in]to_replacepair to replace and free, on list
[in]vpNew pair to insert.

Definition at line 1434 of file pair.c.

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

◆ fr_pair_root_afrom_da()

fr_pair_t* fr_pair_root_afrom_da ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  da 
)

A special allocation function which disables child autofree.

This is intended to allocate root attributes for requests. These roots are special in that they do not necessarily own the child attributes and MUST NOT free them when they themselves are freed. The children are allocated in special ctxs which may be moved between session state entries and requests, or may belong to a parent request.

Parameters
[in]ctxto allocate the pair root in.
[in]daThe root attribute.
Returns
  • A new root pair on success.
  • NULL on failure.

Definition at line 238 of file pair.c.

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

◆ fr_pair_steal()

int fr_pair_steal ( TALLOC_CTX *  ctx,
fr_pair_t vp 
)

Steal one VP.

Parameters
[in]ctxto move fr_pair_t into
[in]vpfr_pair_t to move into the new context.

Definition at line 516 of file pair.c.

+ Here is the caller graph for this function:

◆ fr_pair_steal_append()

int fr_pair_steal_append ( TALLOC_CTX *  list_ctx,
fr_pair_list_t list,
fr_pair_t vp 
)

Change a vp's talloc ctx and insert it into a new list.

Parameters
[in]list_ctxto move vp into.
[out]listto add vp to.
[in]vpto move.
Returns
  • 0 on success.
  • -1 on failure (already in list).

Definition at line 541 of file pair.c.

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

◆ fr_pair_steal_prepend()

int fr_pair_steal_prepend ( TALLOC_CTX *  list_ctx,
fr_pair_list_t list,
fr_pair_t vp 
)

Change a vp's talloc ctx and insert it into a new list.

Parameters
[in]list_ctxto move vp into.
[out]listto add vp to.
[in]vpto move.
Returns
  • 0 on success.
  • -1 on failure (already in list).

Definition at line 564 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_sublist_copy()

int fr_pair_sublist_copy ( TALLOC_CTX *  ctx,
fr_pair_list_t to,
fr_pair_list_t const *  from,
fr_pair_t const *  start,
unsigned int  count 
)

Duplicate a list of pairs starting at a particular item.

Copy all pairs from 'from' regardless of tag, attribute or vendor, starting at 'item'.

Parameters
[in]ctxfor new fr_pair_t (s) to be allocated in.
[in]towhere to copy attributes to.
[in]fromwhence to copy fr_pair_t (s).
[in]startfirst pair to start copying from.
[in]countHow many instances to copy. Use 0 for all attributes.
Returns
  • >0 the number of attributes copied.
  • 0 if no attributes copied.
  • -1 on error.

Definition at line 2505 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_update_by_da_parent()

int fr_pair_update_by_da_parent ( fr_pair_t parent,
fr_pair_t **  out,
fr_dict_attr_t const *  da 
)

Return the first fr_pair_t matching the fr_dict_attr_t or alloc a new fr_pair_t and its subtree (and append)

Parameters
[in]parentIf parent->da is an ancestor of the specified da, we continue building out the nested structure from the parent. If parent is NOT an ancestor, then it must be a group attribute, and we will append the shallowest member of the struct or TLV as a child, and build out everything to the specified da.
[out]outPair we allocated or found. May be NULL if the caller doesn't care about manipulating the fr_pair_t.
[in]daof attribute to locate or alloc.
Returns
  • 1 if attribute already existed.
  • 0 if we allocated a new attribute.
  • -1 on memory allocation failure.
  • -2 if the parent is not a group attribute.

Definition at line 1591 of file pair.c.

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

◆ fr_pair_validate()

bool fr_pair_validate ( fr_pair_t const *  failed[2],
fr_pair_list_t filter,
fr_pair_list_t list 
)

Uses fr_pair_cmp to verify all fr_pair_ts in list match the filter defined by check.

Note
will sort both filter and list in place.
Parameters
failedpointer to an array to write the pointers of the filter/list attributes that didn't match. May be NULL.
filterattributes to check list against.
listattributes, probably a request or reply

Definition at line 2125 of file pair.c.

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

◆ fr_pair_validate_debug()

void fr_pair_validate_debug ( fr_pair_t const *  failed[2])

Write an error to the library errorbuff detailing the mismatch.

Retrieve output with fr_strerror();

Todo:
add thread specific talloc contexts.
Parameters
failedpair of attributes which didn't match.

Definition at line 2090 of file pair.c.

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

◆ fr_pair_validate_relaxed()

bool fr_pair_validate_relaxed ( fr_pair_t const *  failed[2],
fr_pair_list_t filter,
fr_pair_list_t list 
)

Uses fr_pair_cmp to verify all fr_pair_ts in list match the filter defined by check.

Note
will sort both filter and list in place.
Parameters
failedpointer to an array to write the pointers of the filter/list attributes that didn't match. May be NULL.
filterattributes to check list against.
listattributes, probably a request or reply

Definition at line 2202 of file pair.c.

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

◆ fr_pair_value_aprintf()

int fr_pair_value_aprintf ( fr_pair_t vp,
char const *  fmt,
  ... 
)

Print data into an "string" data type.

Note
vp->da must be of type FR_TYPE_STRING.
Parameters
[in,out]vpto update
[in]fmtthe format string

Definition at line 2695 of file pair.c.

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

◆ fr_pair_value_bstr_alloc()

int fr_pair_value_bstr_alloc ( fr_pair_t vp,
char **  out,
size_t  size,
bool  tainted 
)

Pre-allocate a memory buffer for a "string" type value pair.

Note
Will clear existing values (including buffers).
Parameters
[in,out]vpto update
[out]outIf non-null will be filled with a pointer to the new buffer.
[in]sizeof the data.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2727 of file pair.c.

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

◆ fr_pair_value_bstr_append_buffer()

int fr_pair_value_bstr_append_buffer ( fr_pair_t vp,
char const *  src,
bool  tainted 
)

Append a talloced buffer to an existing "string" type value pair.

Parameters
[in,out]vpto update.
[in]srca talloced nul terminated buffer.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
    • -1 on failure.

Definition at line 2900 of file pair.c.

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

◆ fr_pair_value_bstr_realloc()

int fr_pair_value_bstr_realloc ( fr_pair_t vp,
char **  out,
size_t  size 
)

Change the length of a buffer for a "string" type value pair.

Parameters
[in,out]vpto update
[out]outIf non-null will be filled with a pointer to the new buffer.
[in]sizeof the data.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2752 of file pair.c.

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

◆ fr_pair_value_bstrdup_buffer()

int fr_pair_value_bstrdup_buffer ( fr_pair_t vp,
char const *  src,
bool  tainted 
)

Copy a nul terminated talloced buffer a "string" type value pair.

The buffer must be \0 terminated, or an error will be returned.

Parameters
[in,out]vpto update.
[in]srca talloced nul terminated buffer.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2807 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_value_bstrdup_buffer_shallow()

int fr_pair_value_bstrdup_buffer_shallow ( fr_pair_t vp,
char const *  src,
bool  tainted 
)

Assign a string to a "string" type value pair.

Parameters
[in]vpto assign new buffer to.
[in]srca string.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2852 of file pair.c.

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

◆ fr_pair_value_bstrn_append()

int fr_pair_value_bstrn_append ( fr_pair_t vp,
char const *  src,
size_t  len,
bool  tainted 
)

Append bytes from a buffer to an existing "string" type value pair.

Parameters
[in,out]vpto update.
[in]srcdata to copy.
[in]lenof data to copy.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
    • -1 on failure.

Definition at line 2877 of file pair.c.

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

◆ fr_pair_value_bstrndup()

int fr_pair_value_bstrndup ( fr_pair_t vp,
char const *  src,
size_t  len,
bool  tainted 
)

Copy data into a "string" type value pair.

Note
unlike the original strncpy, this function does not stop if it finds \0 bytes embedded in the string.
vp->da must be of type FR_TYPE_STRING.
Parameters
[in,out]vpto update.
[in]srcdata to copy.
[in]lenof data to copy.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2781 of file pair.c.

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

◆ fr_pair_value_bstrndup_shallow()

int fr_pair_value_bstrndup_shallow ( fr_pair_t vp,
char const *  src,
size_t  len,
bool  tainted 
)

Assign a string to a "string" type value pair.

Parameters
[in]vpto assign new buffer to.
[in]srca string.
[in]lenof src.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2832 of file pair.c.

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

◆ fr_pair_value_clear()

void fr_pair_value_clear ( fr_pair_t vp)

Free/zero out value (or children) of a given VP.

Parameters
[in]vpto clear value from.

Definition at line 2530 of file pair.c.

+ Here is the call graph for this function:

◆ fr_pair_value_copy()

int fr_pair_value_copy ( fr_pair_t dst,
fr_pair_t src 
)

Copy the value from one pair to another.

Parameters
[out]dstwhere to copy the value to. will clear assigned value.
[in]srcwhere to copy the value from Must have an assigned value.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2560 of file pair.c.

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

◆ fr_pair_value_enum()

char const* fr_pair_value_enum ( fr_pair_t const *  vp,
char  buff[20] 
)

Return a const buffer for an enum type attribute.

Where the vp type is numeric but does not have any enumv, or its value does not map to an enumv, the integer value of the pair will be printed to buff, and a pointer to buff will be returned.

Parameters
[in]vpto print.
[in]buffto print integer value to.
Returns
a talloced buffer.

Definition at line 3122 of file pair.c.

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

◆ fr_pair_value_enum_box()

int fr_pair_value_enum_box ( fr_value_box_t const **  out,
fr_pair_t vp 
)

Get value box of a VP, optionally prefer enum value.

Get the data value box of the given VP. If 'e' is set to 1 and the VP has an enum value, this will be returned instead. Otherwise it will be set to the value box of the VP itself.

Parameters
[out]outpointer to a value box.
[in]vpto print.
Returns
1 if the enum value has been used, 0 otherwise, -1 on error.

Definition at line 3161 of file pair.c.

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

◆ fr_pair_value_from_str()

int fr_pair_value_from_str ( fr_pair_t vp,
char const *  value,
size_t  inlen,
fr_sbuff_unescape_rules_t const *  uerules,
bool  tainted 
)

Convert string value to native attribute value.

Parameters
[in]vpto assign value to.
[in]valuestring to convert. Binary safe for variable length values if len is provided.
[in]inlenThe length of the input string.
[in]uerulesused to perform unescaping.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2586 of file pair.c.

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

◆ fr_pair_value_mem_alloc()

int fr_pair_value_mem_alloc ( fr_pair_t vp,
uint8_t **  out,
size_t  size,
bool  tainted 
)

Pre-allocate a memory buffer for a "octets" type value pair.

Note
Will clear existing values (including buffers).
Parameters
[in,out]vpto update
[out]outIf non-null will be filled with a pointer to the new buffer.
[in]sizeof the data.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2927 of file pair.c.

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

◆ fr_pair_value_mem_append()

int fr_pair_value_mem_append ( fr_pair_t vp,
uint8_t src,
size_t  len,
bool  tainted 
)

Append bytes from a buffer to an existing "octets" type value pair.

Parameters
[in,out]vpto update.
[in]srcdata to copy.
[in]lenof data to copy.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
    • -1 on failure.

Definition at line 3075 of file pair.c.

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

◆ fr_pair_value_mem_append_buffer()

int fr_pair_value_mem_append_buffer ( fr_pair_t vp,
uint8_t src,
bool  tainted 
)

Append a talloced buffer to an existing "octets" type value pair.

Parameters
[in,out]vpto update.
[in]srcdata to copy.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
    • -1 on failure.

Definition at line 3098 of file pair.c.

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

◆ fr_pair_value_mem_realloc()

int fr_pair_value_mem_realloc ( fr_pair_t vp,
uint8_t **  out,
size_t  size 
)

Change the length of a buffer for a "octets" type value pair.

Parameters
[in,out]vpto update
[out]outIf non-null will be filled with a pointer to the new buffer.
[in]sizeof the data.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2952 of file pair.c.

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

◆ fr_pair_value_memdup()

int fr_pair_value_memdup ( fr_pair_t vp,
uint8_t const *  src,
size_t  len,
bool  tainted 
)

Copy data into an "octets" data type.

Note
Will clear existing values (including buffers).
Parameters
[in,out]vpto update
[in]srcdata to copy
[in]lenof the data.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2978 of file pair.c.

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

◆ fr_pair_value_memdup_buffer()

int fr_pair_value_memdup_buffer ( fr_pair_t vp,
uint8_t const *  src,
bool  tainted 
)

Copy data from a talloced buffer into an "octets" data type.

Note
Will clear existing values (including buffers).
Parameters
[in,out]vpto update
[in]srcdata to copy
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3008 of file pair.c.

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

◆ fr_pair_value_memdup_buffer_shallow()

int fr_pair_value_memdup_buffer_shallow ( fr_pair_t vp,
uint8_t const *  src,
bool  tainted 
)

Assign a talloced buffer to a "octets" type value pair.

Parameters
[in]vpto assign new buffer to.
[in]srcdata to copy.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3053 of file pair.c.

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

◆ fr_pair_value_memdup_shallow()

int fr_pair_value_memdup_shallow ( fr_pair_t vp,
uint8_t const *  src,
size_t  len,
bool  tainted 
)

Assign a buffer to a "octets" type value pair.

Parameters
[in]vpto assign new buffer to.
[in]srcdata to copy.
[in]lenof src.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3033 of file pair.c.

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

◆ fr_pair_value_strdup()

int fr_pair_value_strdup ( fr_pair_t vp,
char const *  src,
bool  tainted 
)

Copy data into an "string" data type.

Note
vp->da must be of type FR_TYPE_STRING.
Parameters
[in,out]vpto update
[in]srcdata to copy
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2631 of file pair.c.

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

◆ fr_pair_value_strdup_shallow()

int fr_pair_value_strdup_shallow ( fr_pair_t vp,
char const *  src,
bool  tainted 
)

Assign a buffer containing a nul terminated string to a vp, but don't copy it.

Parameters
[in]vpto assign string to.
[in]srcto copy string from.
[in]taintedWhether the value came from a trusted source.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2655 of file pair.c.

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

◆ fr_pair_value_strtrim()

int fr_pair_value_strtrim ( fr_pair_t vp)

Trim the length of the string buffer to match the length of the C string.

Parameters
[in,out]vpto trim.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2674 of file pair.c.

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

◆ pair_alloc_parent()

static fr_pair_t* pair_alloc_parent ( fr_pair_t in,
fr_pair_t item,
fr_dict_attr_t const *  da 
)
static

Find or allocate a parent attribute.

The input da is somewhere down inside of the da hierarchy. We need to recursively find or create parent VPs which match the given da.

We find (or add) the VP into the "in" list. Any newly created VP is inserted before "next". Or if "next==NULL", at the tail of "in".

Parameters
[in]inthe parent vp to look in
[in]itemif we create a new vp, insert it before this item
[in]dalook for vps in the parent which match this da
Returns
  • NULL on OOM
  • parent vp we've found or allocated.

Definition at line 3507 of file pair.c.

+ Here is the call graph for this function:

◆ pair_cmp_by_num()

static int8_t pair_cmp_by_num ( void const *  a,
void const *  b 
)
inlinestatic

Order attributes by their attribute number, and tag.

Parameters
[in]afirst dict_attr_t.
[in]bsecond dict_attr_t.
Returns
  • +1 if a > b
  • 0 if a == b
  • -1 if a < b

Definition at line 1861 of file pair.c.

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

◆ pair_init_from_da()

static void pair_init_from_da ( fr_pair_t vp,
fr_dict_attr_t const *  da 
)
inlinestatic

Continue initialising an fr_pair_t assigning a da.

Note
Internal use by the pair allocation functions only.

Definition at line 187 of file pair.c.

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

◆ pair_init_null()

static void pair_init_null ( fr_pair_t vp)
inlinestatic

Initialise fields in an fr_pair_t without assigning a da.

Note
Internal use by the allocation functions only.

Definition at line 133 of file pair.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ spaces

const char spaces[] = " "
static

Definition at line 3599 of file pair.c.

◆ value_dlist

fr_dlist_head_t value_dlist
static
Initial value:
= {
.offset = offsetof(fr_dlist_head_t, entry),
.type = NULL,
.num_elements = 0,
.entry = {
.prev = &value_dlist.entry,
},
}
fr_dlist_t * next
Definition: dlist.h:43
fr_dlist_t entry
Struct holding the head and tail of the list.
Definition: dlist.h:52
Head of a doubly linked list.
Definition: dlist.h:51
static fr_dlist_head_t value_dlist
Definition: pair.c:1221

Definition at line 1221 of file pair.c.