The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
AVP manipulation and search API. More...
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/pair.h>
#include <freeradius-devel/util/pair_legacy.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/regex.h>
#include <freeradius-devel/util/pair_inline.c>
Go to the source code of this file.
Macros | |
#define | _PAIR_INLINE 1 |
#define | _PAIR_PRIVATE 1 |
#define | IN_A_LIST_MSG "Pair %pV is already in a list, and cannot be moved" |
#define | NOT_IN_THIS_LIST_MSG "Pair %pV is not in the given list" |
Functions | |
fr_pair_t * | _fr_pair_dcursor_by_ancestor_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dict_attr_t const *da, bool is_const) |
Initialise a cursor that will return only attributes descended from the specified fr_dict_attr_t. | |
fr_pair_t * | _fr_pair_dcursor_by_da_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dict_attr_t const *da, bool is_const) |
Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t. | |
fr_pair_t * | _fr_pair_dcursor_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, bool is_const) |
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly. | |
fr_pair_t * | _fr_pair_dcursor_iter_init (fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dcursor_iter_t iter, void const *uctx, bool is_const) |
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly. | |
static int | _fr_pair_free (fr_pair_t *vp) |
Free a fr_pair_t. | |
static void * | _fr_pair_iter_next_dcursor_value (UNUSED fr_dlist_head_t *list, void *current, void *uctx) |
Iterate over pairs. | |
static void * | _fr_pair_iter_next_value (fr_dlist_head_t *list, void *current, UNUSED void *uctx) |
Iterate over pairs. | |
static int | _pair_list_dcursor_insert (fr_dlist_head_t *list, void *to_insert, UNUSED void *uctx) |
Keep attr tree and sublists synced on cursor insert. | |
static int | _pair_list_dcursor_remove (NDEBUG_UNUSED fr_dlist_head_t *list, void *to_remove, UNUSED void *uctx) |
Keep attr tree and sublists synced on cursor removal. | |
static void | fprintf_pair_list (FILE *fp, fr_pair_list_t const *list, int depth) |
void | fr_fprintf_pair (FILE *fp, char const *msg, fr_pair_t const *vp) |
void | fr_fprintf_pair_list (FILE *fp, fr_pair_list_t const *list) |
fr_pair_t * | fr_pair_afrom_child_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr) |
Create a new valuepair. | |
fr_pair_t * | fr_pair_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da) |
Dynamically allocate a new attribute and assign a fr_dict_attr_t. | |
fr_pair_t * | fr_pair_afrom_da_depth_nested (TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da, int start) |
Create a pair (and all intermediate parents), and append it to the list. | |
fr_pair_t * | fr_pair_afrom_da_nested (TALLOC_CTX *ctx, fr_pair_list_t *list, fr_dict_attr_t const *da) |
Create a pair (and all intermediate parents), and append it to the list. | |
fr_pair_t * | fr_pair_alloc_null (TALLOC_CTX *ctx) |
Dynamically allocate a new attribute with no fr_dict_attr_t assigned. | |
int | fr_pair_append (fr_pair_list_t *list, fr_pair_t *to_add) |
Add a VP to the end of the list. | |
int | fr_pair_append_by_da (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da) |
Alloc a new fr_pair_t (and append) | |
int | fr_pair_append_by_da_parent (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da) |
Alloc a new fr_pair_t, adding the parent attributes if required. | |
fr_pair_list_t * | fr_pair_children (fr_pair_t *vp) |
Get the child list of a group. | |
int | fr_pair_cmp (fr_pair_t const *a, fr_pair_t const *b) |
Compare two pairs, using the operator from "a". | |
int8_t | fr_pair_cmp_by_da (void const *a, void const *b) |
Order attributes by their da, and tag. | |
int8_t | fr_pair_cmp_by_parent_num (void const *a, void const *b) |
Order attributes by their parent(s), attribute number, and tag. | |
fr_pair_t * | fr_pair_copy (TALLOC_CTX *ctx, fr_pair_t const *vp) |
Copy a single valuepair. | |
unsigned int | fr_pair_count_by_da (fr_pair_list_t const *list, fr_dict_attr_t const *da) |
Return the number of instances of a given da in the specified list. | |
fr_value_box_t * | fr_pair_dcursor_nested_init (fr_dcursor_t *cursor, fr_dcursor_t *parent) |
Initialises a special dcursor over another cursor which returns fr_pair_t, but we return fr_value_box_t. | |
fr_value_box_t * | fr_pair_dcursor_value_init (fr_dcursor_t *cursor) |
Initialises a special dcursor over a fr_pair_list_t, but which returns fr_value_box_t. | |
int | fr_pair_delete (fr_pair_list_t *list, fr_pair_t *vp) |
Remove fr_pair_t from a list and free. | |
int | fr_pair_delete_by_child_num (fr_pair_list_t *list, fr_dict_attr_t const *parent, unsigned int attr) |
Delete matching pairs from the specified list. | |
int | fr_pair_delete_by_da (fr_pair_list_t *list, fr_dict_attr_t const *da) |
Delete matching pairs from the specified list. | |
int | fr_pair_delete_by_da_nested (fr_pair_list_t *list, fr_dict_attr_t const *da) |
Delete matching pairs from the specified list, and prune any empty branches. | |
fr_pair_t * | fr_pair_find_by_child_num (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. | |
fr_pair_t * | fr_pair_find_by_child_num_idx (fr_pair_list_t const *list, fr_dict_attr_t const *parent, unsigned int attr, unsigned int idx) |
Find the pair with the matching child attribute at a given index. | |
fr_pair_t * | fr_pair_find_by_da (fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da) |
Find the first pair with a matching da. | |
fr_pair_t * | fr_pair_find_by_da_idx (fr_pair_list_t const *list, fr_dict_attr_t const *da, unsigned int idx) |
Find a pair with a matching da at a given index. | |
fr_pair_t * | fr_pair_find_by_da_nested (fr_pair_list_t const *list, fr_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. | |
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. | |
bool | fr_pair_immutable (fr_pair_t const *vp) |
void | fr_pair_init_null (fr_pair_t *vp) |
Initialise fields in an fr_pair_t without assigning a da. | |
int | fr_pair_insert_after (fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_add) |
Add a VP after another VP. | |
int | fr_pair_insert_before (fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_add) |
Add a VP before another VP. | |
static void * | fr_pair_iter_next_by_ancestor (fr_dlist_head_t *list, void *current, void *uctx) |
Iterate over pairs which are decedents of the specified da. | |
static void * | fr_pair_iter_next_by_da (fr_dlist_head_t *list, void *current, void *uctx) |
Iterate over pairs with a specified da. | |
void | fr_pair_list_afrom_box (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_t const *dict, fr_value_box_t *box) |
Parse a list of VPs from a value box. | |
fr_pair_list_t * | fr_pair_list_alloc (TALLOC_CTX *ctx) |
Allocate a new pair list on the heap. | |
int | fr_pair_list_cmp (fr_pair_list_t const *a, fr_pair_list_t const *b) |
Determine equality of two lists. | |
int | fr_pair_list_copy (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from) |
Duplicate a list of pairs. | |
int | fr_pair_list_copy_by_ancestor (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from, fr_dict_attr_t const *parent_da) |
Duplicate pairs in a list where the da is a descendant of parent_da. | |
int | fr_pair_list_copy_by_da (TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from, fr_dict_attr_t const *da, unsigned int count) |
Duplicate pairs in a list matching the specified da. | |
int | fr_pair_list_copy_to_box (fr_value_box_t *dst, fr_pair_list_t *from) |
Copy the contents of a pair list to a set of value-boxes. | |
void | fr_pair_list_init (fr_pair_list_t *list) |
Initialise a pair list header. | |
fr_pair_t * | fr_pair_list_iter_leaf (fr_pair_list_t *list, fr_pair_t *vp) |
Iterates over the leaves of a list. | |
fr_pair_t * | fr_pair_list_parent (fr_pair_list_t const *list) |
Return a pointer to the parent pair which contains this list. | |
void | fr_pair_list_steal (TALLOC_CTX *ctx, fr_pair_list_t *list) |
Steal a list of pairs to a new context. | |
void | fr_pair_list_tainted (fr_pair_list_t *list) |
Mark up a list of VPs as tainted. | |
bool | fr_pair_matches_da (void const *item, void const *uctx) |
Evaluation function for matching if vp matches a given da. | |
fr_pair_t * | fr_pair_parent (fr_pair_t const *vp) |
Return a pointer to the parent pair. | |
fr_pair_list_t * | fr_pair_parent_list (fr_pair_t const *vp) |
Return a pointer to the parent pair list. | |
int | fr_pair_prepend (fr_pair_list_t *list, fr_pair_t *to_add) |
Add a VP to the start of the list. | |
int | fr_pair_prepend_by_da (TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da) |
Alloc a new fr_pair_t (and prepend) | |
int | fr_pair_raw_afrom_pair (fr_pair_t *vp, uint8_t const *data, size_t data_len) |
Mark malformed attribute as raw. | |
int | fr_pair_reinit_from_da (fr_pair_list_t *list, fr_pair_t *vp, fr_dict_attr_t const *da) |
Re-initialise an attribute with a different da. | |
void | fr_pair_replace (fr_pair_list_t *list, fr_pair_t *to_replace, fr_pair_t *vp) |
Replace a given VP. | |
fr_pair_t * | fr_pair_root_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da) |
A special allocation function which disables child autofree. | |
int | fr_pair_steal (TALLOC_CTX *ctx, fr_pair_t *vp) |
Steal one VP. | |
int | fr_pair_steal_append (TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp) |
Change a vp's talloc ctx and insert it into a new list. | |
int | fr_pair_steal_prepend (TALLOC_CTX *list_ctx, fr_pair_list_t *list, fr_pair_t *vp) |
Change a vp's talloc ctx and insert it into a new list. | |
int | fr_pair_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. | |
int | fr_pair_update_by_da_parent (fr_pair_t *parent, fr_pair_t **out, fr_dict_attr_t const *da) |
Return the first fr_pair_t matching the fr_dict_attr_t or alloc a new fr_pair_t and its subtree (and append) | |
bool | fr_pair_validate (fr_pair_t const *failed[2], fr_pair_list_t *filter, fr_pair_list_t *list) |
Uses fr_pair_cmp to verify all fr_pair_ts in list match the filter defined by check. | |
void | fr_pair_validate_debug (fr_pair_t const *failed[2]) |
Write an error to the library errorbuff detailing the mismatch. | |
bool | fr_pair_validate_relaxed (fr_pair_t const *failed[2], fr_pair_list_t *filter, fr_pair_list_t *list) |
Uses fr_pair_cmp to verify all fr_pair_ts in list match the filter defined by check. | |
int | fr_pair_value_aprintf (fr_pair_t *vp, char const *fmt,...) |
Print data into an "string" data type. | |
int | fr_pair_value_bstr_alloc (fr_pair_t *vp, char **out, size_t size, bool tainted) |
Pre-allocate a memory buffer for a "string" type value pair. | |
int | fr_pair_value_bstr_append_buffer (fr_pair_t *vp, char const *src, bool tainted) |
Append a talloced buffer to an existing "string" type value pair. | |
int | fr_pair_value_bstr_realloc (fr_pair_t *vp, char **out, size_t size) |
Change the length of a buffer for a "string" type value pair. | |
int | fr_pair_value_bstrdup_buffer (fr_pair_t *vp, char const *src, bool tainted) |
Copy a nul terminated talloced buffer a "string" type value pair. | |
int | fr_pair_value_bstrdup_buffer_shallow (fr_pair_t *vp, char const *src, bool tainted) |
Assign a string to a "string" type value pair. | |
int | fr_pair_value_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. | |
int | fr_pair_value_bstrndup (fr_pair_t *vp, char const *src, size_t len, bool tainted) |
Copy data into a "string" type value pair. | |
int | fr_pair_value_bstrndup_shallow (fr_pair_t *vp, char const *src, size_t len, bool tainted) |
Assign a string to a "string" type value pair. | |
void | fr_pair_value_clear (fr_pair_t *vp) |
Free/zero out value (or children) of a given VP. | |
int | fr_pair_value_copy (fr_pair_t *dst, fr_pair_t *src) |
Copy the value from one pair to another. | |
char const * | fr_pair_value_enum (fr_pair_t const *vp, char buff[20]) |
Return a const buffer for an enum type attribute. | |
int | fr_pair_value_enum_box (fr_value_box_t const **out, fr_pair_t *vp) |
Get value box of a VP, optionally prefer enum value. | |
int | fr_pair_value_from_str (fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, bool tainted) |
Convert string value to native attribute value. | |
int | fr_pair_value_mem_alloc (fr_pair_t *vp, uint8_t **out, size_t size, bool tainted) |
Pre-allocate a memory buffer for a "octets" type value pair. | |
int | fr_pair_value_mem_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. | |
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. | |
int | fr_pair_value_mem_realloc (fr_pair_t *vp, uint8_t **out, size_t size) |
Change the length of a buffer for a "octets" type value pair. | |
int | fr_pair_value_memdup (fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted) |
Copy data into an "octets" data type. | |
int | fr_pair_value_memdup_buffer (fr_pair_t *vp, uint8_t const *src, bool tainted) |
Copy data from a talloced buffer into an "octets" data type. | |
int | fr_pair_value_memdup_buffer_shallow (fr_pair_t *vp, uint8_t const *src, bool tainted) |
Assign a talloced buffer to a "octets" type value pair. | |
int | fr_pair_value_memdup_shallow (fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted) |
Assign a buffer to a "octets" type value pair. | |
int | fr_pair_value_strdup (fr_pair_t *vp, char const *src, bool tainted) |
Copy data into an "string" data type. | |
int | fr_pair_value_strdup_shallow (fr_pair_t *vp, char const *src, bool tainted) |
Assign a buffer containing a nul terminated string to a vp, but don't copy it. | |
int | fr_pair_value_strtrim (fr_pair_t *vp) |
Trim the length of the string buffer to match the length of the C string. | |
static fr_pair_t * | pair_alloc_parent (fr_pair_t *in, fr_pair_t *item, fr_dict_attr_t const *da) |
Find or allocate a parent attribute. | |
static int8_t | pair_cmp_by_num (void const *a, void const *b) |
Order attributes by their attribute number, and tag. | |
static void | pair_init_from_da (fr_pair_t *vp, fr_dict_attr_t const *da) |
Continue initialising an fr_pair_t assigning a da. | |
static void | pair_init_null (fr_pair_t *vp) |
Initialise fields in an fr_pair_t without assigning a da. | |
Variables | |
static const char | spaces [] = " " |
static fr_dlist_head_t | value_dlist |
AVP manipulation and search API.
Definition in file pair.c.
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.
|
static |
|
static |
Iterate over pairs.
[in] | list | to iterate over. |
[in] | current | The fr_value_box_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t. |
[in] | uctx | The parent dcursor |
Definition at line 1264 of file pair.c.
|
static |
Iterate over pairs.
[in] | list | to iterate over. |
[in] | current | The fr_value_box_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t. |
[in] | uctx | unused |
Definition at line 1200 of file pair.c.
|
static |
Keep attr tree and sublists synced on cursor insert.
[in] | list | Underlying order list from the fr_pair_list_t. |
[in] | to_insert | fr_pair_t being inserted. |
[in] | uctx | fr_pair_list_t containing the order list. |
Definition at line 973 of file pair.c.
|
static |
Keep attr tree and sublists synced on cursor removal.
[in] | list | Underlying order list from the fr_pair_list_t. |
[in] | to_remove | fr_pair_t being removed. |
[in] | uctx | fr_pair_list_t containing the order list. |
Definition at line 998 of file pair.c.
|
static |
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 | ||
) |
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.
fr_pair_list_t * fr_pair_children | ( | fr_pair_t * | vp | ) |
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 | ||
) |
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.
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.
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 | ||
) |
int fr_pair_insert_before | ( | fr_pair_list_t * | list, |
fr_pair_t * | pos, | ||
fr_pair_t * | to_add | ||
) |
|
static |
Iterate over pairs which are decedents of the specified da.
[in] | list | to iterate over. |
[in] | current | The fr_pair_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t. |
[in] | uctx | The fr_dict_attr_t to search for. |
Definition at line 649 of file pair.c.
|
static |
Iterate over pairs with a specified da.
[in] | list | to iterate over. |
[in] | current | The fr_pair_t cursor->current. Will be advanced and checked to see if it matches the specified fr_dict_attr_t. |
[in] | uctx | The fr_dict_attr_t to search for. |
Definition at line 626 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.
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_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_parent | ( | fr_pair_list_t const * | list | ) |
void fr_pair_list_steal | ( | TALLOC_CTX * | ctx, |
fr_pair_list_t * | list | ||
) |
void fr_pair_list_tainted | ( | fr_pair_list_t * | list | ) |
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.
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.
int fr_pair_reinit_from_da | ( | fr_pair_list_t * | list, |
fr_pair_t * | vp, | ||
fr_dict_attr_t const * | da | ||
) |
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.
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[20] | ||
) |
Return a const buffer for an enum type attribute.
Where the vp type is numeric but does not have any enumv, or its value does not map to an enumv, the integer value of the pair will be printed to buff, and a pointer to buff will be returned.
[in] | vp | to print. |
[in] | buff | to print integer value to. |
Definition at line 3125 of file pair.c.
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 | ) |
|
static |
Find or allocate a parent attribute.
The input da is somewhere down inside of the da hierarchy. We need to recursively find or create parent VPs which match the given da.
We find (or add) the VP into the "in" list. Any newly created VP is inserted before "next". Or if "next==NULL", at the tail of "in".
[in] | in | the parent vp to look in |
[in] | item | if we create a new vp, insert it before this item |
[in] | da | look for vps in the parent which match this da |
Definition at line 3500 of file pair.c.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |