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  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_protocol_t
 Protocol-specific callbacks in libfreeradius-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_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_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_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, fr_dict_attr_flags_t *flags)
 
typedef struct fr_dict_autoload_talloc_s fr_dict_autoload_talloc_t
 
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 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_protocol_t const * fr_dict_protocol (fr_dict_t const *dict)
 Return the protocol descriptor for the 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_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_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_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)
 

Unknown ephemeral attributes

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_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...
 
fr_dict_attr_t const * fr_dict_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_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_unknown_afrom_oid_substr (TALLOC_CTX *ctx, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, fr_sbuff_t *in))
 Create a fr_dict_attr_t from an ASCII attribute and value. More...
 
fr_dict_attr_tfr_dict_unknown_attr_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da))
 Initialise an octets type attribute from a da. More...
 
fr_dict_attr_tfr_dict_unknown_attr_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num))
 Initialise a fr_dict_attr_t from a number. More...
 
static fr_dict_attr_tfr_dict_unknown_copy (TALLOC_CTX *ctx, fr_dict_attr_t const *da)
 
void fr_dict_unknown_free (fr_dict_attr_t const **da)
 Free dynamically allocated (unknown attributes) More...
 
fr_dict_attr_tfr_dict_unknown_tlv_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int num))
 Initialise a fr_dict_attr_t from a number. More...
 
fr_dict_attr_tfr_dict_unknown_vendor_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int vendor))
 Build an unknown vendor, parented by a VSA attribute. More...
 

Attribute comparisons

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

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 174 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.
fr_dict_attr_t * fixup Attribute has been marked up for fixups.
fr_dict_attr_flags_t flags Flags.
unsigned int last_child_attr highest value of last child attribute.
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.
fr_type_t type Value type.

◆ 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 249 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, not by number
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 262 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 238 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 209 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_protocol_t

struct fr_dict_protocol_t

Protocol-specific callbacks in libfreeradius-PROTOCOL.

Definition at line 341 of file dict.h.

+ Collaboration diagram for fr_dict_protocol_t:
Data Fields
fr_dict_attr_valid_func_t attr_valid validation function for new attributes
fr_dict_attr_decode_func_t decode for decoding 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
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_table_num_ordered_t const * subtype_table for "encrypt=1", etc.
size_t subtype_table_len length of subtype_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 227 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 150 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 151 of file dict.h.

◆ da_length_offset

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

Definition at line 152 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 136 of file dict.h.

◆ flag_time_res

#define flag_time_res   type_size

Definition at line 135 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 149 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 364 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 521 of file dict.h.

◆ fr_dict_autofree

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

Definition at line 674 of file dict.h.

◆ fr_dict_autoload

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

Definition at line 671 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 677 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 372 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 362 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 384 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 361 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 368 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 363 of file dict.h.

Typedef Documentation

◆ fr_dbuff_t

typedef struct fr_dbuff_s fr_dbuff_t

Definition at line 288 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 312 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 328 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_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, fr_dict_attr_flags_t *flags)

Definition at line 288 of file dict.h.

◆ fr_dict_autoload_talloc_t

Definition at line 1 of file dict.h.

◆ fr_dict_gctx_t

Definition at line 335 of file dict.h.

◆ fr_dict_global_ctx_iter_t

Definition at line 720 of file dict.h.

◆ fr_dict_protocol_free_t

typedef void(* fr_dict_protocol_free_t) (void)

Definition at line 335 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 334 of file dict.h.

◆ fr_dict_t

typedef struct fr_dict 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 749 of file dict.h.

◆ fr_pair_list_t

typedef struct pair_list_s fr_pair_list_t

Definition at line 288 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 141 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 272 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 159 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 200 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 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_alloc()

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

Definition at line 2997 of file dict_tokenize.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,
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 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()

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 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_cmp()

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

Definition at line 466 of file dict.h.

+ 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_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 578 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 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_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 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_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 536 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_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 589 of file dict_unknown.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_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 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_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 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_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 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_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 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_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 2751 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 2002 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 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_parse_str()

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

Definition at line 3052 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 4537 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 2888 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 3512 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 3032 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 1997 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 80 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 4179 of file dict_util.c.

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

◆ fr_dict_unknown_add()

fr_dict_attr_t const* fr_dict_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_unknown_afrom_da()

fr_dict_attr_t* fr_dict_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 226 of file dict_unknown.c.

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

◆ fr_dict_unknown_afrom_oid_substr()

fr_slen_t fr_dict_unknown_afrom_oid_substr ( TALLOC_CTX *  ctx,
fr_dict_attr_t const **  out,
fr_dict_attr_t const *  parent,
fr_sbuff_t in 
)

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]inof attribute.
Returns
  • The number of bytes parsed on success.
  • <= 0 on failure. Negative offset indicates parse error position.

Definition at line 403 of file dict_unknown.c.

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

◆ fr_dict_unknown_attr_afrom_da()

fr_dict_attr_t* fr_dict_unknown_attr_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 378 of file dict_unknown.c.

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

◆ fr_dict_unknown_attr_afrom_num()

fr_dict_attr_t* fr_dict_unknown_attr_afrom_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  num 
)

Initialise a fr_dict_attr_t from a number.

Parameters
[in]ctxto allocate the attribute in.
[in]parentof the unknown attribute (may also be unknown).
[in]numof the unknown attribute.
Returns

Definition at line 345 of file dict_unknown.c.

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

◆ fr_dict_unknown_copy()

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

Definition at line 428 of file dict.h.

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

◆ fr_dict_unknown_free()

void fr_dict_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_unknown_tlv_afrom_num()

fr_dict_attr_t* fr_dict_unknown_tlv_afrom_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  num 
)

Initialise a fr_dict_attr_t from a number.

Parameters
[in]ctxto allocate the attribute in.
[in]parentof the unknown attribute (may also be unknown).
[in]numof the unknown attribute.
Returns

Definition at line 312 of file dict_unknown.c.

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

◆ fr_dict_unknown_vendor_afrom_num()

fr_dict_attr_t* fr_dict_unknown_vendor_afrom_num ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  parent,
unsigned int  vendor 
)

Build an unknown vendor, parented by a VSA attribute.

This allows us to complete the path back to the dictionary root in the case of unknown attributes with unknown vendors.

Note
Will return known vendors attributes where possible. Do not free directly, use fr_dict_unknown_free.
Parameters
[in]ctxto allocate the vendor attribute in.
[in]parentof the VSA attribute.
[in]vendorid.
Returns

Definition at line 272 of file dict_unknown.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 ( 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 645 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 45 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 66 of file dict_util.c.

◆ in

Definition at line 645 of file dict.h.