The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Enumerations | Variables
dict.h File Reference

Multi-protocol AVP dictionary API. More...

#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/dl.h>
#include <freeradius-devel/util/ext.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/talloc.h>
#include <freeradius-devel/util/types.h>
#include <stdbool.h>
#include <stdint.h>
#include <freeradius-devel/util/dict_ext.h>
+ Include dependency graph for dict.h:

Go to the source code of this file.

Data Structures

struct  dict_attr_s
 Dictionary attribute. More...
 
struct  dict_attr_s.state
 
struct  fr_dict_attr_autoload_t
 Specifies an attribute which must be present for the module to function. More...
 
struct  fr_dict_attr_flags_t
 Values of the encryption flags. More...
 
struct  fr_dict_autoload_t
 Specifies a dictionary which must be loaded/loadable for the module to function. More...
 
struct  fr_dict_enum_autoload_t
 Specifies a value which must be present for the module to function. More...
 
struct  fr_dict_enum_value_t
 Value of an enumerated attribute. More...
 
struct  fr_dict_flag_parser_rule_s
 
struct  fr_dict_flag_parser_t
 Protocol specific custom flag definitnion. More...
 
struct  fr_dict_protocol_t
 Protocol-specific callbacks in libfreeradius-PROTOCOL. More...
 
struct  fr_dict_protocol_t.attr
 
struct  fr_dict_protocol_t.attr.flags
 Custom flags for this protocol. More...
 
struct  fr_dict_vendor_t
 Private enterprise. More...
 

Macros

#define _CONST   const
 
#define da_is_bit_field(_da)   ((_da)->flags.extra && ((_da)->flags.subtype == FLAG_BIT_FIELD))
 
#define da_is_length_field(_da)   ((_da)->flags.extra && (((_da)->flags.subtype == FLAG_LENGTH_UINT8) || ((_da)->flags.subtype == FLAG_LENGTH_UINT16)))
 
#define da_length_offset(_da)   ((_da)->flags.type_size)
 
#define DA_VERIFY(_x)   fr_cond_assert(_x)
 
#define flag_byte_offset   type_size
 
#define flag_time_res   type_size
 
#define FR_DICT_ATTR_FLAG_FUNC(_struct, _name)
 Define a flag setting function, which sets one bit in a fr_dict_attr_flags_t. More...
 
#define fr_dict_attr_is_key_field(_da)   ((_da)->flags.extra && ((_da)->flags.subtype == FLAG_KEY_FIELD))
 
#define FR_DICT_ATTR_MAX_NAME_LEN   (128)
 Maximum length of a attribute name. More...
 
#define FR_DICT_DA_STACK_CACHE_MAX   (5)
 Maximum level of da stack caching. More...
 
#define FR_DICT_ENUM_MAX_NAME_LEN   (128)
 Maximum length of a enum value. More...
 
#define FR_DICT_MAX_TLV_STACK   (FR_DICT_TLV_NEST_MAX + 5)
 Maximum TLV stack size. More...
 
#define FR_DICT_PROTO_MAX_NAME_LEN   (128)
 Maximum length of a protocol name. More...
 
#define FR_DICT_PROTOCOL_FLAG(_struct, _field)
 conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct More...
 
#define FR_DICT_TLV_NEST_MAX   (24)
 Maximum level of TLV nesting allowed. More...
 
#define FR_DICT_VENDOR_MAX_NAME_LEN   (128)
 Maximum length of a vendor name. More...
 

Typedefs

typedef struct fr_dbuff_s fr_dbuff_t
 
typedef ssize_t(* fr_dict_attr_decode_func_t) (TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t const *data, size_t data_len)
 A generic interface for decoding packets to fr_pair_ts. More...
 
typedef ssize_t(* fr_dict_attr_encode_func_t) (fr_dbuff_t *dbuff, fr_pair_list_t const *vps)
 A generic interface for encoding fr_pair_ts to packets. More...
 
typedef struct dict_attr_s fr_dict_attr_t
 
typedef bool(* fr_dict_attr_valid_func_t) (fr_dict_attr_t *da)
 
typedef struct fr_dict_autoload_talloc_s fr_dict_autoload_talloc_t
 
typedef int(* fr_dict_flag_parse_func_t) (fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule)
 Custom protocol-specific flag parsing function. More...
 
typedef struct fr_dict_flag_parser_rule_s fr_dict_flag_parser_rule_t
 
typedef int(* fr_dict_flags_cmp_func_t) (fr_dict_attr_t const *da_a, fr_dict_attr_t const *da_b)
 Compare the protocol specific flags struct from two attributes. More...
 
typedef int(* fr_dict_flags_copy_func_t) (fr_dict_attr_t *da_to, void *flags_to, void *flags_from)
 Copy custom flags from one attribute to another. More...
 
typedef struct fr_dict_gctx_s fr_dict_gctx_t
 
typedef void(* fr_dict_protocol_free_t) (void)
 
typedef int(* fr_dict_protocol_init_t) (void)
 Init / free callbacks. More...
 
typedef struct fr_dict_s fr_dict_t
 
typedef struct pair_list_s fr_pair_list_t
 
typedef struct value_box_s fr_value_box_t
 

Enumerations

enum  {
  FLAG_EXTRA_NONE = 0 ,
  FLAG_KEY_FIELD ,
  FLAG_BIT_FIELD ,
  FLAG_LENGTH_UINT8 ,
  FLAG_LENGTH_UINT16
}
 subtype values for the dictionary when extra=1 More...
 
enum  fr_dict_attr_err_t {
  FR_DICT_ATTR_OK = 0 ,
  FR_DICT_ATTR_NOTFOUND = -1 ,
  FR_DICT_ATTR_PROTOCOL_NOTFOUND = -2 ,
  FR_DICT_ATTR_PARSE_ERROR = -3 ,
  FR_DICT_ATTR_INTERNAL_ERROR = -4 ,
  FR_DICT_ATTR_OOM = -5 ,
  FR_DICT_ATTR_NOT_DESCENDENT = -6 ,
  FR_DICT_ATTR_NOT_ANCESTOR = -7 ,
  FR_DICT_ATTR_NO_CHILDREN = -8 ,
  FR_DICT_ATTR_EINVAL = -9
}
 Errors returned by attribute lookup functions. More...
 
enum  fr_dict_attr_ext_t {
  FR_DICT_ATTR_EXT_NAME = 0 ,
  FR_DICT_ATTR_EXT_CHILDREN ,
  FR_DICT_ATTR_EXT_REF ,
  FR_DICT_ATTR_EXT_VENDOR ,
  FR_DICT_ATTR_EXT_DA_STACK ,
  FR_DICT_ATTR_EXT_ENUMV ,
  FR_DICT_ATTR_EXT_NAMESPACE ,
  FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC ,
  FR_DICT_ATTR_EXT_MAX
}
 Extension identifier. More...
 
enum  fr_dict_enum_ext_t {
  FR_DICT_ENUM_EXT_UNION_REF = 0 ,
  FR_DICT_ENUM_EXT_MAX
}
 Extension identifier. More...
 

Variables

bool const fr_dict_attr_allowed_chars [UINT8_MAX+1]
 Characters that are allowed in dictionary attribute names. More...
 
bool const fr_dict_enum_allowed_chars [UINT8_MAX+1]
 Characters that are allowed in dictionary enumeration value names. More...
 

Attribute lineage

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...
 
fr_slen_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_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_slen_t fr_dict_attr_flags_print (fr_sbuff_t *out, fr_dict_t const *dict, fr_type_t type, fr_dict_attr_flags_t const *flags)
 
fr_slen_t fr_dict_attr_oid_print (fr_sbuff_t *out, fr_dict_attr_t const *ancestor, fr_dict_attr_t const *da, bool numeric)
 Build the da_stack for the specified DA and encode the path by name in OID form. More...
 
#define FR_DICT_ATTR_OID_PRINT_RETURN(...)   FR_SBUFF_RETURN(fr_dict_attr_oid_print, ##__VA_ARGS__)
 
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...
 

Autoloader interface

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...
 
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...
 
#define fr_dict_autofree(_to_free)   _fr_dict_autofree(_to_free, __FILE__)
 
#define fr_dict_autoload(_to_load)   _fr_dict_autoload(_to_load, __FILE__)
 
#define fr_dict_autoload_talloc(_ctx, _dict_out, _proto)   _fr_dict_autoload_talloc(_ctx, _dict_out, _proto, __FILE__)
 
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...
 
int fr_dl_dict_attr_autoload (dl_t const *module, void *symbol, void *user_ctx)
 
void fr_dl_dict_autofree (dl_t const *module, void *symbol, void *user_ctx)
 
int fr_dl_dict_autoload (dl_t const *module, void *symbol, void *user_ctx)
 
int fr_dl_dict_enum_autoload (dl_t const *module, void *symbol, void *user_ctx)
 

Global dictionary management

fr_dict_attr_tfr_dict_attr_unconst (fr_dict_attr_t const *da)
 Coerce to non-const. 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)
 
typedef struct fr_hash_iter_s fr_dict_global_ctx_iter_t
 
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)
 
fr_dict_tfr_dict_unconst (fr_dict_t const *dict)
 Coerce to non-const. More...
 

Dictionary testing and validation

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...
 
void fr_dict_attr_verify (char const *file, int line, fr_dict_attr_t const *da)
 
int fr_dict_parse_str (fr_dict_t *dict, char *buf, fr_dict_attr_t const *parent)
 
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)
 
int fr_dict_walk (fr_dict_attr_t const *da, fr_dict_walk_t callback, void *uctx)
 
typedef int(* fr_dict_walk_t) (fr_dict_attr_t const *da, void *uctx)
 

Attribute, vendor and dictionary lookup

static fr_slen_t err
 
fr_dict_attr_t const * fr_dict_attr_by_name (fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *attr))
 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, fr_sbuff_term_t const *tt))
 
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...
 
static bool fr_dict_attr_is_top_level (fr_dict_attr_t const *da)
 Return true if this attribute is parented directly off the dictionary root. 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 *attr, 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_t const * fr_dict_by_attr_name (fr_dict_attr_t const **found, char const *name)
 
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...
 
dl_tfr_dict_dl (fr_dict_t const *dict)
 
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...
 
static fr_slen_t fr_dict_enum_name_afrom_substr (TALLOC_CTX *ctx, char **out, fr_sbuff_parse_error_t *err, fr_sbuff_t *in, fr_sbuff_term_t const *tt) 1(fr_dict_enum_name_from_substr
 
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...
 
bool fr_dict_is_read_only (fr_dict_t const *dict)
 
fr_dict_attr_t const * fr_dict_root (fr_dict_t const *dict)
 Return the root attribute of a dictionary. More...
 
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. 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...
 
static fr_slen_t in
 

Programmatically create dictionary attributes and values

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_enum_add_name (fr_dict_attr_t *da, char const *name, fr_value_box_t const *value, bool coerce, bool replace)
 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_str_to_argv (char *str, char **argv, int max_argc)
 

Dict accessors

fr_dict_protocol_t const * fr_dict_protocol (fr_dict_t const *dict)
 Return the protocol descriptor for the dictionary. More...
 

Unknown ephemeral attributes

fr_dict_attr_t const * fr_dict_attr_unknown_add (fr_dict_t *dict, fr_dict_attr_t const *old)
 Converts an unknown to a known by adding it to the internal dictionaries. More...
 
fr_dict_attr_tfr_dict_attr_unknown_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da))
 Copy a known or unknown attribute to produce an unknown attribute with the specified name. More...
 
fr_slen_t fr_dict_attr_unknown_afrom_oid_substr (TALLOC_CTX *ctx, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in, fr_type_t type))
 Create a fr_dict_attr_t from an ASCII attribute and value. More...
 
static fr_dict_attr_tfr_dict_attr_unknown_copy (TALLOC_CTX *ctx, fr_dict_attr_t const *da)
 
void fr_dict_attr_unknown_free (fr_dict_attr_t const **da)
 Free dynamically allocated (unknown attributes) More...
 
int fr_dict_attr_unknown_parent_to_known (fr_dict_attr_t *da, fr_dict_attr_t const *parent)
 Fixup the parent of an unknown attribute using an equivalent known attribute. More...
 
fr_dict_attr_tfr_dict_attr_unknown_raw_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da))
 Initialise an octets type attribute from a da. More...
 
static fr_dict_attr_tfr_dict_attr_unknown_raw_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
 
fr_dict_attr_t const * fr_dict_attr_unknown_resolve (fr_dict_t const *dict, fr_dict_attr_t const *da)
 Check to see if we can convert a nested TLV structure to known attributes. More...
 
static fr_dict_attr_tfr_dict_attr_unknown_typed_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num, fr_type_t type)
 
fr_dict_attr_tfr_dict_attr_unknown_typed_afrom_num_raw (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num, fr_type_t type, bool raw))
 Initialise a fr_dict_attr_t from a number and a data type. More...
 
static fr_dict_attr_tfr_dict_attr_unknown_vendor_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int vendor)
 

Attribute comparisons

static int8_t fr_dict_attr_cmp (fr_dict_attr_t const *a, fr_dict_attr_t const *b)
 
static int8_t fr_dict_attr_cmp_fields (const fr_dict_attr_t *a, const fr_dict_attr_t *b)
 Compare two dictionary attributes by their contents. More...
 

Debugging functions

void fr_dict_attr_debug (fr_dict_attr_t const *da)
 
void fr_dict_debug (fr_dict_t const *dict)
 
void fr_dict_export (fr_dict_t const *dict)
 Export in the standard form: ATTRIBUTE name oid flags. More...
 
void fr_dict_namespace_debug (fr_dict_attr_t const *da)
 

Dictionary and protocol loading

int fr_dict_internal_afrom_file (fr_dict_t **out, char const *internal_name, char const *dependent)
 (Re-)Initialize the special internal dictionary More...
 
int fr_dict_protocol_afrom_file (fr_dict_t **out, char const *proto_name, char const *proto_dir, char const *dependent)
 (Re)-initialize a protocol dictionary More...
 
fr_dict_tfr_dict_protocol_alloc (fr_dict_t const *parent)
 Allocate a new local dictionary. More...
 
int fr_dict_read (fr_dict_t *dict, char const *dict_dir, char const *filename)
 Read supplementary attribute definitions into an existing dictionary. More...
 

Allocating and freeing

fr_dict_tfr_dict_alloc (char const *proto_name, unsigned int proto_number)
 
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...
 
int fr_dict_free (fr_dict_t **dict, char const *dependent)
 Decrement the reference count on a previously loaded dictionary. More...
 

Detailed Description

Multi-protocol AVP dictionary API.

Definition in file dict.h.


Data Structure Documentation

◆ dict_attr_s

struct dict_attr_s

Dictionary attribute.

Definition at line 176 of file dict.h.

+ Collaboration diagram for dict_attr_s:
Data Fields
unsigned int attr Attribute number.
unsigned int depth Depth of nesting for this attribute.
fr_dict_t _CONST *_CONST dict Dict attribute belongs to.
uint8_t ext[FR_DICT_ATTR_EXT_MAX] Extensions to the dictionary attribute.
char const * filename Where the attribute was defined.

this buffer's lifetime is bound to the fr_dict_t.

fr_dict_attr_flags_t flags Flags.
unsigned int last_child_attr highest value of last child attribute.
int line Line number where the attribute was defined.
char const * name Attribute name.
size_t name_len Length of the name.
fr_dict_attr_t const * next Next child in bin.
fr_dict_attr_t const * parent Immediate parent of this attribute.
struct dict_attr_s state
fr_type_t type Value type.

◆ dict_attr_s.state

struct dict_attr_s.state

Definition at line 194 of file dict.h.

Data Fields
bool attr_set: 1 Attribute number has been set.

We need the full range of values 0-UINT32_MAX so we can't use any attr values to indicate "unsetness".

bool finalised: 1 Attribute definition is complete and modifications that would change the address of the memory chunk of the attribute are no longer permitted.

◆ fr_dict_attr_autoload_t

struct fr_dict_attr_autoload_t

Specifies an attribute which must be present for the module to function.

Definition at line 266 of file dict.h.

+ Collaboration diagram for fr_dict_attr_autoload_t:
Data Fields
fr_dict_t const ** dict The protocol dictionary the attribute should be resolved in.

** so it's a compile time constant.

char const * name of the attribute.
fr_dict_attr_t const ** out Where to write a pointer to the resolved fr_dict_attr_t.
fr_type_t type of the attribute. Mismatch is a fatal error.

◆ fr_dict_attr_flags_t

struct fr_dict_attr_flags_t

Values of the encryption flags.

Definition at line 139 of file merged_model.c.

Data Fields
unsigned int array: 1 Pack multiples into 1 attr.
unsigned int counter: 1 integer attribute is actually an impulse / counter
unsigned int extra: 1 really "subtype is used by dict, not by protocol"
unsigned int has_value: 1 Has a value.
unsigned int: 1 is a local variable
unsigned int internal: 1 Internal attribute, should not be received in protocol packets, should not be encoded.
unsigned int is_alias: 1 This isn't a real attribute, it's a reference to to one.
unsigned int is_known_width: 1 is treated as if it has a known width for structs
unsigned int is_raw: 1 This dictionary attribute was constructed from a known attribute to allow the user to assign octets values directly.

See .is_unknown to determine if it is ephemeral.

unsigned int is_root: 1 Is root of a dictionary.
unsigned int is_unknown: 1 This dictionary attribute is ephemeral and not part of the main dictionary.
unsigned int is_unsigned: 1 hackity hack for dates and time deltas
uint8_t length length of the attribute
unsigned int name_only: 1 this attribute should always be referred to by name.

A number will be allocated, but the allocation scheme will depend on the parent, and definition type, and may not be stable in all instances.

unsigned int secret: 1 this attribute should be omitted in debug mode
uint8_t subtype protocol-specific values, OR key fields
uint8_t type_size For TLV2 and root attributes.

◆ fr_dict_autoload_t

struct fr_dict_autoload_t

Specifies a dictionary which must be loaded/loadable for the module to function.

Definition at line 279 of file dict.h.

+ Collaboration diagram for fr_dict_autoload_t:
Data Fields
char const * base_dir Directory structure beneath share.
fr_dict_t const ** out Where to write a pointer to the loaded/resolved fr_dict_t.
char const * proto The protocol dictionary name.

◆ fr_dict_enum_autoload_t

struct fr_dict_enum_autoload_t

Specifies a value which must be present for the module to function.

Definition at line 255 of file dict.h.

+ Collaboration diagram for fr_dict_enum_autoload_t:
Data Fields
fr_dict_attr_t const ** attr The protocol dictionary the attribute should be resolved in.

** so it's a compile time constant.

char const * name of the attribute.
fr_value_box_t const ** out Enumeration value.

◆ fr_dict_enum_value_t

struct fr_dict_enum_value_t

Value of an enumerated attribute.

Maps one of more string values to integers and vice versa.

Definition at line 226 of file dict.h.

+ Collaboration diagram for fr_dict_enum_value_t:
Data Fields
fr_dict_attr_t const * child_struct[] for key fields
uint8_t ext[FR_DICT_ENUM_EXT_MAX] Extensions to the dictionary attribute.
char const * name Enum name.
size_t name_len Allows for efficient name lookups when operating on partial buffers.
fr_value_box_t const * value Enum value (what name maps to).

◆ fr_dict_flag_parser_rule_s

struct fr_dict_flag_parser_rule_s

Definition at line 365 of file dict.h.

+ Collaboration diagram for fr_dict_flag_parser_rule_s:
Data Fields
fr_dict_flag_parse_func_t func Custom parsing function to convert a flag value string to a C type value.
bool needs_value This parsing flag must have a value. Else we error.
void * uctx Use context to pass to the custom parsing function.

◆ fr_dict_flag_parser_t

struct fr_dict_flag_parser_t

Protocol specific custom flag definitnion.

Definition at line 396 of file dict.h.

+ Collaboration diagram for fr_dict_flag_parser_t:
Data Fields
fr_table_elem_name_t name Name of the flag.
fr_dict_flag_parser_rule_t value Function and context to parse the flag.

◆ fr_dict_protocol_t

struct fr_dict_protocol_t

Protocol-specific callbacks in libfreeradius-PROTOCOL.

Definition at line 427 of file dict.h.

+ Collaboration diagram for fr_dict_protocol_t:
Data Fields
struct fr_dict_protocol_t attr
fr_dict_attr_decode_func_t decode for decoding attributes.

Used for implementing foreign protocol attributes.

int default_type_length how many octets are in "length" field
int default_type_size how many octets are in "type" field
fr_dict_attr_encode_func_t encode for encoding attributes.

Used for implementing foreign protocol attributes.

fr_dict_protocol_free_t free free the library
fr_dict_protocol_init_t init initialize the library
char const * name name of this protocol

◆ fr_dict_protocol_t.attr

struct fr_dict_protocol_t.attr

Definition at line 433 of file dict.h.

Data Fields
attr flags Custom flags for this protocol.
fr_dict_attr_valid_func_t valid Validation function to ensure that new attributes are valid.

◆ fr_dict_protocol_t.attr.flags

struct fr_dict_protocol_t.attr.flags

Custom flags for this protocol.

Definition at line 436 of file dict.h.

Data Fields
fr_dict_flags_cmp_func_t cmp Compare protocol-specific flags from two attributes.

Called when comparing attributes by their fields.

fr_dict_flags_copy_func_t copy Copy protocol-specific flags from one attribute to another.

Called when copying attributes.

size_t len Length of the protocol specific flags structure.

This is used to allocate a FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC extension of the specified length.

fr_dict_flag_parser_t const * table Flags for this protocol, an array of fr_dict_flag_parser_t.
size_t table_len Length of protocol_flags table.

◆ fr_dict_vendor_t

struct fr_dict_vendor_t

Private enterprise.

Represents an IANA private enterprise allocation.

The width of the private enterprise number must be the same for all protocols so we can represent a vendor with a single struct.

Definition at line 244 of file dict.h.

Data Fields
bool continuation we only have one flag for now, for WiMAX
size_t length Length of length data.
char const * name Vendor name.
uint32_t pen Private enterprise number.
size_t type Length of type data.

Macro Definition Documentation

◆ _CONST

#define _CONST   const

Definition at line 58 of file dict.h.

◆ da_is_bit_field

#define da_is_bit_field (   _da)    ((_da)->flags.extra && ((_da)->flags.subtype == FLAG_BIT_FIELD))

Definition at line 153 of file dict.h.

◆ da_is_length_field

#define da_is_length_field (   _da)    ((_da)->flags.extra && (((_da)->flags.subtype == FLAG_LENGTH_UINT8) || ((_da)->flags.subtype == FLAG_LENGTH_UINT16)))

Definition at line 154 of file dict.h.

◆ da_length_offset

#define da_length_offset (   _da)    ((_da)->flags.type_size)

Definition at line 155 of file dict.h.

◆ DA_VERIFY

#define DA_VERIFY (   _x)    fr_cond_assert(_x)

Definition at line 66 of file dict.h.

◆ flag_byte_offset

#define flag_byte_offset   type_size

Definition at line 139 of file dict.h.

◆ flag_time_res

#define flag_time_res   type_size

Definition at line 138 of file dict.h.

◆ FR_DICT_ATTR_FLAG_FUNC

#define FR_DICT_ATTR_FLAG_FUNC (   _struct,
  _name 
)
Value:
static int dict_flag_##_name(fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)\
{ \
flags->_name = 1; \
return 0; \
}
#define UNUSED
Definition: build.h:313
@ FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC
Protocol specific extensions.
Definition: dict.h:170
static void * fr_dict_attr_ext(fr_dict_attr_t const *da, fr_dict_attr_ext_t ext)
Definition: dict_ext.h:140
Test enumeration values.
Definition: dict_test.h:92

Define a flag setting function, which sets one bit in a fr_dict_attr_flags_t.

This is here, because AFAIK there's no completely portable way to get the bit offset of a bit field in a structure.

Definition at line 406 of file dict.h.

◆ fr_dict_attr_is_key_field

#define fr_dict_attr_is_key_field (   _da)    ((_da)->flags.extra && ((_da)->flags.subtype == FLAG_KEY_FIELD))

Definition at line 152 of file dict.h.

◆ FR_DICT_ATTR_MAX_NAME_LEN

#define FR_DICT_ATTR_MAX_NAME_LEN   (128)

Maximum length of a attribute name.

Definition at line 472 of file dict.h.

◆ FR_DICT_ATTR_OID_PRINT_RETURN

#define FR_DICT_ATTR_OID_PRINT_RETURN (   ...)    FR_SBUFF_RETURN(fr_dict_attr_oid_print, ##__VA_ARGS__)

Definition at line 697 of file dict.h.

◆ fr_dict_autofree

#define fr_dict_autofree (   _to_free)    _fr_dict_autofree(_to_free, __FILE__)

Definition at line 850 of file dict.h.

◆ fr_dict_autoload

#define fr_dict_autoload (   _to_load)    _fr_dict_autoload(_to_load, __FILE__)

Definition at line 847 of file dict.h.

◆ fr_dict_autoload_talloc

#define fr_dict_autoload_talloc (   _ctx,
  _dict_out,
  _proto 
)    _fr_dict_autoload_talloc(_ctx, _dict_out, _proto, __FILE__)

Definition at line 853 of file dict.h.

◆ FR_DICT_DA_STACK_CACHE_MAX

#define FR_DICT_DA_STACK_CACHE_MAX   (5)

Maximum level of da stack caching.

Definition at line 480 of file dict.h.

◆ FR_DICT_ENUM_MAX_NAME_LEN

#define FR_DICT_ENUM_MAX_NAME_LEN   (128)

Maximum length of a enum value.

Definition at line 470 of file dict.h.

◆ FR_DICT_MAX_TLV_STACK

#define FR_DICT_MAX_TLV_STACK   (FR_DICT_TLV_NEST_MAX + 5)

Maximum TLV stack size.

The additional attributes are to account for

Root + Vendor + NULL (top frame). Root + Embedded protocol + Root + Vendor + NULL.

Code should ensure that it doesn't run off the end of the stack, as this could be remotely exploitable, using odd nesting.

Definition at line 492 of file dict.h.

◆ FR_DICT_PROTO_MAX_NAME_LEN

#define FR_DICT_PROTO_MAX_NAME_LEN   (128)

Maximum length of a protocol name.

Definition at line 469 of file dict.h.

◆ FR_DICT_PROTOCOL_FLAG

#define FR_DICT_PROTOCOL_FLAG (   _struct,
  _field 
)
Value:
.type = FR_CTYPE_TO_TYPE((((_struct *)NULL)->_field)), \
.offset = offsetof(_struct, _field)
#define FR_CTYPE_TO_TYPE(_ct)
Given a variable, return the equivalent FR_TYPE_* value.
Definition: types.h:385

conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct

Parameters
[in]_nameof the flag search for.
[in]_structcontaining the field to write the result to.
[in]_fieldto write the flag to

Definition at line 420 of file dict.h.

◆ FR_DICT_TLV_NEST_MAX

#define FR_DICT_TLV_NEST_MAX   (24)

Maximum level of TLV nesting allowed.

Definition at line 476 of file dict.h.

◆ FR_DICT_VENDOR_MAX_NAME_LEN

#define FR_DICT_VENDOR_MAX_NAME_LEN   (128)

Maximum length of a vendor name.

Definition at line 471 of file dict.h.

Typedef Documentation

◆ fr_dbuff_t

typedef struct fr_dbuff_s fr_dbuff_t

Definition at line 305 of file dict.h.

◆ fr_dict_attr_decode_func_t

typedef ssize_t(* fr_dict_attr_decode_func_t) (TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t const *data, size_t data_len)

A generic interface for decoding packets to fr_pair_ts.

A decoding function should decode a single top level packet from wire format.

Note that unlike fr_tp_proto_decode_t, this function is NOT passed an encode_ctx. That is because when we do cross-protocol encoding, the "outer" protocol has no information it can share with the "inner" protocol.

Parameters
[in]ctxto allocate new pairs in.
[in]vpswhere new VPs will be added
[in]datato decode.
[in]data_lenThe length of the incoming data.
Returns
  • <= 0 on error. May be the offset (as a negative value) where the error occurred.
  • > 0 on success. How many bytes were decoded.

Definition at line 328 of file dict.h.

◆ fr_dict_attr_encode_func_t

typedef ssize_t(* fr_dict_attr_encode_func_t) (fr_dbuff_t *dbuff, fr_pair_list_t const *vps)

A generic interface for encoding fr_pair_ts to packets.

An encoding function should encode multiple VPs to a wire format packet

Note that unlike fr_tp_proto_encode_t, this function is NOT passed an encode_ctx. That is because when we do cross-protocol encoding, the "outer" protocol has no information it can share with the "inner" protocol.

Parameters
[in]vpsvps to encode
[in]dbuffbuffer where data can be written
Returns
  • <= 0 on error. May be the offset (as a negative value) where the error occurred.
  • > 0 on success. How many bytes were encoded

Definition at line 344 of file dict.h.

◆ fr_dict_attr_t

typedef struct dict_attr_s fr_dict_attr_t

Definition at line 1 of file dict.h.

◆ fr_dict_attr_valid_func_t

typedef bool(* fr_dict_attr_valid_func_t) (fr_dict_attr_t *da)

Definition at line 305 of file dict.h.

◆ fr_dict_autoload_talloc_t

Definition at line 1 of file dict.h.

◆ fr_dict_flag_parse_func_t

typedef int(* fr_dict_flag_parse_func_t) (fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule)

Custom protocol-specific flag parsing function.

Note
This function should be used to implement table based flag parsing.
Parameters
[in]da_pwe're currently populating
[in]valueflag value to parse.
[in]ruleHow to parse the flag.

Definition at line 363 of file dict.h.

◆ fr_dict_flag_parser_rule_t

Definition at line 351 of file dict.h.

◆ fr_dict_flags_cmp_func_t

typedef int(* fr_dict_flags_cmp_func_t) (fr_dict_attr_t const *da_a, fr_dict_attr_t const *da_b)

Compare the protocol specific flags struct from two attributes.

@para[in] da_a first attribute to compare. @para[in] da_b second attribute to compare.

Returns
  • 0 if the flags are equal.
  • < 0 if da_a < da_b.
  • > 0 if da_a > da_b.

Definition at line 391 of file dict.h.

◆ fr_dict_flags_copy_func_t

typedef int(* fr_dict_flags_copy_func_t) (fr_dict_attr_t *da_to, void *flags_to, void *flags_from)

Copy custom flags from one attribute to another.

Parameters
[out]da_toattribute to copy to. Use for the talloc_ctx for any heap allocated flag values.
[out]flags_toprotocol specific flags struct to copy to.
[in]flags_fromprotocol specific flags struct to copy from.
Returns
  • 0 on success.
  • -1 on error.

Definition at line 380 of file dict.h.

◆ fr_dict_gctx_t

Definition at line 391 of file dict.h.

◆ fr_dict_global_ctx_iter_t

Definition at line 896 of file dict.h.

◆ fr_dict_protocol_free_t

typedef void(* fr_dict_protocol_free_t) (void)

Definition at line 351 of file dict.h.

◆ fr_dict_protocol_init_t

typedef int(* fr_dict_protocol_init_t) (void)

Init / free callbacks.

Only for "autoref" usage.

Definition at line 350 of file dict.h.

◆ fr_dict_t

typedef struct fr_dict_s fr_dict_t

Definition at line 1 of file dict.h.

◆ fr_dict_walk_t

typedef int(* fr_dict_walk_t) (fr_dict_attr_t const *da, void *uctx)

Definition at line 925 of file dict.h.

◆ fr_pair_list_t

typedef struct pair_list_s fr_pair_list_t

Definition at line 305 of file dict.h.

◆ fr_value_box_t

typedef struct value_box_s fr_value_box_t

Definition at line 1 of file dict.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

subtype values for the dictionary when extra=1

Enumerator
FLAG_EXTRA_NONE 

no extra meaning, should be invalid

FLAG_KEY_FIELD 

this is a key field for a subsequent struct

FLAG_BIT_FIELD 

bit field inside of a struct

FLAG_LENGTH_UINT8 

string / octets type is prefixed by uint8 of length

FLAG_LENGTH_UINT16 

string / octets type is prefixed by uint16 of length

Definition at line 144 of file dict.h.

◆ fr_dict_attr_err_t

Errors returned by attribute lookup functions.

Enumerator
FR_DICT_ATTR_OK 

No error.

FR_DICT_ATTR_NOTFOUND 

Attribute couldn't be found.

FR_DICT_ATTR_PROTOCOL_NOTFOUND 

Protocol couldn't be found.

FR_DICT_ATTR_PARSE_ERROR 

Attribute string couldn't be parsed.

FR_DICT_ATTR_INTERNAL_ERROR 

Internal error occurred.

FR_DICT_ATTR_OOM 

Memory allocation error.

FR_DICT_ATTR_NOT_DESCENDENT 

Attribute is not a descendent of the parent attribute.

FR_DICT_ATTR_NOT_ANCESTOR 

Attribute is not an ancestor of the child attribute.

FR_DICT_ATTR_NO_CHILDREN 

Child lookup in attribute with no children.

FR_DICT_ATTR_EINVAL 

Invalid arguments.

Definition at line 289 of file dict.h.

◆ fr_dict_attr_ext_t

Extension identifier.

Note
New extension structures should also be added to the to the appropriate table in dict_ext.c
Enumerator
FR_DICT_ATTR_EXT_NAME 

Name of the attribute.

FR_DICT_ATTR_EXT_CHILDREN 

Attribute has children.

FR_DICT_ATTR_EXT_REF 

Attribute references another attribute and/or dictionary.

FR_DICT_ATTR_EXT_VENDOR 

Cached vendor pointer.

FR_DICT_ATTR_EXT_DA_STACK 

Cached da stack.

FR_DICT_ATTR_EXT_ENUMV 

Enumeration values.

FR_DICT_ATTR_EXT_NAMESPACE 

Attribute has its own namespace.

FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC 

Protocol specific extensions.

FR_DICT_ATTR_EXT_MAX 

Definition at line 161 of file dict.h.

◆ fr_dict_enum_ext_t

Extension identifier.

Note
New extension structures should also be added to the appropriate table in dict_ext.c
Enumerator
FR_DICT_ENUM_EXT_UNION_REF 

Reference to a union/subs-struct.

FR_DICT_ENUM_EXT_MAX 

Definition at line 217 of file dict.h.

Function Documentation

◆ _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 4172 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 4139 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 4223 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dict_alloc()

fr_dict_t* fr_dict_alloc ( char const *  proto_name,
unsigned int  proto_number 
)

Definition at line 3212 of file dict_tokenize.c.

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

◆ fr_dict_attr_acopy_local()

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.

+ 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,
unsigned 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 1712 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_initialised()

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.

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

◆ fr_dict_attr_add_name_only()

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.

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]typeof attribute.
[in]flagsto set in the attribute.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1738 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 4090 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 3263 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,
fr_sbuff_term_t const *  tt 
)
+ 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 2373 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()

fr_slen_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 2125 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 2324 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 4875 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 3328 of file dict_util.c.

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

◆ fr_dict_attr_cmp()

static int8_t fr_dict_attr_cmp ( fr_dict_attr_t const *  a,
fr_dict_attr_t const *  b 
)
inlinestatic

Definition at line 603 of file dict.h.

+ Here is the caller graph for this function:

◆ fr_dict_attr_cmp_fields()

static int8_t fr_dict_attr_cmp_fields ( const fr_dict_attr_t a,
const fr_dict_attr_t b 
)
inlinestatic

Compare two dictionary attributes by their contents.

Parameters
[in]aFirst attribute to compare.
[in]bSecond attribute to compare.
Returns
  • 0 if the attributes are equal.
  • -1 if a < b.
  • +1 if a > b.

Definition at line 640 of file dict.h.

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

+ Here is the caller graph for this function:

◆ fr_dict_attr_debug()

void fr_dict_attr_debug ( fr_dict_attr_t const *  da)

Definition at line 250 of file dict_print.c.

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

◆ fr_dict_attr_flags_print()

fr_slen_t fr_dict_attr_flags_print ( fr_sbuff_t out,
fr_dict_t const *  dict,
fr_type_t  type,
fr_dict_attr_flags_t const *  flags 
)

Definition at line 201 of file merged_model.c.

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

◆ fr_dict_attr_is_top_level()

static bool fr_dict_attr_is_top_level ( fr_dict_attr_t const *  da)
inlinestatic

Return true if this attribute is parented directly off the dictionary root.

Parameters
[in]dato check.
Returns
  • true if attribute is top level.
  • false if attribute is not top level.

Definition at line 754 of file dict.h.

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

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

◆ fr_dict_attr_oid_print()

fr_slen_t fr_dict_attr_oid_print ( fr_sbuff_t out,
fr_dict_attr_t const *  ancestor,
fr_dict_attr_t const *  da,
bool  numeric 
)

Build the da_stack for the specified DA and encode the path by name in OID form.

Parameters
[out]outWhere to write the OID.
[in]ancestorIf not NULL, only print OID portion between ancestor and da.
[in]dato print OID string for.
[in]numericprint the OID components as numbers, not attribute names.
Returns
  • >0 The number of bytes written to the buffer.
  • <= 0 The number of bytes we would have needed to write the next OID component.

Definition at line 188 of file merged_model.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 3004 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 3062 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 2975 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 3081 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 3033 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 4597 of file dict_util.c.

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

◆ fr_dict_attr_unknown_add()

fr_dict_attr_t const* fr_dict_attr_unknown_add ( fr_dict_t dict,
fr_dict_attr_t const *  unknown 
)

Converts an unknown to a known by adding it to the internal dictionaries.

Does not free old fr_dict_attr_t, that is left up to the caller.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]unknownattribute to add.
Returns
  • Existing fr_dict_attr_t if unknown was found in a dictionary.
  • A new entry representing unknown.

Definition at line 38 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_afrom_da()

fr_dict_attr_t* fr_dict_attr_unknown_afrom_da ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  da 
)

Copy a known or unknown attribute to produce an unknown attribute with the specified name.

Will copy the complete hierarchy down to the first known attribute.

Definition at line 229 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_afrom_oid_substr()

fr_slen_t fr_dict_attr_unknown_afrom_oid_substr ( TALLOC_CTX *  ctx,
fr_dict_attr_t const **  out,
fr_dict_attr_t const *  parent,
fr_sbuff_t in,
fr_type_t  type 
)

Create a fr_dict_attr_t from an ASCII attribute and value.

Where the attribute name is in the form:

  • d
  • d.d.d...
Note
If vendor != 0, an unknown vendor (may) also be created, parented by the correct VSA attribute. This is accessible via vp->parent, and will be use the unknown da as its talloc parent.
Parameters
[in]ctxto alloc new attribute in.
[out]outWhere to write the head of the chain unknown dictionary attributes.
[in]parentAttribute to use as the root for resolving OIDs in. Usually the root of a protocol dictionary.
[in]inOID string to parse
[in]typedata type of the unknown attribute
Returns
  • The number of bytes parsed on success.
  • <= 0 on failure. Negative offset indicates parse error position.

Definition at line 378 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_copy()

static fr_dict_attr_t* fr_dict_attr_unknown_copy ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  da 
)
inlinestatic

Definition at line 550 of file dict.h.

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

◆ fr_dict_attr_unknown_free()

void fr_dict_attr_unknown_free ( fr_dict_attr_t const **  da)

Free dynamically allocated (unknown attributes)

If the da was dynamically allocated it will be freed, else the function will return without doing anything.

Parameters
[in]dato free.

Definition at line 148 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_parent_to_known()

int fr_dict_attr_unknown_parent_to_known ( fr_dict_attr_t da,
fr_dict_attr_t const *  parent 
)

Fixup the parent of an unknown attribute using an equivalent known attribute.

This can be useful where an unknown attribute's ancestors are added to a dictionary but not the unknown attribute itself.

Parameters
[in]dato fixup.
[in]parentto assign. If NULL, we will attempt to resolve the parent in the dictionary the current unknown attribute extends.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 511 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_raw_afrom_da()

fr_dict_attr_t* fr_dict_attr_unknown_raw_afrom_da ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  da 
)

Initialise an octets type attribute from a da.

Parameters
[in]ctxto allocate the attribute in.
[in]daof the unknown attribute.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 352 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_raw_afrom_num()

static fr_dict_attr_t* fr_dict_attr_unknown_raw_afrom_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  attr 
)
inlinestatic

Definition at line 577 of file dict.h.

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

◆ fr_dict_attr_unknown_resolve()

fr_dict_attr_t const* fr_dict_attr_unknown_resolve ( fr_dict_t const *  dict,
fr_dict_attr_t const *  da 
)

Check to see if we can convert a nested TLV structure to known attributes.

Parameters
[in]dictto search in.
[in]daNested tlv structure to convert.
Returns
  • NULL if we can't.
  • Known attribute if we can.

Definition at line 564 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_typed_afrom_num()

static fr_dict_attr_t* fr_dict_attr_unknown_typed_afrom_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  num,
fr_type_t  type 
)
inlinestatic

Definition at line 562 of file dict.h.

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

◆ fr_dict_attr_unknown_typed_afrom_num_raw()

fr_dict_attr_t* fr_dict_attr_unknown_typed_afrom_num_raw ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  num,
fr_type_t  type,
bool  raw 
)

Initialise a fr_dict_attr_t from a number and a data type.

Parameters
[in]ctxto allocate the attribute in.
[in]parentof the unknown attribute (may also be unknown).
[in]numof the unknown attribute.
[in]typedata type
[in]rawis it raw, i.e. bad value, versus unknown?
Returns

Definition at line 271 of file dict_unknown.c.

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

◆ fr_dict_attr_unknown_vendor_afrom_num()

static fr_dict_attr_t* fr_dict_attr_unknown_vendor_afrom_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  vendor 
)
inlinestatic

Definition at line 570 of file dict.h.

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

+ Here is the call graph for this function:

◆ fr_dict_by_attr_name()

fr_dict_t const* fr_dict_by_attr_name ( fr_dict_attr_t const **  found,
char const *  name 
)

◆ 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 2606 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 2577 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 2590 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 2497 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 2619 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 4008 of file dict_util.c.

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

◆ fr_dict_debug()

void fr_dict_debug ( fr_dict_t const *  dict)

Definition at line 258 of file dict_print.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 3691 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 2410 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 1941 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 1953 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 4051 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 3395 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 3421 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 3349 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_afrom_substr()

static fr_slen_t fr_dict_enum_name_afrom_substr ( TALLOC_CTX *  ctx,
char **  out,
fr_sbuff_parse_error_t err,
fr_sbuff_t in,
fr_sbuff_term_t const *  tt 
)
inlinestatic
+ 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 3382 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 3515 of file dict_util.c.

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

◆ fr_dict_export()

void fr_dict_export ( fr_dict_t const *  dict)

Export in the standard form: ATTRIBUTE name oid flags.

Definition at line 295 of file dict_print.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 4024 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 4530 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 4494 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 4483 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 4469 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 4392 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 4567 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 4574 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 4444 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 4503 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 4453 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 4610 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_internal_afrom_file()

int fr_dict_internal_afrom_file ( fr_dict_t **  out,
char const *  dict_subdir,
char const *  dependent 
)

(Re-)Initialize the special internal dictionary

This dictionary has additional programmatically generated attributes added to it, and is checked in addition to the protocol specific dictionaries.

Note
The dictionary pointer returned in out must have its reference counter decremented with fr_dict_free when no longer used.
Parameters
[out]outWhere to write pointer to the internal dictionary.
[in]dict_subdirname of the internal dictionary dir (may be NULL).
[in]dependentEither C src file, or another dictionary.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2966 of file dict_tokenize.c.

+ Here is the call graph for this function:
+ 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 2405 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_namespace_debug()

void fr_dict_namespace_debug ( fr_dict_attr_t const *  da)

Definition at line 230 of file dict_print.c.

+ Here is the call 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 2229 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 2080 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_parse_str()

int fr_dict_parse_str ( fr_dict_t dict,
char *  buf,
fr_dict_attr_t const *  parent 
)

Definition at line 3267 of file dict_tokenize.c.

+ Here is the call graph for this function:
+ 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 4948 of file dict_util.c.

+ Here is the caller graph for this function:

◆ fr_dict_protocol_afrom_file()

int fr_dict_protocol_afrom_file ( fr_dict_t **  out,
char const *  proto_name,
char const *  proto_dir,
char const *  dependent 
)

(Re)-initialize a protocol dictionary

Initialize the directory, then fix the attr number of all attributes.

Parameters
[out]outWhere to write a pointer to the new dictionary. Will free existing dictionary if files have changed and *out is not NULL.
[in]proto_namethat we're loading the dictionary for.
[in]proto_dirExplicitly set where to hunt for the dictionary files. May be NULL.
[in]dependentEither C src file, or another dictionary.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3103 of file dict_tokenize.c.

+ Here is the call graph for this function:
+ 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 3961 of file dict_util.c.

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

◆ fr_dict_read()

int fr_dict_read ( fr_dict_t dict,
char const *  dir,
char const *  filename 
)

Read supplementary attribute definitions into an existing dictionary.

Parameters
[in]dictExisting dictionary.
[in]dirdictionary is located in.
[in]filenameof the dictionary.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3247 of file dict_tokenize.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 2400 of file dict_util.c.

◆ fr_dict_str_to_argv()

int fr_dict_str_to_argv ( char *  str,
char **  argv,
int  max_argc 
)

Definition at line 86 of file dict_tokenize.c.

+ Here is the caller graph for this function:

◆ fr_dict_unconst()

fr_dict_t* fr_dict_unconst ( fr_dict_t const *  dict)

Coerce to non-const.

Definition at line 4585 of file dict_util.c.

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

◆ fr_dict_unlocal()

fr_dict_attr_t const* fr_dict_unlocal ( fr_dict_attr_t const *  da)

Definition at line 4956 of file dict_util.c.

+ Here is the call graph for this function:

◆ fr_dict_valid_name()

ssize_t fr_dict_valid_name ( char const *  name,
ssize_t  len 
)

Definition at line 4620 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 4663 of file dict_util.c.

+ Here is the caller graph for this function:

◆ 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 2635 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 2657 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 2680 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 2695 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 4777 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 ( dl_t const *  module,
void *  symbol,
void *  user_ctx 
)
+ Here is the caller graph for this function:

◆ fr_dl_dict_autofree()

void fr_dl_dict_autofree ( dl_t const *  module,
void *  symbol,
void *  user_ctx 
)
+ Here is the caller graph for this function:

◆ fr_dl_dict_autoload()

int fr_dl_dict_autoload ( dl_t const *  module,
void *  symbol,
void *  user_ctx 
)
+ Here is the caller graph for this function:

◆ fr_dl_dict_enum_autoload()

int fr_dl_dict_enum_autoload ( dl_t const *  module,
void *  symbol,
void *  user_ctx 
)
+ Here is the caller graph for this function:

Variable Documentation

◆ err

fr_slen_t err

Definition at line 821 of file dict.h.

◆ fr_dict_attr_allowed_chars

bool const fr_dict_attr_allowed_chars[UINT8_MAX+1]
extern

Characters that are allowed in dictionary attribute names.

Characters that are allowed in dictionary attribute names.

Definition at line 51 of file dict_util.c.

◆ fr_dict_enum_allowed_chars

bool const fr_dict_enum_allowed_chars[UINT8_MAX+1]
extern

Characters that are allowed in dictionary enumeration value names.

Characters that are allowed in dictionary enumeration value names.

Definition at line 72 of file dict_util.c.

◆ in

Definition at line 821 of file dict.h.