24RCSID(
"$Id: 2268c0bdb4a8b4acdb0868fb01feb2ebad6234bb $")
26#include <freeradius-devel/util/dict_priv.h>
39 uint32_t shift_is_root, shift_internal;
40 uint32_t shift_array, shift_has_value;
45 char const *
name = da->name;
57#define SET_FLAG(_flag) do { shift_ ## _flag = 1 << ++bit; if (flags->_flag) all_flags |= (1 << bit); } while (0)
66#define FORBID_OTHER_FLAGS(_flag, _allowed) \
68 if (all_flags & ~shift_ ## _flag & ~(_allowed)) { \
69 fr_strerror_printf("The '" STRINGIFY(_flag) "' flag cannot be used with any other flag (%u) %s[%d]", all_flags, da->filename, da->line); \
74#define ALLOW_FLAG(_flag) do { all_flags &= ~shift_ ## _flag; } while (0)
91 fr_strerror_const(
"The 'unknown' flag cannot be set for attributes in the dictionary.");
166 "of type 'integer'");
214 fr_strerror_const(
"The 'key' and 'length' flags cannot be used with any other flags.");
225 fr_strerror_const(
"Invalid type (not 'key' field or 'bit' field) for extra flag.");
376 if (dict->string_based)
break;
385 if ((flags->
length != 1) &&
388 fr_strerror_const(
"The 'length' flag can only be used for attributes of type 'vendor' with lengths of 1,2 or 4");
394 if ((flags->
length != 1) &&
397 fr_strerror_const(
"The 'length' flag can only be used for attributes of type 'tlv' with lengths of 1,2 or 4");
421 if (flags->
length > 253) {
430 fr_strerror_printf(
"Attributes of type 'union' must have a parent of type 'struct', not of type '%s'",
470 }
else if (!flags->
extra) {
513 fr_strerror_const(
"Variable-sized fields cannot be used within a 'struct' which is 'array'");
556 if (sibling && !sibling->flags.length && !sibling->flags.is_known_width) {
557 fr_strerror_const(
"No other field can follow a struct MEMBER which is variable sized");
564 if (sibling && sibling->flags.array) {
575 for (i = 1; i < attr; i++) {
585 fr_strerror_printf(
"Duplicate key attributes '%s' and '%s' in 'struct' type attribute %s are forbidden",
642 if (da->dict->proto->attr.valid && !da->dict->proto->attr.valid(da))
return false;
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
unsigned int has_value
Has a value.
unsigned int is_root
Is root of a dictionary.
unsigned int array
Pack multiples into 1 attr.
unsigned int extra
really "subtype is used by dict, not by protocol"
unsigned int internal
Internal attribute, should not be received in protocol packets, should not be encoded.
unsigned int is_raw
This dictionary attribute was constructed from a known attribute to allow the user to assign octets v...
#define da_is_bit_field(_da)
@ FLAG_KEY_FIELD
this is a key field for a subsequent struct
@ FLAG_BIT_FIELD
bit field inside of a struct
#define da_is_length_field(_da)
uint8_t type_size
Type size for TLVs.
uint16_t length
length of the attribute
unsigned int local
is a local variable
@ FR_DICT_ATTR_EXT_REF
Attribute references another attribute and/or dictionary.
@ FR_DICT_ATTR_EXT_KEY
UNION attribute references a key.
unsigned int is_known_width
is treated as if it has a known width for structs
ssize_t fr_dict_valid_name(char const *name, ssize_t len)
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)
uint8_t subtype
needs a fixup during dictionary parsing
unsigned int is_alias
This isn't a real attribute, it's a reference to to one.
unsigned int counter
integer attribute is actually an impulse / counter
unsigned int is_unknown
This dictionary attribute is ephemeral and not part of the main dictionary.
Values of the encryption flags.
static void * fr_dict_attr_ext(fr_dict_attr_t const *da, fr_dict_attr_ext_t ext)
Attribute extension - Holds a reference to an attribute in another dictionary.
#define FORBID_OTHER_FLAGS(_flag, _allowed)
bool dict_attr_flags_valid(fr_dict_attr_t *da)
Validate a set of flags.
bool dict_attr_valid(fr_dict_attr_t *da)
Validate a new attribute definition.
#define ALLOW_FLAG(_flag)
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_FLOAT32
Single precision floating point.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_INT8
8 Bit signed integer.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_ETHERNET
48 Bit Mac-Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_INT64
64 Bit signed integer.
@ FR_TYPE_INT16
16 Bit signed integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_INT32
32 Bit signed integer.
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_SIZE
Unsigned integer capable of representing any memory address on the local system.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
@ FR_TYPE_IFID
Interface ID.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
@ FR_TYPE_FLOAT64
Double precision floating point.
fr_aka_sim_id_type_t type
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
@ FR_TYPE_UNION
A union of limited children.
@ FR_TYPE_ATTR
A contains an attribute reference.
#define fr_type_is_signed(_x)
#define fr_type_is_leaf(_x)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
#define fr_type_is_integer(_x)
#define FR_TYPE_FIXED_SIZE