The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
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>
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.__unnamed132__ |
struct | value_pair_s.__unnamed132__.__unnamed136__ |
struct | value_pair_s.__unnamed134__ |
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_edit data.edit |
#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_t * | fr_pair_afrom_child_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr) |
Create a new valuepair. More... | |
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. More... | |
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. More... | |
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. More... | |
fr_pair_t * | fr_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_t * | fr_pair_children (fr_pair_t *head) |
Get the child list of a group. More... | |
static void | fr_pair_clear_immutable (fr_pair_t *vp) |
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_t * | fr_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_t * | fr_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_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. More... | |
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. More... | |
int | fr_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_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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. 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_t * | fr_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_t * | fr_pair_list_from_dlist (fr_dlist_head_t const *list) |
Get the pair list head from a dlist. More... | |
fr_pair_t * | fr_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_t * | fr_pair_list_iter_leaf (fr_pair_list_t *list, fr_pair_t *vp) |
Iterates over the leaves of a list. More... | |
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. 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_t * | fr_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_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. 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_t * | fr_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_t * | fr_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_t * | fr_pair_parent (fr_pair_t const *vp) |
Return a pointer to the parent pair. More... | |
fr_pair_list_t * | fr_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_t * | fr_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_t * | fr_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... | |
AVP manipulation and search API.
Definition in file pair.h.
struct 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 |
union value_pair_s.__unnamed132__ |
Data Fields | ||
---|---|---|
__unnamed132__ | __unnamed__ | |
fr_value_box_t | data | The value of this pair. |
struct value_pair_s.__unnamed132__.__unnamed136__ |
Data Fields | ||
---|---|---|
fr_pair_list_t | children | Nested attributes of this pair. |
uint8_t | pad[offsetof(fr_value_box_t, safe_for)] |
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. |
struct value_pair_s.__unnamed134__ |
Data Fields | ||
---|---|---|
fr_token_t | op | Operator to use when moving or inserting. |
#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) |
#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.
[in] | _cursor | to initialise. |
[in] | _list | to iterate over. |
[in] | _da | who's decentness to search for. |
#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.
[in] | _cursor | to initialise. |
[in] | _list | to iterate over. |
[in] | _da | to search for. |
#define fr_pair_dcursor_init | ( | _cursor, | |
_list | |||
) |
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
Filters can be applied later with fr_dcursor_filter_set.
[out] | _cursor | to initialise. |
[in] | _list | to iterate over. |
#define fr_pair_dcursor_iter_init | ( | _cursor, | |
_list, | |||
_iter, | |||
_uctx | |||
) |
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
Filters can be applied later with fr_dcursor_filter_set.
[out] | _cursor | to initialise. |
[in] | _list | to iterate over. |
[in] | _iter | Iterator to use when filtering pairs. |
[in] | _uctx | To pass to iterator. |
#define fr_pair_list_append_by_da | ( | _ctx, | |
_vp, | |||
_list, | |||
_attr, | |||
_val, | |||
_tainted | |||
) |
Append a pair to a list, assigning its value.
Version for simple C data types
[in] | _ctx | to allocate the pair in |
[out] | _vp | the allocated pair |
[in] | _list | to append the pair to |
[in] | _attr | to use when creating pair |
[in] | _val | to assign to the pair |
[in] | _tainted | does the value come from a trusted source |
#define fr_pair_list_append_by_da_len | ( | _ctx, | |
_vp, | |||
_list, | |||
_attr, | |||
_val, | |||
_len, | |||
_tainted | |||
) |
Append a pair to a list, assigning its value.
Version for char* and uint8_t*
[in] | _ctx | to allocate the pair in |
[out] | _vp | the allocated pair |
[in] | _list | to append the pair to |
[in] | _attr | to use when creating pair |
[in] | _val | to assign to the pair |
[in] | _len | of value |
[in] | _tainted | does the value come from a trusted source |
#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.
The iteration variable can be safely removed from the list at each pass.
[in] | _list_head | to iterate over. |
[in] | _iter | Name of iteration variable. Will be declared in the scope of the loop. |
#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.
[in] | _list_head | to iterate over. |
[in] | _iter | Name of iteration variable. Will be declared in the scope of the loop. |
#define fr_pair_list_log | ( | _log, | |
_lvl, | |||
_list | |||
) | _fr_pair_list_log(_log, _lvl, NULL, _list, __FILE__, __LINE__) |
#define fr_pair_list_prepend_by_da | ( | _ctx, | |
_vp, | |||
_list, | |||
_attr, | |||
_val, | |||
_tainted | |||
) |
Prepend a pair to a list, assigning its value.
Version for simple C data types
[in] | _ctx | to allocate the pair in |
[out] | _vp | the allocated pair |
[in] | _list | to prepend the pair to |
[in] | _attr | to use when creating pair |
[in] | _val | to assign to the pair |
[in] | _tainted | does the value come from a trusted source |
#define fr_pair_list_prepend_by_da_len | ( | _ctx, | |
_vp, | |||
_list, | |||
_attr, | |||
_val, | |||
_len, | |||
_tainted | |||
) |
Prepend a pair to a list, assigning its value.
Version for char* and uint8_t*
[in] | _ctx | to allocate the pair in |
[out] | _vp | the allocated pair |
[in] | _list | to prepend the pair to |
[in] | _attr | to use when creating pair |
[in] | _val | to assign to the pair |
[in] | _len | of value |
[in] | _tainted | does the value come from a trusted source |
#define fr_pair_list_replace_by_da | ( | _ctx, | |
_vp, | |||
_list, | |||
_attr, | |||
_val, | |||
_tainted | |||
) |
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.
[in] | _ctx | to allocate the pair in |
[out] | _vp | the allocated pair |
[in] | _list | to append the pair to |
[in] | _attr | to use when creating pair |
[in] | _val | to assign to the pair |
[in] | _tainted | does the value come from a trusted source |
#define fr_pair_list_replace_by_da_len | ( | _ctx, | |
_vp, | |||
_list, | |||
_attr, | |||
_val, | |||
_len, | |||
_tainted | |||
) |
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.
[in] | _ctx | to allocate the pair in |
[out] | _vp | the allocated pair |
[in] | _list | to append the pair to |
[in] | _attr | to use when creating pair |
[in] | _val | to assign to the pair |
[in] | _len | of value |
[in] | _tainted | does the value come from a trusted source |
#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_date data.vb_date |
#define vp_ether data.vb_ether |
#define vp_float32 data.vb_float32 |
#define vp_float64 data.vb_float64 |
#define vp_ifid data.vb_ifid |
#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_length data.vb_length |
#define vp_octets data.vb_octets |
#define vp_strvalue data.vb_strvalue |
#define vp_time_delta data.vb_time_delta |
#define vp_uint16 data.vb_uint16 |
#define vp_uint32 data.vb_uint32 |
#define vp_uint64 data.vb_uint64 |
#define vp_uint8 data.vb_uint8 |
typedef struct pair_list_s fr_pair_list_t |
typedef struct value_pair_s fr_pair_t |
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.
[in] | cursor | to initialise. |
[in] | list | to iterate over. |
[in] | da | who's decentness to search for. |
[in] | is_const | whether the fr_pair_list_t is const. |
Definition at line 1162 of file pair.c.
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.
[in] | cursor | to initialise. |
[in] | list | to iterate over. |
[in] | da | to search for. |
[in] | is_const | whether the fr_pair_list_t is const. |
Definition at line 1143 of file pair.c.
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.
[out] | cursor | to initialise. |
[in] | list | to iterate over. |
[in] | is_const | whether the fr_pair_list_t is const. |
Definition at line 1125 of file pair.c.
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.
[out] | cursor | to initialise. |
[in] | list | to iterate over. |
[in] | iter | Iterator to use when filtering pairs. |
[in] | uctx | To pass to iterator. |
[in] | is_const | whether the fr_pair_list_t is const. |
Definition at line 1103 of file pair.c.
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.
[in] | log | to output to. |
[in] | lvl | depth in structural attribute. |
[in] | parent | parent attribute |
[in] | list | to print. |
[in] | file | where the message originated |
[in] | line | where the message originated |
Definition at line 305 of file pair_print.c.
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_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
.
[in] | ctx | for allocated memory, usually a pointer to a fr_packet_t. |
[in] | parent | of the attribute being allocated (usually a dictionary or vendor). |
[in] | attr | number. |
Definition at line 371 of file pair.c.
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.
[in] | ctx | for allocated memory, usually a pointer to a fr_packet_t |
[in] | da | Specifies the dictionary attribute to build the fr_pair_t from. If unknown, will be duplicated, with the memory being bound to the pair. |
Definition at line 283 of file pair.c.
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.
[in] | ctx | for allocated memory, usually a pointer to a fr_packet_t. |
[out] | list | where the created pair is supposed to go. |
[in] | da | the da for the pair to create |
[in] | start | the starting depth. If start != 0, we must have ctx==vp at that depth, and list==&vp->vp_group |
Definition at line 408 of file pair.c.
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.
[in] | ctx | for allocated memory, usually a pointer to a fr_packet_t. |
[out] | list | where the created pair is supposed to go. |
[in] | da | the da for the pair to create |
Definition at line 467 of file pair.c.
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.
[in] | ctx | to allocate the pair list in. |
Definition at line 167 of file pair.c.
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.
[in] | list | VP in linked list. Will add new VP to this list. |
[in] | to_add | VP to add to list. |
Definition at line 1345 of file pair.c.
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)
[in] | ctx | to allocate new fr_pair_t in. |
[out] | out | Pair we allocated. May be NULL if the caller doesn't care about manipulating the fr_pair_t. |
[in,out] | list | in search and insert into. |
[in] | da | of attribute to update. |
Definition at line 1466 of file pair.c.
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.
[in] | ctx | to allocate new fr_pair_t in |
[out] | out | Pair we allocated. May be NULL if the caller doesn't care about manipulating the fr_pair_t. |
[in] | list | in which to insert the pair. |
[in] | da | of the attribute to create. |
Definition at line 1523 of file pair.c.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
fr_pair_list_t* fr_pair_children | ( | fr_pair_t * | vp | ) |
|
inlinestatic |
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"
[in] | a | the head attribute |
[in] | b | the second attribute |
Definition at line 1969 of file pair.c.
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.
[in] | a | first dict_attr_t. |
[in] | b | second dict_attr_t. |
Definition at line 1844 of file pair.c.
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.
[in] | a | first dict_attr_t. |
[in] | b | second dict_attr_t. |
Definition at line 1921 of file pair.c.
unsigned int fr_pair_count_by_da | ( | fr_pair_list_t const * | list, |
fr_dict_attr_t const * | da | ||
) |
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.
pair_ctx | the parsing context |
in | String to parse |
inlen | length of string to parse |
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:
Definition at line 375 of file pair_tokenize.c.
void fr_pair_ctx_reset | ( | fr_pair_ctx_t * | pair_ctx, |
fr_dict_t const * | dict | ||
) |
Reset a pair_ctx to the dictionary root.
pair_ctx | the parsing context |
dict | the 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.
|
inlinestatic |
Initializes a child dcursor from a parent cursor, with an iteration function.
Filters can be applied later with fr_dcursor_filter_set.
[out] | cursor | to initialise. |
[in] | list | to iterate over. |
[in] | parent | parent cursor to take the iterator from |
Definition at line 611 of file pair.h.
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.
[out] | cursor | to initialise. |
[in] | parent | to iterate over |
Definition at line 1298 of file pair.c.
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.
[out] | cursor | to initialise. |
Definition at line 1248 of file pair.c.
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 327 of file pair_print.c.
int fr_pair_delete | ( | fr_pair_list_t * | list, |
fr_pair_t * | vp | ||
) |
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.
[in] | list | to delete attributes from. |
[in] | parent | to match. |
[in] | attr | to match. |
Definition at line 1808 of file pair.c.
int fr_pair_delete_by_da | ( | fr_pair_list_t * | list, |
fr_dict_attr_t const * | da | ||
) |
Delete matching pairs from the specified list.
[in,out] | list | to search for attributes in or delete attributes from. |
[in] | da | to match. |
Definition at line 1689 of file pair.c.
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.
[in,out] | list | to search for attributes in or delete attributes from. |
[in] | da | to match. |
Definition at line 1713 of file pair.c.
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.
[in] | list | in which to search. |
[in] | prev | attribute to start search from. |
[in] | parent | attribute in which to lookup child. |
[in] | attr | id of child. |
Definition at line 867 of file pair.c.
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.
[in] | list | in which to search. |
[in] | parent | attribute in which to lookup child. |
[in] | attr | id of child. |
[in] | idx | Instance of the attribute to return. |
Definition at line 893 of file pair.c.
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 | ||
) |
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.
[in] | list | to search in. |
[in] | da | to look for in the list. |
[in] | idx | Instance of the attribute to return. |
Definition at line 741 of file pair.c.
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.
[in] | list | to search in. |
[in] | prev | pair to start searching from. |
[in] | da | the next da to find. |
Definition at line 770 of file pair.c.
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.
[in] | list | to search in. |
[in] | prev | the previous attribute in the list. |
[in] | da | the previous da to find. |
Definition at line 717 of file pair.c.
|
inlinestatic |
void fr_pair_init_null | ( | fr_pair_t * | vp | ) |
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.
[in] | list | VP in linked list. Will add new VP to this list. |
[in] | pos | to insert pair after. |
[in] | to_add | VP to add to list. |
Definition at line 1373 of file pair.c.
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.
[in] | list | VP in linked list. Will add new VP to this list. |
[in] | pos | to insert pair after. |
[in] | to_add | VP to add to list. |
Definition at line 1406 of file pair.c.
void fr_pair_list_afrom_box | ( | TALLOC_CTX * | ctx, |
fr_pair_list_t * | out, | ||
fr_dict_t const * | dict, | ||
fr_value_box_t * | box | ||
) |
fr_pair_list_t* fr_pair_list_alloc | ( | TALLOC_CTX * | ctx | ) |
Allocate a new pair list on the heap.
[in] | ctx | to allocate the pair list in. |
Definition at line 117 of file pair.c.
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.
dst | list to move pairs into |
src | list from which to take pairs |
Definition at line 182 of file pair_inline.c.
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.
Definition at line 2047 of file pair.c.
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.
[in] | ctx | for new fr_pair_t (s) to be allocated in. |
[in] | to | where to copy attributes to. |
[in] | from | whence to copy fr_pair_t (s). |
Definition at line 2319 of file pair.c.
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.
[in] | ctx | for new fr_pair_t (s) to be allocated in. |
[in] | to | where to copy attributes to. |
[in] | from | whence to copy fr_pair_t (s). |
[in] | parent_da | to match. |
Definition at line 2455 of file pair.c.
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.
[in] | ctx | for new fr_pair_t (s) to be allocated in. |
[in] | to | where to copy attributes to. |
[in] | from | whence to copy fr_pair_t (s). |
[in] | da | to match. |
[in] | count | How many instances to copy. Use 0 for all attributes. |
Definition at line 2406 of file pair.c.
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.
[in] | dst | where boxes will be created |
[in] | from | whence to copy fr_pair_t (s). |
Definition at line 2354 of file pair.c.
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 318 of file pair_print.c.
bool fr_pair_list_empty | ( | fr_pair_list_t const * | list | ) |
Is a valuepair list empty.
[in] | list | to check |
Definition at line 125 of file pair_inline.c.
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_t* fr_pair_list_from_dlist | ( | fr_dlist_head_t const * | list | ) |
Get the pair list head from a dlist.
[in] | list | The order list from a pair list. |
Definition at line 172 of file pair_inline.c.
fr_pair_t* fr_pair_list_head | ( | fr_pair_list_t const * | list | ) |
Get the head of a valuepair list.
[in] | list | to return the head of |
Definition at line 43 of file pair_inline.c.
void fr_pair_list_init | ( | fr_pair_list_t * | list | ) |
fr_pair_t* fr_pair_list_iter_leaf | ( | fr_pair_list_t * | list, |
fr_pair_t * | vp | ||
) |
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.
[in] | list | to walk |
[in] | item | whose "next" item to return |
Definition at line 70 of file pair_inline.c.
|
inlinestatic |
size_t fr_pair_list_num_elements | ( | fr_pair_list_t const * | list | ) |
Get the length of a list of fr_pair_t.
[in] | list | to return the length of |
Definition at line 151 of file pair_inline.c.
fr_pair_t* fr_pair_list_parent | ( | fr_pair_list_t const * | list | ) |
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.
dst | list to move pairs into |
src | from which to take pairs |
Definition at line 195 of file pair_inline.c.
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.
[in] | list | to walk |
[in] | item | whose "prev" item to return |
Definition at line 83 of file pair_inline.c.
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.
[in] | out | Where to write the string. |
[in] | parent | parent da to start from |
[in] | list | pair list |
Definition at line 233 of file pair_print.c.
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.
[in,out] | list | head of dlinked fr_pair_ts to sort. |
[in] | cmp | to sort with |
Definition at line 140 of file pair_inline.c.
void fr_pair_list_steal | ( | TALLOC_CTX * | ctx, |
fr_pair_list_t * | list | ||
) |
fr_pair_t* fr_pair_list_tail | ( | fr_pair_list_t const * | list | ) |
Get the tail of a valuepair list.
[in] | list | to return the tail of |
Definition at line 56 of file pair_inline.c.
void fr_pair_list_tainted | ( | fr_pair_list_t * | vps | ) |
fr_dlist_head_t* fr_pair_list_to_dlist | ( | fr_pair_list_t const * | list | ) |
Get the dlist head from a pair list.
[in] | list | to get the head from |
Definition at line 162 of file pair_inline.c.
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()
item | pointer to a fr_pair_t |
uctx | da to match |
Definition at line 3476 of file pair.c.
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.
fr_pair_list_t* fr_pair_parent_list | ( | fr_pair_t const * | vp | ) |
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.
[in] | list | VP in linked list. Will add new VP to this list. |
[in] | to_add | VP to add to list. |
Definition at line 1314 of file pair.c.
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)
[in] | ctx | to allocate new fr_pair_t in. |
[out] | out | Pair we allocated. May be NULL if the caller doesn't care about manipulating the fr_pair_t. |
[in,out] | list | in search and insert into. |
[in] | da | of attribute to update. |
Definition at line 1493 of file pair.c.
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.
[in] | out | Where to write the string. |
[in] | parent | If not NULL, only print OID components from this parent to the VP. |
[in] | vp | to print. |
Definition at line 104 of file pair_print.c.
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.
[in] | out | Where to write the string. |
[in] | parent | If not NULL, only print OID components from this parent to the VP. |
[in] | vp | to print. |
Definition at line 166 of file pair_print.c.
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.
[in] | out | Where to write the string. |
[in] | vp | to print. |
[in] | quote | Char to add before and after printed value, if 0 no char will be added, if < 0 raw string will be added. |
Definition at line 40 of file pair_print.c.
int fr_pair_reinit_from_da | ( | fr_pair_list_t * | list, |
fr_pair_t * | vp, | ||
fr_dict_attr_t const * | da | ||
) |
fr_pair_t* fr_pair_remove | ( | fr_pair_list_t * | list, |
fr_pair_t * | vp | ||
) |
Remove fr_pair_t from a list without freeing.
[in] | list | of value pairs to remove VP from. |
[in] | vp | to remove |
Definition at line 94 of file pair_inline.c.
void fr_pair_replace | ( | fr_pair_list_t * | list, |
fr_pair_t * | to_replace, | ||
fr_pair_t * | vp | ||
) |
Replace a given VP.
[in,out] | list | pair list |
[in] | to_replace | pair to replace and free, on list |
[in] | vp | New pair to insert. |
Definition at line 1439 of file pair.c.
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.
[in] | ctx | to allocate the pair root in. |
[in] | da | The root attribute. |
Definition at line 243 of file pair.c.
|
inlinestatic |
int fr_pair_steal | ( | TALLOC_CTX * | ctx, |
fr_pair_t * | vp | ||
) |
int fr_pair_steal_append | ( | TALLOC_CTX * | list_ctx, |
fr_pair_list_t * | list, | ||
fr_pair_t * | vp | ||
) |
Change a vp's talloc ctx and insert it into a new list.
[in] | list_ctx | to move vp into. |
[out] | list | to add vp to. |
[in] | vp | to move. |
Definition at line 546 of file pair.c.
int fr_pair_steal_prepend | ( | TALLOC_CTX * | list_ctx, |
fr_pair_list_t * | list, | ||
fr_pair_t * | vp | ||
) |
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'.
[in] | ctx | for new fr_pair_t (s) to be allocated in. |
[in] | to | where to copy attributes to. |
[in] | from | whence to copy fr_pair_t (s). |
[in] | start | first pair to start copying from. |
[in] | count | How many instances to copy. Use 0 for all attributes. |
Definition at line 2508 of file pair.c.
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)
[in] | parent | If 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] | out | Pair we allocated or found. May be NULL if the caller doesn't care about manipulating the fr_pair_t. |
[in] | da | of attribute to locate or alloc. |
Definition at line 1596 of file pair.c.
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.
failed | pointer to an array to write the pointers of the filter/list attributes that didn't match. May be NULL. |
filter | attributes to check list against. |
list | attributes, probably a request or reply |
Definition at line 2128 of file pair.c.
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();
failed | pair of attributes which didn't match. |
Definition at line 2093 of file pair.c.
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.
failed | pointer to an array to write the pointers of the filter/list attributes that didn't match. May be NULL. |
filter | attributes to check list against. |
list | attributes, probably a request or reply |
Definition at line 2205 of file pair.c.
int fr_pair_value_aprintf | ( | fr_pair_t * | vp, |
char const * | fmt, | ||
... | |||
) |
Pre-allocate a memory buffer for a "string" type value pair.
[in,out] | vp | to update |
[out] | out | If non-null will be filled with a pointer to the new buffer. |
[in] | size | of the data. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2730 of file pair.c.
Append a talloced buffer to an existing "string" type value pair.
[in,out] | vp | to update. |
[in] | src | a talloced nul terminated buffer. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2903 of file pair.c.
Change the length of a buffer for a "string" type value pair.
[in,out] | vp | to update |
[out] | out | If non-null will be filled with a pointer to the new buffer. |
[in] | size | of the data. |
Definition at line 2755 of file pair.c.
Copy a nul terminated talloced buffer a "string" type value pair.
The buffer must be \0 terminated, or an error will be returned.
[in,out] | vp | to update. |
[in] | src | a talloced nul terminated buffer. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2810 of file pair.c.
Assign a string to a "string" type value pair.
[in] | vp | to assign new buffer to. |
[in] | src | a string. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2855 of file pair.c.
Append bytes from a buffer to an existing "string" type value pair.
[in,out] | vp | to update. |
[in] | src | data to copy. |
[in] | len | of data to copy. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2880 of file pair.c.
Copy data into a "string" type value pair.
[in,out] | vp | to update. |
[in] | src | data to copy. |
[in] | len | of data to copy. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2784 of file pair.c.
Assign a string to a "string" type value pair.
[in] | vp | to assign new buffer to. |
[in] | src | a string. |
[in] | len | of src. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2835 of file pair.c.
void fr_pair_value_clear | ( | fr_pair_t * | vp | ) |
Copy the value from one pair to another.
[out] | dst | where to copy the value to. will clear assigned value. |
[in] | src | where to copy the value from Must have an assigned value. |
Definition at line 2563 of file pair.c.
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.
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.
[out] | out | pointer to a value box. |
[in] | vp | to print. |
Definition at line 3158 of file pair.c.
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.
[in] | vp | to assign value to. |
[in] | value | string to convert. Binary safe for variable length values if len is provided. |
[in] | inlen | The length of the input string. |
[in] | uerules | used to perform unescaping. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2589 of file pair.c.
Pre-allocate a memory buffer for a "octets" type value pair.
[in,out] | vp | to update |
[out] | out | If non-null will be filled with a pointer to the new buffer. |
[in] | size | of the data. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2930 of file pair.c.
Append bytes from a buffer to an existing "octets" type value pair.
[in,out] | vp | to update. |
[in] | src | data to copy. |
[in] | len | of data to copy. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 3078 of file pair.c.
Append a talloced buffer to an existing "octets" type value pair.
[in,out] | vp | to update. |
[in] | src | data to copy. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 3101 of file pair.c.
Change the length of a buffer for a "octets" type value pair.
[in,out] | vp | to update |
[out] | out | If non-null will be filled with a pointer to the new buffer. |
[in] | size | of the data. |
Definition at line 2955 of file pair.c.
Copy data into an "octets" data type.
[in,out] | vp | to update |
[in] | src | data to copy |
[in] | len | of the data. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2981 of file pair.c.
Copy data from a talloced buffer into an "octets" data type.
[in,out] | vp | to update |
[in] | src | data to copy |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 3011 of file pair.c.
Assign a talloced buffer to a "octets" type value pair.
[in] | vp | to assign new buffer to. |
[in] | src | data to copy. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 3056 of file pair.c.
Assign a buffer to a "octets" type value pair.
[in] | vp | to assign new buffer to. |
[in] | src | data to copy. |
[in] | len | of src. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 3036 of file pair.c.
Copy data into an "string" data type.
[in,out] | vp | to update |
[in] | src | data to copy |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2634 of file pair.c.
Assign a buffer containing a nul terminated string to a vp, but don't copy it.
[in] | vp | to assign string to. |
[in] | src | to copy string from. |
[in] | tainted | Whether the value came from a trusted source. |
Definition at line 2658 of file pair.c.
int fr_pair_value_strtrim | ( | fr_pair_t * | vp | ) |