The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
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.
 
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.
 
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.
 
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.
 
static int _fr_pair_free (fr_pair_t *vp)
 Free a fr_pair_t.
 
static void * _fr_pair_iter_next_dcursor_value (UNUSED fr_dcursor_t *cursor, void *current, void *uctx)
 Iterate over pairs.
 
static void * _fr_pair_iter_next_value (fr_dcursor_t *cursor, void *current, UNUSED void *uctx)
 Iterate over pairs.
 
static int _pair_list_dcursor_insert (fr_dcursor_t *cursor, void *to_insert, UNUSED void *uctx)
 Keep attr tree and sublists synced on cursor insert.
 
static int _pair_list_dcursor_remove (NDEBUG_UNUSED fr_dcursor_t *cursor, void *to_remove, UNUSED void *uctx)
 Keep attr tree and sublists synced on cursor removal.
 
fr_pair_t * fr_pair_afrom_child_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
 Create a new valuepair.
 
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.
 
fr_pair_t * fr_pair_afrom_da_depth_nested (TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da, unsigned int start)
 Create a pair (and all intermediate parents), and append it to the list.
 
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.
 
fr_pair_t * fr_pair_alloc_null (TALLOC_CTX *ctx)
 Dynamically allocate a new attribute with no fr_dict_attr_t assigned.
 
int fr_pair_append (fr_pair_list_t *list, fr_pair_t *to_add)
 Add a VP to the end of the list.
 
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)
 
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.
 
fr_pair_list_t * fr_pair_children (fr_pair_t *vp)
 Get the child list of a group.
 
int fr_pair_cmp (fr_pair_t const *a, fr_pair_t const *b)
 Compare two pairs, using the operator from "a".
 
fr_cmp_ret_t fr_pair_cmp_by_da (void const *a, void const *b)
 Order attributes by their da.
 
fr_cmp_ret_t fr_pair_cmp_by_parent_num (void const *a, void const *b)
 Order attributes by their parent(s), attribute number, and tag.
 
fr_pair_t * fr_pair_copy (TALLOC_CTX *ctx, fr_pair_t const *vp)
 Copy a single valuepair.
 
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.
 
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.
 
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.
 
int fr_pair_delete (fr_pair_list_t *list, fr_pair_t *vp)
 Remove fr_pair_t from a list and free.
 
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.
 
int fr_pair_delete_by_da (fr_pair_list_t *list, fr_dict_attr_t const *da)
 Delete matching pairs from the specified list.
 
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.
 
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.
 
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.
 
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.
 
fr_pair_t * fr_pair_find_by_da_nested (fr_pair_list_t const *list, 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.
 
fr_pair_t * fr_pair_find_last_by_da (fr_pair_list_t const *list, fr_dict_attr_t const *da)
 Find the last pair with a matching da.
 
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.
 
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.
 
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.
 
static void * fr_pair_iter_next_by_ancestor (fr_dcursor_t *cursor, void *current, void *uctx)
 Iterate over pairs which are decedents of the specified da.
 
static void * fr_pair_iter_next_by_da (fr_dcursor_t *cursor, void *current, void *uctx)
 Iterate over pairs with a specified da.
 
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.
 
fr_pair_list_t * fr_pair_list_alloc (TALLOC_CTX *ctx)
 Allocate a new pair list on the heap.
 
fr_cmp_ret_t fr_pair_list_cmp (fr_pair_list_t const *a, fr_pair_list_t const *b)
 Determine equality of two lists.
 
int fr_pair_list_copy (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
 Duplicate a list of pairs.
 
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.
 
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)
 Duplicate pairs in a list matching the specified da.
 
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.
 
void fr_pair_list_init (fr_pair_list_t *list)
 Initialise a pair list header.
 
fr_pair_t * fr_pair_list_iter_leaf (fr_pair_list_t *list, fr_pair_t *vp)
 Iterates over the leaves of a list.
 
fr_pair_t * fr_pair_list_parent (fr_pair_list_t const *list)
 Return a pointer to the parent pair which contains this list.
 
void fr_pair_list_steal (TALLOC_CTX *ctx, fr_pair_list_t *list)
 Steal a list of pairs to a new context.
 
void fr_pair_list_tainted (fr_pair_list_t *list)
 Mark up a list of VPs as tainted.
 
bool fr_pair_matches_da (void const *item, void const *uctx)
 Evaluation function for matching if vp matches a given da.
 
fr_pair_t * fr_pair_parent (fr_pair_t const *vp)
 Return a pointer to the parent pair.
 
fr_pair_list_t * fr_pair_parent_list (fr_pair_t const *vp)
 Return a pointer to the parent pair list.
 
int fr_pair_prepend (fr_pair_list_t *list, fr_pair_t *to_add)
 Add a VP to the start of the list.
 
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)
 
int fr_pair_raw_afrom_pair (fr_pair_t *vp, uint8_t const *data, size_t data_len)
 Mark malformed attribute as raw.
 
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.
 
void fr_pair_replace (fr_pair_list_t *list, fr_pair_t *to_replace, fr_pair_t *vp)
 Replace a given VP.
 
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.
 
int fr_pair_steal (TALLOC_CTX *ctx, fr_pair_t *vp)
 Steal one VP.
 
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.
 
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.
 
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)
 
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.
 
void fr_pair_validate_debug (fr_pair_t const *failed[2])
 Write an error to the library errorbuff detailing the mismatch.
 
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.
 
int fr_pair_value_aprintf (fr_pair_t *vp, char const *fmt,...)
 Print data into an "string" data type.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void fr_pair_value_clear (fr_pair_t *vp)
 Free/zero out value (or children) of a given VP.
 
int fr_pair_value_copy (fr_pair_t *dst, fr_pair_t *src)
 Copy the value from one pair to another.
 
char const * fr_pair_value_enum (fr_pair_t const *vp, char buff[20])
 Return a const buffer for an enum type attribute.
 
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.
 
int fr_pair_value_from_str (fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, UNUSED bool tainted)
 Convert string value to native attribute value.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
int fr_pair_value_strdup (fr_pair_t *vp, char const *src, bool tainted)
 Copy data into an "string" data type.
 
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.
 
int fr_pair_value_strtrim (fr_pair_t *vp)
 Trim the length of the string buffer to match the length of the C string.
 
static fr_pair_t * pair_alloc_parent (fr_pair_t *in, fr_pair_t *item, fr_dict_attr_t const *da)
 Find or allocate a parent attribute.
 
static fr_cmp_ret_t pair_cmp_by_num (void const *a, void const *b)
 Order attributes by their attribute number, and tag.
 
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.
 
static void pair_init_null (fr_pair_t *vp)
 Initialise fields in an fr_pair_t without assigning a da.
 

Variables

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 551 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 552 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 descendants 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 1120 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 1101 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.

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

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 1063 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 70 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_dcursor_t *  cursor,
void *  current,
void *  uctx 
)
static

Iterate over pairs.

Parameters
[in]cursorto 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 1220 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_dcursor_t *  cursor,
void *  current,
UNUSED void *  uctx 
)
static

Iterate over pairs.

Parameters
[in]cursorto 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 1158 of file pair.c.

+ Here is the caller graph for this function:

◆ _pair_list_dcursor_insert()

static int _pair_list_dcursor_insert ( fr_dcursor_t *  cursor,
void *  to_insert,
UNUSED void *  uctx 
)
static

Keep attr tree and sublists synced on cursor insert.

Parameters
[in]cursorthe cursor being modified
[in]to_insertfr_pair_t being inserted.
[in]uctxfr_pair_list_t containing the order list.
Returns
  • 0 on success.

Definition at line 946 of file pair.c.

+ Here is the caller graph for this function:

◆ _pair_list_dcursor_remove()

static int _pair_list_dcursor_remove ( NDEBUG_UNUSED fr_dcursor_t *  cursor,
void *  to_remove,
UNUSED void *  uctx 
)
static

Keep attr tree and sublists synced on cursor removal.

Parameters
[in]cursorthe cursor being modified
[in]to_removefr_pair_t being removed.
[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:

◆ 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 385 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 291 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,
unsigned 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 423 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 481 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 170 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 1298 of file pair.c.

◆ 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 which to append the pair.
[in]daof attribute to create.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1417 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 1474 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 897 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 1950 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()

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

Order attributes by their da.

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

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

Definition at line 1797 of file pair.c.

+ Here is the caller graph for this function:

◆ fr_pair_cmp_by_parent_num()

fr_cmp_ret_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 1902 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 504 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 685 of file pair.c.

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

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

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 1204 of file pair.c.

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

◆ fr_pair_delete()

int 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
  • <0 on error: pair wasn't deleted
  • 0 on success

Definition at line 1779 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 1761 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 1642 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 1666 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_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 873 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 708 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 755 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_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]dathe next da to find.
Returns
  • first matching fr_pair_t.
  • NULL if no fr_pair_ts match.

Definition at line 783 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_dict_attr_t const *  da 
)

Find the last pair with a matching da.

Parameters
[in]listto search in.
[in]dathe da to find
Returns

Definition at line 731 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 2257 of file pair.c.

+ Here is the call graph for this function:
+ 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 150 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 1324 of file pair.c.

+ 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 1357 of file pair.c.

+ Here is the caller graph for this function:

◆ fr_pair_iter_next_by_ancestor()

static void * fr_pair_iter_next_by_ancestor ( fr_dcursor_t *  cursor,
void *  current,
void *  uctx 
)
static

Iterate over pairs which are decedents of the specified da.

Parameters
[in]cursorto 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 664 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_dcursor_t *  cursor,
void *  current,
void *  uctx 
)
static

Iterate over pairs with a specified da.

Parameters
[in]cursorto 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 641 of file pair.c.

+ 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 3494 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 120 of file pair.c.

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

◆ fr_pair_list_cmp()

fr_cmp_ret_t 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
  • CMP_LT if a < b.
  • CMP_EQ if the two lists are equal.
  • CMP_GT if a > b.
  • CMP_ERR if the lists are not comparable, retrieve the error with fr_strerror.

Definition at line 2028 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 2300 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 2432 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 
)

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.
Returns
  • >0 the number of attributes copied.
  • 0 if no attributes copied.
  • -1 on error.

Definition at line 2388 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 2335 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 47 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 998 of file pair.c.

+ Here is the call graph for this function:
+ Here is the caller 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 929 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 2281 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 3382 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.

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

Definition at line 3409 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 915 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 907 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 1267 of file pair.c.

+ 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 which to prepend the pair.
[in]daof attribute to create.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1444 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 610 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 328 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 1390 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 249 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 538 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 563 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 586 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 1548 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 2105 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 2070 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 2182 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 2659 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 2691 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 2716 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 2770 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 2815 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
This API will copy binary data, including embedded '\0'
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 2744 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 2795 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 2482 of file pair.c.

+ Here is the call graph for this function:
+ Here is the caller 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 2512 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 2991 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 3024 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,
UNUSED 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 2549 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 2843 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 2868 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 2894 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 2924 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 2969 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 2949 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 2595 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 2619 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 2638 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 3433 of file pair.c.

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

◆ pair_cmp_by_num()

static fr_cmp_ret_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 1845 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 191 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 136 of file pair.c.

+ Here is the caller graph for this function:

Variable Documentation

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

Definition at line 1184 of file pair.c.