23 RCSID(
"$Id: b4033caa25c18109481e5ad502bfa64a759ff52d $")
25 #include <freeradius-devel/util/dict_priv.h>
49 #ifdef STATIC_ANALYZER
50 if (!unknown->name || !unknown->parent)
return NULL;
55 if (da->attr == unknown->attr)
return da;
57 fr_strerror_printf(
"Unknown attribute '%s' conflicts with existing attribute in namespace '%s'",
58 da->name, unknown->parent->name);
65 if (unknown->parent && unknown->parent->flags.is_unknown) {
75 memcpy(&flags, &unknown->flags,
sizeof(flags));
150 if (!da || !*da)
return;
153 if (!(*da)->flags.is_unknown) {
185 flags.
length = da->flags.length;
201 if (da->parent && da->parent->flags.is_unknown) {
275 .internal =
parent->flags.internal,
297 fr_strerror_printf(
"%s: Cannot allocate unknown %s attribute (%u) - invalid data type",
307 fr_strerror_printf(
"%s: Cannot allocate unknown %s attribute (%u) with parent type %s",
322 if (child && (child->type !=
type)) {
323 fr_strerror_printf(
"%s: Cannot allocate unknown attribute (%u) which changes type from %s to %s",
389 .type_size =
parent->dict->root->flags.type_size,
390 .length =
parent->dict->root->flags.length,
420 switch (our_parent->type) {
481 fr_sbuff_marker(&c_start, &our_in);
520 for (da_u = da->parent, da_k =
parent;
521 da_k && da_u && da_u->flags.is_unknown;
522 da_u = da_u->parent, da_k = da_k->parent) {
523 if (
unlikely(da_u->attr != da_k->attr)) {
525 "known parent number %u (%s)",
526 da_u->attr, da_k->attr, da_k->name);
530 if (
unlikely(da_u->depth != da_k->depth)) {
532 "known parent depth %u (%s)",
533 da_u->depth, da_k->depth, da_k->name);
537 if ((da_k == NULL) != (da_u == NULL)) {
539 "for unknown attribute %u", da->attr);
546 "in dictionary", da->attr);
568 if (!da->flags.is_unknown)
return da;
579 if (
dict->root == da)
return dict->root;
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
static fr_dict_attr_t * fr_dict_attr_unknown_copy(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
unsigned int has_value
Has a value.
fr_dict_attr_t * fr_dict_attr_unconst(fr_dict_attr_t const *da)
Coerce to non-const.
fr_dict_attr_t const * fr_dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *attr))
Locate a fr_dict_attr_t by its name.
bool const fr_dict_attr_allowed_chars[UINT8_MAX+1]
Characters that are allowed in dictionary attribute names.
static fr_dict_attr_t * fr_dict_attr_unknown_vendor_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int vendor)
unsigned int array
Pack multiples into 1 attr.
unsigned int extra
really "subtype is used by dict, not by protocol"
unsigned int is_raw
This dictionary attribute was constructed from a known attribute to allow the user to assign octets v...
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
fr_dict_t const * fr_dict_by_da(fr_dict_attr_t const *da)
Attempt to locate the protocol dictionary containing an attribute.
uint8_t type_size
For TLV2 and root attributes.
static fr_dict_attr_t * fr_dict_attr_unknown_typed_afrom_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num, fr_type_t type)
#define FR_DICT_MAX_TLV_STACK
Maximum TLV stack size.
int fr_dict_attr_add(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, unsigned int attr, fr_type_t type, fr_dict_attr_flags_t const *flags))
Add an attribute to the dictionary.
fr_dict_attr_t const * fr_dict_attr_child_by_num(fr_dict_attr_t const *parent, unsigned int attr)
Check if a child attribute exists in a parent using an attribute number.
#define fr_dict_attr_is_key_field(_da)
#define FR_DICT_ATTR_MAX_NAME_LEN
Maximum length of a attribute name.
uint8_t length
length of the attribute
unsigned int is_unknown
This dictionary attribute is ephemeral and not part of the main dictionary.
Values of the encryption flags.
static int dict_attr_ext_copy_all(fr_dict_attr_t **da_out_p, fr_dict_attr_t const *da_in)
Copy all attribute extensions from one attribute to another.
#define dict_attr_alloc(_ctx, _parent, _name, _attr, _type, _args)
#define INTERNAL_IF_NULL(_dict, _ret)
Set the internal dictionary if none was provided.
int dict_attr_add_to_namespace(fr_dict_attr_t const *parent, fr_dict_attr_t *da)
Add an attribute to the name table for an attribute.
int dict_attr_child_add(fr_dict_attr_t *parent, fr_dict_attr_t *child)
Add a child to a parent.
int dict_vendor_add(fr_dict_t *dict, char const *name, unsigned int num)
Add a vendor to the dictionary.
#define dict_attr_init(_da_p, _parent, _name, _attr, _type, _args)
Full initialisation functions.
fr_dict_attr_t * dict_attr_alloc_null(TALLOC_CTX *ctx, fr_dict_protocol_t const *dict)
Partial initialisation functions.
Optional arguments for initialising/allocating attributes.
fr_slen_t fr_dict_attr_unknown_afrom_oid_substr(TALLOC_CTX *ctx, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_type_t type)
Create a fr_dict_attr_t from an ASCII attribute and value.
fr_dict_attr_t * fr_dict_attr_unknown_typed_afrom_num_raw(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num, fr_type_t type, bool raw)
Initialise a fr_dict_attr_t from a number and a data type.
fr_dict_attr_t * fr_dict_attr_unknown_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Copy a known or unknown attribute to produce an unknown attribute with the specified name.
int fr_dict_attr_unknown_parent_to_known(fr_dict_attr_t *da, fr_dict_attr_t const *parent)
Fixup the parent of an unknown attribute using an equivalent known attribute.
void fr_dict_attr_unknown_free(fr_dict_attr_t const **da)
Free dynamically allocated (unknown attributes)
fr_dict_attr_t * fr_dict_attr_unknown_raw_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Initialise an octets type attribute from a da.
fr_dict_attr_t const * fr_dict_attr_unknown_resolve(fr_dict_t const *dict, fr_dict_attr_t const *da)
Check to see if we can convert a nested TLV structure to known attributes.
fr_dict_attr_t const * fr_dict_attr_unknown_add(fr_dict_t *dict, fr_dict_attr_t const *unknown)
Converts an unknown to a known by adding it to the internal dictionaries.
static fr_dict_attr_t * dict_unknown_alloc(TALLOC_CTX *ctx, fr_dict_attr_t const *da, fr_type_t type)
Allocate an unknown DA.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_MAX
Number of defined data types.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_VALUE_BOX
A boxed value.
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_SBUFF_PARSE_OK
No error.
size_t fr_sbuff_adv_past_allowed(fr_sbuff_t *sbuff, size_t len, bool const allowed[static UINT8_MAX+1], fr_sbuff_term_t const *tt)
Wind position past characters in the allowed set.
bool fr_sbuff_next_if_char(fr_sbuff_t *sbuff, char c)
Return true if the current char matches, and if it does, advance.
#define fr_sbuff_current(_sbuff_or_marker)
#define fr_sbuff_is_char(_sbuff_or_marker, _c)
#define FR_SBUFF_ERROR_RETURN(_sbuff_or_marker)
#define FR_SBUFF(_sbuff_or_marker)
#define fr_sbuff_out(_err, _out, _in)
#define fr_sbuff_behind(_sbuff_or_marker)
fr_aka_sim_id_type_t type
static int talloc_const_free(void const *ptr)
Free const'd memory.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_printf_push(_fmt,...)
Add a message to an existing stack of messages at the tail.
#define fr_strerror_const(_msg)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
#define FR_TYPE_STRUCTURAL_EXCEPT_VSA
#define fr_type_is_structural_except_vsa(_x)
FR_SBUFF_SET_RETURN(sbuff, &our_sbuff)
static size_t char ** out