24 RCSID(
"$Id: 8e84b99e5d52354d614a68bc89a91430d3c14885 $")
26 #include <freeradius-devel/util/dict_priv.h>
39 uint32_t shift_is_root, shift_internal;
40 uint32_t shift_array, shift_has_value;
46 char const *
name = da->name;
58 #define SET_FLAG(_flag) do { shift_ ## _flag = 1 << ++bit; if (flags->_flag) all_flags |= (1 << bit); } while (0)
67 #define FORBID_OTHER_FLAGS(_flag, _allowed) \
69 if (all_flags & ~shift_ ## _flag & ~(_allowed)) { \
70 fr_strerror_printf("The '" STRINGIFY(_flag) "' flag cannot be used with any other flag (%u) %s[%u]", all_flags, da->filename, da->line); \
75 #define ALLOW_FLAG(_flag) do { all_flags &= ~shift_ ## _flag; } while (0)
92 fr_strerror_const(
"The 'unknown' flag cannot be set for attributes in the dictionary.");
96 if (flags->local !=
parent->flags.local) {
158 "of type 'integer'");
172 fr_strerror_const(
"The 'key' and 'length' flags cannot be used with any other flags.");
183 fr_strerror_const(
"Invalid type (not 'key' field or 'bit' field) for extra flag.");
335 if ((flags->
length != 1) &&
338 fr_strerror_const(
"The 'length' flag can only be used for attributes of type 'vendor' with lengths of 1,2 or 4");
364 if ((flags->
length != 1) &&
367 fr_strerror_const(
"The 'length' flag can only be used for attributes of type 'tlv' with lengths of 1,2 or 4");
378 for (v =
parent; v != NULL; v = v->parent) {
398 flags->
length = v->flags.length;
420 if (flags->
length > 253) {
444 }
else if (!flags->
extra) {
446 fr_strerror_const(
"The 'format=' flag can only be used with attributes of type 'tlv'");
453 fr_strerror_const(
"The 'format=' flag can only be used with attributes of type size 1,2 or 4");
482 fr_strerror_const(
"Variable-sized fields cannot be used within a 'struct' which is 'array'");
525 if (sibling && !sibling->flags.length && !sibling->flags.is_known_width) {
526 fr_strerror_const(
"No other field can follow a struct MEMBER which is variable sized");
533 if (sibling && sibling->flags.array) {
544 for (i = 1; i < attr; i++) {
554 fr_strerror_printf(
"Duplicate key attributes '%s' and '%s' in 'struct' type attribute %s are forbidden",
613 if (da->dict->proto->attr.valid && !da->dict->proto->attr.valid(da))
return false;
#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.
size_t type
Length of type data.
@ FLAG_LENGTH_UINT8
string / octets type is prefixed by uint8 of length
@ FLAG_LENGTH_UINT16
string / octets type is prefixed by uint16 of length
@ FLAG_KEY_FIELD
this is a key field for a subsequent struct
@ FLAG_BIT_FIELD
bit field inside of a struct
unsigned int has_value
Has a value.
fr_dict_vendor_t const * fr_dict_vendor_by_num(fr_dict_t const *dict, uint32_t vendor_pen)
Look up a vendor by its PEN.
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.
uint8_t type_size
For TLV2 and root attributes.
size_t length
Length of length data.
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
protocol-specific values, OR key fields
uint8_t length
length of the attribute
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.
#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_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_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_FLOAT64
Double precision floating point.
static size_t array[MY_ARRAY_SIZE]
fr_aka_sim_id_type_t type
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#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_is_signed(_x)
#define fr_type_is_integer(_x)
#define FR_TYPE_FIXED_SIZE