30 #define USE_CONSTRUCTOR
35 #ifdef USE_CONSTRUCTOR
39 # define TEST_INIT test_init()
42 #include <freeradius-devel/util/acutest.h>
43 #include <freeradius-devel/util/acutest_helpers.h>
44 #include <freeradius-devel/util/pair_test_helpers.h>
46 #include <freeradius-devel/util/conf.h>
47 #include <freeradius-devel/util/dict.h>
49 #ifdef HAVE_GPERFTOOLS_PROFILER_H
50 # include <gperftools/profiler.h>
64 #ifdef TEST_NESTED_PAIRS
82 #ifdef TEST_NESTED_PAIRS
96 TEST_CASE(
"Allocation using fr_pair_afrom_da");
108 TEST_MSG(
"Expected vp->vp_strvalue == test_string");
118 TEST_CASE(
"Allocation using fr_pair_afrom_child_num");
125 TEST_MSG(
"Expected attr(%d) == vp->da->attr(%d)", attr,
vp->
da->attr);
137 TEST_CASE(
"Allocation using fr_pair_afrom_da_nested");
146 TEST_CASE(
"Top list does not have the tlv child attribute");
149 TEST_CASE(
"Top list does have the tlv attribute");
153 TEST_CASE(
"Parent list does have the tlv child attribute");
167 TEST_CASE(
"Allocation using fr_pair_afrom_da_nested");
176 TEST_CASE(
"Top list still has the tlv attribute");
180 TEST_CASE(
"Parent list does not have the tlv child attribute");
197 TEST_CASE(
"Allocation using fr_pair_copy");
210 TEST_CASE(
"Compare fr_pair_cmp(copy == vp) should be TRUE");
222 TEST_CASE(
"Allocate a new attribute fr_pair_afrom_da");
228 TEST_CASE(
"Stealing 'vp' pair using fr_pair_steal()");
231 TEST_CASE(
"Checking if talloc_parent(vp) == autofree");
240 TEST_CASE(
"Allocate a new attribute fr_pair_afrom_da");
246 TEST_CASE(
"Converting regular 'vp' as unknown");
249 TEST_CASE(
"Checking if a real 'raw' vp");
258 TEST_CASE(
"Searching for fr_dict_attr_test_uint32 using fr_pair_dcursor_by_da_init()");
275 TEST_CASE(
"Expected (needle->da == fr_dict_attr_test_uint32)");
284 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()");
301 TEST_CASE(
"Expected (needle->da == fr_dict_attr_test_tlv_string)");
320 vp->vp_uint32 = 6809;
327 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()");
333 TEST_CASE(
"First box is a string with value 'hello'");
335 TEST_CHECK(strcmp(box->vb_strvalue,
"hello") == 0);
339 TEST_CASE(
"First box is a uint32 with value 6809");
345 TEST_CASE(
"First box is a uint8 r with value 12");
364 TEST_CASE(
"Search for fr_dict_attr_test_string using fr_pair_find_by_da_idx()");
370 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
378 TEST_CASE(
"Search for FR_TEST_ATTR_STRING using fr_pair_find_by_child_num_idx()");
384 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
390 fr_pair_t *vp1, *vp2, *vp3, *vp4, *vp5, *vp_found;
412 TEST_CASE(
"Find child node in first TLV");
413 TEST_CHECK_PAIR(vp_found, vp1);
416 TEST_CASE(
"Find child node in second TLV");
417 TEST_CHECK_PAIR(vp_found, vp2);
420 TEST_CASE(
"Look for child in first node after second");
421 TEST_CHECK_PAIR(vp_found, NULL);
437 TEST_CASE(
"Find child node in first TLV");
438 TEST_CHECK_PAIR(vp_found, vp1);
441 TEST_CASE(
"Find child node in third TLV");
442 TEST_CHECK_PAIR(vp_found, vp3);
445 TEST_CASE(
"Find child node after third TLV");
446 TEST_CHECK_PAIR(vp_found, NULL);
461 TEST_CASE(
"Find child node in first TLV");
462 TEST_CHECK_PAIR(vp_found, vp1);
465 TEST_CASE(
"Find child node in third TLV");
466 TEST_CHECK_PAIR(vp_found, vp3);
469 TEST_CASE(
"Find first entry in \"flat\" list");
470 TEST_CHECK_PAIR(vp_found, vp4);
473 TEST_CASE(
"Find second \"flat\" list entry");
474 TEST_CHECK_PAIR(vp_found, vp5);
478 TEST_CHECK_PAIR(vp_found, NULL);
490 TEST_CASE(
"Add 3 pairs using fr_pair_append()");
514 fr_pair_t *leaf1, *leaf2, *found, *inter1, *inter2;
520 TEST_CASE(
"Add nested attribute including parents");
525 TEST_CASE(
"Check nested attributes added");
533 TEST_CHECK_PAIR(found, leaf1);
535 TEST_CASE(
"Ensure no flat list attribute created");
537 TEST_CHECK_PAIR(found, NULL);
539 TEST_CASE(
"Add additional nested attribute where parents exist");
545 TEST_CASE(
"Check additional leaf added under existing parent");
547 TEST_CHECK_PAIR(found, leaf2);
549 TEST_CASE(
"Check no extra parent attributes created");
551 TEST_CHECK_PAIR(found, inter1);
553 TEST_CHECK_PAIR(found, NULL);
556 TEST_CHECK_PAIR(found, inter2);
558 TEST_CHECK_PAIR(found, NULL);
565 TEST_CASE(
"Delete fr_dict_attr_test_string using fr_pair_delete_by_child_num()");
568 TEST_CASE(
"The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
571 TEST_CASE(
"Add fr_dict_attr_test_string back into 'test_pairs'");
584 TEST_CASE(
"Add using fr_pair_prepend_by_da()");
591 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
605 TEST_CASE(
"Update Add using fr_pair_prepend_by_da()");
607 vp->vp_uint32 = 54321;
609 TEST_CASE(
"Expected fr_dict_attr_test_uint32 (vp->vp_uint32 == 54321)");
623 TEST_CASE(
"Delete fr_dict_attr_test_string using fr_pair_delete_by_da()");
626 TEST_CASE(
"The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
629 TEST_CASE(
"Add fr_dict_attr_test_string back into 'test_pairs'");
637 TEST_CASE(
"Delete fr_dict_attr_test_string using fr_pair_delete()");
641 TEST_CASE(
"The fr_dict_attr_test_string shouldn't exist in 'test_pairs'");
644 TEST_CASE(
"Add fr_dict_attr_test_string back into 'test_pairs'");
652 TEST_CASE(
"Create the vp1 'Test-Integer = 123'");
659 vp1->vp_uint32 = 123;
661 TEST_CASE(
"Create the vp2 'Test-Integer = 321'");
668 vp2->vp_uint32 = 321;
670 TEST_CASE(
"Compare fr_pair_cmp(vp1 == vp2) should be FALSE");
687 TEST_CASE(
"Check if 'local_pairs1' == 'local_pairs2' using fr_pair_list_cmp()");
700 TEST_CASE(
"Copy 'test_pairs' into 'local_pairs'");
703 TEST_CASE(
"Check if 'local_pairs' == 'test_pairs' using fr_pair_list_cmp()");
717 TEST_CASE(
"Copy 'test_pairs' into 'local_pairs'");
720 TEST_CASE(
"The 'local_pairs' should have only fr_dict_attr_test_string");
727 TEST_CASE(
"Expected (vp->da == fr_dict_attr_test_string)");
741 TEST_CASE(
"Copy 'test_pairs' into 'local_pairs'");
744 TEST_CASE(
"The 'local_pairs' should have only one attribute in it");
747 TEST_CASE(
"The 'local_pairs' should have only fr_dict_attr_test_tlv_string (ancestor of 'Test-TLV-Root'");
750 TEST_CASE(
"Validating we copied the attribute");
754 #ifdef TEST_NESTED_PAIRS
755 TEST_CASE(
"Expected copied attribute == fr_dict_attr_test_tlv)");
758 TEST_CASE(
"Expected copied attribute == fr_dict_attr_test_tlv_string)");
762 TEST_CASE(
"Verifying the copied attribute");
765 TEST_CASE(
"Expecting nothing else in local list");
778 TEST_CASE(
"Create 'local_pairs' with 3 attributes not ordered");
781 TEST_CASE(
"Add fr_dict_attr_test_string back into 'local_pairs'");
792 TEST_CASE(
"Sorting 'local_pairs' by fr_pair_list_sort(local_pairs, fr_pair_cmp_by_da)");
795 TEST_CASE(
"1st (da == fr_dict_attr_test_string)");
799 TEST_CASE(
"2nd (da == fr_dict_attr_test_octets)");
803 TEST_CASE(
"3rd (da == fr_dict_attr_test_ipv4_addr)");
807 TEST_CASE(
"4th (da == fr_dict_attr_test_uint32)");
811 TEST_CASE(
"5th (da == fr_dict_attr_test_date)");
815 TEST_CASE(
"6th (da == fr_dict_attr_test_enum)");
826 TEST_CASE(
"Create 'vp1' with Test-Integer = 123");
828 vp1->vp_uint32 = 123;
839 TEST_CASE(
"Copy 'vp1' to 'vp2' using fr_pair_value_copy()");
859 TEST_CASE(
"Convert 'test_string' value to attribute value using fr_pair_value_from_str()");
865 TEST_CASE(
"Check (vp->vp_string == test_string)");
879 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_strdup()");
885 TEST_CASE(
"Check (vp->vp_string == test_string)");
892 char *copy_test_string;
902 copy_test_string = talloc_strdup(nvp,
test_string);
903 talloc_set_type(copy_test_string,
char);
905 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_strdup_shallow()");
911 TEST_CASE(
"Check (vp->vp_string == copy_test_string)");
927 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_strdup_shallow()");
930 TEST_CASE(
"Trim the length of the string buffer using fr_pair_value_strtrim()");
936 TEST_CASE(
"Check (vp->vp_string == test_string)");
954 TEST_CASE(
"Copy content of 'fmt_test' to attribute value using fr_pair_value_aprintf()");
960 TEST_CASE(
"Check (vp->vp_string == fmt_test)");
975 TEST_CASE(
"Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
981 TEST_CASE(
"Copy 'test_string' to the pre-allocated pointer");
987 TEST_CASE(
"Check (vp->vp_string == test_string)");
1002 TEST_CASE(
"Pre-allocate 1 byte of memory buffer using fr_pair_value_bstr_alloc()");
1005 TEST_CASE(
"Re-allocate (test_string_len-1) byte of memory buffer using fr_pair_value_bstr_realloc()");
1011 TEST_CASE(
"Copy 'test_string' to the pre-allocated pointer");
1014 TEST_CASE(
"Check (out == test_string)");
1017 TEST_CASE(
"Check (vp->vp_string == test_string)");
1031 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup()");
1034 TEST_CASE(
"Check (vp->vp_string == test_string)");
1041 char *copy_test_string;
1050 talloc_set_type(copy_test_string,
char);
1052 TEST_CASE(
"Copy content of 'copy_test_string' to attribute value using fr_pair_value_bstrdup_buffer()");
1055 TEST_CASE(
"Check (vp->vp_string == test_string)");
1056 TEST_CHECK(
vp && strcmp(
vp->vp_strvalue, copy_test_string) == 0);
1064 char *copy_test_string;
1073 talloc_set_type(copy_test_string,
char);
1075 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup_shallow()");
1078 TEST_CASE(
"Check (vp->vp_string == copy_test_string)");
1087 char *copy_test_string;
1096 talloc_set_type(copy_test_string,
char);
1098 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrdup_buffer_shallow()");
1101 TEST_CASE(
"Check (vp->vp_string == copy_test_string)");
1110 char *copy_test_string;
1119 talloc_set_type(copy_test_string,
char);
1121 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup()");
1124 TEST_CASE(
"Append the 'copy_test_string' value using fr_pair_value_bstrn_append()");
1128 TEST_CASE(
"Check 1. part (vp->vp_string == test_string)");
1131 TEST_CASE(
"Check 2. part ((vp->vp_string+test_string_len) == test_string)");
1140 char *copy_test_string;
1149 talloc_set_type(copy_test_string,
char);
1151 TEST_CASE(
"Copy content of 'test_string' to attribute value using fr_pair_value_bstrndup()");
1154 TEST_CASE(
"Append the 'copy_test_string' value using fr_pair_value_bstr_append_buffer()");
1161 TEST_CASE(
"Check 1. part (vp->vp_string == test_string)");
1164 TEST_CASE(
"Check 2. part ((vp->vp_string+test_string_len) == test_string)");
1181 TEST_CASE(
"Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
1184 TEST_CASE(
"Copy 'test_octets' to the pre-allocated pointer");
1187 TEST_CASE(
"Check (out == test_octets)");
1190 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1205 TEST_CASE(
"Pre-allocate a memory buffer using fr_pair_value_bstr_alloc()");
1208 TEST_CASE(
"Copy 'test_octets' to the pre-allocated pointer");
1211 TEST_CASE(
"Realloc pre-allocated pointer to fit extra 'test_octets' copy");
1214 TEST_CASE(
"Copy 'test_octets' into the tail");
1217 TEST_CASE(
"Check first chunk (out == test_octets)");
1222 TEST_CASE(
"Check first chunk (vp->vp_octets == test_octets)");
1225 TEST_CASE(
"Check second chunk (out+NUM_ELEMENTS(test_octets) == test_octets)");
1228 TEST_CASE(
"Check second chunk (vp->vp_octets+NUM_ELEMENTS(test_octets) == test_octets)");
1242 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup()");
1245 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1261 talloc_set_type(copy_test_octets,
uint8_t);
1263 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_buffer()");
1266 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1284 talloc_set_type(copy_test_octets,
uint8_t);
1286 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_shallow()");
1289 TEST_CASE(
"Check (vp->vp_octets == test_octets)");
1307 talloc_set_type(copy_test_octets,
uint8_t);
1309 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup_buffer_shallow()");
1312 TEST_CASE(
"Check (vp->vp_octets == copy_test_octets)");
1328 TEST_CASE(
"Copy content of 'test_octets' to attribute value using fr_pair_value_memdup()");
1331 TEST_CASE(
"Append the 'test_octets' value using fr_pair_value_mem_append()");
1335 TEST_CASE(
"Check 1. part (vp->vp_octets == test_octets)");
1338 TEST_CASE(
"Check 2. part ((vp->vp_string+NUM_ELEMENTS(test_octets)) == test_octets)");
1354 talloc_set_type(copy_test_octets,
uint8_t);
1356 TEST_CASE(
"Copy content of 'copy_test_octets' to attribute value using fr_pair_value_memdup()");
1359 TEST_CASE(
"Append the 'copy_test_octets' value using fr_pair_value_mem_append_buffer()");
1363 TEST_CASE(
"Check 1. part (vp->vp_octets == test_octets)");
1366 TEST_CASE(
"Check 2. part ((vp->vp_string+NUM_ELEMENTS(test_octets)) == test_octets)");
1384 vp->vp_uint32 = 123;
1386 TEST_CASE(
"Lookup enum value attribute using fr_pair_value_enum()");
1389 TEST_MSG(
"Checking fr_pair_value_enum()");
1391 TEST_CHECK(var && strcmp(var,
"test123") == 0);
1392 TEST_MSG(
"Expected var == 'test123'");
1406 vp->vp_uint32 = 123;
1408 TEST_CASE(
"Lookup enum value attribute using fr_pair_value_enum_box()");
1411 TEST_MSG(
"Checking fr_pair_value_enum()");
1414 TEST_MSG(
"Expected vb->vb_uint32 == 123");
#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_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.
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.
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_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.
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_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_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.
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_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_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_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_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_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.
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_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.
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_afrom_child_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
Create a new valuepair.
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_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_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.
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.
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.
fr_pair_t * fr_pair_copy(TALLOC_CTX *ctx, fr_pair_t const *vp)
Copy a single valuepair.
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_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_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.
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_prepend(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the start of the list.
int fr_pair_raw_afrom_pair(fr_pair_t *vp, uint8_t const *data, size_t data_len)
Mark malformed attribute as raw.
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.
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)
static fr_pair_list_t test_pairs
static fr_dict_t * test_dict
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_value_mem_append_buffer(void)
static void test_fr_pair_list_copy_by_ancestor(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_value_bstrn_append(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_value_mem_append(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_value_bstr_append_buffer(void)
static void test_fr_pair_dcursor_value_init(void)
static void test_fr_pair_value_memdup(void)
static TALLOC_CTX * autofree
#define local_pairs
Convenience macro for accessing the state list.
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
fr_pair_value_bstrdup_buffer(vp, eap_session->identity, true)
#define fr_time()
Allow us to arbitrarily manipulate time.
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.
static int64_t fr_time_unwrap(fr_time_t time)
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_da_init(_cursor, _list, _da)
Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t.
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_sort(fr_pair_list_t *list, fr_cmp_t cmp)
Sort a doubly linked list of fr_pair_ts using merge sort.
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.
#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.
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 fr_value_unescape_double
static size_t char ** out