The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Multi-protocol AVP dictionary API. More...
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/util/dict_ext_priv.h>
#include <freeradius-devel/util/dict_fixup_priv.h>
#include <freeradius-devel/util/dict_ext.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/util/hash.h>
#include <freeradius-devel/util/proto.h>
#include <freeradius-devel/util/rand.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/talloc.h>
Go to the source code of this file.
Data Structures | |
struct | fr_dict_autoload_talloc_s |
Structure used to managed the lifetime of a dictionary. More... | |
Macros | |
#define | _DICT_PRIVATE 1 |
#define | DICT_NAME_APPEND(_in, _dict) |
#define | FNV_MAGIC_INIT (0x811c9dc5) |
#define | FNV_MAGIC_PRIME (0x01000193) |
Typedefs | |
typedef fr_slen_t(* | dict_attr_resolve_func_t) (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_sbuff_term_t const *tt) |
Callback function for resolving dictionary attributes. More... | |
Functions | |
fr_dict_attr_t * | _dict_attr_alloc (char const *filename, int line, 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. More... | |
fr_dict_attr_t * | _dict_attr_alloc_root (char const *filename, int line, TALLOC_CTX *ctx, fr_dict_t const *dict, char const *name, int proto_number, dict_attr_args_t const *args) |
Allocate a dictionary root attribute on the heap. More... | |
static int | _dict_attr_free (fr_dict_attr_t *da) |
int | _dict_attr_init (char const *filename, int line, fr_dict_attr_t **da_p, fr_dict_attr_t const *parent, char const *name, unsigned int attr, fr_type_t type, dict_attr_args_t const *args) |
Initialise fields in a dictionary attribute structure. More... | |
int | _dict_attr_init_name_only (char const *filename, int line, fr_dict_attr_t **da_p, fr_dict_attr_t const *parent, char const *name, fr_type_t type, dict_attr_args_t const *args) |
Initialise fields in a dictionary attribute structure. More... | |
static int8_t | _dict_dependent_cmp (void const *a, void const *b) |
Find a dependent in the tree of dependents. More... | |
static int | _dict_free (fr_dict_t *dict) |
static int | _dict_global_free (fr_dict_gctx_t *gctx) |
static int | _dict_global_free_at_exit (void *uctx) |
int | _fr_dict_autofree (fr_dict_autoload_t const *to_free, char const *dependent) |
Decrement the reference count on a previously loaded dictionary. More... | |
int | _fr_dict_autoload (fr_dict_autoload_t const *to_load, char const *dependent) |
Process a dict_autoload element to load a protocol. More... | |
fr_dict_autoload_talloc_t * | _fr_dict_autoload_talloc (TALLOC_CTX *ctx, fr_dict_t const **out, char const *proto, char const *dependent) |
Autoload a dictionary and bind the lifetime to a talloc chunk. More... | |
static int | _fr_dict_autoload_talloc_free (fr_dict_autoload_talloc_t const *to_free) |
Talloc destructor to automatically free dictionaries. More... | |
static void | dependent_debug (fr_dict_t *dict) |
fr_dict_t * | dict_alloc (TALLOC_CTX *ctx) |
Allocate a new dictionary. More... | |
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. More... | |
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. More... | |
static fr_dict_attr_t * | dict_attr_acopy_dict (TALLOC_CTX *ctx, fr_dict_attr_t *parent, fr_dict_attr_t const *in) |
Copy an existing attribute to a different dictionary. More... | |
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. More... | |
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. More... | |
static fr_dict_attr_t const * | dict_attr_alias (fr_dict_attr_err_t *err, fr_dict_attr_t const *da) |
Resolve an alias attribute to the concrete attribute it points to. More... | |
int | dict_attr_alias_add (fr_dict_attr_t const *parent, char const *alias, fr_dict_attr_t const *ref) |
Add an alias to an existing attribute. More... | |
fr_dict_attr_t * | dict_attr_alloc_null (TALLOC_CTX *ctx, fr_dict_protocol_t const *proto) |
Allocate a partially completed attribute. More... | |
fr_dict_attr_t * | dict_attr_by_name (fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *name) |
bool | dict_attr_can_have_children (fr_dict_attr_t const *da) |
See if a fr_dict_attr_t can have children. More... | |
int | dict_attr_child_add (fr_dict_attr_t *parent, fr_dict_attr_t *child) |
Add a child to a parent. More... | |
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. More... | |
static int | dict_attr_children_init (fr_dict_attr_t **da_p) |
Add a child/nesting extension to an attribute. More... | |
static int | dict_attr_da_stack_set (fr_dict_attr_t **da_p) |
Initialise an attribute's da stack from its parent. More... | |
int | dict_attr_enum_add_name (fr_dict_attr_t *da, char const *name, fr_value_box_t const *value, bool coerce, bool takes_precedence, fr_dict_attr_t const *child_struct) |
static int | dict_attr_enumv_init (fr_dict_attr_t **da_p) |
Initialise a per-attribute enumeration table. More... | |
int | dict_attr_finalise (fr_dict_attr_t **da_p, char const *name) |
Set remaining fields in a dictionary attribute before insertion. More... | |
static int | dict_attr_init_common (char const *filename, int line, fr_dict_attr_t **da_p, fr_dict_attr_t const *parent, fr_type_t type, dict_attr_args_t const *args) |
void | dict_attr_location_init (fr_dict_attr_t *da, char const *filename, int line) |
Set where the dictionary attribute was defined. More... | |
static int8_t | dict_attr_name_cmp (void const *one, void const *two) |
Compare two attribute names. More... | |
static uint32_t | dict_attr_name_hash (void const *data) |
Wrap name hash function for fr_dict_attr_t. More... | |
static int | dict_attr_name_set (fr_dict_attr_t **da_p, char const *name) |
Set a dictionary attribute's name. More... | |
static int | dict_attr_namespace_init (fr_dict_attr_t **da_p) |
Initialise a per-attribute namespace. More... | |
int | dict_attr_num_init (fr_dict_attr_t *da, unsigned int num) |
Set the attribute number (if any) More... | |
int | dict_attr_num_init_name_only (fr_dict_attr_t *da) |
Set the attribute number (if any) More... | |
int | dict_attr_parent_init (fr_dict_attr_t **da_p, fr_dict_attr_t const *parent) |
Initialise fields which depend on a parent attribute. More... | |
static fr_slen_t | dict_attr_search (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_t const *dict_def, fr_sbuff_t *in, fr_sbuff_term_t const *tt, bool internal, bool foreign, dict_attr_resolve_func_t func) |
Internal function for searching for attributes in multiple dictionaries. More... | |
static fr_slen_t | dict_attr_search_qualified (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_t const *dict_def, fr_sbuff_t *in, fr_sbuff_term_t const *tt, bool internal, bool foreign, dict_attr_resolve_func_t func) |
Internal function for searching for attributes in multiple dictionaries. More... | |
int | dict_attr_type_init (fr_dict_attr_t **da_p, fr_type_t type) |
Initialise type specific fields within the dictionary attribute. More... | |
static int | dict_attr_vendor_set (fr_dict_attr_t **da_p, fr_dict_attr_t const *vendor) |
Cache the vendor pointer for an attribute. More... | |
static int | dict_autoref_free (fr_dict_t *dict) |
fr_dict_t * | dict_by_da (fr_dict_attr_t const *da) |
Internal version of fr_dict_by_da. More... | |
fr_dict_t * | dict_by_protocol_name (char const *name) |
Internal version of fr_dict_by_protocol_name. More... | |
fr_dict_t * | dict_by_protocol_num (unsigned int num) |
Internal version of fr_dict_by_protocol_num. More... | |
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) |
int | dict_dependent_add (fr_dict_t *dict, char const *dependent) |
Record a new dependency on a dictionary. More... | |
int | dict_dependent_remove (fr_dict_t *dict, char const *dependent) |
Decrement ref count for a dependent in a dictionary. More... | |
int | dict_dlopen (fr_dict_t *dict, char const *name) |
static int8_t | dict_enum_name_cmp (void const *one, void const *two) |
Compare two dictionary attribute enum values. More... | |
static uint32_t | dict_enum_name_hash (void const *data) |
Hash a enumeration name. More... | |
static int8_t | dict_enum_value_cmp (void const *one, void const *two) |
Compare two dictionary enum values. More... | |
static uint32_t | dict_enum_value_hash (void const *data) |
Hash a dictionary enum value. More... | |
bool | dict_has_dependents (fr_dict_t *dict) |
Check if a dictionary still has dependents. More... | |
static uint32_t | dict_hash_name (char const *name, size_t len) |
Apply a simple (case insensitive) hashing function to the name of an attribute, vendor or protocol. More... | |
int | dict_protocol_add (fr_dict_t *dict) |
Add a protocol to the global protocol table. More... | |
static int8_t | dict_protocol_name_cmp (void const *one, void const *two) |
Compare two protocol names. More... | |
static uint32_t | dict_protocol_name_hash (void const *data) |
Wrap name hash function for fr_dict_protocol_t. More... | |
static int8_t | dict_protocol_num_cmp (void const *one, void const *two) |
Compare two protocol numbers. More... | |
static uint32_t | dict_protocol_num_hash (void const *data) |
Hash a protocol number. More... | |
int | dict_vendor_add (fr_dict_t *dict, char const *name, unsigned int num) |
Add a vendor to the dictionary. More... | |
static int8_t | dict_vendor_name_cmp (void const *one, void const *two) |
Compare two attribute names. More... | |
static uint32_t | dict_vendor_name_hash (void const *data) |
Wrap name hash function for fr_dict_vendor_t. More... | |
static int8_t | dict_vendor_pen_cmp (void const *one, void const *two) |
Compare two vendor numbers. More... | |
static uint32_t | dict_vendor_pen_hash (void const *data) |
Hash a vendor number. More... | |
static int | dict_walk (fr_dict_attr_t const *da, fr_dict_walk_t callback, void *uctx) |
Call the specified callback for da and then for all its children. More... | |
int | fr_dict_attr_acopy_local (fr_dict_attr_t const *dst, fr_dict_attr_t const *src) |
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. More... | |
int | fr_dict_attr_add_initialised (fr_dict_attr_t *da) |
A variant of fr_dict_attr_t that allows a pre-allocated, populated fr_dict_attr_t to be added. More... | |
int | fr_dict_attr_add_name_only (fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, fr_type_t type, fr_dict_attr_flags_t const *flags) |
Add an attribute to the dictionary. More... | |
int | fr_dict_attr_autoload (fr_dict_attr_autoload_t const *to_load) |
Process a dict_attr_autoload element to load/verify a dictionary attribute. More... | |
fr_dict_attr_t const * | fr_dict_attr_by_name (fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *name) |
Locate a fr_dict_attr_t by its name. More... | |
fr_slen_t | fr_dict_attr_by_name_substr (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *name, UNUSED fr_sbuff_term_t const *tt) |
Look up a dictionary attribute by a name embedded in another string. More... | |
fr_dict_attr_t const * | fr_dict_attr_by_oid (fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *oid) |
Resolve an attribute using an OID string. More... | |
ssize_t | fr_dict_attr_by_oid_legacy (fr_dict_t const *dict, fr_dict_attr_t const **parent, unsigned int *attr, char const *oid) |
Get the leaf attribute of an OID string. More... | |
fr_slen_t | fr_dict_attr_by_oid_substr (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_sbuff_term_t const *tt) |
Resolve an attribute using an OID string. More... | |
bool | fr_dict_attr_can_contain (fr_dict_attr_t const *parent, fr_dict_attr_t const *child) |
See if a structural da is allowed to contain another da. More... | |
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. More... | |
fr_dict_attr_t const * | fr_dict_attr_common_parent (fr_dict_attr_t const *a, fr_dict_attr_t const *b, bool is_ancestor) |
Find a common ancestor that two TLV type attributes share. More... | |
fr_dict_attr_t const * | fr_dict_attr_iterate_children (fr_dict_attr_t const *parent, fr_dict_attr_t const **prev) |
Iterate over children of a DA. More... | |
fr_slen_t | fr_dict_attr_search_by_name_substr (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_t const *dict_def, fr_sbuff_t *name, fr_sbuff_term_t const *tt, bool internal, bool foreign) |
Locate a fr_dict_attr_t by its name in the top level namespace of a dictionary. More... | |
fr_slen_t | fr_dict_attr_search_by_oid_substr (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_t const *dict_def, fr_sbuff_t *in, fr_sbuff_term_t const *tt, bool internal, bool foreign) |
Locate a qualified fr_dict_attr_t by a dictionary using a non-qualified OID string. More... | |
fr_slen_t | fr_dict_attr_search_by_qualified_name_substr (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_t const *dict_def, fr_sbuff_t *name, fr_sbuff_term_t const *tt, bool internal, bool foreign) |
Locate a qualified fr_dict_attr_t by its name and a dictionary qualifier. More... | |
fr_dict_attr_t const * | fr_dict_attr_search_by_qualified_oid (fr_dict_attr_err_t *err, fr_dict_t const *dict_def, char const *name, bool internal, bool foreign) |
Locate a qualified fr_dict_attr_t by its name and a dictionary qualifier. More... | |
fr_slen_t | fr_dict_attr_search_by_qualified_oid_substr (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_t const *dict_def, fr_sbuff_t *in, fr_sbuff_term_t const *tt, bool internal, bool foreign) |
Locate a qualified fr_dict_attr_t by a dictionary qualified OID string. More... | |
fr_dict_attr_t * | fr_dict_attr_unconst (fr_dict_attr_t const *da) |
Coerce to non-const. More... | |
void | fr_dict_attr_verify (char const *file, int line, fr_dict_attr_t const *da) |
fr_dict_t const * | fr_dict_by_da (fr_dict_attr_t const *da) |
Attempt to locate the protocol dictionary containing an attribute. More... | |
fr_dict_t const * | fr_dict_by_protocol_name (char const *name) |
Lookup a protocol by its name. More... | |
fr_dict_t const * | fr_dict_by_protocol_num (unsigned int num) |
Lookup a protocol by its number. More... | |
fr_slen_t | fr_dict_by_protocol_substr (fr_dict_attr_err_t *err, fr_dict_t const **out, fr_sbuff_t *name, fr_dict_t const *dict_def) |
Look up a protocol name embedded in another string. More... | |
bool | fr_dict_compatible (fr_dict_t const *dict1, fr_dict_t const *dict2) |
See if two dictionaries have the same end parent. More... | |
int | fr_dict_const_free (fr_dict_t const **dict, char const *dependent) |
Decrement the reference count on a previously loaded dictionary. More... | |
int | fr_dict_dependent_add (fr_dict_t const *dict, char const *dependent) |
Manually increase the reference count for a dictionary. More... | |
dl_t * | fr_dict_dl (fr_dict_t const *dict) |
int | fr_dict_enum_add_name (fr_dict_attr_t *da, char const *name, fr_value_box_t const *value, bool coerce, bool takes_precedence) |
Add a value name. More... | |
int | fr_dict_enum_add_name_next (fr_dict_attr_t *da, char const *name) |
Add an name to an integer attribute hashing the name for the integer value. More... | |
int | fr_dict_enum_autoload (fr_dict_enum_autoload_t const *to_load) |
Process a dict_attr_autoload element to load/verify a dictionary attribute. More... | |
fr_dict_enum_value_t * | fr_dict_enum_by_name (fr_dict_attr_t const *da, char const *name, ssize_t len) |
fr_slen_t | fr_dict_enum_by_name_substr (fr_dict_enum_value_t **out, fr_dict_attr_t const *da, fr_sbuff_t *in) |
fr_dict_enum_value_t * | fr_dict_enum_by_value (fr_dict_attr_t const *da, fr_value_box_t const *value) |
Lookup the structure representing an enum value in a fr_dict_attr_t. More... | |
char const * | fr_dict_enum_name_by_value (fr_dict_attr_t const *da, fr_value_box_t const *value) |
Lookup the name of an enum value in a fr_dict_attr_t. More... | |
fr_slen_t | fr_dict_enum_name_from_substr (fr_sbuff_t *out, fr_sbuff_parse_error_t *err, fr_sbuff_t *in, fr_sbuff_term_t const *tt) |
Extract an enumeration name from a string. More... | |
int | fr_dict_free (fr_dict_t **dict, char const *dependent) |
Decrement the reference count on a previously loaded dictionary. More... | |
void | fr_dict_global_ctx_debug (fr_dict_gctx_t const *gctx) |
Dump information about currently loaded dictionaries. More... | |
char const * | fr_dict_global_ctx_dir (void) |
int | fr_dict_global_ctx_dir_set (char const *dict_dir) |
Allow the default dict dir to be changed after initialisation. More... | |
int | fr_dict_global_ctx_free (fr_dict_gctx_t const *gctx) |
Explicitly free all data associated with a global dictionary context. More... | |
fr_dict_gctx_t * | fr_dict_global_ctx_init (TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir) |
Initialise the global protocol hashes. More... | |
fr_dict_t * | fr_dict_global_ctx_iter_init (fr_dict_global_ctx_iter_t *iter) |
Iterate protocols by name. More... | |
fr_dict_t * | fr_dict_global_ctx_iter_next (fr_dict_global_ctx_iter_t *iter) |
void | fr_dict_global_ctx_perm_check (fr_dict_gctx_t *gctx, bool enable) |
Set whether we check dictionary file permissions. More... | |
void | fr_dict_global_ctx_read_only (void) |
Mark all dictionaries and the global dictionary ctx as read only. More... | |
void | fr_dict_global_ctx_set (fr_dict_gctx_t const *gctx) |
Set a new, active, global dictionary context. More... | |
fr_dict_t const * | fr_dict_internal (void) |
bool | fr_dict_is_read_only (fr_dict_t const *dict) |
fr_slen_t | fr_dict_oid_component (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_sbuff_term_t const *tt) |
Parse an OID component, resolving it to a defined attribute. More... | |
int | fr_dict_oid_component_legacy (unsigned int *out, char const **oid) |
Process a single OID component. More... | |
fr_dict_protocol_t const * | fr_dict_protocol (fr_dict_t const *dict) |
Return the protocol descriptor for the dictionary. More... | |
fr_dict_t * | fr_dict_protocol_alloc (fr_dict_t const *parent) |
Allocate a new local dictionary. More... | |
fr_dict_attr_t const * | fr_dict_root (fr_dict_t const *dict) |
Return the root attribute of a dictionary. More... | |
fr_dict_t * | fr_dict_unconst (fr_dict_t const *dict) |
Coerce to non-const. More... | |
fr_dict_attr_t const * | fr_dict_unlocal (fr_dict_attr_t const *da) |
ssize_t | fr_dict_valid_name (char const *name, ssize_t len) |
ssize_t | fr_dict_valid_oid_str (char const *name, ssize_t len) |
fr_dict_vendor_t const * | fr_dict_vendor_by_da (fr_dict_attr_t const *da) |
Look up a vendor by one of its child attributes. More... | |
fr_dict_vendor_t const * | fr_dict_vendor_by_name (fr_dict_t const *dict, char const *name) |
Look up a vendor by its name. More... | |
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. More... | |
fr_dict_attr_t const * | fr_dict_vendor_da_by_num (fr_dict_attr_t const *vendor_root, uint32_t vendor_pen) |
Return vendor attribute for the specified dictionary and pen. More... | |
int | fr_dict_walk (fr_dict_attr_t const *da, fr_dict_walk_t callback, void *uctx) |
int | fr_dl_dict_attr_autoload (UNUSED dl_t const *module, void *symbol, UNUSED void *user_ctx) |
Callback to automatically resolve attributes and check the types are correct. More... | |
void | fr_dl_dict_autofree (UNUSED dl_t const *module, void *symbol, UNUSED void *user_ctx) |
Callback to automatically free a dictionary when the module is unloaded. More... | |
int | fr_dl_dict_autoload (UNUSED dl_t const *module, void *symbol, UNUSED void *user_ctx) |
Callback to automatically load dictionaries required by modules. More... | |
int | fr_dl_dict_enum_autoload (UNUSED dl_t const *module, void *symbol, UNUSED void *user_ctx) |
Callback to automatically resolve enum values. More... | |
static void | hash_pool_free (void *to_free) |
Variables | |
fr_dict_gctx_t * | dict_gctx = NULL |
Top level structure containing global dictionary state. More... | |
static fr_dict_protocol_t | dict_proto_default |
Default protocol rules set for every dictionary. More... | |
bool const | fr_dict_attr_allowed_chars [UINT8_MAX+1] |
Characters allowed in dictionary names. More... | |
bool const | fr_dict_enum_allowed_chars [UINT8_MAX+1] |
Characters allowed in enumeration value names. More... | |
Multi-protocol AVP dictionary API.
Definition in file dict_util.c.
struct fr_dict_autoload_talloc_s |
Structure used to managed the lifetime of a dictionary.
This should only be used when dictionaries are being dynamically loaded during compilation. It should not be used to load dictionaries at runtime, or if modules need to load dictionaries (use static fr_dict_autoload_t defs).
Definition at line 4196 of file dict_util.c.
Data Fields | ||
---|---|---|
char const * | dependent | Dependent that loaded the dictionary. |
fr_dict_autoload_t | load[2] | Autoloader def. |
#define _DICT_PRIVATE 1 |
Definition at line 26 of file dict_util.c.
#define DICT_NAME_APPEND | ( | _in, | |
_dict | |||
) |
#define FNV_MAGIC_INIT (0x811c9dc5) |
Definition at line 107 of file dict_util.c.
#define FNV_MAGIC_PRIME (0x01000193) |
Definition at line 108 of file dict_util.c.
typedef fr_slen_t(* dict_attr_resolve_func_t) (fr_dict_attr_err_t *err, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_sbuff_term_t const *tt) |
Callback function for resolving dictionary attributes.
[out] | err | Where to write error codes. Any error other than FR_DICT_ATTR_NOTFOUND will prevent resolution from continuing. |
[out] | out | Where to write resolved DA. |
[in] | parent | The dictionary root or other attribute to search from. |
[in] | in | Contains the string to resolve. |
[in] | tt | Terminal sequences to use to determine the portion of in to search. |
Definition at line 2740 of file dict_util.c.
fr_dict_attr_t* _dict_attr_alloc | ( | char const * | filename, |
int | line, | ||
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.
[in] | ctx | to allocate the attribute in. |
[in] | parent | of the attribute. |
[in] | name | of the attribute. If NULL an OID string will be created and set as the name. |
[in] | attr | number. |
[in] | type | of the attribute. |
[in] | args | optional initialisation arguments. |
Definition at line 988 of file dict_util.c.
fr_dict_attr_t* _dict_attr_alloc_root | ( | char const * | filename, |
int | line, | ||
TALLOC_CTX * | ctx, | ||
fr_dict_t const * | dict, | ||
char const * | name, | ||
int | proto_number, | ||
dict_attr_args_t const * | args | ||
) |
Allocate a dictionary root attribute on the heap.
[in] | ctx | to allocate the attribute in. |
[in] | dict | the attribute will be used in. |
[in] | name | of the attribute. If NULL an OID string will be created and set as the name. |
[in] | proto_number | number. This should be |
[in] | args | optional initialisation arguments. |
Definition at line 956 of file dict_util.c.
|
static |
Definition at line 883 of file dict_util.c.
int _dict_attr_init | ( | char const * | filename, |
int | line, | ||
fr_dict_attr_t ** | da_p, | ||
fr_dict_attr_t const * | parent, | ||
char const * | name, | ||
unsigned int | attr, | ||
fr_type_t | type, | ||
dict_attr_args_t const * | args | ||
) |
Initialise fields in a dictionary attribute structure.
This function is a wrapper around the other initialisation functions.
The reason for the separation, is that sometimes we're initialising a dictionary attribute by parsing an actual dictionary file, and other times we're copying attribute, or initialising them programatically.
This function should only be used for the second case, where we have a complet attribute definition already.
[in] | filename | file. |
[in] | line | number. |
[in] | da_p | to initialise. |
[in] | parent | of the attribute, if none, this attribute will be initialised as a dictionary root. |
[in] | name | of attribute. Pass NULL for auto-generated name. |
[in] | attr | number. |
[in] | type | of the attribute. |
[in] | args | optional initialisation arguments. |
Definition at line 824 of file dict_util.c.
int _dict_attr_init_name_only | ( | char const * | filename, |
int | line, | ||
fr_dict_attr_t ** | da_p, | ||
fr_dict_attr_t const * | parent, | ||
char const * | name, | ||
fr_type_t | type, | ||
dict_attr_args_t const * | args | ||
) |
Initialise fields in a dictionary attribute structure.
This function is a wrapper around the other initialisation functions.
The reason for the separation, is that sometimes we're initialising a dictionary attribute by parsing an actual dictionary file, and other times we're copying attribute, or initialising them programatically.
This function should only be used for the second case, where we have a complet attribute definition already.
[in] | filename | file. |
[in] | line | number. |
[in] | da_p | to initialise. |
[in] | parent | of the attribute, if none, this attribute will be initialised as a dictionary root. |
[in] | name | of attribute. Pass NULL for auto-generated name. automatically generated. |
[in] | type | of the attribute. |
[in] | args | optional initialisation arguments. |
Definition at line 865 of file dict_util.c.
|
static |
Find a dependent in the tree of dependents.
Definition at line 3627 of file dict_util.c.
|
static |
Definition at line 3789 of file dict_util.c.
|
static |
Definition at line 4316 of file dict_util.c.
|
static |
Definition at line 4311 of file dict_util.c.
int _fr_dict_autofree | ( | fr_dict_autoload_t const * | to_free, |
char const * | dependent | ||
) |
Decrement the reference count on a previously loaded dictionary.
[in] | to_free | previously loaded dictionary to free. |
[in] | dependent | that originally allocated this dictionary |
Definition at line 4172 of file dict_util.c.
int _fr_dict_autoload | ( | fr_dict_autoload_t const * | to_load, |
char const * | dependent | ||
) |
Process a dict_autoload element to load a protocol.
[in] | to_load | dictionary definition. |
[in] | dependent | that is loading this dictionary. |
Definition at line 4139 of file dict_util.c.
fr_dict_autoload_talloc_t* _fr_dict_autoload_talloc | ( | TALLOC_CTX * | ctx, |
fr_dict_t const ** | out, | ||
char const * | proto, | ||
char const * | dependent | ||
) |
Autoload a dictionary and bind the lifetime to a talloc chunk.
Mainly useful for resolving "forward" references from unlang immediately.
[in] | ctx | to bind the dictionary lifetime to. |
[out] | out | pointer to the loaded dictionary. |
[in] | proto | to load. |
[in] | dependent | to register this reference to. Will be dupd. |
Definition at line 4223 of file dict_util.c.
|
static |
Talloc destructor to automatically free dictionaries.
[in] | to_free | dictionary autoloader definition describing the dictionary to free. |
Definition at line 4205 of file dict_util.c.
|
static |
fr_dict_t* dict_alloc | ( | TALLOC_CTX * | ctx | ) |
Allocate a new dictionary.
[in] | ctx | to allocate dictionary in. |
Definition at line 3872 of file dict_util.c.
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.
[in] | ctx | to allocate new attribute in. |
[in] | in | attribute to copy. |
[in] | new_name | to assign to the attribute. If NULL the existing name will be used. |
Definition at line 1017 of file dict_util.c.
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.
[in] | dict | to allocate the children in |
[in] | dst | where to copy the children to |
[in] | src | where to copy the children from |
Definition at line 1087 of file dict_util.c.
|
static |
Copy an existing attribute to a different dictionary.
[in] | ctx | to allocate new attribute in. |
[in] | parent | new parent to copy into |
[in] | in | attribute to copy. |
Definition at line 1043 of file dict_util.c.
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.
[in] | dst | where to cast the VALUEs to |
[in] | src | where to cast the VALUEs from |
Definition at line 1145 of file dict_util.c.
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.
[in] | parent | containing the namespace to add this attribute to. |
[in] | da | to add to the name lookup tables. |
Definition at line 1524 of file dict_util.c.
|
inlinestatic |
Resolve an alias attribute to the concrete attribute it points to.
[out] | err | where to write the error (if any). |
[in] | da | to resolve. |
Definition at line 321 of file dict_util.c.
int dict_attr_alias_add | ( | fr_dict_attr_t const * | parent, |
char const * | alias, | ||
fr_dict_attr_t const * | ref | ||
) |
Add an alias to an existing attribute.
Definition at line 1174 of file dict_util.c.
fr_dict_attr_t* dict_attr_alloc_null | ( | TALLOC_CTX * | ctx, |
fr_dict_protocol_t const * | proto | ||
) |
Allocate a partially completed attribute.
Partial initialisation functions.
This is useful in some instances where we need to pre-allocate the attribute for talloc hierarchy reasons, but want to finish initialising it with dict_attr_init later.
[in] | ctx | to allocate attribute in. |
[in] | proto | protocol specific extensions. |
Definition at line 917 of file dict_util.c.
fr_dict_attr_t* dict_attr_by_name | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const * | parent, | ||
char const * | name | ||
) |
Definition at line 3217 of file dict_util.c.
bool dict_attr_can_have_children | ( | fr_dict_attr_t const * | da | ) |
See if a fr_dict_attr_t can have children.
The check for children is complicated by the need for "int" types to have children, when they are key
fields in a struct
. This situation occurs when a struct has multiple sub-structures, which are selected based on a key
field.
There is no other place for the sub-structures to go. In the future, we may extend the functionality of the key
field, by allowing non-integer data types. That would require storing keys as fr_dict_enum_value_t, and then placing the child (i.e. sub) structures there. But that would involve adding children to enums, which is currently not supported.
da | the dictionary attribute to check. |
Definition at line 1391 of file dict_util.c.
int dict_attr_child_add | ( | fr_dict_attr_t * | parent, |
fr_dict_attr_t * | child | ||
) |
Add a child to a parent.
[in] | parent | we're adding a child to. |
[in] | child | to add to parent. |
Definition at line 1425 of file dict_util.c.
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.
Definition at line 3281 of file dict_util.c.
|
inlinestatic |
Add a child/nesting extension to an attribute.
[in] | da_p | to set a group reference for. |
Definition at line 399 of file dict_util.c.
|
inlinestatic |
Initialise an attribute's da stack from its parent.
[in] | da_p | to populate the da_stack for. |
Definition at line 434 of file dict_util.c.
int dict_attr_enum_add_name | ( | fr_dict_attr_t * | da, |
char const * | name, | ||
fr_value_box_t const * | value, | ||
bool | coerce, | ||
bool | takes_precedence, | ||
fr_dict_attr_t const * | child_struct | ||
) |
Definition at line 1752 of file dict_util.c.
|
inlinestatic |
Initialise a per-attribute enumeration table.
[in] | da_p | to set a group reference for. |
Definition at line 466 of file dict_util.c.
int dict_attr_finalise | ( | fr_dict_attr_t ** | da_p, |
char const * | name | ||
) |
Set remaining fields in a dictionary attribute before insertion.
[in] | da_p | to finalise. |
[in] | name | of the attribute. |
Definition at line 709 of file dict_util.c.
|
inlinestatic |
Definition at line 780 of file dict_util.c.
void dict_attr_location_init | ( | fr_dict_attr_t * | da, |
char const * | filename, | ||
int | line | ||
) |
Set where the dictionary attribute was defined.
Definition at line 695 of file dict_util.c.
|
static |
Compare two attribute names.
Definition at line 204 of file dict_util.c.
|
static |
Wrap name hash function for fr_dict_attr_t.
data | fr_dict_attr_t to hash. |
Definition at line 192 of file dict_util.c.
|
inlinestatic |
Set a dictionary attribute's name.
[in] | da_p | to set name for. |
[in] | name | to set. If NULL a name will be automatically generated. |
Definition at line 346 of file dict_util.c.
|
inlinestatic |
Initialise a per-attribute namespace.
[in] | da_p | to set a group reference for. |
Definition at line 482 of file dict_util.c.
int dict_attr_num_init | ( | fr_dict_attr_t * | da, |
unsigned int | num | ||
) |
Set the attribute number (if any)
[in] | da | to set the attribute number for. |
[in] | num | to set. |
Definition at line 665 of file dict_util.c.
int dict_attr_num_init_name_only | ( | fr_dict_attr_t * | da | ) |
Set the attribute number (if any)
[in] | da | to set the attribute number for. |
Definition at line 683 of file dict_util.c.
int dict_attr_parent_init | ( | fr_dict_attr_t ** | da_p, |
fr_dict_attr_t const * | parent | ||
) |
Initialise fields which depend on a parent attribute.
[in,out] | da_p | to initialise. |
[in] | parent | of the attribute. |
Definition at line 613 of file dict_util.c.
|
inlinestatic |
Internal function for searching for attributes in multiple dictionaries.
[out] | err | Any errors that occurred searching. |
[out] | out | The attribute we found. |
[in] | dict_def | The default dictionary to search in. |
[in] | in | string to resolve to an attribute. |
[in] | tt | terminals that indicate the end of the string. |
[in] | internal | Resolve the attribute in the internal dictionary. |
[in] | foreign | Resolve attribute in a foreign dictionary, i.e. one other than dict_def. |
[in] | func | to use for resolution. |
Definition at line 2760 of file dict_util.c.
|
inlinestatic |
Internal function for searching for attributes in multiple dictionaries.
Unlike dict_attr_search this function searches for a protocol name preceding the attribute identifier.
Definition at line 2908 of file dict_util.c.
int dict_attr_type_init | ( | fr_dict_attr_t ** | da_p, |
fr_type_t | type | ||
) |
Initialise type specific fields within the dictionary attribute.
Call when the type of the attribute is known.
[in,out] | da_p | to set the type for. |
[in] | type | to set. |
Definition at line 519 of file dict_util.c.
|
inlinestatic |
Cache the vendor pointer for an attribute.
[in] | da_p | to set a group reference for. |
[in] | vendor | to set. |
Definition at line 416 of file dict_util.c.
|
static |
Definition at line 3762 of file dict_util.c.
fr_dict_t* dict_by_da | ( | fr_dict_attr_t const * | da | ) |
Internal version of fr_dict_by_da.
Attempt to locate the protocol dictionary containing an attribute.
Definition at line 2536 of file dict_util.c.
fr_dict_t* dict_by_protocol_name | ( | char const * | name | ) |
Internal version of fr_dict_by_protocol_name.
Lookup a protocol by its name.
Definition at line 2508 of file dict_util.c.
fr_dict_t* dict_by_protocol_num | ( | unsigned int | num | ) |
Internal version of fr_dict_by_protocol_num.
Lookup a protocol by its number.
Definition at line 2522 of file dict_util.c.
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 | ||
) |
Definition at line 2415 of file dict_util.c.
int dict_dependent_add | ( | fr_dict_t * | dict, |
char const * | dependent | ||
) |
Record a new dependency on a dictionary.
These are used to determine what is currently depending on a dictionary.
[in] | dict | to record dependency on. |
[in] | dependent | Either C src file, or another dictionary. |
Definition at line 3647 of file dict_util.c.
int dict_dependent_remove | ( | fr_dict_t * | dict, |
char const * | dependent | ||
) |
Decrement ref count for a dependent in a dictionary.
[in] | dict | to remove dependency from. |
[in] | dependent | Either C src, or another dictionary dependent. What depends on this dictionary. |
Definition at line 3706 of file dict_util.c.
int dict_dlopen | ( | fr_dict_t * | dict, |
char const * | name | ||
) |
Definition at line 3555 of file dict_util.c.
|
static |
Compare two dictionary attribute enum values.
Definition at line 273 of file dict_util.c.
|
static |
Hash a enumeration name.
Definition at line 263 of file dict_util.c.
|
static |
Compare two dictionary enum values.
Definition at line 303 of file dict_util.c.
|
static |
Hash a dictionary enum value.
Definition at line 293 of file dict_util.c.
Check if a dictionary still has dependents.
[in] | dict | to check |
Definition at line 3738 of file dict_util.c.
Apply a simple (case insensitive) hashing function to the name of an attribute, vendor or protocol.
[in] | name | of the attribute, vendor or protocol. |
[in] | len | length of the input string. |
Definition at line 122 of file dict_util.c.
int dict_protocol_add | ( | fr_dict_t * | dict | ) |
Add a protocol to the global protocol table.
Inserts a protocol into the global protocol table. Uses the root attributes of the dictionary for comparisons.
[in] | dict | of protocol we're inserting. |
Definition at line 1236 of file dict_util.c.
|
static |
Compare two protocol names.
Definition at line 158 of file dict_util.c.
|
static |
Wrap name hash function for fr_dict_protocol_t.
[in] | data | fr_dict_attr_t to hash. |
Definition at line 146 of file dict_util.c.
|
static |
Compare two protocol numbers.
Definition at line 179 of file dict_util.c.
|
static |
Hash a protocol number.
Definition at line 171 of file dict_util.c.
int dict_vendor_add | ( | fr_dict_t * | dict, |
char const * | name, | ||
unsigned int | num | ||
) |
Add a vendor to the dictionary.
Inserts a vendor entry into the vendor hash table. This must be done before adding attributes under a VSA.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | name | of the vendor. |
[in] | num | Vendor's Private Enterprise Number. |
Definition at line 1309 of file dict_util.c.
|
static |
Compare two attribute names.
Definition at line 230 of file dict_util.c.
|
static |
Wrap name hash function for fr_dict_vendor_t.
data | fr_dict_vendor_t to hash. |
Definition at line 218 of file dict_util.c.
|
static |
Compare two vendor numbers.
Definition at line 252 of file dict_util.c.
|
static |
Hash a vendor number.
Definition at line 243 of file dict_util.c.
|
static |
Call the specified callback for da and then for all its children.
Definition at line 4752 of file dict_util.c.
int fr_dict_attr_acopy_local | ( | fr_dict_attr_t const * | dst, |
fr_dict_attr_t const * | src | ||
) |
Definition at line 1060 of file dict_util.c.
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.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | parent | to add attribute under. |
[in] | name | of the attribute. |
[in] | attr | number. |
[in] | type | of attribute. |
[in] | flags | to set in the attribute. |
Definition at line 1712 of file dict_util.c.
int fr_dict_attr_add_initialised | ( | fr_dict_attr_t * | da | ) |
A variant of fr_dict_attr_t that allows a pre-allocated, populated fr_dict_attr_t to be added.
Definition at line 1590 of file dict_util.c.
int fr_dict_attr_add_name_only | ( | fr_dict_t * | dict, |
fr_dict_attr_t const * | parent, | ||
char const * | name, | ||
fr_type_t | type, | ||
fr_dict_attr_flags_t const * | flags | ||
) |
Add an attribute to the dictionary.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | parent | to add attribute under. |
[in] | name | of the attribute. |
[in] | type | of attribute. |
[in] | flags | to set in the attribute. |
Definition at line 1738 of file dict_util.c.
int fr_dict_attr_autoload | ( | fr_dict_attr_autoload_t const * | to_load | ) |
Process a dict_attr_autoload element to load/verify a dictionary attribute.
[in] | to_load | attribute definition |
Definition at line 4090 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_by_name | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const * | parent, | ||
char const * | name | ||
) |
Locate a fr_dict_attr_t by its name.
[out] | err | Why the lookup failed. May be NULL. |
[in] | parent | containing the namespace we're searching in. |
[in] | name | of the attribute to locate. |
Definition at line 3263 of file dict_util.c.
fr_slen_t fr_dict_attr_by_name_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_attr_t const * | parent, | ||
fr_sbuff_t * | name, | ||
UNUSED fr_sbuff_term_t const * | tt | ||
) |
Look up a dictionary attribute by a name embedded in another string.
Find the first invalid attribute name char in the string pointed to by name.
Copy the characters between the start of the name string and the first none fr_dict_attr_allowed_chars char to a buffer and perform a dictionary lookup using that value.
If the attribute exists, advance the pointer pointed to by name to the first none fr_dict_attr_allowed_chars char, and return the DA.
If the attribute does not exist, don't advance the pointer and return NULL.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Where to store the resolve attribute. |
[in] | parent | containing the namespace to search in. |
[in] | name | string start. |
[in] | tt | Terminal sequences to use to determine the portion of in to search. |
Definition at line 3132 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_by_oid | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const * | parent, | ||
char const * | oid | ||
) |
Resolve an attribute using an OID string.
[out] | err | The parsing error that occurred. |
[in] | parent | Where to resolve relative attributes from. |
[in] | oid | string to parse. |
Definition at line 2373 of file dict_util.c.
ssize_t fr_dict_attr_by_oid_legacy | ( | fr_dict_t const * | dict, |
fr_dict_attr_t const ** | parent, | ||
unsigned int * | attr, | ||
char const * | oid | ||
) |
Get the leaf attribute of an OID string.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[out] | attr | Number we parsed. |
[in,out] | parent | attribute (or root of dictionary). Will be updated to the parent directly beneath the leaf. |
[in] | oid | string to parse. |
Definition at line 2125 of file dict_util.c.
fr_slen_t fr_dict_attr_by_oid_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_attr_t const * | parent, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt | ||
) |
Resolve an attribute using an OID string.
[out] | err | The parsing error that occurred. |
[out] | out | The deepest attribute we resolved. |
[in] | parent | Where to resolve relative attributes from. |
[in] | in | string to parse. |
[in] | tt | Terminal strings. |
Definition at line 2324 of file dict_util.c.
bool fr_dict_attr_can_contain | ( | fr_dict_attr_t const * | parent, |
fr_dict_attr_t const * | child | ||
) |
See if a structural da is allowed to contain another da.
We have some complex rules with different structural types, different protocol dictionaries, references to other protocols, etc.
[in] | parent | The parent da, must be structural |
[in] | child | The alleged child |
Definition at line 4875 of file dict_util.c.
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.
[in] | parent | to check for child in. |
[in] | attr | number to look for. |
Definition at line 3328 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_common_parent | ( | fr_dict_attr_t const * | a, |
fr_dict_attr_t const * | b, | ||
bool | is_ancestor | ||
) |
Find a common ancestor that two TLV type attributes share.
[in] | a | first TLV attribute. |
[in] | b | second TLV attribute. |
[in] | is_ancestor | Enforce a->b relationship (a is parent or ancestor of b). |
Definition at line 2037 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_iterate_children | ( | fr_dict_attr_t const * | parent, |
fr_dict_attr_t const ** | prev | ||
) |
Iterate over children of a DA.
[in] | parent | the parent da to iterate over |
[in,out] | prev | pointer to NULL to start, otherwise pointer to the previously returned child |
Definition at line 4696 of file dict_util.c.
fr_slen_t fr_dict_attr_search_by_name_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | name, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a fr_dict_attr_t by its name in the top level namespace of a dictionary.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute in the top level namespace.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | name | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3004 of file dict_util.c.
fr_slen_t fr_dict_attr_search_by_oid_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by a dictionary using a non-qualified OID string.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | in | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3062 of file dict_util.c.
fr_slen_t fr_dict_attr_search_by_qualified_name_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | name, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by its name and a dictionary qualifier.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute in the top level namespace.
This attribute may be qualified with <protocol>.
to selection an attribute in a specific case.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | name | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 2975 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_search_by_qualified_oid | ( | fr_dict_attr_err_t * | err, |
fr_dict_t const * | dict_def, | ||
char const * | name, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by its name and a dictionary qualifier.
[out] | err | Why parsing failed. May be NULL. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | name | Dictionary/Attribute name. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3081 of file dict_util.c.
fr_slen_t fr_dict_attr_search_by_qualified_oid_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by a dictionary qualified OID string.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | in | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3033 of file dict_util.c.
fr_dict_attr_t* fr_dict_attr_unconst | ( | fr_dict_attr_t const * | da | ) |
Coerce to non-const.
Definition at line 4597 of file dict_util.c.
void fr_dict_attr_verify | ( | char const * | file, |
int | line, | ||
fr_dict_attr_t const * | da | ||
) |
fr_dict_t const* fr_dict_by_da | ( | fr_dict_attr_t const * | da | ) |
Attempt to locate the protocol dictionary containing an attribute.
[in] | da | To get the containing dictionary for. |
Definition at line 2606 of file dict_util.c.
fr_dict_t const* fr_dict_by_protocol_name | ( | char const * | name | ) |
Lookup a protocol by its name.
[in] | name | of the protocol to locate. |
Definition at line 2577 of file dict_util.c.
fr_dict_t const* fr_dict_by_protocol_num | ( | unsigned int | num | ) |
Lookup a protocol by its number.
Returns the fr_dict_t belonging to the protocol with the specified number if any have been registered.
[in] | num | to search for. |
Definition at line 2590 of file dict_util.c.
fr_slen_t fr_dict_by_protocol_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_t const ** | out, | ||
fr_sbuff_t * | name, | ||
fr_dict_t const * | dict_def | ||
) |
Look up a protocol name embedded in another string.
[out] | err | Parsing error. |
[out] | out | the resolve dictionary or NULL if the dictionary couldn't be resolved. |
[in] | name | string start. |
[in] | dict_def | The dictionary to return if no dictionary qualifier was found. |
Definition at line 2497 of file dict_util.c.
See if two dictionaries have the same end parent.
[in] | dict1 | one dictionary |
[in] | dict2 | two dictionary |
Definition at line 2619 of file dict_util.c.
int fr_dict_const_free | ( | fr_dict_t const ** | dict, |
char const * | dependent | ||
) |
Decrement the reference count on a previously loaded dictionary.
[in] | dict | to free. |
[in] | dependent | that originally allocated this dictionary. |
Definition at line 4008 of file dict_util.c.
int fr_dict_dependent_add | ( | fr_dict_t const * | dict, |
char const * | dependent | ||
) |
Manually increase the reference count for a dictionary.
This is useful if a previously loaded dictionary needs to be bound to the lifetime of an additional object.
[in] | dict | to increase the reference count for. |
[in] | dependent | requesting the loading of the dictionary. |
Definition at line 3691 of file dict_util.c.
int fr_dict_enum_add_name | ( | fr_dict_attr_t * | da, |
char const * | name, | ||
fr_value_box_t const * | value, | ||
bool | coerce, | ||
bool | takes_precedence | ||
) |
Add a value name.
Aliases are textual (string) names for a given value.
Value names are not limited to integers, and may be added for any non-structural attribute type.
[in] | da | to add enumeration value to. |
[in] | name | Name of value name. |
[in] | value | to associate with name. |
[in] | coerce | if the type of the value does not match the type of the da, attempt to cast it to match the type of the da. If this is false and there's a type mismatch, we fail. We also fail if the value cannot be coerced to the attribute type. |
[in] | takes_precedence | This name should take precedence over previous names for the same value, when resolving value to name. |
Definition at line 1941 of file dict_util.c.
int fr_dict_enum_add_name_next | ( | fr_dict_attr_t * | da, |
char const * | name | ||
) |
Add an name to an integer attribute hashing the name for the integer value.
If the integer value conflicts with an existing name, it's incremented until we find a free value.
Definition at line 1953 of file dict_util.c.
int fr_dict_enum_autoload | ( | fr_dict_enum_autoload_t const * | to_load | ) |
Process a dict_attr_autoload element to load/verify a dictionary attribute.
[in] | to_load | attribute definition |
Definition at line 4051 of file dict_util.c.
fr_dict_enum_value_t* fr_dict_enum_by_name | ( | fr_dict_attr_t const * | da, |
char const * | name, | ||
ssize_t | len | ||
) |
Definition at line 3395 of file dict_util.c.
fr_slen_t fr_dict_enum_by_name_substr | ( | fr_dict_enum_value_t ** | out, |
fr_dict_attr_t const * | da, | ||
fr_sbuff_t * | in | ||
) |
fr_dict_enum_value_t* fr_dict_enum_by_value | ( | fr_dict_attr_t const * | da, |
fr_value_box_t const * | value | ||
) |
Lookup the structure representing an enum value in a fr_dict_attr_t.
[in] | da | to search in. |
[in] | value | to search for. |
Definition at line 3349 of file dict_util.c.
char const* fr_dict_enum_name_by_value | ( | fr_dict_attr_t const * | da, |
fr_value_box_t const * | value | ||
) |
Lookup the name of an enum value in a fr_dict_attr_t.
[in] | da | to search in. |
[in] | value | number to search for. |
Definition at line 3382 of file dict_util.c.
fr_slen_t fr_dict_enum_name_from_substr | ( | fr_sbuff_t * | out, |
fr_sbuff_parse_error_t * | err, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt | ||
) |
Extract an enumeration name from a string.
This function defines the canonical format for an enumeration name.
An enumeration name is made up of one or more fr_dict_attr_allowed_chars with at least one character in the sequence not being a special character i.e. [-+/_] or a number.
This disambiguates enumeration identifiers from mathematical expressions.
If we allowed enumeration names consisting of sequences of numbers separated by special characters it would not be possible to determine if the special character were an operator in a subexpression.
For example take:
&My-Enum-Attr == 01234-5678
Without having access to the enumeration values of My-Enum-Attr (which we might not have during tokenisation), we cannot tell if this is:
(&My-Enum-Attr == 01234-5678)
OR
((&My-Enum-Attr == 01234) - 5678)
If an alpha character occurs anywhere in the string i.e:
(&My-Enum-Attr == 01234-A5678)
we know 01234-A5678 can't be a mathematical sub-expression because the second potential operand can no longer be parsed as an integer constant.
[out] | out | The name string we managed to extract. May be NULL in which case only the length of the name will be returned. |
[out] | err | Type of parsing error which occurred. May be NULL. |
[in] | in | The string containing the enum identifier. |
[in] | tt | If non-null verify that a terminal sequence occurs after the enumeration name. |
Definition at line 3515 of file dict_util.c.
int fr_dict_free | ( | fr_dict_t ** | dict, |
char const * | dependent | ||
) |
Decrement the reference count on a previously loaded dictionary.
[in] | dict | to free. |
[in] | dependent | that originally allocated this dictionary. |
Definition at line 4024 of file dict_util.c.
void fr_dict_global_ctx_debug | ( | fr_dict_gctx_t const * | gctx | ) |
Dump information about currently loaded dictionaries.
Intended to be called from a debugger
Definition at line 4530 of file dict_util.c.
char const* fr_dict_global_ctx_dir | ( | void | ) |
int fr_dict_global_ctx_dir_set | ( | char const * | dict_dir | ) |
Allow the default dict dir to be changed after initialisation.
[in] | dict_dir | New default dict dir to use. |
Definition at line 4483 of file dict_util.c.
int fr_dict_global_ctx_free | ( | fr_dict_gctx_t const * | gctx | ) |
Explicitly free all data associated with a global dictionary context.
[in] | gctx | To set. |
Definition at line 4469 of file dict_util.c.
fr_dict_gctx_t* fr_dict_global_ctx_init | ( | TALLOC_CTX * | ctx, |
bool | free_at_exit, | ||
char const * | dict_dir | ||
) |
Initialise the global protocol hashes.
[in] | ctx | to allocate global resources in. |
[in] | free_at_exit | Install an at_exit handler to free the global ctx. This is useful when dictionaries are held by other libraries which free them using atexit handlers. |
[in] | dict_dir | the default location for the dictionaries. |
Definition at line 4392 of file dict_util.c.
fr_dict_t* fr_dict_global_ctx_iter_init | ( | fr_dict_global_ctx_iter_t * | iter | ) |
Iterate protocols by name.
Definition at line 4567 of file dict_util.c.
fr_dict_t* fr_dict_global_ctx_iter_next | ( | fr_dict_global_ctx_iter_t * | iter | ) |
Definition at line 4574 of file dict_util.c.
void fr_dict_global_ctx_perm_check | ( | fr_dict_gctx_t * | gctx, |
bool | enable | ||
) |
Set whether we check dictionary file permissions.
[in] | gctx | to alter. |
[in] | enable | Whether we should check file permissions as they're loaded. |
Definition at line 4444 of file dict_util.c.
void fr_dict_global_ctx_read_only | ( | void | ) |
Mark all dictionaries and the global dictionary ctx as read only.
Any attempts to add new attributes will now fail.
Definition at line 4503 of file dict_util.c.
void fr_dict_global_ctx_set | ( | fr_dict_gctx_t const * | gctx | ) |
Set a new, active, global dictionary context.
[in] | gctx | To set. |
Definition at line 4453 of file dict_util.c.
fr_dict_t const* fr_dict_internal | ( | void | ) |
fr_slen_t fr_dict_oid_component | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_attr_t const * | parent, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt | ||
) |
Parse an OID component, resolving it to a defined attribute.
[out] | err | The parsing error that occurred. |
[out] | out | The deepest attribute we resolved. |
[in] | parent | Where to resolve relative attributes from. |
[in] | in | string to parse. |
[in] | tt | Terminal strings. |
Definition at line 2229 of file dict_util.c.
int fr_dict_oid_component_legacy | ( | unsigned int * | out, |
char const ** | oid | ||
) |
Process a single OID component.
[out] | out | Value of component. |
[in] | oid | string to parse. |
Definition at line 2080 of file dict_util.c.
fr_dict_protocol_t const* fr_dict_protocol | ( | fr_dict_t const * | dict | ) |
Return the protocol descriptor for the dictionary.
Definition at line 4948 of file dict_util.c.
Allocate a new local dictionary.
[in] | parent | parent dictionary and talloc ctx |
This dictionary cannot define vendors, or inter-dictionary dependencies. However, we initialize the relevant fields just in case. We should arguably just skip initializing those fields, and just allow the server to crash if programmers do something stupid with it.
Definition at line 3961 of file dict_util.c.
fr_dict_attr_t const* fr_dict_root | ( | fr_dict_t const * | dict | ) |
Return the root attribute of a dictionary.
dict | to return root for. |
Definition at line 2400 of file dict_util.c.
Coerce to non-const.
Definition at line 4585 of file dict_util.c.
fr_dict_attr_t const* fr_dict_unlocal | ( | fr_dict_attr_t const * | da | ) |
fr_dict_vendor_t const* fr_dict_vendor_by_da | ( | fr_dict_attr_t const * | da | ) |
Look up a vendor by one of its child attributes.
[in] | da | The vendor attribute. |
Definition at line 2635 of file dict_util.c.
fr_dict_vendor_t const* fr_dict_vendor_by_name | ( | fr_dict_t const * | dict, |
char const * | name | ||
) |
Look up a vendor by its name.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | name | to search for. |
Definition at line 2657 of file dict_util.c.
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.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | vendor_pen | to search for. |
Definition at line 2680 of file dict_util.c.
fr_dict_attr_t const* fr_dict_vendor_da_by_num | ( | fr_dict_attr_t const * | vendor_root, |
uint32_t | vendor_pen | ||
) |
Return vendor attribute for the specified dictionary and pen.
[in] | vendor_root | of the vendor root attribute. Could be 26 (for example) in RADIUS. |
[in] | vendor_pen | to find. |
Definition at line 2695 of file dict_util.c.
int fr_dict_walk | ( | fr_dict_attr_t const * | da, |
fr_dict_walk_t | callback, | ||
void * | uctx | ||
) |
Definition at line 4777 of file dict_util.c.
Callback to automatically resolve attributes and check the types are correct.
[in] | module | being loaded. |
[in] | symbol | An array of fr_dict_attr_autoload_t to load. |
[in] | user_ctx | unused. |
Definition at line 4277 of file dict_util.c.
Callback to automatically free a dictionary when the module is unloaded.
[in] | module | being loaded. |
[in] | symbol | An array of fr_dict_autoload_t to load. |
[in] | user_ctx | unused. |
Definition at line 4306 of file dict_util.c.
Callback to automatically load dictionaries required by modules.
[in] | module | being loaded. |
[in] | symbol | An array of fr_dict_autoload_t to load. |
[in] | user_ctx | unused. |
Definition at line 4293 of file dict_util.c.
Callback to automatically resolve enum values.
[in] | module | being loaded. |
[in] | symbol | An array of fr_dict_enum_autoload_t to load. |
[in] | user_ctx | unused. |
Definition at line 4261 of file dict_util.c.
|
static |
Definition at line 110 of file dict_util.c.
fr_dict_gctx_t* dict_gctx = NULL |
Top level structure containing global dictionary state.
Definition at line 46 of file dict_util.c.
|
static |
Default protocol rules set for every dictionary.
This is usually overriden by the public symbol from the protocol library associated with the dictionary e.g. libfreeradius-dhcpv6.so -> libfreeradius_dhcpv6_dict_protocol.
Definition at line 96 of file dict_util.c.
Characters allowed in dictionary names.
Characters that are allowed in dictionary attribute names.
Definition at line 51 of file dict_util.c.
Characters allowed in enumeration value names.
Characters that are allowed in dictionary enumeration value names.
Definition at line 72 of file dict_util.c.