24 RCSIDH(dpair_h,
"$Id: a1aac7ea57dfd2f707225714d8fb3b407bd51d24 $")
26 #include <freeradius-devel/build.h>
27 #include <freeradius-devel/missing.h>
28 #include <freeradius-devel/util/dcursor.h>
29 #include <freeradius-devel/util/value.h>
30 #include <freeradius-devel/util/tlist.h>
40 # error _CONST can only be defined in the local header
57 #ifdef WITH_VERIFY_PTR
58 unsigned int verified : 1;
109 #define vp_strvalue data.vb_strvalue
110 #define vp_octets data.vb_octets
111 #define vp_ptr data.datum.ptr
112 #define vp_length data.vb_length
114 #define vp_ipv4addr data.vb_ip.addr.v4.s_addr
115 #define vp_ipv6addr data.vb_ip.addr.v6.s6_addr
116 #define vp_ip data.vb_ip
117 #define vp_ifid data.vb_ifid
118 #define vp_ether data.vb_ether
120 #define vp_bool data.datum.boolean
121 #define vp_uint8 data.vb_uint8
122 #define vp_uint16 data.vb_uint16
123 #define vp_uint32 data.vb_uint32
124 #define vp_uint64 data.vb_uint64
126 #define vp_int8 data.vb_int8
127 #define vp_int16 data.vb_int16
128 #define vp_int32 data.vb_int32
129 #define vp_int64 data.vb_int64
131 #define vp_float32 data.vb_float32
132 #define vp_float64 data.vb_float64
134 #define vp_date data.vb_date
135 #define vp_time_delta data.vb_time_delta
137 #define vp_group children
139 #define vp_size data.datum.size
140 #define vp_filter data.datum.filter
142 #define vp_type data.type
143 #define vp_tainted data.tainted
144 #define vp_immutable data.immutable
145 #define vp_edit data.edit
146 #define vp_raw da->flags.is_raw
148 #define ATTRIBUTE_EQ(_x, _y) ((_x && _y) && (_x->da == _y->da))
153 #ifdef WITH_VERIFY_PTR
156 void fr_pair_list_verify(
char const *
file,
int line,
159 # define PAIR_VERIFY(_x) fr_pair_verify(__FILE__, __LINE__, NULL, _x)
160 # define PAIR_VERIFY_WITH_LIST(_l, _x) fr_pair_verify(__FILE__, __LINE__, _l, _x)
161 # define PAIR_LIST_VERIFY(_x) fr_pair_list_verify(__FILE__, __LINE__, NULL, _x)
191 # define PAIR_VERIFY(_x) fr_pair_nonnull_assert(_x)
192 # define PAIR_VERIFY_WITH_LIST(_l, _x) fr_pair_list_nonnull_assert(_l); \
193 fr_pair_nonnull_assert(_x)
194 # define PAIR_LIST_VERIFY(_x) fr_pair_list_nonnull_assert(_x)
201 #define TEST_CHECK_PAIR(_got, _exp) \
203 fr_pair_t const *_our_got = (_got); \
204 fr_pair_t const *_our_exp = (_exp); \
205 TEST_CHECK_(_our_exp == _our_got, "%s", #_got); \
207 TEST_MSG("Expected pair : %s - %p (%s)", (_our_exp)->da->name, _our_exp, talloc_get_name(_our_exp)); \
209 TEST_MSG("Expected pair : NULL"); \
212 TEST_MSG("Got pair : %s - %p (%s)", (_our_got)->da->name, _our_got, talloc_get_name(_our_got)); \
214 TEST_MSG("Got Pair : NULL"); \
218 #define TEST_CHECK_PAIR_NEQ(_got, _neq) \
220 fr_pair_t const *_our_got = (_got); \
221 fr_pair_t const *_our_neq = (_neq); \
222 TEST_CHECK_(_our_got != _our_neq, "%s", #_got); \
224 TEST_MSG("Pair must not equal : %s - %p (%s)", (_our_neq)->da->name, _our_neq, talloc_get_name(_our_neq)); \
226 TEST_MSG("Pair must not equal : NULL"); \
244 if (
vp->vp_type ==
vp->da->type)
return true;
246 fr_strerror_printf(
"fr_pair_t attribute %p \"%s\" data type (%s) does not match da type (%s)",
247 vp->da,
vp->da->name,
261 #define fr_pair_list_foreach(_list_head, _iter) \
262 for (fr_pair_t *JOIN(_next,_iter), *_iter = fr_pair_list_head(_list_head); JOIN(_next,_iter) = fr_pair_list_next(_list_head, _iter), _iter != NULL; _iter = JOIN(_next,_iter))
272 #define fr_pair_list_foreach_leaf(_list_head, _iter) \
273 for (fr_pair_t *_iter = fr_pair_list_iter_leaf(_list_head, NULL); _iter != NULL; _iter = fr_pair_list_iter_leaf(_list_head, _iter))
286 #define fr_pair_list_append_by_da(_ctx, _vp, _list, _attr, _val, _tainted) \
289 if (fr_pair_append_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
290 fr_value_box(&_vp->data, _val, _tainted); \
291 if (!vp_da_data_type_check(_vp)) { \
292 fr_pair_delete(_list, _vp); \
309 #define fr_pair_list_append_by_da_len(_ctx, _vp, _list, _attr, _val, _len, _tainted) \
312 if (fr_pair_append_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
313 fr_value_box_len(_vp, &_vp->data, _val, _len, _tainted); \
314 if (!vp_da_data_type_check(_vp)) { \
315 fr_pair_delete(_list, _vp); \
320 #define fr_pair_list_append_by_da_parent(_ctx, _vp, _list, _attr, _val, _tainted) \
323 if (fr_pair_append_by_da_parent(_ctx, &_vp, _list, _attr) < 0) break; \
324 fr_value_box(&_vp->data, _val, _tainted); \
325 if (!vp_da_data_type_check(_vp)) { \
326 fr_pair_delete(_list, _vp); \
331 #define fr_pair_list_append_by_da_parent_len(_ctx, _vp, _list, _attr, _val, _len, _tainted) \
334 if (fr_pair_append_by_da_parent(_ctx, &vp, _list, _attr) < 0) break; \
335 fr_value_box_len(_vp, &_vp->data, _val, _len, _tainted); \
336 if (!vp_da_data_type_check(_vp)) { \
337 fr_pair_delete(_list, _vp); \
353 #define fr_pair_list_prepend_by_da(_ctx, _vp, _list, _attr, _val, _tainted) \
356 if (fr_pair_prepend_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
357 fr_value_box(&_vp->data, _val, _tainted); \
358 if (!vp_da_data_type_check(_vp)) { \
359 fr_pair_delete(_list, _vp); \
376 #define fr_pair_list_prepend_by_da_len(_ctx, _vp, _list, _attr, _val, _len, _tainted) \
379 if (fr_pair_prepend_by_da(_ctx, &_vp, _list, _attr) < 0) break; \
380 fr_value_box_len(_vp, &_vp->data, _val, _len, _tainted); \
381 if (!vp_da_data_type_check(_vp)) { \
382 fr_pair_delete(_list, _vp); \
399 #define fr_pair_list_replace_by_da(_ctx, _vp, _list, _attr, _val, _tainted) \
401 fr_pair_update_by_da(_ctx, _vp, _list, _attr, 0); \
403 fr_value_box(&_vp->data, _val, _tainted); \
404 if (!vp_da_data_type_check(_vp)) { \
405 fr_pair_delete(_list, _vp); \
423 #define fr_pair_list_replace_by_da_len(_ctx, _vp, _list, _attr, _val, _len, _tainted) \
425 fr_pair_t *oldvp = fr_pair_find_by_da(_list, NULL, _attr); \
426 fr_pair_list_append_by_da_len(_ctx, _vp_, _list, _attr, _val, _len, _tainted) \
427 if (!vp_da_data_type_check(_vp)) { \
428 fr_pair_delete(_list, _vp); \
432 if (oldvp) fr_pair_delete(_list, oldvp); \
495 unsigned int idx) CC_HINT(
nonnull);
569 #define fr_pair_dcursor_iter_init(_cursor, _list, _iter, _uctx) \
570 _fr_pair_dcursor_iter_init(_cursor, \
574 IS_CONST(fr_pair_list_t *, _list))
577 bool is_const) CC_HINT(
nonnull);
591 #define fr_pair_dcursor_init(_cursor, _list) \
592 _fr_pair_dcursor_init(_cursor, \
594 IS_CONST(fr_pair_list_t *, _list))
596 bool is_const) CC_HINT(
nonnull);
628 #define fr_pair_dcursor_by_da_init(_cursor, _list, _da) \
629 _fr_pair_dcursor_by_da_init(_cursor, \
632 IS_CONST(fr_pair_list_t *, _list))
635 bool is_const) CC_HINT(
nonnull);
646 #define fr_pair_dcursor_by_ancestor_init(_cursor, _list, _da) \
647 _fr_pair_dcursor_by_ancestor_init(_cursor, \
650 IS_CONST(fr_pair_list_t *, _list))
653 bool is_const) CC_HINT(
nonnull);
666 #define fr_pair_cmp_op(_op, _a, _b) fr_value_box_cmp_op(_op, &_a->data, &_b->data)
687 static inline CC_HINT(
nonnull, always_inline)
690 vp->vp_immutable =
true;
693 static inline CC_HINT(
nonnull, always_inline)
696 vp->vp_immutable =
false;
766 bool tainted) CC_HINT(
nonnull(1,2));
857 #define fr_pair_list_log(_log, _lvl, _list) _fr_pair_list_log(_log, _lvl, NULL, _list, __FILE__, __LINE__)
static int const char * fmt
fr_dcursor_eval_t void const * uctx
void *(* fr_dcursor_iter_t)(fr_dlist_head_t *list, void *to_eval, void *uctx)
Callback for implementing custom iterators.
static void fr_dcursor_copy_iter(fr_dcursor_t *out, fr_dcursor_t const *in)
Copy a read-only iterator from a parent to a child cursor.
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Head of a doubly linked list.
int8_t(* fr_cmp_t)(void const *a, void const *b)
#define SBUFF_OUT_TALLOC_FUNC_NO_LEN_DEF(_func,...)
Set of parsing rules for *unescape_until functions.
static char buff[sizeof("18446744073709551615")+3]
bool _CONST is_child
is a child of a VP
FR_TLIST_HEAD(fr_pair_order_list) order
Maintains the relative order of pairs in a list.
Stores an attribute, a value and various bits of other data.
FR_TLIST_ENTRY(fr_pair_order_list) _CONST order_entry
Entry to maintain relative order within a list.
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
#define FR_TLIST_TYPES(_name)
Define type specific wrapper structs for tlists.
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_list_head(fr_pair_list_t const *list)
Get the head of a valuepair list.
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_copy(TALLOC_CTX *ctx, fr_pair_t const *vp))
Copy a single valuepair.
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_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_dlist_head_t * fr_pair_list_to_dlist(fr_pair_list_t const *list)
Get the dlist head from a pair list.
TALLOC_CTX * ctx
to allocate VPs in
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.
struct pair_list_s fr_pair_list_t
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_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_from_str(fr_pair_t *vp, char const *value, size_t len, fr_sbuff_unescape_rules_t const *erules, bool tainted))
Convert string value to native attribute value.
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_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_insert_after(fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_add))
Add a VP after another VP.
void fr_fprintf_pair_list(FILE *fp, fr_pair_list_t const *list)
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.
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.
fr_pair_t * fr_pair_list_tail(fr_pair_list_t const *list)
Get the tail of a valuepair list.
fr_pair_t * fr_pair_alloc_null(TALLOC_CTX *ctx)
Dynamically allocate a new attribute with no fr_dict_attr_t assigned.
fr_pair_t * fr_pair_remove(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list without freeing.
static bool vp_da_data_type_check(fr_pair_t *vp)
Check a pair's data type matches the DA data type.
fr_pair_t * fr_pair_parent(fr_pair_t const *vp)
Return a pointer to the parent 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.
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.
int fr_pair_list_copy(TALLOC_CTX *ctx, fr_pair_list_t *to, fr_pair_list_t const *from)
Duplicate a list of pairs.
static fr_pair_t * fr_pair_dcursor_child_iter_init(fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dcursor_t const *parent)
Initializes a child dcursor from a parent cursor, with an iteration function.
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_insert_before(fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *to_add))
Add a VP before another VP.
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.
static fr_slen_t fr_pair_aprint(TALLOC_CTX *ctx, char **out, fr_dict_attr_t const *parent, fr_pair_t const *vp) 1(fr_pair_print
bool fr_pair_list_empty(fr_pair_list_t const *list)
Is a valuepair list empty.
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.
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)
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_validate_debug(fr_pair_t const *failed[2])
Write an error to the library errorbuff detailing the mismatch.
int fr_pair_value_strdup(fr_pair_t *vp, char const *src, bool tainted)
Copy data into an "string" data type.
int fr_pair_steal_append(TALLOC_CTX *nctx, fr_pair_list_t *list, fr_pair_t *vp)
Change a vp's talloc ctx and insert it into a new list.
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.
void fr_pair_init_null(fr_pair_t *vp)
Initialise fields in an fr_pair_t without assigning a da.
fr_pair_t * _fr_pair_dcursor_by_da_init(fr_dcursor_t *cursor, fr_pair_list_t const *list, fr_dict_attr_t const *da, bool is_const)
Initialise a cursor that will return only attributes matching the specified fr_dict_attr_t.
int8_t fr_pair_cmp_by_parent_num(void const *a, void const *b)
Order attributes by their parent(s), attribute number, and tag.
int fr_pair_delete_by_da(fr_pair_list_t *head, fr_dict_attr_t const *da)
Delete matching pairs from the specified list.
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.
int fr_pair_cmp(fr_pair_t const *a, fr_pair_t const *b)
Compare two pairs, using the operator from "a".
void fr_pair_list_debug(fr_pair_list_t const *list)
Dumps a list to the default logging destination - Useful for calling from debuggers.
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.
void fr_pair_replace(fr_pair_list_t *list, fr_pair_t *to_replace, fr_pair_t *vp)
Replace a given VP.
int fr_pair_prepend(fr_pair_list_t *list, fr_pair_t *vp)
Add a VP to the start of the list.
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_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_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.
static bool fr_pair_nonnull_assert(fr_pair_t const *vp)
If WITH_VERIFY_PTR is defined, we perform runtime checks to ensure the fr_pair_t are sane.
static fr_slen_t quote ssize_t fr_pair_print(fr_sbuff_t *out, fr_dict_attr_t const *parent, fr_pair_t const *vp))
Print one attribute and value to a string.
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.
static int fr_pair_find_or_append_by_da(TALLOC_CTX *ctx, fr_pair_t **out, fr_pair_list_t *list, fr_dict_attr_t const *da)
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
static void fr_pair_clear_immutable(fr_pair_t *vp)
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
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.
void fr_pair_ctx_reset(fr_pair_ctx_t *pair_ctx, fr_dict_t const *dict)
Reset a pair_ctx to the dictionary root.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *vp)
Add a VP to the end of 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.
void fr_fprintf_pair(FILE *fp, char const *msg, fr_pair_t const *vp)
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_bstrndup_shallow(fr_pair_t *vp, char const *src, size_t len, bool tainted))
Assign a string to a "string" type value pair.
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.
void fr_pair_list_prepend(fr_pair_list_t *dst, fr_pair_list_t *src)
Move a list of fr_pair_t from a temporary list to the head of a destination list.
bool fr_pair_immutable(fr_pair_t const *vp)
void fr_pair_list_tainted(fr_pair_list_t *vps)
Mark up a list of VPs as tainted.
void fr_pair_value_clear(fr_pair_t *vp)
Free/zero out value (or children) of a given VP.
static void fr_pair_set_immutable(fr_pair_t *vp)
fr_pair_list_t * list
of VPs to add
void fr_pair_debug(fr_pair_t const *pair)
Dumps a pair to the default logging destination - Useful for calling from debuggers.
int fr_pair_delete(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list and free.
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_list_t * fr_pair_list_from_dlist(fr_dlist_head_t const *list)
Get the pair list head from a dlist.
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.
static bool fr_pair_list_nonnull_assert(fr_pair_list_t const *pair_list)
fr_pair_list_t * fr_pair_list_alloc(TALLOC_CTX *ctx)
Allocate a new pair list on the heap.
ssize_t fr_pair_print_value_quoted(fr_sbuff_t *out, fr_pair_t const *vp, fr_token_t quote)
Print the value of an attribute to a string.
fr_pair_t * fr_pair_list_prev(fr_pair_list_t const *list, fr_pair_t const *item))
Get the previous item in a valuepair list before a specific entry.
int fr_pair_steal(TALLOC_CTX *ctx, fr_pair_t *vp)
Steal one VP.
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.
static fr_slen_t fr_pair_aprint_value_quoted(TALLOC_CTX *ctx, char **out, fr_pair_t const *vp, fr_token_t quote) 1(fr_pair_print_value_quoted
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.
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_parent_list(fr_pair_t const *vp)
Return a pointer to the parent pair list.
ssize_t fr_pair_ctx_afrom_str(fr_pair_ctx_t *pair_ctx, char const *in, size_t inlen)
Parse a pair context from a string.
int fr_pair_value_strtrim(fr_pair_t *vp)
Trim the length of the string buffer to match the length of the C string.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
void _fr_pair_list_log(fr_log_t const *log, int lvl, fr_pair_t *parent, fr_pair_list_t const *list, char const *file, int line))
Print a list of attributes and enumv.
fr_dict_attr_t const * parent
current attribute to allocate VPs in
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 ...
void fr_pair_list_init(fr_pair_list_t *head)
Initialise a pair list header.
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.
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_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_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.
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_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...
void fr_pair_list_steal(TALLOC_CTX *ctx, fr_pair_list_t *list)
Steal a list of pairs to a new context.
fr_pair_t * fr_pair_list_parent(fr_pair_list_t const *list)
Return a pointer to the parent pair which contains this list.
size_t fr_pair_list_num_elements(fr_pair_list_t const *list)
Get the length of a list of fr_pair_t.
int fr_pair_steal_prepend(TALLOC_CTX *nctx, fr_pair_list_t *list, fr_pair_t *vp)
Change a vp's talloc ctx and insert it into a new list.
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_list_iter_leaf(fr_pair_list_t *list, fr_pair_t *vp)
Iterates over the leaves of a 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.
fr_pair_list_t * fr_pair_children(fr_pair_t *head)
Get the child list of a group.
ssize_t fr_pair_print_secure(fr_sbuff_t *out, fr_dict_attr_t const *parent, fr_pair_t const *vp))
Print one attribute and value to a string with escape rules.
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.
ssize_t fr_pair_list_print(fr_sbuff_t *out, fr_dict_attr_t const *parent, fr_pair_list_t const *list)
Print a pair list.
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_root_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
A special allocation function which disables child autofree.
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.
char const * fr_pair_value_enum(fr_pair_t const *vp, char buff[static 20])
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.
static fr_slen_t static vp fr_slen_t fr_pair_aprint_secure(TALLOC_CTX *ctx, char **out, fr_dict_attr_t const *parent, fr_pair_t const *vp) 1(fr_pair_print_secure
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
fr_table_num_ordered_t const fr_type_table[]
Map data types to names representing those types.
static size_t char fr_sbuff_t size_t inlen
int format(printf, 5, 0))
static size_t char ** out