24RCSID(
"$Id: e64fb640bf096fdf88ff31d6da368c25a8275969 $")
26#include <freeradius-devel/util/dict_priv.h>
27#include <freeradius-devel/util/dict_ext_priv.h>
46 void *ext_ptr,
UNUSED size_t ext_ptr_len)
59 TALLOC_CTX *chunk_dst,
61 TALLOC_CTX
const *chunk_src,
62 void *src_ext_ptr,
UNUSED size_t src_ext_len)
91 if (!child_struct)
return -1;
93 child_struct->parent = da_dst;
101 true,
true, child_struct) < 0)
return -1;
111 TALLOC_CTX *chunk_dst,
112 void *dst_ext_ptr,
UNUSED size_t dst_ext_len,
113 UNUSED TALLOC_CTX
const *chunk_src,
114 void *src_ext_ptr,
UNUSED size_t src_ext_len)
134 new_vendor = da_stack[old_vendor->depth];
135 if ((new_vendor->type == old_vendor->type) && (new_vendor->attr == old_vendor->attr)) {
136 dst_ext->
vendor = new_vendor;
148 for (da = da_dst->parent; da; da = da->parent) {
149 if ((da->type == old_vendor->type) && (da->attr == old_vendor->attr)) {
159 TALLOC_CTX *dst_chunk,
160 void *dst_ext_ptr,
size_t dst_ext_len,
161 TALLOC_CTX
const *src_chunk,
162 void *src_ext_ptr,
size_t src_ext_len)
175 if (from->dict != to->dict)
return 0;
180 if (
unlikely(from_proto->
attr.flags.len != src_ext_len)) {
181 fr_strerror_printf(
"Protocol specific extension length mismatch in source attribute %s. Expected %zu, got %zu",
187 if (
unlikely(to_proto->
attr.flags.len != dst_ext_len)) {
188 fr_strerror_printf(
"Protocol specific extension length mismatch in destintion attribute %s. Expected %zu, got %zu",
197 if (!to_proto->
attr.flags.copy) {
198 memcpy(dst_ext_ptr, src_ext_ptr, src_ext_len);
207 return to_proto->
attr.flags.copy(dst_chunk, dst_ext_ptr, src_ext_ptr);
#define L(_str)
Helper for initialising arrays of string literals.
int dict_attr_acopy_children(fr_dict_t *dict, fr_dict_attr_t *dst, fr_dict_attr_t const *src)
Copy the children of an existing attribute.
@ FR_DICT_ENUM_EXT_UNION_REF
Reference to a union/subs-struct.
fr_dict_protocol_t const * fr_dict_protocol(fr_dict_t const *dict)
Return the protocol descriptor for the dictionary.
fr_value_box_t const * value
Enum value (what name maps to).
@ FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC
Protocol specific extensions.
@ FR_DICT_ATTR_EXT_ENUMV
Enumeration values.
@ FR_DICT_ATTR_EXT_NAMESPACE
Attribute has its own namespace.
@ FR_DICT_ATTR_EXT_DA_STACK
Cached da stack.
@ FR_DICT_ATTR_EXT_REF
Attribute references another attribute and/or dictionary.
@ FR_DICT_ATTR_EXT_VENDOR
Cached vendor pointer.
@ FR_DICT_ATTR_EXT_NAME
Name of the attribute.
@ FR_DICT_ATTR_EXT_CHILDREN
Attribute has children.
struct fr_dict_protocol_t::@121 attr
#define fr_dict_attr_is_key_field(_da)
char const * name
Enum name.
fr_dict_attr_t const * child_struct[]
for key fields
Value of an enumerated attribute.
Protocol-specific callbacks in libfreeradius-PROTOCOL.
fr_ext_t const fr_dict_attr_ext_def
Holds additional information about extension structures.
fr_ext_t const fr_dict_enum_ext_def
Holds additional information about extension structures.
static int fr_dict_attr_ext_vendor_copy(UNUSED int ext, TALLOC_CTX *chunk_dst, void *dst_ext_ptr, UNUSED size_t dst_ext_len, UNUSED TALLOC_CTX const *chunk_src, void *src_ext_ptr, UNUSED size_t src_ext_len)
Rediscover the parent of this attribute, and cache it.
static size_t dict_attr_ext_table_len
static size_t dict_enum_ext_table_len
static int fr_dict_attr_ext_enumv_copy(UNUSED int ext, TALLOC_CTX *chunk_dst, UNUSED void *dst_ext_ptr, UNUSED size_t dst_ext_len, TALLOC_CTX const *chunk_src, void *src_ext_ptr, UNUSED size_t src_ext_len)
Copy all enumeration values from one attribute to another.
void fr_dict_attr_ext_debug(fr_dict_attr_t const *da)
static fr_table_num_ordered_t const dict_enum_ext_table[]
static int dict_ext_protocol_specific_copy(UNUSED int ext, TALLOC_CTX *dst_chunk, void *dst_ext_ptr, size_t dst_ext_len, TALLOC_CTX const *src_chunk, void *src_ext_ptr, size_t src_ext_len)
static fr_table_num_ordered_t const dict_attr_ext_table[]
static int fr_dict_attr_ext_name_fixup(UNUSED int ext, TALLOC_CTX *chunk, void *ext_ptr, UNUSED size_t ext_ptr_len)
Fixup name pointer on realloc.
fr_dict_attr_t const * vendor
ancestor which has type FR_TYPE_VENDOR
fr_hash_table_t * value_by_name
Lookup an enumeration value by name.
static fr_dict_attr_t const ** fr_dict_attr_da_stack(fr_dict_attr_t const *da)
Return the cached da stack (if any) associated with an attribute.
Attribute extension - Holds children for an attribute.
Attribute extension - Stack of dictionary attributes that describe the path back to the root of the d...
Attribute extension - Holds enumeration values.
Attribute extension - Holds a hash table with the names of all children of this attribute.
Attribute extension - Holds a reference to an attribute in another dictionary.
Attribute extension - Cached vendor pointer.
Enum extension - Sub-struct or union pointer.
static fr_dict_attr_t const ** dict_attr_children(fr_dict_attr_t const *da)
int dict_attr_enum_add_name(fr_dict_attr_t *da, char const *name, fr_value_box_t const *value, bool coerce, bool replace, fr_dict_attr_t const *child_struct)
fr_dict_t * dict_by_da(fr_dict_attr_t const *da)
Internal version of fr_dict_by_da.
fr_dict_attr_t * dict_attr_acopy(TALLOC_CTX *ctx, fr_dict_attr_t const *in, char const *new_name)
Copy a an existing attribute.
void fr_ext_debug(fr_ext_t const *def, char const *name, void const *chunk)
Print out all extensions and hexdump their contents.
size_t offset_of_exts
Where in the extended struct the extensions array starts.
#define FR_EXT_ALIGNMENT
The alignment of object extension structures.
Additional information for a given extension.
Structure to define a set of extensions.
void * fr_hash_table_iter_next(fr_hash_table_t *ht, fr_hash_iter_t *iter)
Iterate over entries in a hash table.
void * fr_hash_table_iter_init(fr_hash_table_t *ht, fr_hash_iter_t *iter)
Initialise an iterator.
Stores the state of the current iteration operation.
An element in an arbitrarily ordered array of name to num mappings.
#define talloc_get_type_abort_const
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.