The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions
pair.h File Reference

AVP manipulation and search API. More...

#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/dcursor.h>
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/tlist.h>
+ Include dependency graph for pair.h:

Go to the source code of this file.

Data Structures

struct  fr_pair_ctx_t
 
struct  pair_list_s
 
struct  value_pair_s
 Stores an attribute, a value and various bits of other data. More...
 
union  value_pair_s.__unnamed123__
 
struct  value_pair_s.__unnamed123__.__unnamed127__
 
struct  value_pair_s.__unnamed125__
 

Macros

#define _CONST   const
 
#define ATTRIBUTE_EQ(_x, _y)   ((_x && _y) && (_x->da == _y->da))
 
#define fr_pair_cmp_op(_op, _a, _b)   fr_value_box_cmp_op(_op, &_a->data, &_b->data)
 Compare two attributes using and operator. More...
 
#define fr_pair_dcursor_by_ancestor_init(_cursor, _list, _da)
 Initialise a cursor that will return only attributes descended from the specified fr_dict_attr_t. More...
 
#define fr_pair_dcursor_by_da_init(_cursor, _list, _da)
 Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t. More...
 
#define fr_pair_dcursor_init(_cursor, _list)
 Initialises a special dcursor with callbacks that will maintain the attr sublists correctly. More...
 
#define fr_pair_dcursor_iter_init(_cursor, _list, _iter, _uctx)
 Initialises a special dcursor with callbacks that will maintain the attr sublists correctly. More...
 
#define fr_pair_list_append_by_da(_ctx, _vp, _list, _attr, _val, _tainted)
 Append a pair to a list, assigning its value. More...
 
#define fr_pair_list_append_by_da_len(_ctx, _vp, _list, _attr, _val, _len, _tainted)
 Append a pair to a list, assigning its value. More...
 
#define fr_pair_list_append_by_da_parent(_ctx, _vp, _list, _attr, _val, _tainted)
 
#define fr_pair_list_append_by_da_parent_len(_ctx, _vp, _list, _attr, _val, _len, _tainted)
 
#define fr_pair_list_foreach(_list_head, _iter)    for (fr_pair_t *JOIN(_next,_iter), *_iter = fr_pair_list_head(_list_head); JOIN(_next,_iter) = fr_pair_list_next(_list_head, _iter), _iter != NULL; _iter = JOIN(_next,_iter))
 Iterate over the contents of a fr_pair_list_t. More...
 
#define fr_pair_list_foreach_leaf(_list_head, _iter)    for (fr_pair_t *_iter = fr_pair_list_iter_leaf(_list_head, NULL); _iter != NULL; _iter = fr_pair_list_iter_leaf(_list_head, _iter))
 Iterate over the leaf nodes of a fr_pair_list_t. More...
 
#define fr_pair_list_prepend_by_da(_ctx, _vp, _list, _attr, _val, _tainted)
 Prepend a pair to a list, assigning its value. More...
 
#define fr_pair_list_prepend_by_da_len(_ctx, _vp, _list, _attr, _val, _len, _tainted)
 Prepend a pair to a list, assigning its value. More...
 
#define fr_pair_list_replace_by_da(_ctx, _vp, _list, _attr, _val, _tainted)
 Replace a pair in a list, assigning its value. More...
 
#define fr_pair_list_replace_by_da_len(_ctx, _vp, _list, _attr, _val, _len, _tainted)
 Replace a pair in a list, assigning its value. More...
 
#define PAIR_LIST_VERIFY(_x)   fr_pair_list_nonnull_assert(_x)
 
#define PAIR_VERIFY(_x)   fr_pair_nonnull_assert(_x)
 
#define PAIR_VERIFY_WITH_LIST(_l, _x)
 
#define vp_bool   data.datum.boolean
 
#define vp_date   data.vb_date
 
#define vp_ether   data.vb_ether
 
#define vp_filter   data.datum.filter
 
#define vp_float32   data.vb_float32
 
#define vp_float64   data.vb_float64
 
#define vp_group   children
 
#define vp_ifid   data.vb_ifid
 
#define vp_immutable   data.immutable
 
#define vp_int16   data.vb_int16
 
#define vp_int32   data.vb_int32
 
#define vp_int64   data.vb_int64
 
#define vp_int8   data.vb_int8
 
#define vp_ip   data.vb_ip
 
#define vp_ipv4addr   data.vb_ip.addr.v4.s_addr
 
#define vp_ipv6addr   data.vb_ip.addr.v6.s6_addr
 
#define vp_length   data.vb_length
 
#define vp_octets   data.vb_octets
 
#define vp_ptr   data.datum.ptr
 Either octets or strvalue. More...
 
#define vp_raw   da->flags.is_raw
 
#define vp_size   data.datum.size
 
#define vp_strvalue   data.vb_strvalue
 
#define vp_tainted   data.tainted
 
#define vp_time_delta   data.vb_time_delta
 
#define vp_type   data.type
 
#define vp_uint16   data.vb_uint16
 
#define vp_uint32   data.vb_uint32
 
#define vp_uint64   data.vb_uint64
 
#define vp_uint8   data.vb_uint8
 

Typedefs

typedef struct pair_list_s fr_pair_list_t
 
typedef struct value_pair_s fr_pair_t
 

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...
 
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 *vp)
 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 *head)
 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...
 
ssize_t fr_pair_ctx_afrom_str (fr_pair_ctx_t *pair_ctx, char const *in, size_t inlen)
 Parse a pair context from a string. More...
 
void fr_pair_ctx_reset (fr_pair_ctx_t *pair_ctx, fr_dict_t const *dict)
 Reset a pair_ctx to the dictionary root. More...
 
static fr_pair_tfr_pair_dcursor_child_iter_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dcursor_t const *parent)
 Initializes a child dcursor from a parent cursor, with an iteration function. 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 *head, 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...
 
static int fr_pair_find_or_append_by_da (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *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. 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...
 
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...
 
void fr_pair_list_append (fr_pair_list_t *dst, fr_pair_list_t *src)
 Appends a list of fr_pair_t from a temporary list to a destination list. 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...
 
bool fr_pair_list_empty (fr_pair_list_t const *list)
 Is a valuepair list empty. More...
 
void fr_pair_list_free (fr_pair_list_t *list)
 Free memory used by a valuepair list. More...
 
fr_pair_list_tfr_pair_list_from_dlist (fr_dlist_head_t const *list)
 Get the pair list head from a dlist. More...
 
fr_pair_tfr_pair_list_head (fr_pair_list_t const *list)
 Get the head of a valuepair list. More...
 
void fr_pair_list_init (fr_pair_list_t *head)
 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_next (fr_pair_list_t const *list, fr_pair_t const *item))
 Get the next item in a valuepair list after a specific entry. More...
 
static bool fr_pair_list_nonnull_assert (fr_pair_list_t const *pair_list)
 
size_t fr_pair_list_num_elements (fr_pair_list_t const *list)
 Get the length of a list of fr_pair_t. 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_prepend (fr_pair_list_t *dst, fr_pair_list_t *src)
 Move a list of fr_pair_t from a temporary list to the head of a destination list. More...
 
fr_pair_tfr_pair_list_prev (fr_pair_list_t const *list, fr_pair_t const *item))
 Get the previous item in a valuepair list before a specific entry. More...
 
void fr_pair_list_sort (fr_pair_list_t *list, fr_cmp_t cmp)
 Sort a doubly linked list of fr_pair_ts using merge sort. More...
 
void fr_pair_list_steal (TALLOC_CTX *ctx, fr_pair_list_t *list)
 Steal a list of pairs to a new context. More...
 
fr_pair_tfr_pair_list_tail (fr_pair_list_t const *list)
 Get the tail of a valuepair list. More...
 
void fr_pair_list_tainted (fr_pair_list_t *vps)
 Mark up a list of VPs as tainted. More...
 
fr_dlist_head_tfr_pair_list_to_dlist (fr_pair_list_t const *list)
 Get the dlist head from a pair list. More...
 
bool fr_pair_matches_da (void const *item, void const *uctx)
 Evaluation function for matching if vp matches a given da. More...
 
static bool fr_pair_nonnull_assert (fr_pair_t const *vp)
 If WITH_VERIFY_PTR is defined, we perform runtime checks to ensure the fr_pair_t are sane. 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 *vp)
 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...
 
fr_pair_tfr_pair_remove (fr_pair_list_t *list, fr_pair_t *vp)
 Remove fr_pair_t from a list without freeing. 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...
 
static void fr_pair_set_immutable (fr_pair_t *vp)
 
int fr_pair_steal (TALLOC_CTX *ctx, fr_pair_t *vp)
 Steal one VP. More...
 
int fr_pair_steal_append (TALLOC_CTX *nctx, 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 *nctx, 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...
 
static bool vp_da_data_type_check (fr_pair_t *vp)
 Check a pair's data type matches the DA data type. More...
 

Printing functions

void _fr_pair_list_log (fr_log_t const *log, int lvl, fr_pair_t *parent, fr_pair_list_t const *list, char const *file, int line))
 Print a list of attributes and enumv. More...
 
static fr_slen_t fr_pair_aprint (TALLOC_CTX *ctx, char **out, fr_dict_attr_t const *parent, fr_pair_t const *vp) 1(fr_pair_print
 
static fr_slen_t static vp fr_slen_t fr_pair_aprint_secure (TALLOC_CTX *ctx, char **out, fr_dict_attr_t const *parent, fr_pair_t const *vp) 1(fr_pair_print_secure
 
static fr_slen_t fr_pair_aprint_value_quoted (TALLOC_CTX *ctx, char **out, fr_pair_t const *vp, fr_token_t quote) 1(fr_pair_print_value_quoted
 
void fr_pair_debug (fr_pair_t const *pair)
 Dumps a pair to the default logging destination - Useful for calling from debuggers. More...
 
void fr_pair_list_debug (fr_pair_list_t const *list)
 Dumps a list to the default logging destination - Useful for calling from debuggers. More...
 
#define fr_pair_list_log(_log, _lvl, _list)   _fr_pair_list_log(_log, _lvl, NULL, _list, __FILE__, __LINE__)
 
ssize_t fr_pair_list_print (fr_sbuff_t *out, fr_dict_attr_t const *parent, fr_pair_list_t const *list)
 Print a pair list. More...
 
static fr_slen_t quote ssize_t fr_pair_print (fr_sbuff_t *out, fr_dict_attr_t const *parent, fr_pair_t const *vp))
 Print one attribute and value to a string. More...
 
ssize_t fr_pair_print_secure (fr_sbuff_t *out, fr_dict_attr_t const *parent, fr_pair_t const *vp))
 Print one attribute and value to a string with escape rules. More...
 
ssize_t fr_pair_print_value_quoted (fr_sbuff_t *out, fr_pair_t const *vp, fr_token_t quote)
 Print the value of an attribute to a string. More...
 
static fr_slen_t parent
 
static fr_slen_t vp
 

Pair to pair copying

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

Assign and manipulate binary-unsafe C strings

int fr_pair_value_aprintf (fr_pair_t *vp, char const *fmt,...)
 Print data into an "string" data type. More...
 
int fr_pair_value_from_str (fr_pair_t *vp, char const *value, size_t len, fr_sbuff_unescape_rules_t const *erules, bool tainted))
 Convert string value to native attribute value. 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...
 

Assign and manipulate binary-safe strings

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

Assign and manipulate octets strings

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

Enum functions

char const * fr_pair_value_enum (fr_pair_t const *vp, char buff[static 20])
 
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...
 

Detailed Description

AVP manipulation and search API.

Definition in file pair.h.


Data Structure Documentation

◆ fr_pair_ctx_t

struct fr_pair_ctx_t

Definition at line 865 of file pair.h.

+ Collaboration diagram for fr_pair_ctx_t:
Data Fields
TALLOC_CTX * ctx to allocate VPs in
fr_pair_list_t * list of VPs to add
fr_dict_attr_t const * parent current attribute to allocate VPs in

◆ value_pair_s.__unnamed123__

union value_pair_s.__unnamed123__

Definition at line 83 of file pair.h.

Data Fields
__unnamed123__ __unnamed__
fr_value_box_t data The value of this pair.

◆ value_pair_s.__unnamed123__.__unnamed127__

struct value_pair_s.__unnamed123__.__unnamed127__

Definition at line 86 of file pair.h.

Data Fields
fr_pair_list_t children Nested attributes of this pair.
uint8_t pad[offsetof(fr_value_box_t, type)+sizeof(fr_type_t)] Force children field to come after the type field in the fr_value_box_t.

This works no matter where type appears in fr_value_box_t, whereas just listing another fr_type_t field here does not.

This hack allows the majority of the fr_pair_list_t to overlap with the fr_value_box_t which gives us much greater packing efficiency.

◆ value_pair_s.__unnamed125__

struct value_pair_s.__unnamed125__

Definition at line 104 of file pair.h.

Data Fields
fr_token_t op Operator to use when moving or inserting.

Macro Definition Documentation

◆ _CONST

#define _CONST   const

Definition at line 43 of file pair.h.

◆ ATTRIBUTE_EQ

#define ATTRIBUTE_EQ (   _x,
  _y 
)    ((_x && _y) && (_x->da == _y->da))

Definition at line 147 of file pair.h.

◆ fr_pair_cmp_op

#define fr_pair_cmp_op (   _op,
  _a,
  _b 
)    fr_value_box_cmp_op(_op, &_a->data, &_b->data)

Compare two attributes using and operator.

Returns
  • 1 if equal.
  • 0 if not equal.
  • -1 on failure.

Definition at line 665 of file pair.h.

◆ fr_pair_dcursor_by_ancestor_init

#define fr_pair_dcursor_by_ancestor_init (   _cursor,
  _list,
  _da 
)
Value:
_list, \
_da, \
#define IS_CONST(_type, _var)
Check if a given variable is the _const or not.
Definition: build.h:277
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.
Definition: pair.c:1157

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.
Returns
  • The first matching pair.
  • NULL if no pairs match.

Definition at line 645 of file pair.h.

◆ fr_pair_dcursor_by_da_init

#define fr_pair_dcursor_by_da_init (   _cursor,
  _list,
  _da 
)
Value:
_list, \
_da, \
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.
Definition: pair.c:1138

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.
Returns
  • The first matching pair.
  • NULL if no pairs match.

Definition at line 627 of file pair.h.

◆ fr_pair_dcursor_init

#define fr_pair_dcursor_init (   _cursor,
  _list 
)
Value:
_list, \
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.
Definition: pair.c:1120

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.
Returns
  • NULL if src does not point to any items.
  • The first pair in the list.

Definition at line 590 of file pair.h.

◆ fr_pair_dcursor_iter_init

#define fr_pair_dcursor_iter_init (   _cursor,
  _list,
  _iter,
  _uctx 
)
Value:
_list, \
_iter, \
_uctx, \
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.
Definition: pair.c:1098

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.
Returns
  • NULL if src does not point to any items.
  • The first pair in the list.

Definition at line 568 of file pair.h.

◆ fr_pair_list_append_by_da

#define fr_pair_list_append_by_da (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _tainted 
)
Value:
do { \
_vp = NULL; \
if (fr_pair_append_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
fr_value_box(&_vp->data, _val, _tainted); \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
} while (0)
break
Definition: rlm_securid.c:421
if(!subtype_vp) goto fail
static bool vp_da_data_type_check(fr_pair_t *vp)
Check a pair's data type matches the DA data type.
Definition: pair.h:241
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)
Definition: pair.c:1461
static fr_slen_t data
Definition: value.h:1259
#define fr_value_box(_box, _var, _tainted)
Automagically fill in a box, determining the value type from the type of the C variable.
Definition: value.h:858

Append a pair to a list, assigning its value.

Version for simple C data types

Parameters
[in]_ctxto allocate the pair in
[out]_vpthe allocated pair
[in]_listto append the pair to
[in]_attrto use when creating pair
[in]_valto assign to the pair
[in]_tainteddoes the value come from a trusted source

Definition at line 285 of file pair.h.

◆ fr_pair_list_append_by_da_len

#define fr_pair_list_append_by_da_len (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _len,
  _tainted 
)
Value:
do { \
_vp = NULL; \
if (fr_pair_append_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
fr_value_box_len(_vp, &_vp->data, _val, _len, _tainted); \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
} while (0)
#define fr_value_box_len(_ctx, _box, _var, _len, _tainted)
Automagically fill in a box, for types with length.
Definition: value.h:885

Append a pair to a list, assigning its value.

Version for char* and uint8_t*

Parameters
[in]_ctxto allocate the pair in
[out]_vpthe allocated pair
[in]_listto append the pair to
[in]_attrto use when creating pair
[in]_valto assign to the pair
[in]_lenof value
[in]_tainteddoes the value come from a trusted source

Definition at line 308 of file pair.h.

◆ fr_pair_list_append_by_da_parent

#define fr_pair_list_append_by_da_parent (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _tainted 
)
Value:
do { \
_vp = NULL; \
if (fr_pair_append_by_da_parent(_ctx, &_vp, _list, _attr) < 0) break; \
fr_value_box(&_vp->data, _val, _tainted); \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
} while (0)
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.
Definition: pair.c:1518

Definition at line 319 of file pair.h.

◆ fr_pair_list_append_by_da_parent_len

#define fr_pair_list_append_by_da_parent_len (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _len,
  _tainted 
)
Value:
do { \
_vp = NULL; \
if (fr_pair_append_by_da_parent(_ctx, &vp, _list, _attr) < 0) break; \
fr_value_box_len(_vp, &_vp->data, _val, _len, _tainted); \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
} while (0)
static fr_slen_t vp
Definition: pair.h:832

Definition at line 330 of file pair.h.

◆ fr_pair_list_foreach

#define fr_pair_list_foreach (   _list_head,
  _iter 
)     for (fr_pair_t *JOIN(_next,_iter), *_iter = fr_pair_list_head(_list_head); JOIN(_next,_iter) = fr_pair_list_next(_list_head, _iter), _iter != NULL; _iter = JOIN(_next,_iter))

Iterate over the contents of a fr_pair_list_t.

The iteration variable can be safely removed from the list at each pass.

Parameters
[in]_list_headto iterate over.
[in]_iterName of iteration variable. Will be declared in the scope of the loop.

Definition at line 260 of file pair.h.

◆ fr_pair_list_foreach_leaf

#define fr_pair_list_foreach_leaf (   _list_head,
  _iter 
)     for (fr_pair_t *_iter = fr_pair_list_iter_leaf(_list_head, NULL); _iter != NULL; _iter = fr_pair_list_iter_leaf(_list_head, _iter))

Iterate over the leaf nodes of a fr_pair_list_t.

The iteration variable CANNOT be modified. This is a read-only operation.

Parameters
[in]_list_headto iterate over.
[in]_iterName of iteration variable. Will be declared in the scope of the loop.

Definition at line 271 of file pair.h.

◆ fr_pair_list_log

#define fr_pair_list_log (   _log,
  _lvl,
  _list 
)    _fr_pair_list_log(_log, _lvl, NULL, _list, __FILE__, __LINE__)

Definition at line 850 of file pair.h.

◆ fr_pair_list_prepend_by_da

#define fr_pair_list_prepend_by_da (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _tainted 
)
Value:
do { \
_vp = NULL; \
if (fr_pair_prepend_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
fr_value_box(&_vp->data, _val, _tainted); \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
} while (0)
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)
Definition: pair.c:1488

Prepend a pair to a list, assigning its value.

Version for simple C data types

Parameters
[in]_ctxto allocate the pair in
[out]_vpthe allocated pair
[in]_listto prepend the pair to
[in]_attrto use when creating pair
[in]_valto assign to the pair
[in]_tainteddoes the value come from a trusted source

Definition at line 352 of file pair.h.

◆ fr_pair_list_prepend_by_da_len

#define fr_pair_list_prepend_by_da_len (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _len,
  _tainted 
)
Value:
do { \
_vp = NULL; \
if (fr_pair_prepend_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
fr_value_box_len(_vp, &_vp->data, _val, _len, _tainted); \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
} while (0)

Prepend a pair to a list, assigning its value.

Version for char* and uint8_t*

Parameters
[in]_ctxto allocate the pair in
[out]_vpthe allocated pair
[in]_listto prepend the pair to
[in]_attrto use when creating pair
[in]_valto assign to the pair
[in]_lenof value
[in]_tainteddoes the value come from a trusted source

Definition at line 375 of file pair.h.

◆ fr_pair_list_replace_by_da

#define fr_pair_list_replace_by_da (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _tainted 
)
Value:
do { \
fr_pair_update_by_da(_ctx, _vp, _list, _attr, 0); \
if (!vp) break; \
fr_value_box(&_vp->data, _val, _tainted); \
if (!vp_da_data_type_check(_vp)) { \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
} while (0)

Replace a pair in a list, assigning its value.

Version for simple C data types. If the pair does not already exist, a new one is allocated.

Parameters
[in]_ctxto allocate the pair in
[out]_vpthe allocated pair
[in]_listto append the pair to
[in]_attrto use when creating pair
[in]_valto assign to the pair
[in]_tainteddoes the value come from a trusted source

Definition at line 398 of file pair.h.

◆ fr_pair_list_replace_by_da_len

#define fr_pair_list_replace_by_da_len (   _ctx,
  _vp,
  _list,
  _attr,
  _val,
  _len,
  _tainted 
)
Value:
do { \
fr_pair_t *oldvp = fr_pair_find_by_da(_list, NULL, _attr); \
fr_pair_list_append_by_da_len(_ctx, _vp_, _list, _attr, _val, _len, _tainted) \
if (!vp_da_data_type_check(_vp)) { \
fr_pair_delete(_list, _vp); \
_vp = NULL; \
} \
if (!_vp) break; \
if (oldvp) fr_pair_delete(_list, oldvp); \
} while (0)
fr_pair_t * fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list and free.
Definition: pair.c:1819
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.
Definition: pair.c:688

Replace a pair in a list, assigning its value.

Version for char* and uint8_t* If the pair does not already exist, a new one is allocated.

Parameters
[in]_ctxto allocate the pair in
[out]_vpthe allocated pair
[in]_listto append the pair to
[in]_attrto use when creating pair
[in]_valto assign to the pair
[in]_lenof value
[in]_tainteddoes the value come from a trusted source

Definition at line 422 of file pair.h.

◆ PAIR_LIST_VERIFY

#define PAIR_LIST_VERIFY (   _x)    fr_pair_list_nonnull_assert(_x)

Definition at line 193 of file pair.h.

◆ PAIR_VERIFY

#define PAIR_VERIFY (   _x)    fr_pair_nonnull_assert(_x)

Definition at line 190 of file pair.h.

◆ PAIR_VERIFY_WITH_LIST

#define PAIR_VERIFY_WITH_LIST (   _l,
  _x 
)
Value:
fr_pair_nonnull_assert(_x)
static bool fr_pair_list_nonnull_assert(fr_pair_list_t const *pair_list)
Definition: pair.h:179

Definition at line 191 of file pair.h.

◆ vp_bool

#define vp_bool   data.datum.boolean

Definition at line 120 of file pair.h.

◆ vp_date

#define vp_date   data.vb_date

Definition at line 134 of file pair.h.

◆ vp_ether

#define vp_ether   data.vb_ether

Definition at line 118 of file pair.h.

◆ vp_filter

#define vp_filter   data.datum.filter

Definition at line 140 of file pair.h.

◆ vp_float32

#define vp_float32   data.vb_float32

Definition at line 131 of file pair.h.

◆ vp_float64

#define vp_float64   data.vb_float64

Definition at line 132 of file pair.h.

◆ vp_group

#define vp_group   children

Definition at line 137 of file pair.h.

◆ vp_ifid

#define vp_ifid   data.vb_ifid

Definition at line 117 of file pair.h.

◆ vp_immutable

#define vp_immutable   data.immutable

Definition at line 144 of file pair.h.

◆ vp_int16

#define vp_int16   data.vb_int16

Definition at line 127 of file pair.h.

◆ vp_int32

#define vp_int32   data.vb_int32

Definition at line 128 of file pair.h.

◆ vp_int64

#define vp_int64   data.vb_int64

Definition at line 129 of file pair.h.

◆ vp_int8

#define vp_int8   data.vb_int8

Definition at line 126 of file pair.h.

◆ vp_ip

#define vp_ip   data.vb_ip

Definition at line 116 of file pair.h.

◆ vp_ipv4addr

#define vp_ipv4addr   data.vb_ip.addr.v4.s_addr

Definition at line 114 of file pair.h.

◆ vp_ipv6addr

#define vp_ipv6addr   data.vb_ip.addr.v6.s6_addr

Definition at line 115 of file pair.h.

◆ vp_length

#define vp_length   data.vb_length

Definition at line 112 of file pair.h.

◆ vp_octets

#define vp_octets   data.vb_octets

Definition at line 110 of file pair.h.

◆ vp_ptr

#define vp_ptr   data.datum.ptr

Either octets or strvalue.

Definition at line 111 of file pair.h.

◆ vp_raw

#define vp_raw   da->flags.is_raw

Definition at line 145 of file pair.h.

◆ vp_size

#define vp_size   data.datum.size

Definition at line 139 of file pair.h.

◆ vp_strvalue

#define vp_strvalue   data.vb_strvalue

Definition at line 109 of file pair.h.

◆ vp_tainted

#define vp_tainted   data.tainted

Definition at line 143 of file pair.h.

◆ vp_time_delta

#define vp_time_delta   data.vb_time_delta

Definition at line 135 of file pair.h.

◆ vp_type

#define vp_type   data.type

Definition at line 142 of file pair.h.

◆ vp_uint16

#define vp_uint16   data.vb_uint16

Definition at line 122 of file pair.h.

◆ vp_uint32

#define vp_uint32   data.vb_uint32

Definition at line 123 of file pair.h.

◆ vp_uint64

#define vp_uint64   data.vb_uint64

Definition at line 124 of file pair.h.

◆ vp_uint8

#define vp_uint8   data.vb_uint8

Definition at line 121 of file pair.h.

Typedef Documentation

◆ fr_pair_list_t

typedef struct pair_list_s fr_pair_list_t

◆ fr_pair_t

typedef struct value_pair_s fr_pair_t

Definition at line 1 of file pair.h.

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_list_log()

void _fr_pair_list_log ( fr_log_t const *  log,
int  lvl,
fr_pair_t parent,
fr_pair_list_t const *  list,
char const *  file,
int  line 
)

Print a list of attributes and enumv.

Parameters
[in]logto output to.
[in]lvldepth in structural attribute.
[in]parentparent attribute
[in]listto print.
[in]filewhere the message originated
[in]linewhere the message originated

Definition at line 283 of file pair_print.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_aprint()

static fr_slen_t fr_pair_aprint ( TALLOC_CTX *  ctx,
char **  out,
fr_dict_attr_t const *  parent,
fr_pair_t const *  vp 
)
inlinestatic
+ Here is the caller graph for this function:

◆ fr_pair_aprint_secure()

static fr_slen_t static vp fr_slen_t fr_pair_aprint_secure ( TALLOC_CTX *  ctx,
char **  out,
fr_dict_attr_t const *  parent,
fr_pair_t const *  vp 
)
inlinestatic
+ Here is the caller graph for this function:

◆ fr_pair_aprint_value_quoted()

static fr_slen_t fr_pair_aprint_value_quoted ( TALLOC_CTX *  ctx,
char **  out,
fr_pair_t const *  vp,
fr_token_t  quote 
)
inlinestatic
+ 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_ctx_afrom_str()

ssize_t fr_pair_ctx_afrom_str ( fr_pair_ctx_t pair_ctx,
char const *  in,
size_t  inlen 
)

Parse a pair context from a string.

Parameters
pair_ctxthe parsing context
inString to parse
inlenlength of string to parse
Returns
  • <= 0 on error (offset as negative integer)
  • > 0 on success (number of bytes parsed).

This function will parse fr_pair_ts, or context changes, up to end of string, or a trailing ','. The caller is responsible for parsing the comma.

It accepts the following syntax:

  • Attribute = value
    • reset to a new top-level context according to the parent of Attribute
    • parse the attribute and the value
  • .Attribute = value
    • parse the attribute and the value in the CURRENT top-level context
  • .Attribute
    • reset to a new context according to Attribute, relative to the current context
  • ..Attribute
    • reset to a new context according to Attribute, relative to the current context
    • more '.' will walk back up the context tree.
  • Attribute
    • reset to a new top-level context according to Attribute

Definition at line 375 of file pair_tokenize.c.

+ Here is the call graph for this function:

◆ fr_pair_ctx_reset()

void fr_pair_ctx_reset ( fr_pair_ctx_t pair_ctx,
fr_dict_t const *  dict 
)

Reset a pair_ctx to the dictionary root.

Parameters
pair_ctxthe parsing context
dictthe dictionary to reset to the root

This function is used in order to reset contexts when parsing strings that change attribute lists. i.e. &request.foo, &reply.bar

This function is simple for now, but will get complex once we start using vp->vp_children

Definition at line 495 of file pair_tokenize.c.

+ Here is the call graph for this function:

◆ fr_pair_dcursor_child_iter_init()

static fr_pair_t* fr_pair_dcursor_child_iter_init ( fr_dcursor_t cursor,
fr_pair_list_t const *  list,
fr_dcursor_t const *  parent 
)
inlinestatic

Initializes a child dcursor from a parent cursor, with an iteration function.

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]parentparent cursor to take the iterator from
Returns
  • NULL if src does not point to any items.
  • The first pair in the list.

Definition at line 610 of file pair.h.

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

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_debug()

void fr_pair_debug ( fr_pair_t const *  pair)

Dumps a pair to the default logging destination - Useful for calling from debuggers.

Definition at line 305 of file pair_print.c.

+ Here is the call 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_find_or_append_by_da()

static int fr_pair_find_or_append_by_da ( TALLOC_CTX *  ctx,
fr_pair_t **  out,
fr_pair_list_t list,
fr_dict_attr_t const *  da 
)
inlinestatic

Definition at line 522 of file pair.h.

+ 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_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_append()

void fr_pair_list_append ( fr_pair_list_t dst,
fr_pair_list_t src 
)

Appends a list of fr_pair_t from a temporary list to a destination list.

Parameters
dstlist to move pairs into
srclist from which to take pairs

Definition at line 182 of file pair_inline.c.

+ Here is the caller 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_debug()

void fr_pair_list_debug ( fr_pair_list_t const *  list)

Dumps a list to the default logging destination - Useful for calling from debuggers.

Definition at line 296 of file pair_print.c.

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

◆ fr_pair_list_empty()

bool fr_pair_list_empty ( fr_pair_list_t const *  list)

Is a valuepair list empty.

Parameters
[in]listto check
Returns
true if empty

Definition at line 125 of file pair_inline.c.

◆ fr_pair_list_free()

void fr_pair_list_free ( fr_pair_list_t list)

Free memory used by a valuepair list.

Definition at line 113 of file pair_inline.c.

◆ fr_pair_list_from_dlist()

fr_pair_list_t* fr_pair_list_from_dlist ( fr_dlist_head_t const *  list)

Get the pair list head from a dlist.

Parameters
[in]listThe order list from a pair list.
Returns
The pair list head.

Definition at line 172 of file pair_inline.c.

◆ fr_pair_list_head()

fr_pair_t* fr_pair_list_head ( fr_pair_list_t const *  list)

Get the head of a valuepair list.

Parameters
[in]listto return the head of
Returns
  • NULL if the list is empty
  • pointer to the first item in the list.

Definition at line 43 of file pair_inline.c.

◆ 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_next()

fr_pair_t* fr_pair_list_next ( fr_pair_list_t const *  list,
fr_pair_t const *  item 
)

Get the next item in a valuepair list after a specific entry.

Parameters
[in]listto walk
[in]itemwhose "next" item to return
Returns
  • NULL if the end of the list has been reached
  • pointer to the next item

Definition at line 70 of file pair_inline.c.

+ Here is the call graph for this function:

◆ fr_pair_list_nonnull_assert()

static bool fr_pair_list_nonnull_assert ( fr_pair_list_t const *  pair_list)
inlinestatic

Definition at line 179 of file pair.h.

◆ fr_pair_list_num_elements()

size_t fr_pair_list_num_elements ( fr_pair_list_t const *  list)

Get the length of a list of fr_pair_t.

Parameters
[in]listto return the length of
Returns
number of entries in the list

Definition at line 151 of file pair_inline.c.

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

+ Here is the caller graph for this function:

◆ fr_pair_list_prepend()

void fr_pair_list_prepend ( fr_pair_list_t dst,
fr_pair_list_t src 
)

Move a list of fr_pair_t from a temporary list to the head of a destination list.

Parameters
dstlist to move pairs into
srcfrom which to take pairs

Definition at line 195 of file pair_inline.c.

+ Here is the caller graph for this function:

◆ fr_pair_list_prev()

fr_pair_t* fr_pair_list_prev ( fr_pair_list_t const *  list,
fr_pair_t const *  item 
)

Get the previous item in a valuepair list before a specific entry.

Parameters
[in]listto walk
[in]itemwhose "prev" item to return
Returns
  • NULL if the head of the list has been reached
  • pointer to the previous item

Definition at line 83 of file pair_inline.c.

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

◆ fr_pair_list_print()

ssize_t fr_pair_list_print ( fr_sbuff_t out,
fr_dict_attr_t const *  parent,
fr_pair_list_t const *  list 
)

Print a pair list.

Parameters
[in]outWhere to write the string.
[in]parentparent da to start from
[in]listpair list
Returns
  • Length of data written to out.
  • value >= outlen on truncation.

Definition at line 211 of file pair_print.c.

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

◆ fr_pair_list_sort()

void fr_pair_list_sort ( fr_pair_list_t list,
fr_cmp_t  cmp 
)

Sort a doubly linked list of fr_pair_ts using merge sort.

Note
We use a merge sort (which is a stable sort), making this suitable for use on lists with things like EAP-Message fragments where the order of EAP-Message attributes needs to be maintained.
Parameters
[in,out]listhead of dlinked fr_pair_ts to sort.
[in]cmpto sort with

Definition at line 140 of file pair_inline.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_tail()

fr_pair_t* fr_pair_list_tail ( fr_pair_list_t const *  list)

Get the tail of a valuepair list.

Parameters
[in]listto return the tail of
Returns
  • NULL if the list is empty
  • pointer to the last item in the list.

Definition at line 56 of file pair_inline.c.

+ Here is the caller graph for this function:

◆ fr_pair_list_tainted()

void fr_pair_list_tainted ( fr_pair_list_t vps)

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_list_to_dlist()

fr_dlist_head_t* fr_pair_list_to_dlist ( fr_pair_list_t const *  list)

Get the dlist head from a pair list.

Parameters
[in]listto get the head from
Returns
the pointer to the dlist within the pair list.

Definition at line 162 of file pair_inline.c.

+ 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_nonnull_assert()

static bool fr_pair_nonnull_assert ( fr_pair_t const *  vp)
inlinestatic

If WITH_VERIFY_PTR is defined, we perform runtime checks to ensure the fr_pair_t are sane.

Wrapper function to defeat nonnull checks

We may sprinkle PAIR_VERIFY and PAIR_LIST_VERIFY in functions which have their pair argument marked up as nonnull.

This would usually generate errors when WITH_VERIFY_PTR is not defined, as the assert macros check for an arguments NULLness.

This function wraps the assert but has nonnull-compare disabled meaning a warning won't be emitted.

Definition at line 174 of file pair.h.

◆ 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_print()

static fr_slen_t quote ssize_t fr_pair_print ( fr_sbuff_t out,
fr_dict_attr_t const *  parent,
fr_pair_t const *  vp 
)

Print one attribute and value to a string.

Print a fr_pair_t in the format:

        <attribute_name> <op> <value>

to a string.

Parameters
[in]outWhere to write the string.
[in]parentIf not NULL, only print OID components from this parent to the VP.
[in]vpto print.
Returns
  • Length of data written to out.
  • value >= outlen on truncation.

Definition at line 89 of file pair_print.c.

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

◆ fr_pair_print_secure()

ssize_t fr_pair_print_secure ( fr_sbuff_t out,
fr_dict_attr_t const *  parent,
fr_pair_t const *  vp 
)

Print one attribute and value to a string with escape rules.

Similar to fr_pair_print(), but secrets are omitted. This function duplicates parts of the functionality of fr_pair_print(). fr_pair_print_value_quoted(), and fr_value_box_print_quoted(), but for the special case of secure strings.

Note that only secrets of type "string" and "octets" are omitted. Other "secret" data types are still printed as-is.

"octets" are still printed as "<<< secret >>>". Which won't parse correctly, but that's fine. Because omitted data is not meant to be parsed into real data.

Parameters
[in]outWhere to write the string.
[in]parentIf not NULL, only print OID components from this parent to the VP.
[in]vpto print.
Returns
  • < 0 on error
  • Length of data written to out.
  • value >= outlen on truncation.

Definition at line 139 of file pair_print.c.

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

◆ fr_pair_print_value_quoted()

ssize_t fr_pair_print_value_quoted ( fr_sbuff_t out,
fr_pair_t const *  vp,
fr_token_t  quote 
)

Print the value of an attribute to a string.

Parameters
[in]outWhere to write the string.
[in]vpto print.
[in]quoteChar to add before and after printed value, if 0 no char will be added, if < 0 raw string will be added.
Returns
  • >= 0 length of data written to out.
  • <0 the number of bytes we would have needed to write the complete string to out.

Definition at line 40 of file pair_print.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_remove()

fr_pair_t* fr_pair_remove ( fr_pair_list_t list,
fr_pair_t vp 
)

Remove fr_pair_t from a list without freeing.

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 94 of file pair_inline.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_set_immutable()

static void fr_pair_set_immutable ( fr_pair_t vp)
inlinestatic

Definition at line 687 of file pair.h.

+ 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[static 20] 
)

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

◆ vp_da_data_type_check()

static bool vp_da_data_type_check ( fr_pair_t vp)
inlinestatic

Check a pair's data type matches the DA data type.

Parameters
[in]vpto check consistency of.
Returns
  • true for match
  • false for error

Definition at line 241 of file pair.h.

Variable Documentation

◆ parent

static fr_slen_t static vp fr_slen_t parent

Definition at line 844 of file pair.h.

◆ vp

Definition at line 832 of file pair.h.