The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions | Variables
dict_util.c File Reference

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_fixup_priv.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 dependency graph for dict_util.c:

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 COPY(_x)   dict->_x = proto->_x
 
#define DICT_NAME_APPEND(_in, _dict)
 
#define FLAGS_EQUAL(_x)   (old->flags._x == flags->_x)
 
#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

static int _dict_attr_free (fr_dict_attr_t *da)
 
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)
 
static int _dict_validation_onload (dl_t const *dl, void *symbol, UNUSED void *user_ctx)
 Callback to automatically load validation routines for dictionaries. More...
 
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_tdict_alloc (TALLOC_CTX *ctx)
 Allocate a new dictionary. More...
 
fr_dict_attr_tdict_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...
 
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...
 
fr_dict_attr_tdict_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. More...
 
fr_dict_attr_tdict_attr_alloc_null (TALLOC_CTX *ctx)
 Allocate a partially completed attribute. More...
 
fr_dict_attr_tdict_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_tdict_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_compatible (fr_dict_attr_t const *parent, fr_dict_attr_t const *old, fr_dict_attr_t const *n)
 
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_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. 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...
 
static int dict_attr_ref_init (fr_dict_attr_t **da_p, fr_dict_attr_t const *ref)
 Set a reference for a grouping attribute or an alias 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...
 
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_tdict_by_da (fr_dict_attr_t const *da)
 Internal version of fr_dict_by_da. More...
 
fr_dict_tdict_by_protocol_name (char const *name)
 Internal version of fr_dict_by_protocol_name. More...
 
fr_dict_tdict_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_add (fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, 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_tfr_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_tfr_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_tfr_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_tfr_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_tfr_dict_global_ctx_init (TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir)
 Initialise the global protocol hashes. More...
 
fr_dict_tfr_dict_global_ctx_iter_init (fr_dict_global_ctx_iter_t *iter)
 Iterate protocols by name. More...
 
fr_dict_tfr_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_tfr_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_tfr_dict_unconst (fr_dict_t const *dict)
 Coerce to non-const. More...
 
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_tdict_gctx = NULL
 Top level structure containing global dictionary state. 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...
 

Detailed Description

Multi-protocol AVP dictionary API.

Definition in file dict_util.c.


Data Structure Documentation

◆ fr_dict_autoload_talloc_s

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 3753 of file dict_util.c.

+ Collaboration diagram for fr_dict_autoload_talloc_s:
Data Fields
char const * dependent Dependent that loaded the dictionary.
fr_dict_autoload_t load[2] Autoloader def.

Macro Definition Documentation

◆ _DICT_PRIVATE

#define _DICT_PRIVATE   1

Definition at line 25 of file dict_util.c.

◆ COPY

#define COPY (   _x)    dict->_x = proto->_x

◆ DICT_NAME_APPEND

#define DICT_NAME_APPEND (   _in,
  _dict 
)
Value:
do { \
char *_n; \
_n = talloc_strdup_append_buffer(_in, fr_dict_root(_dict)->name); \
if (unlikely(!_n)) { \
talloc_free(_in); \
goto done; \
} \
_in = _n; \
_n = talloc_strdup_append_buffer(_in, ", "); \
if (unlikely(!_n)) { \
talloc_free(_in); \
goto done; \
} \
_in = _n; \
} while (0)
#define unlikely(_x)
Definition: build.h:378
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition: dict_util.c:1997
static bool done
Definition: radclient.c:80
static char const * name

◆ FLAGS_EQUAL

#define FLAGS_EQUAL (   _x)    (old->flags._x == flags->_x)

◆ FNV_MAGIC_INIT

#define FNV_MAGIC_INIT   (0x811c9dc5)

Definition at line 89 of file dict_util.c.

◆ FNV_MAGIC_PRIME

#define FNV_MAGIC_PRIME   (0x01000193)

Definition at line 90 of file dict_util.c.

Typedef Documentation

◆ dict_attr_resolve_func_t

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.

Parameters
[out]errWhere to write error codes. Any error other than FR_DICT_ATTR_NOTFOUND will prevent resolution from continuing.
[out]outWhere to write resolved DA.
[in]parentThe dictionary root or other attribute to search from.
[in]inContains the string to resolve.
[in]ttTerminal sequences to use to determine the portion of in to search.
Returns
  • < 0 on failure.
  • The number of bytes of name consumed on success.

Definition at line 2337 of file dict_util.c.

Function Documentation

◆ _dict_attr_free()

static int _dict_attr_free ( fr_dict_attr_t da)
static

Definition at line 625 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dict_dependent_cmp()

static int8_t _dict_dependent_cmp ( void const *  a,
void const *  b 
)
static

Find a dependent in the tree of dependents.

Definition at line 3183 of file dict_util.c.

+ Here is the caller graph for this function:

◆ _dict_free()

static int _dict_free ( fr_dict_t dict)
static

Definition at line 3345 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dict_global_free()

static int _dict_global_free ( fr_dict_gctx_t gctx)
static

Definition at line 3908 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dict_global_free_at_exit()

static int _dict_global_free_at_exit ( void *  uctx)
static

Definition at line 3903 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _dict_validation_onload()

static int _dict_validation_onload ( dl_t const *  dl,
void *  symbol,
UNUSED void *  user_ctx 
)
static

Callback to automatically load validation routines for dictionaries.

Parameters
[in]dlthe library we just loaded
[in]symbolpointer to a fr_dict_protocol_t table
[in]user_ctxthe global context which we don't need
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3877 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_dict_autofree()

int _fr_dict_autofree ( fr_dict_autoload_t const *  to_free,
char const *  dependent 
)

Decrement the reference count on a previously loaded dictionary.

Parameters
[in]to_freepreviously loaded dictionary to free.
[in]dependentthat originally allocated this dictionary

Definition at line 3729 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_dict_autoload()

int _fr_dict_autoload ( fr_dict_autoload_t const *  to_load,
char const *  dependent 
)

Process a dict_autoload element to load a protocol.

Parameters
[in]to_loaddictionary definition.
[in]dependentthat is loading this dictionary.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3696 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_dict_autoload_talloc()

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.

Note
If the talloc chunk is freed it does not mean the dictionary will be immediately freed. It will be freed when all other references to the dictionary are gone.
Parameters
[in]ctxto bind the dictionary lifetime to.
[out]outpointer to the loaded dictionary.
[in]prototo load.
[in]dependentto register this reference to. Will be dupd.

Definition at line 3780 of file dict_util.c.

+ Here is the call graph for this function:

◆ _fr_dict_autoload_talloc_free()

static int _fr_dict_autoload_talloc_free ( fr_dict_autoload_talloc_t const *  to_free)
static

Talloc destructor to automatically free dictionaries.

Parameters
[in]to_freedictionary autoloader definition describing the dictionary to free.

Definition at line 3762 of file dict_util.c.

+ Here is the call graph for this function:

◆ dependent_debug()

static void dependent_debug ( fr_dict_t dict)
static

Definition at line 3300 of file dict_util.c.

+ Here is the call graph for this function:

◆ dict_alloc()

fr_dict_t* dict_alloc ( TALLOC_CTX *  ctx)

Allocate a new dictionary.

Parameters
[in]ctxto allocate dictionary in.
Returns
  • NULL on memory allocation error.

Definition at line 3428 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_acopy()

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.

Parameters
[in]ctxto allocate new attribute in.
[in]inattribute to copy.
[in]new_nameto assign to the attribute. If NULL the existing name will be used.
Returns

Definition at line 725 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_acopy_children()

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.

Parameters
[in]dictto allocate the children in
[in]dstwhere to copy the children to
[in]srcwhere to copy the children from
Returns
  • 0 on success
  • <0 on error

Definition at line 751 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_acopy_enumv()

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.

Parameters
[in]dstwhere to cast the VALUEs to
[in]srcwhere to cast the VALUEs from
Returns
  • 0 on success (but copied no values)
  • 1 on success (but copied at least one value)
  • <0 on error

Definition at line 804 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_add_to_namespace()

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.

Parameters
[in]parentcontaining the namespace to add this attribute to.
[in]dato add to the name lookup tables.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1145 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_alias()

static fr_dict_attr_t const* dict_attr_alias ( fr_dict_attr_err_t err,
fr_dict_attr_t const *  da 
)
inlinestatic

Resolve an alias attribute to the concrete attribute it points to.

Parameters
[out]errwhere to write the error (if any).
[in]dato resolve.
Returns
  • NULL on error.
  • The concrete attribute on success.

Definition at line 302 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_alloc()

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.

Parameters
[in]ctxto allocate the attribute in.
[in]parentof the attribute, if none, should be the dictionary root.
[in]nameof the attribute. If NULL an OID string will be created and set as the name.
[in]attrnumber.
[in]typeof the attribute.
[in]argsoptional initialisation arguments.
Returns

Definition at line 697 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_alloc_null()

fr_dict_attr_t* dict_attr_alloc_null ( TALLOC_CTX *  ctx)

Allocate a partially completed attribute.

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.

Parameters
[in]ctxto allocate attribute in.
Returns
  • A new, partially completed, fr_dict_attr_t on success.
  • NULL on failure (memory allocation error).

Definition at line 657 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_by_name()

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 2814 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_can_have_children()

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.

Parameters
dathe dictionary attribute to check.

Definition at line 1012 of file dict_util.c.

+ Here is the caller graph for this function:

◆ dict_attr_child_add()

int dict_attr_child_add ( fr_dict_attr_t parent,
fr_dict_attr_t child 
)

Add a child to a parent.

Parameters
[in]parentwe're adding a child to.
[in]childto add to parent.
Returns
  • 0 on success.
  • -1 on failure (memory allocation error).

Definition at line 1046 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_child_by_num()

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 2878 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_children_init()

static int dict_attr_children_init ( fr_dict_attr_t **  da_p)
inlinestatic

Add a child/nesting extension to an attribute.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto set a group reference for.

Definition at line 380 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_compatible()

static int dict_attr_compatible ( fr_dict_attr_t const *  parent,
fr_dict_attr_t const *  old,
fr_dict_attr_t const *  n 
)
static

Definition at line 1205 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_da_stack_set()

static int dict_attr_da_stack_set ( fr_dict_attr_t **  da_p)
inlinestatic

Initialise an attribute's da stack from its parent.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto populate the da_stack for.

Definition at line 434 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_enum_add_name()

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 1346 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_enumv_init()

static int dict_attr_enumv_init ( fr_dict_attr_t **  da_p)
inlinestatic

Initialise a per-attribute enumeration table.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto set a group reference for.

Definition at line 466 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_init()

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.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto initialise.
[in]parentof the attribute, if none, should be the dictionary root.
[in]nameof attribute. Pass NULL for auto-generated name.
[in]attrnumber.
[in]typeof the attribute.
[in]argsoptional initialisation arguments.

Definition at line 521 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_name_cmp()

static int8_t dict_attr_name_cmp ( void const *  one,
void const *  two 
)
static

Compare two attribute names.

Definition at line 185 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_name_hash()

static uint32_t dict_attr_name_hash ( void const *  data)
static

Wrap name hash function for fr_dict_attr_t.

Parameters
datafr_dict_attr_t to hash.
Returns
the hash derived from the name of the attribute.

Definition at line 173 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_name_set()

static int dict_attr_name_set ( fr_dict_attr_t **  da_p,
char const *  name 
)
inlinestatic

Set a dictionary attribute's name.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto set name for.
[in]nameto set. If NULL a name will be automatically generated.

Definition at line 327 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_namespace_init()

static int dict_attr_namespace_init ( fr_dict_attr_t **  da_p)
inlinestatic

Initialise a per-attribute namespace.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto set a group reference for.

Definition at line 482 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_ref_init()

static int dict_attr_ref_init ( fr_dict_attr_t **  da_p,
fr_dict_attr_t const *  ref 
)
inlinestatic

Set a reference for a grouping attribute or an alias attribute.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto set reference for.
[in]refThe attribute referred to by this attribute.

Definition at line 397 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_search()

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 
)
inlinestatic

Internal function for searching for attributes in multiple dictionaries.

Parameters
[out]errAny errors that occurred searching.
[out]outThe attribute we found.
[in]dict_defThe default dictionary to search in.
[in]instring to resolve to an attribute.
[in]ttterminals that indicate the end of the string.
[in]internalResolve the attribute in the internal dictionary.
[in]foreignResolve attribute in a foreign dictionary, i.e. one other than dict_def.
[in]functo use for resolution.
Returns
  • <=0 on error (the offset of the error).
  • >0 on success.

Definition at line 2357 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_search_qualified()

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 
)
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 2505 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_attr_vendor_set()

static int dict_attr_vendor_set ( fr_dict_attr_t **  da_p,
fr_dict_attr_t const *  vendor 
)
inlinestatic

Cache the vendor pointer for an attribute.

Note
This function can only be used before the attribute is inserted into the dictionary.
Parameters
[in]da_pto set a group reference for.
[in]vendorto set.

Definition at line 416 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_autoref_free()

static int dict_autoref_free ( fr_dict_t dict)
static

Definition at line 3318 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_by_da()

fr_dict_t* dict_by_da ( fr_dict_attr_t const *  da)

Internal version of fr_dict_by_da.

Note
For internal use by the dictionary API only.

Attempt to locate the protocol dictionary containing an attribute.

Definition at line 2133 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_by_protocol_name()

fr_dict_t* dict_by_protocol_name ( char const *  name)

Internal version of fr_dict_by_protocol_name.

Note
For internal use by the dictionary API only.

Lookup a protocol by its name.

Definition at line 2105 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_by_protocol_num()

fr_dict_t* dict_by_protocol_num ( unsigned int  num)

Internal version of fr_dict_by_protocol_num.

Note
For internal use by the dictionary API only.

Lookup a protocol by its number.

Definition at line 2119 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_by_protocol_substr()

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 2012 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_dependent_add()

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.

Parameters
[in]dictto record dependency on.
[in]dependentEither C src file, or another dictionary.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3203 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_dependent_remove()

int dict_dependent_remove ( fr_dict_t dict,
char const *  dependent 
)

Decrement ref count for a dependent in a dictionary.

Parameters
[in]dictto remove dependency from.
[in]dependentEither C src, or another dictionary dependent. What depends on this dictionary.

Definition at line 3262 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_dlopen()

int dict_dlopen ( fr_dict_t dict,
char const *  name 
)

Definition at line 3152 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_enum_name_cmp()

static int8_t dict_enum_name_cmp ( void const *  one,
void const *  two 
)
static

Compare two dictionary attribute enum values.

Definition at line 254 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_enum_name_hash()

static uint32_t dict_enum_name_hash ( void const *  data)
static

Hash a enumeration name.

Definition at line 244 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_enum_value_cmp()

static int8_t dict_enum_value_cmp ( void const *  one,
void const *  two 
)
static

Compare two dictionary enum values.

Definition at line 284 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_enum_value_hash()

static uint32_t dict_enum_value_hash ( void const *  data)
static

Hash a dictionary enum value.

Definition at line 274 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_has_dependents()

bool dict_has_dependents ( fr_dict_t dict)

Check if a dictionary still has dependents.

Parameters
[in]dictto check
Returns
  • true if there's still at least one dependent.
  • false if there are no dependents.

Definition at line 3294 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_hash_name()

static uint32_t dict_hash_name ( char const *  name,
size_t  len 
)
static

Apply a simple (case insensitive) hashing function to the name of an attribute, vendor or protocol.

Parameters
[in]nameof the attribute, vendor or protocol.
[in]lenlength of the input string.
Returns
the hashed derived from the name.

Definition at line 104 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_protocol_add()

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.

Parameters
[in]dictof protocol we're inserting.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 858 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_protocol_name_cmp()

static int8_t dict_protocol_name_cmp ( void const *  one,
void const *  two 
)
static

Compare two protocol names.

Definition at line 139 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_protocol_name_hash()

static uint32_t dict_protocol_name_hash ( void const *  data)
static

Wrap name hash function for fr_dict_protocol_t.

Parameters
[in]datafr_dict_attr_t to hash.
Returns
the hash derived from the name of the attribute.

Definition at line 127 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_protocol_num_cmp()

static int8_t dict_protocol_num_cmp ( void const *  one,
void const *  two 
)
static

Compare two protocol numbers.

Definition at line 160 of file dict_util.c.

+ Here is the caller graph for this function:

◆ dict_protocol_num_hash()

static uint32_t dict_protocol_num_hash ( void const *  data)
static

Hash a protocol number.

Definition at line 152 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_vendor_add()

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.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]nameof the vendor.
[in]numVendor's Private Enterprise Number.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 930 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_vendor_name_cmp()

static int8_t dict_vendor_name_cmp ( void const *  one,
void const *  two 
)
static

Compare two attribute names.

Definition at line 211 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_vendor_name_hash()

static uint32_t dict_vendor_name_hash ( void const *  data)
static

Wrap name hash function for fr_dict_vendor_t.

Parameters
datafr_dict_vendor_t to hash.
Returns
the hash derived from the name of the attribute.

Definition at line 199 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_vendor_pen_cmp()

static int8_t dict_vendor_pen_cmp ( void const *  one,
void const *  two 
)
static

Compare two vendor numbers.

Definition at line 233 of file dict_util.c.

+ Here is the caller graph for this function:

◆ dict_vendor_pen_hash()

static uint32_t dict_vendor_pen_hash ( void const *  data)
static

Hash a vendor number.

Definition at line 224 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dict_walk()

static int dict_walk ( fr_dict_attr_t const *  da,
fr_dict_walk_t  callback,
void *  uctx 
)
static

Call the specified callback for da and then for all its children.

Definition at line 4346 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_add()

int fr_dict_attr_add ( fr_dict_t dict,
fr_dict_attr_t const *  parent,
char const *  name,
int  attr,
fr_type_t  type,
fr_dict_attr_flags_t const *  flags 
)

Add an attribute to the dictionary.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]parentto add attribute under.
[in]nameof the attribute.
[in]attrnumber.
[in]typeof attribute.
[in]flagsto set in the attribute.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1245 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_autoload()

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.

Parameters
[in]to_loadattribute definition
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3647 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_by_name()

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.

Parameters
[out]errWhy the lookup failed. May be NULL.
See also
fr_dict_attr_err_t.
Parameters
[in]parentcontaining the namespace we're searching in.
[in]nameof the attribute to locate.
Returns
  • Attribute matching name.
  • NULL if no matching attribute could be found.

Definition at line 2860 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_by_name_substr()

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.

Parameters
[out]errWhy parsing failed. May be NULL.
See also
fr_dict_attr_err_t
Parameters
[out]outWhere to store the resolve attribute.
[in]parentcontaining the namespace to search in.
[in]namestring start.
[in]ttTerminal sequences to use to determine the portion of in to search.
Returns
  • <= 0 on failure.
  • The number of bytes of name consumed on success.

Definition at line 2729 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_by_oid()

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.

Parameters
[out]errThe parsing error that occurred.
[in]parentWhere to resolve relative attributes from.
[in]oidstring to parse.
Returns
  • NULL if we couldn't resolve the attribute.
  • The resolved attribute.

Definition at line 1970 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_by_oid_legacy()

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.

Note
On error, vendor will be set (if present), parent will be the maximum depth we managed to resolve to, and attr will be the child we failed to resolve.
Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[out]attrNumber we parsed.
[in,out]parentattribute (or root of dictionary). Will be updated to the parent directly beneath the leaf.
[in]oidstring to parse.
Returns
  • > 0 on success (number of bytes parsed).
  • <= 0 on parse error (negative offset of parse error).

Definition at line 1719 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_by_oid_substr()

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.

Note
Will leave the sbuff pointing at the component the error occurred at so that the caller can attempt to process the component in another way. An err pointer should be provided in order to determine if an error occurred.
Parameters
[out]errThe parsing error that occurred.
[out]outThe deepest attribute we resolved.
[in]parentWhere to resolve relative attributes from.
[in]instring to parse.
[in]ttTerminal strings.
Returns
The number of bytes of name consumed.

Definition at line 1921 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_can_contain()

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.

Parameters
[in]parentThe parent da, must be structural
[in]childThe alleged child
Returns
  • false - the child is not allowed to be contained by the parent
  • true - the child is allowed to be contained by the parent

Definition at line 4464 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_child_by_num()

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.

Parameters
[in]parentto check for child in.
[in]attrnumber to look for.
Returns
  • The child attribute on success.
  • NULL if the child attribute does not exist.

Definition at line 2925 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_common_parent()

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.

Parameters
[in]afirst TLV attribute.
[in]bsecond TLV attribute.
[in]is_ancestorEnforce a->b relationship (a is parent or ancestor of b).
Returns
  • Common ancestor if one exists.
  • NULL if no common ancestor exists.

Definition at line 1631 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_attr_iterate_children()

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.

Parameters
[in]parentthe parent da to iterate over
[in,out]prevpointer to NULL to start, otherwise pointer to the previously returned child
Returns
  • NULL for end of iteration
  • !NULL for a valid child. This child MUST be passed to the next loop.

Definition at line 4290 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_search_by_name_substr()

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.

Note
If calling this function from the server any list or request qualifiers should be stripped first.
Parameters
[out]errWhy parsing failed. May be NULL.
See also
fr_dict_attr_err_t
Parameters
[out]outDictionary found attribute.
[in]dict_defDefault dictionary for non-qualified dictionaries.
[in]nameDictionary/Attribute name.
[in]ttTerminal strings.
[in]internalIf true, fallback to the internal dictionary.
[in]foreignIf true, fallback to foreign dictionaries.
Returns
  • < 0 on failure.
  • The number of bytes of name consumed on success.

Definition at line 2601 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_search_by_oid_substr()

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.

Note
If calling this function from the server any list or request qualifiers should be stripped first.
err should be checked to determine if a parse error occurred.
Parameters
[out]errWhy parsing failed. May be NULL.
See also
fr_dict_attr_err_t
Parameters
[out]outDictionary found attribute.
[in]dict_defDefault dictionary for non-qualified dictionaries.
[in]inDictionary/Attribute name.
[in]ttTerminal strings.
[in]internalIf true, fallback to the internal dictionary.
[in]foreignIf true, fallback to foreign dictionaries.
Returns
The number of bytes of name consumed.

Definition at line 2659 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dict_attr_search_by_qualified_name_substr()

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.

Note
If calling this function from the server any list or request qualifiers should be stripped first.
Parameters
[out]errWhy parsing failed. May be NULL.
See also
fr_dict_attr_err_t
Parameters
[out]outDictionary found attribute.
[in]dict_defDefault dictionary for non-qualified dictionaries.
[in]nameDictionary/Attribute name.
[in]ttTerminal strings.
[in]internalIf true, fallback to the internal dictionary.
[in]foreignIf true, fallback to foreign dictionaries.
Returns
  • < 0 on failure.
  • The number of bytes of name consumed on success.

Definition at line 2572 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_search_by_qualified_oid()

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.

Parameters
[out]errWhy parsing failed. May be NULL.
See also
fr_dict_attr_err_t.
Parameters
[in]dict_defDefault dictionary for non-qualified dictionaries.
[in]nameDictionary/Attribute name.
[in]internalIf true, fallback to the internal dictionary.
[in]foreignIf true, fallback to foreign dictionaries.
Returns
an fr_dict_attr_err_t value.

Definition at line 2678 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_search_by_qualified_oid_substr()

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.

Note
If calling this function from the server any list or request qualifiers should be stripped first.
err should be checked to determine if a parse error occurred.
Parameters
[out]errWhy parsing failed. May be NULL.
See also
fr_dict_attr_err_t
Parameters
[out]outDictionary found attribute.
[in]dict_defDefault dictionary for non-qualified dictionaries.
[in]inDictionary/Attribute name.
[in]ttTerminal strings.
[in]internalIf true, fallback to the internal dictionary.
[in]foreignIf true, fallback to foreign dictionaries.
Returns
The number of bytes of name consumed.

Definition at line 2630 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_unconst()

fr_dict_attr_t* fr_dict_attr_unconst ( fr_dict_attr_t const *  da)

Coerce to non-const.

Definition at line 4191 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_attr_verify()

void fr_dict_attr_verify ( char const *  file,
int  line,
fr_dict_attr_t const *  da 
)

Definition at line 4377 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dict_by_da()

fr_dict_t const* fr_dict_by_da ( fr_dict_attr_t const *  da)

Attempt to locate the protocol dictionary containing an attribute.

Note
Unlike fr_dict_by_attr_name, doesn't search through all the dictionaries, just uses the fr_dict_attr_t hierarchy and the talloc hierarchy to locate the dictionary (much much faster and more scalable).
Parameters
[in]daTo get the containing dictionary for.
Returns
  • The dictionary containing da.
  • NULL.

Definition at line 2203 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_by_protocol_name()

fr_dict_t const* fr_dict_by_protocol_name ( char const *  name)

Lookup a protocol by its name.

Note
For internal use by the dictionary API only.
Parameters
[in]nameof the protocol to locate.
Returns
  • Attribute matching name.
  • NULL if no matching protocol could be found.

Definition at line 2174 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_by_protocol_num()

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.

Parameters
[in]numto search for.
Returns
dictionary representing the protocol (if it exists).

Definition at line 2187 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_by_protocol_substr()

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.

Parameters
[out]errParsing error.
[out]outthe resolve dictionary or NULL if the dictionary couldn't be resolved.
[in]namestring start.
[in]dict_defThe dictionary to return if no dictionary qualifier was found.
Returns
  • 0 and *out != NULL. Couldn't find a dictionary qualifier, so returned dict_def.
  • < 0 on error and (*out == NULL) (offset as negative integer)
  • > 0 on success (number of bytes parsed).

Definition at line 2094 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dict_compatible()

bool fr_dict_compatible ( fr_dict_t const *  dict1,
fr_dict_t const *  dict2 
)

See if two dictionaries have the same end parent.

Parameters
[in]dict1one dictionary
[in]dict2two dictionary
Returns
  • true the dictionaries have the same end parent
  • false the dictionaries do not have the same end parent.

Definition at line 2216 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_const_free()

int fr_dict_const_free ( fr_dict_t const **  dict,
char const *  dependent 
)

Decrement the reference count on a previously loaded dictionary.

Parameters
[in]dictto free.
[in]dependentthat originally allocated this dictionary.
Returns
  • 0 on success (dictionary freed).
  • 1 if other things still depend on the dictionary.
  • -1 on error (dependent doesn't exist)

Definition at line 3565 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_dependent_add()

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.

Parameters
[in]dictto increase the reference count for.
[in]dependentrequesting the loading of the dictionary.
Returns
  • 0 on success.
  • -1 on error.

Definition at line 3247 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dict_dl()

dl_t* fr_dict_dl ( fr_dict_t const *  dict)

Definition at line 2007 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_enum_add_name()

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.

Parameters
[in]dato add enumeration value to.
[in]nameName of value name.
[in]valueto associate with name.
[in]coerceif 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_precedenceThis name should take precedence over previous names for the same value, when resolving value to name.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1535 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_enum_add_name_next()

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 1547 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_enum_autoload()

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.

Parameters
[in]to_loadattribute definition
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3608 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_enum_by_name()

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 2992 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_enum_by_name_substr()

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 
)

Definition at line 3018 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dict_enum_by_value()

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.

Parameters
[in]dato search in.
[in]valueto search for.
Returns

Definition at line 2946 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_enum_name_by_value()

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.

Parameters
[in]dato search in.
[in]valuenumber to search for.
Returns
  • Name of value.
  • NULL if no matching value could be found.

Definition at line 2979 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_enum_name_from_substr()

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.

Parameters
[out]outThe name string we managed to extract. May be NULL in which case only the length of the name will be returned.
[out]errType of parsing error which occurred. May be NULL.
[in]inThe string containing the enum identifier.
[in]ttIf non-null verify that a terminal sequence occurs after the enumeration name.
Returns
  • <0 the offset at which the parse error occurred.
  • >1 the number of bytes parsed.

Definition at line 3112 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_free()

int fr_dict_free ( fr_dict_t **  dict,
char const *  dependent 
)

Decrement the reference count on a previously loaded dictionary.

Parameters
[in]dictto free.
[in]dependentthat originally allocated this dictionary.
Returns
  • 0 on success (dictionary freed).
  • 1 if other things still depend on the dictionary.
  • -1 on error (dependent doesn't exist)

Definition at line 3581 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_debug()

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 4124 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_dir()

char const* fr_dict_global_ctx_dir ( void  )

Definition at line 4088 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_dir_set()

int fr_dict_global_ctx_dir_set ( char const *  dict_dir)

Allow the default dict dir to be changed after initialisation.

Parameters
[in]dict_dirNew default dict dir to use.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4077 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_free()

int fr_dict_global_ctx_free ( fr_dict_gctx_t const *  gctx)

Explicitly free all data associated with a global dictionary context.

Note
You should NOT ignore the return code of this function. You should use perror() or PERROR() to print out the reason why freeing failed.
Parameters
[in]gctxTo set.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 4063 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_init()

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.

Note
Must be called before any other dictionary functions.
Parameters
[in]ctxto allocate global resources in.
[in]free_at_exitInstall 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_dirthe default location for the dictionaries.
Returns
  • A pointer to the new global context on success.
  • NULL on failure.

Definition at line 3984 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_iter_init()

fr_dict_t* fr_dict_global_ctx_iter_init ( fr_dict_global_ctx_iter_t iter)

Iterate protocols by name.

Definition at line 4161 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_iter_next()

fr_dict_t* fr_dict_global_ctx_iter_next ( fr_dict_global_ctx_iter_t iter)

Definition at line 4168 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_perm_check()

void fr_dict_global_ctx_perm_check ( fr_dict_gctx_t gctx,
bool  enable 
)

Set whether we check dictionary file permissions.

Parameters
[in]gctxto alter.
[in]enableWhether we should check file permissions as they're loaded.

Definition at line 4038 of file dict_util.c.

◆ fr_dict_global_ctx_read_only()

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 4097 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_global_ctx_set()

void fr_dict_global_ctx_set ( fr_dict_gctx_t const *  gctx)

Set a new, active, global dictionary context.

Parameters
[in]gctxTo set.

Definition at line 4047 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_internal()

fr_dict_t const* fr_dict_internal ( void  )

Definition at line 4204 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_is_read_only()

bool fr_dict_is_read_only ( fr_dict_t const *  dict)

Definition at line 2002 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_oid_component()

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.

Note
Will leave the sbuff pointing at the component the error occurred at so that the caller can attempt to process the component in another way.
Parameters
[out]errThe parsing error that occurred.
[out]outThe deepest attribute we resolved.
[in]parentWhere to resolve relative attributes from.
[in]instring to parse.
[in]ttTerminal strings.
Returns
  • >0 the number of bytes consumed.
  • <0 Parse error occurred here.

Definition at line 1823 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_oid_component_legacy()

int fr_dict_oid_component_legacy ( unsigned int *  out,
char const **  oid 
)

Process a single OID component.

Parameters
[out]outValue of component.
[in]oidstring to parse.
Returns
  • 0 on success.
  • -1 on format error.

Definition at line 1674 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_protocol()

fr_dict_protocol_t const* fr_dict_protocol ( fr_dict_t const *  dict)

Return the protocol descriptor for the dictionary.

Definition at line 4537 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_protocol_alloc()

fr_dict_t* fr_dict_protocol_alloc ( fr_dict_t const *  parent)

Allocate a new local dictionary.

Parameters
[in]parentparent dictionary and talloc ctx
Returns
  • NULL on memory allocation error.

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 3512 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_root()

fr_dict_attr_t const* fr_dict_root ( fr_dict_t const *  dict)

Return the root attribute of a dictionary.

Parameters
dictto return root for.
Returns
the root attribute of the dictionary.

Definition at line 1997 of file dict_util.c.

◆ fr_dict_unconst()

fr_dict_t* fr_dict_unconst ( fr_dict_t const *  dict)

Coerce to non-const.

Definition at line 4179 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_valid_name()

ssize_t fr_dict_valid_name ( char const *  name,
ssize_t  len 
)

Definition at line 4214 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_valid_oid_str()

ssize_t fr_dict_valid_oid_str ( char const *  name,
ssize_t  len 
)

Definition at line 4257 of file dict_util.c.

◆ fr_dict_vendor_by_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.

Parameters
[in]daThe vendor attribute.
Returns
  • The vendor.
  • NULL if no vendor with that number was registered for this protocol.

Definition at line 2232 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_vendor_by_name()

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.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]nameto search for.
Returns
  • The vendor.
  • NULL if no vendor with that name was registered for this protocol.

Definition at line 2254 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_vendor_by_num()

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.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]vendor_pento search for.
Returns
  • The vendor.
  • NULL if no vendor with that number was registered for this protocol.

Definition at line 2277 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_vendor_da_by_num()

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.

Parameters
[in]vendor_rootof the vendor root attribute. Could be 26 (for example) in RADIUS.
[in]vendor_pento find.
Returns
  • NULL if vendor does not exist.
  • A fr_dict_attr_t representing the vendor in the dictionary hierarchy.

Definition at line 2292 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dict_walk()

int fr_dict_walk ( fr_dict_attr_t const *  da,
fr_dict_walk_t  callback,
void *  uctx 
)

Definition at line 4371 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_dl_dict_attr_autoload()

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.

Parameters
[in]modulebeing loaded.
[in]symbolAn array of fr_dict_attr_autoload_t to load.
[in]user_ctxunused.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3834 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dl_dict_autofree()

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.

Parameters
[in]modulebeing loaded.
[in]symbolAn array of fr_dict_autoload_t to load.
[in]user_ctxunused.

Definition at line 3863 of file dict_util.c.

◆ fr_dl_dict_autoload()

int fr_dl_dict_autoload ( UNUSED dl_t const *  module,
void *  symbol,
UNUSED void *  user_ctx 
)

Callback to automatically load dictionaries required by modules.

Parameters
[in]modulebeing loaded.
[in]symbolAn array of fr_dict_autoload_t to load.
[in]user_ctxunused.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3850 of file dict_util.c.

◆ fr_dl_dict_enum_autoload()

int fr_dl_dict_enum_autoload ( UNUSED dl_t const *  module,
void *  symbol,
UNUSED void *  user_ctx 
)

Callback to automatically resolve enum values.

Parameters
[in]modulebeing loaded.
[in]symbolAn array of fr_dict_enum_autoload_t to load.
[in]user_ctxunused.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3818 of file dict_util.c.

+ Here is the call graph for this function:

◆ hash_pool_free()

static void hash_pool_free ( void *  to_free)
static

Definition at line 92 of file dict_util.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ dict_gctx

fr_dict_gctx_t* dict_gctx = NULL

Top level structure containing global dictionary state.

Definition at line 40 of file dict_util.c.

◆ fr_dict_attr_allowed_chars

bool const fr_dict_attr_allowed_chars[UINT8_MAX+1]
Initial value:
= {
['-'] = true, ['/'] = true, ['_'] = true,
['0'] = true, ['1'] = true, ['2'] = true, ['3'] = true, ['4'] = true,
['5'] = true, ['6'] = true, ['7'] = true, ['8'] = true, ['9'] = true,
['A'] = true, ['B'] = true, ['C'] = true, ['D'] = true, ['E'] = true,
['F'] = true, ['G'] = true, ['H'] = true, ['I'] = true, ['J'] = true,
['K'] = true, ['L'] = true, ['M'] = true, ['N'] = true, ['O'] = true,
['P'] = true, ['Q'] = true, ['R'] = true, ['S'] = true, ['T'] = true,
['U'] = true, ['V'] = true, ['W'] = true, ['X'] = true, ['Y'] = true,
['Z'] = true,
['a'] = true, ['b'] = true, ['c'] = true, ['d'] = true, ['e'] = true,
['f'] = true, ['g'] = true, ['h'] = true, ['i'] = true, ['j'] = true,
['k'] = true, ['l'] = true, ['m'] = true, ['n'] = true, ['o'] = true,
['p'] = true, ['q'] = true, ['r'] = true, ['s'] = true, ['t'] = true,
['u'] = true, ['v'] = true, ['w'] = true, ['x'] = true, ['y'] = true,
['z'] = true
}

Characters allowed in dictionary names.

Characters that are allowed in dictionary attribute names.

Definition at line 45 of file dict_util.c.

◆ fr_dict_enum_allowed_chars

bool const fr_dict_enum_allowed_chars[UINT8_MAX+1]
Initial value:
= {
['+'] = true, ['-'] = true, ['.'] = true, ['/'] = true, ['_'] = true,
['0'] = true, ['1'] = true, ['2'] = true, ['3'] = true, ['4'] = true,
['5'] = true, ['6'] = true, ['7'] = true, ['8'] = true, ['9'] = true,
['A'] = true, ['B'] = true, ['C'] = true, ['D'] = true, ['E'] = true,
['F'] = true, ['G'] = true, ['H'] = true, ['I'] = true, ['J'] = true,
['K'] = true, ['L'] = true, ['M'] = true, ['N'] = true, ['O'] = true,
['P'] = true, ['Q'] = true, ['R'] = true, ['S'] = true, ['T'] = true,
['U'] = true, ['V'] = true, ['W'] = true, ['X'] = true, ['Y'] = true,
['Z'] = true,
['a'] = true, ['b'] = true, ['c'] = true, ['d'] = true, ['e'] = true,
['f'] = true, ['g'] = true, ['h'] = true, ['i'] = true, ['j'] = true,
['k'] = true, ['l'] = true, ['m'] = true, ['n'] = true, ['o'] = true,
['p'] = true, ['q'] = true, ['r'] = true, ['s'] = true, ['t'] = true,
['u'] = true, ['v'] = true, ['w'] = true, ['x'] = true, ['y'] = true,
['z'] = true
}

Characters allowed in enumeration value names.

Characters that are allowed in dictionary enumeration value names.

Definition at line 66 of file dict_util.c.