28 #define _DICT_PRIVATE 1
30 #include <freeradius-devel/protocol/base.h>
31 #include <freeradius-devel/util/dict.h>
32 #include <freeradius-devel/util/dict_ext_priv.h>
33 #include <freeradius-devel/util/dl.h>
34 #include <freeradius-devel/util/hash.h>
35 #include <freeradius-devel/util/value.h>
37 #define DICT_POOL_SIZE (1024 * 1024 * 2)
38 #define DICT_FIXUP_POOL_SIZE (1024)
45 #define INTERNAL_IF_NULL(_dict, _ret) \
48 _dict = dict_gctx ? dict_gctx->internal : NULL; \
49 if (unlikely(!(_dict))) { \
50 fr_strerror_const("No dictionaries available for attribute resolution"); \
175 char const *
name,
int attr,
180 char const *
name,
int attr,
bool(* fr_dict_attr_valid_func_t)(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, fr_dict_attr_flags_t *flags)
fr_dict_attr_err_t
Errors returned by attribute lookup functions.
Values of the encryption flags.
Protocol-specific callbacks in libfreeradius-PROTOCOL.
fr_dict_attr_t * root
Root attribute of this dictionary.
bool loaded
from fr_dict_protocol_afrom_file();
fr_dict_attr_t ** fixups
Attributes that need fixing up.
char * dict_dir_default
The default location for loading dictionaries if one wasn't provided.
fr_dict_t const * next
for attribute overloading
fr_hash_table_t * protocol_by_name
Hash containing names of all the registered protocols.
bool read_only
If true, disallow modifications.
fr_dict_attr_valid_func_t attr_valid
validation function for new attributes
fr_dict_t * dict_by_da(fr_dict_attr_t const *da)
Internal version of fr_dict_by_da.
int default_type_size
for TLVs and VSAs
fr_slen_t dict_by_protocol_substr(fr_dict_attr_err_t *err, fr_dict_t **out, fr_sbuff_t *name, fr_dict_t const *dict_def)
fr_hash_table_t * vendors_by_name
Lookup vendor by name.
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_attr_t * dict_attr_alloc_null(TALLOC_CTX *ctx)
Allocate a partially completed attribute.
TALLOC_CTX * pool
Talloc memory pool to reduce allocs.
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.
fr_rb_tree_t * dependents
Which files are using this dictionary.
fr_hash_table_t * protocol_by_num
Hash containing numbers of all the registered protocols.
bool dict_attr_can_have_children(fr_dict_attr_t const *da)
See if a fr_dict_attr_t can have children.
int dict_attr_init(fr_dict_attr_t **da_p, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, dict_attr_args_t const *args)
Initialise fields in a dictionary attribute structure.
bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, UNUSED char const *name, int *attr, fr_type_t type, fr_dict_attr_flags_t *flags))
fr_dict_t * dict_by_protocol_num(unsigned int num)
Internal version of fr_dict_by_protocol_num.
fr_dict_protocol_t const * proto
protocol-specific validation functions
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.
fr_dict_attr_flags_t const * flags
Any flags to assign to the attribute.
bool loading
from fr_dict_protocol_afrom_file();
fr_dict_t * dict_by_protocol_name(char const *name)
Internal version of fr_dict_by_protocol_name.
int dict_attr_child_add(fr_dict_attr_t *parent, fr_dict_attr_t *child)
Add a child to a parent.
int dict_dependent_remove(fr_dict_t *dict, char const *dependent)
Decrement ref count for a dependent in a dictionary.
fr_dict_t * dict_alloc(TALLOC_CTX *ctx)
Allocate a new dictionary.
int dict_vendor_add(fr_dict_t *dict, char const *name, unsigned int num)
Add a vendor to the dictionary.
dl_loader_t * dict_loader
for protocol validation
fr_dict_gctx_t * gctx
Global dictionary context this dictionary was allocated in.
fr_dict_attr_t * dict_attr_child_by_num(fr_dict_attr_t const *parent, unsigned int attr)
Internal version of fr_dict_attr_child_by_num.
unsigned int vsa_parent
varies with different protocols
char const * dependent
File holding the reference.
fr_hash_table_t * vendors_by_num
Lookup vendor by PEN.
int dict_dlopen(fr_dict_t *dict, char const *name)
fr_dict_attr_t const * attr_protocol_encapsulation
int default_type_length
for TLVs and VSAs
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.
bool in_protocol_by_num
Whether the dictionary has been inserted into the protocol_by_num table.
bool string_based
TACACS, etc.
fr_table_num_ordered_t const * subtype_table
table of subtypes for this protocol
bool free_at_exit
This gctx will be freed on exit.
int dict_dependent_add(fr_dict_t *dict, char const *dependent)
Record a new dependency on a dictionary.
fr_dict_attr_t * dict_attr_alloc(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, dict_attr_args_t const *args)
Allocate a dictionary attribute on the heap.
fr_dict_attr_t const * ref
This attribute is a reference to another attribute.
int dict_protocol_add(fr_dict_t *dict)
Add a protocol to the global protocol table.
bool dict_has_dependents(fr_dict_t *dict)
Check if a dictionary still has dependents.
fr_dict_gctx_t * dict_gctx
Top level structure containing global dictionary state.
int dict_attr_acopy_enumv(fr_dict_attr_t *dst, fr_dict_attr_t const *src)
Copy the VALUEs of an existing attribute, by casting them.
bool perm_check
Whether we should check dictionary file permissions as they're loaded.
fr_dict_attr_t * dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *name)
bool in_protocol_by_name
Whether the dictionary has been inserted into the protocol_by_name hash.
int count
How many references are held by this file.
bool dict_attr_fields_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int *attr, fr_type_t type, fr_dict_attr_flags_t *flags)
Validate a new attribute definition.
size_t subtype_table_len
length of table of subtypes for this protocol
fr_hash_table_t * autoref
other dictionaries that we loaded via references
Optional arguments for initialising/allocating attributes.
Vendors and attribute names.
Entry recording dictionary reference holders by file.
The main red black tree structure.
fr_aka_sim_id_type_t type
An element in an arbitrarily ordered array of name to num mappings.
static size_t char ** out