30#define USE_CONSTRUCTOR
39# define TEST_INIT test_init()
46#include <freeradius-devel/util/conf.h>
47#include <freeradius-devel/util/dict.h>
48#include <freeradius-devel/util/sbuff.h>
61#ifdef TEST_NESTED_PAIRS
79#ifdef TEST_NESTED_PAIRS
93 TEST_CASE(
"Allocation using fr_pair_afrom_da");
105 TEST_MSG(
"Expected vp->vp_strvalue == test_string");
115 TEST_CASE(
"Allocation using fr_pair_afrom_child_num");
122 TEST_MSG(
"Expected attr(%u) == vp->da->attr(%u)", attr,
vp->
da->attr);
134 TEST_CASE(
"Allocation using fr_pair_afrom_da_nested");
143 TEST_CASE(
"Top list does not have the tlv child attribute");
146 TEST_CASE(
"Top list does have the tlv attribute");
150 TEST_CASE(
"Parent list does have the tlv child attribute");
164 TEST_CASE(
"Allocation using fr_pair_afrom_da_nested");
173 TEST_CASE(
"Top list still has the tlv attribute");
177 TEST_CASE(
"Parent list does not have the tlv child attribute");
194 TEST_CASE(
"Allocation using fr_pair_copy");
207 TEST_CASE(
"Compare fr_pair_cmp(copy == vp) should be TRUE");
219 TEST_CASE(
"Allocate a new attribute fr_pair_afrom_da");
225 TEST_CASE(
"Stealing 'vp' pair using fr_pair_steal()");
228 TEST_CASE(
"Checking if talloc_parent(vp) == autofree");
237 TEST_CASE(
"Allocate a new attribute fr_pair_afrom_da");
243 TEST_CASE(
"Converting regular 'vp' as unknown");
246 TEST_CASE(
"Checking if a real 'raw' vp");
255 TEST_CASE(
"Searching for fr_dict_attr_test_uint32 using fr_pair_dcursor_by_da_init()");
272 TEST_CASE(
"Expected (needle->da == fr_dict_attr_test_uint32)");
281 TEST_CASE(
"Searching for fr_dict_attr_test_tlv_string as ascend of fr_dict_attr_test_tlv using fr_pair_dcursor_by_ancestor_init()");
298 TEST_CASE(
"Expected (needle->da == fr_dict_attr_test_tlv_string)");
317 vp->vp_uint32 = 6809;
324 TEST_CASE(
"Searching for fr_dict_attr_test_tlv_string as ascend of fr_dict_attr_test_tlv using fr_pair_dcursor_by_ancestor_init()");
330 TEST_CASE(
"First box is a string with value 'hello'");
332 TEST_CHECK(strcmp(box->vb_strvalue,
"hello") == 0);
336 TEST_CASE(
"First box is a uint32 with value 6809");
342 TEST_CASE(
"First box is a uint8 r with value 12");
361 TEST_CASE(
"Search for fr_dict_attr_test_string using fr_pair_find_by_da_idx()");
367 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
375 TEST_CASE(
"Search for FR_TEST_ATTR_STRING using fr_pair_find_by_child_num_idx()");
381 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
387 fr_pair_t *vp1, *vp2, *vp3, *vp4, *vp5, *vp_found;
409 TEST_CASE(
"Find child node in first TLV");
410 TEST_CHECK_PAIR(vp_found, vp1);
413 TEST_CASE(
"Find child node in second TLV");
414 TEST_CHECK_PAIR(vp_found, vp2);
417 TEST_CASE(
"Look for child in first node after second");
418 TEST_CHECK_PAIR(vp_found, NULL);
434 TEST_CASE(
"Find child node in first TLV");
435 TEST_CHECK_PAIR(vp_found, vp1);
438 TEST_CASE(
"Find child node in third TLV");
439 TEST_CHECK_PAIR(vp_found, vp3);
442 TEST_CASE(
"Find child node after third TLV");
443 TEST_CHECK_PAIR(vp_found, NULL);
458 TEST_CASE(
"Find child node in first TLV");
459 TEST_CHECK_PAIR(vp_found, vp1);
462 TEST_CASE(
"Find child node in third TLV");
463 TEST_CHECK_PAIR(vp_found, vp3);
466 TEST_CASE(
"Find first entry in \"flat\" list");
467 TEST_CHECK_PAIR(vp_found, vp4);
470 TEST_CASE(
"Find second \"flat\" list entry");
471 TEST_CHECK_PAIR(vp_found, vp5);
475 TEST_CHECK_PAIR(vp_found, NULL);
487 TEST_CASE(
"Add 3 pairs using fr_pair_append()");
511 fr_pair_t *leaf1, *leaf2, *found, *inter1, *inter2;
517 TEST_CASE(
"Add nested attribute including parents");
522 TEST_CASE(
"Check nested attributes added");
530 TEST_CHECK_PAIR(found, leaf1);
532 TEST_CASE(
"Ensure no flat list attribute created");
534 TEST_CHECK_PAIR(found, NULL);
536 TEST_CASE(
"Add additional nested attribute where parents exist");
542 TEST_CASE(
"Check additional leaf added under existing parent");
544 TEST_CHECK_PAIR(found, leaf2);
546 TEST_CASE(
"Check no extra parent attributes created");
548 TEST_CHECK_PAIR(found, inter1);
550 TEST_CHECK_PAIR(found, NULL);
553 TEST_CHECK_PAIR(found, inter2);
555 TEST_CHECK_PAIR(found, NULL);
562 TEST_CASE(
"Delete fr_dict_attr_test_string using fr_pair_delete_by_child_num()");
565 TEST_CASE(
"The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
568 TEST_CASE(
"Add fr_dict_attr_test_string back into 'test_pairs'");
581 TEST_CASE(
"Add using fr_pair_prepend_by_da()");
588 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
602 TEST_CASE(
"Update Add using fr_pair_prepend_by_da()");
604 vp->vp_uint32 = 54321;
606 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 54321)");
620 TEST_CASE(
"Delete fr_dict_attr_test_string using fr_pair_delete_by_da()");
623 TEST_CASE(
"The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
626 TEST_CASE(
"Add fr_dict_attr_test_string back into 'test_pairs'");
634 TEST_CASE(
"Delete fr_dict_attr_test_string using fr_pair_delete()");
638 TEST_CASE(
"The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
641 TEST_CASE(
"Add fr_dict_attr_test_string back into 'test_pairs'");
649 TEST_CASE(
"Create the vp1 'Test-Integer = 123'");
656 vp1->vp_uint32 = 123;
658 TEST_CASE(
"Create the vp2 'Test-Integer = 321'");
665 vp2->vp_uint32 = 321;
667 TEST_CASE(
"Compare fr_pair_cmp(vp1 == vp2) should be FALSE");
684 TEST_CASE(
"Check if 'local_pairs1' == 'local_pairs2' using fr_pair_list_cmp()");
697 TEST_CASE(
"Copy 'test_pairs' into 'local_pairs'");
700 TEST_CASE(
"Check if 'local_pairs' == 'test_pairs' using fr_pair_list_cmp()");
714 TEST_CASE(
"Copy 'test_pairs' into 'local_pairs'");
717 TEST_CASE(
"The 'local_pairs' should have only fr_dict_attr_test_string");
724 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
738 TEST_CASE(
"Copy 'test_pairs' into 'local_pairs'");
741 TEST_CASE(
"The 'local_pairs' should have only one attribute in it");
744 TEST_CASE(
"The 'local_pairs' should have only fr_dict_attr_test_tlv_string (ancestor of 'Test-TLV-Root'");
747 TEST_CASE(
"Validating we copied the attribute");
751#ifdef TEST_NESTED_PAIRS
752 TEST_CASE(
"Expected copied attribute == fr_dict_attr_test_tlv)");
755 TEST_CASE(
"Expected copied attribute == fr_dict_attr_test_tlv_string)");
759 TEST_CASE(
"Verifying the copied attribute");
762 TEST_CASE(
"Expecting nothing else in local list");
775 TEST_CASE(
"Create 'local_pairs' with 3 attributes not ordered");
778 TEST_CASE(
"Add fr_dict_attr_test_string back into 'local_pairs'");
789 TEST_CASE(
"Sorting 'local_pairs' by fr_pair_list_sort(local_pairs, fr_pair_cmp_by_da)");
792 TEST_CASE(
"1st (da == fr_dict_attr_test_string)");
796 TEST_CASE(
"2nd (da == fr_dict_attr_test_octets)");
800 TEST_CASE(
"3rd (da == fr_dict_attr_test_ipv4_addr)");
804 TEST_CASE(
"4th (da == fr_dict_attr_test_uint32)");
808 TEST_CASE(
"5th (da == fr_dict_attr_test_date)");
812 TEST_CASE(
"6th (da == fr_dict_attr_test_enum)");
823 TEST_CASE(
"Create 'vp1' with Test-Integer = 123");
825 vp1->vp_uint32 = 123;
836 TEST_CASE(
"Copy 'vp1' to 'vp2' using fr_pair_value_copy()");
856 TEST_CASE(
"Convert 'test_string' value to attribute value using fr_pair_value_from_str()");
862 TEST_CASE(
"Check (vp->vp_string == test_string)");
876 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_strdup()");
882 TEST_CASE(
"Check (vp->vp_string == test_string)");
889 char *copy_test_string;
900 talloc_set_type(copy_test_string,
char);
902 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_strdup_shallow()");
908 TEST_CASE(
"Check (vp->vp_string == copy_test_string)");
924 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_strdup_shallow()");
927 TEST_CASE(
"Trim the length of the string buffer using fr_pair_value_strtrim()");
933 TEST_CASE(
"Check (vp->vp_string == test_string)");
951 TEST_CASE(
"Copy content of 'fmt_test' to attribute value using fr_pair_value_aprintf()");
957 TEST_CASE(
"Check (vp->vp_string == fmt_test)");
972 TEST_CASE(
"Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
978 TEST_CASE(
"Copy 'test_string' to the pre-allocated pointer");
984 TEST_CASE(
"Check (vp->vp_string == test_string)");
999 TEST_CASE(
"Pre-allocate 1 byte of memory buffer using fr_pair_value_bstr_alloc()");
1002 TEST_CASE(
"Re-allocate (test_string_len-1) byte of memory buffer using fr_pair_value_bstr_realloc()");
1008 TEST_CASE(
"Copy 'test_string' to the pre-allocated pointer");
1011 TEST_CASE(
"Check (out == test_string)");
1014 TEST_CASE(
"Check (vp->vp_string == test_string)");
1028 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup()");
1031 TEST_CASE(
"Check (vp->vp_string == test_string)");
1038 char *copy_test_string;
1047 talloc_set_type(copy_test_string,
char);
1049 TEST_CASE(
"Copy content of 'copy_test_string' to attribute value using fr_pair_value_bstrdup_buffer()");
1052 TEST_CASE(
"Check (vp->vp_string == test_string)");
1053 TEST_CHECK(
vp && strcmp(
vp->vp_strvalue, copy_test_string) == 0);
1061 char *copy_test_string;
1070 talloc_set_type(copy_test_string,
char);
1072 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup_shallow()");
1075 TEST_CASE(
"Check (vp->vp_string == copy_test_string)");
1084 char *copy_test_string;
1093 talloc_set_type(copy_test_string,
char);
1095 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrdup_buffer_shallow()");
1098 TEST_CASE(
"Check (vp->vp_string == copy_test_string)");
1115 TEST_CASE(
"Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
1118 TEST_CASE(
"Copy 'test_octets' to the pre-allocated pointer");
1121 TEST_CASE(
"Check (out == test_octets)");
1124 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1139 TEST_CASE(
"Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
1142 TEST_CASE(
"Copy 'test_octets' to the pre-allocated pointer");
1145 TEST_CASE(
"Realloc pre-allocated pointer to fit extra 'test_octets' copy");
1148 TEST_CASE(
"Copy 'test_octets' into the tail");
1151 TEST_CASE(
"Check first chunk (out == test_octets)");
1156 TEST_CASE(
"Check first chunk (vp->vp_octets == test_octets)");
1159 TEST_CASE(
"Check second chunk (out+NUM_ELEMENTS(test_octets) == test_octets)");
1162 TEST_CASE(
"Check second chunk (vp->vp_octets+NUM_ELEMENTS(test_octets) == test_octets)");
1176 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup()");
1179 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1195 talloc_set_type(copy_test_octets,
uint8_t);
1197 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_buffer()");
1200 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1218 talloc_set_type(copy_test_octets,
uint8_t);
1220 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_shallow()");
1223 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1241 talloc_set_type(copy_test_octets,
uint8_t);
1243 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_buffer_shallow()");
1246 TEST_CASE(
"Check (vp->vp_octets == copy_test_octets)");
1264 vp->vp_uint32 = 123;
1266 TEST_CASE(
"Lookup enum value attribute using fr_pair_value_enum()");
1269 TEST_MSG(
"Checking fr_pair_value_enum()");
1271 TEST_CHECK(var && strcmp(var,
"test123") == 0);
1272 TEST_MSG(
"Expected var == 'test123'");
1286 vp->vp_uint32 = 123;
1288 TEST_CASE(
"Lookup enum value attribute using fr_pair_value_enum_box()");
1291 TEST_MSG(
"Checking fr_pair_value_enum()");
1294 TEST_MSG(
"Expected vb->vb_uint32 == 123");
1334 memcpy(buf,
"testXXXX", 8);
1340 TEST_MSG(
"Expected slen=4 (matched 'test' protocol), got %zd", (
ssize_t)slen);
1343 TEST_MSG(
"Expected out_dict==test_dict; OOB read of sentinel byte made the buggy code early-return with dict_def (NULL)");
#define TEST_CHECK_(cond,...)
#define TEST_ASSERT(cond)
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
bool fr_dict_attr_can_contain(fr_dict_attr_t const *parent, fr_dict_attr_t const *child)
See if a structural da is allowed to contain another da.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
fr_slen_t fr_dict_by_protocol_substr(fr_dict_attr_err_t *err, fr_dict_t const **out, fr_sbuff_t *name, fr_dict_t const *dict_def)
Look up a protocol name embedded in another string.
fr_dict_attr_t const * fr_dict_attr_test_tlv_string
fr_dict_attr_t const * fr_dict_attr_test_nested_leaf_string
fr_dict_attr_t const * fr_dict_attr_test_enum
fr_dict_attr_t const * fr_dict_attr_test_date
fr_dict_attr_t const * fr_dict_attr_test_tlv
fr_dict_attr_t const * fr_dict_attr_test_nested_top_tlv
fr_dict_attr_t const * fr_dict_attr_test_uint32
fr_dict_attr_t const * fr_dict_attr_test_octets
fr_dict_attr_t const * fr_dict_attr_test_string
fr_dict_attr_t const * fr_dict_attr_test_ipv4_addr
fr_dict_attr_t const * fr_dict_attr_test_nested_child_tlv
int fr_dict_test_init(TALLOC_CTX *ctx, fr_dict_t **dict_p, fr_dict_test_attr_t const *test_defs)
Initialise a test dictionary and add our test_defs to it.
fr_dict_attr_t const * fr_dict_attr_test_uint8
fr_dict_attr_t const * fr_dict_attr_test_group
fr_dict_attr_t const * fr_dict_attr_test_nested_leaf_int32
fr_dict_attr_t const * fr_dict_attr_test_vsa
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
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_cmp(fr_pair_list_t const *a, fr_pair_list_t const *b)
Determine equality of two lists.
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_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_aprintf(fr_pair_t *vp, char const *fmt,...)
Print data into an "string" data type.
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.
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_value_memdup(fr_pair_t *vp, uint8_t const *src, size_t len, bool tainted)
Copy data into an "octets" data type.
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.
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_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_from_str(fr_pair_t *vp, char const *value, size_t inlen, fr_sbuff_unescape_rules_t const *uerules, UNUSED bool tainted)
Convert string value to native attribute value.
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_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.
int fr_pair_cmp(fr_pair_t const *a, fr_pair_t const *b)
Compare two pairs, using the operator from "a".
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.
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_delete_by_da(fr_pair_list_t *list, fr_dict_attr_t const *da)
Delete matching pairs from the specified list.
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_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
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 ...
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.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
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.
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_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_bstr_alloc(fr_pair_t *vp, char **out, size_t size, bool tainted)
Pre-allocate a memory buffer for a "string" type value pair.
int fr_pair_value_bstr_realloc(fr_pair_t *vp, char **out, size_t size)
Change the length of a buffer for a "string" type value pair.
int fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list and free.
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.
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_value_copy(fr_pair_t *dst, fr_pair_t *src)
Copy the value from one pair to another.
int fr_pair_steal(TALLOC_CTX *ctx, fr_pair_t *vp)
Steal one VP.
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.
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
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_strtrim(fr_pair_t *vp)
Trim the length of the string buffer to match the length of the C string.
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.
int fr_pair_prepend(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the start of the list.
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_raw_afrom_pair(fr_pair_t *vp, uint8_t const *data, size_t data_len)
Mark malformed attribute as raw.
int8_t fr_pair_cmp_by_da(void const *a, void const *b)
Order attributes by their da, and tag.
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_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_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)
fr_pair_t * fr_pair_afrom_child_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
Create a new valuepair.
static fr_pair_list_t test_pairs
static fr_dict_t * test_dict
Helper functions for pair tests.
static int fr_pair_test_list_alloc_nested(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_test_attr_t const *test_defs)
static uint8_t test_octets[]
static int fr_pair_test_list_alloc(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_test_attr_t const *test_defs)
static size_t test_string_len
static char const * test_string
static void test_fr_pair_value_memdup_shallow(void)
static void test_fr_pair_list_copy_by_ancestor(void)
static void test_fr_dict_by_protocol_substr_no_overflow(void)
static void test_fr_pair_afrom_child_num(void)
static void test_fr_pair_value_aprintf(void)
static void test_fr_pair_value_mem_realloc(void)
static void test_fr_pair_value_memdup_buffer(void)
static void test_fr_pair_value_enum_box(void)
static void test_fr_pair_value_bstrdup_buffer(void)
static void test_fr_pair_value_copy(void)
static void test_fr_pair_delete(void)
static void test_fr_pair_list_cmp(void)
static void test_fr_pair_copy(void)
static void test_fr_pair_afrom_da(void)
static void test_fr_pair_value_mem_alloc(void)
static void test_fr_pair_value_bstrndup(void)
static void test_fr_pair_find_by_child_num_idx(void)
static void test_fr_pair_value_bstrndup_shallow(void)
static void test_fr_pair_value_bstrdup_buffer_shallow(void)
static void test_fr_pair_list_copy(void)
static void test_fr_pair_value_memdup_buffer_shallow(void)
static void test_fr_pair_value_bstr_realloc(void)
static void test_fr_pair_dcursor_by_da_init(void)
static void test_fr_pair_delete_by_da(void)
static void test_fr_pair_append(void)
static void test_fr_pair_value_strdup_shallow(void)
static void test_fr_pair_find_by_da_idx(void)
static void test_fr_pair_nested_verify(void)
static void test_fr_pair_value_strtrim(void)
static void test_fr_pair_value_enum(void)
static void test_fr_pair_value_bstr_alloc(void)
static void test_fr_pair_list_sort(void)
static void test_fr_pair_value_strdup(void)
static void test_fr_pair_cmp(void)
static void test_fr_pair_prepend_by_da(void)
static void test_fr_pair_afrom_da_nested(void)
static void test_fr_pair_list_copy_by_da(void)
static void test_fr_pair_value_from_str(void)
static void test_fr_pair_append_by_da_parent(void)
static void test_fr_pair_steal(void)
static void test_fr_pair_delete_by_child_num(void)
static void test_fr_pair_dcursor_by_ancestor_init(void)
static void test_fr_pair_delete_by_da_nested(void)
static void test_init(void)
Global initialisation.
static void test_fr_pair_raw_afrom_pair(void)
static void test_fr_pair_update_by_da_parent(void)
static void test_fr_pair_find_by_da_nested(void)
static void test_fr_pair_dcursor_value_init(void)
static void test_fr_pair_value_memdup(void)
int dict_protocol_add(fr_dict_t *dict)
Add a protocol to the global protocol table.
#define local_pairs
Convenience macro for accessing the state list.
#define fr_sbuff_init_in(_out, _start, _len_or_end)
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
fr_pair_value_bstrdup_buffer(vp, eap_session->identity, true)
size_t strlcpy(char *dst, char const *src, size_t siz)
Stores an attribute, a value and various bits of other data.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
void * talloc_null_ctx(void)
Retrieve the current talloc NULL ctx.
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.
#define talloc_strdup(_ctx, _str)
static int64_t fr_time_unwrap(fr_time_t time)
#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.
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.
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.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
fr_pair_t * fr_pair_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
#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.
size_t fr_pair_list_num_elements(fr_pair_list_t const *list)
Get the length of a list of fr_pair_t.
char const * fr_strerror(void)
Get the last library error.
void fr_perror(char const *fmt,...)
Print the current error to stderr with a prefix.
int fr_check_lib_magic(uint64_t magic)
Check if the application linking to the library has the correct magic number.
#define RADIUSD_MAGIC_NUMBER
fr_sbuff_unescape_rules_t const fr_value_unescape_double
static size_t char ** out