The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
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>
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_t * | fr_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_t * | fr_dict_global_ctx_init (TALLOC_CTX *ctx, bool free_at_exit, char const *dict_dir) |
Initialise the global protocol hashes. More... | |
fr_dict_t * | fr_dict_global_ctx_iter_init (fr_dict_global_ctx_iter_t *iter) |
Iterate protocols by name. More... | |
fr_dict_t * | fr_dict_global_ctx_iter_next (fr_dict_global_ctx_iter_t *iter) |
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_t * | fr_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) |
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_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. 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_t * | fr_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_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. More... | |
static fr_dict_attr_t * | fr_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_t * | fr_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_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. More... | |
static fr_dict_attr_t * | fr_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_t * | fr_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_t * | fr_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... | |
Multi-protocol AVP dictionary API.
Definition in file dict.h.
struct 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. |
struct dict_attr_s.state |
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. |
struct fr_dict_attr_autoload_t |
Specifies an attribute which must be present for the module to function.
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. |
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. |
struct fr_dict_autoload_t |
Specifies a dictionary which must be loaded/loadable for the module to function.
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. |
struct fr_dict_enum_autoload_t |
Specifies a value which must be present for the module to function.
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. |
struct fr_dict_enum_value_t |
Value of an enumerated attribute.
Maps one of more string values to integers and vice versa.
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). |
struct 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. |
struct 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. |
struct 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 |
struct fr_dict_protocol_t.attr |
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. |
struct fr_dict_protocol_t.attr.flags |
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. |
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.
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. |
#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_VERIFY | ( | _x | ) | fr_cond_assert(_x) |
#define FR_DICT_ATTR_FLAG_FUNC | ( | _struct, | |
_name | |||
) |
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.
#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) |
#define FR_DICT_ATTR_OID_PRINT_RETURN | ( | ... | ) | FR_SBUFF_RETURN(fr_dict_attr_oid_print, ##__VA_ARGS__) |
#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__) |
#define FR_DICT_DA_STACK_CACHE_MAX (5) |
#define FR_DICT_ENUM_MAX_NAME_LEN (128) |
#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.
#define FR_DICT_PROTO_MAX_NAME_LEN (128) |
#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
[in] | _name | of the flag search for. |
[in] | _struct | containing the field to write the result to. |
[in] | _field | to write the flag to |
#define FR_DICT_TLV_NEST_MAX (24) |
#define FR_DICT_VENDOR_MAX_NAME_LEN (128) |
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.
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.
[in] | ctx | to allocate new pairs in. |
[in] | vps | where new VPs will be added |
[in] | data | to decode. |
[in] | data_len | The length of the incoming data. |
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.
[in] | vps | vps to encode |
[in] | dbuff | buffer where data can be written |
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) |
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) |
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.
[out] | da_to | attribute to copy to. Use for the talloc_ctx for any heap allocated flag values. |
[out] | flags_to | protocol specific flags struct to copy to. |
[in] | flags_from | protocol specific flags struct to copy from. |
typedef struct fr_dict_gctx_s fr_dict_gctx_t |
typedef struct fr_hash_iter_s fr_dict_global_ctx_iter_t |
typedef int(* fr_dict_protocol_init_t) (void) |
typedef int(* fr_dict_walk_t) (fr_dict_attr_t const *da, void *uctx) |
typedef struct pair_list_s fr_pair_list_t |
typedef struct value_box_s fr_value_box_t |
anonymous enum |
subtype values for the dictionary when extra=1
enum fr_dict_attr_err_t |
Errors returned by attribute lookup functions.
enum fr_dict_attr_ext_t |
Extension identifier.
enum fr_dict_enum_ext_t |
Extension identifier.
Enumerator | |
---|---|
FR_DICT_ENUM_EXT_UNION_REF | Reference to a union/subs-struct. |
FR_DICT_ENUM_EXT_MAX |
int _fr_dict_autofree | ( | fr_dict_autoload_t const * | to_free, |
char const * | dependent | ||
) |
Decrement the reference count on a previously loaded dictionary.
[in] | to_free | previously loaded dictionary to free. |
[in] | dependent | that originally allocated this dictionary |
Definition at line 4172 of file dict_util.c.
int _fr_dict_autoload | ( | fr_dict_autoload_t const * | to_load, |
char const * | dependent | ||
) |
Process a dict_autoload element to load a protocol.
[in] | to_load | dictionary definition. |
[in] | dependent | that is loading this dictionary. |
Definition at line 4139 of file dict_util.c.
fr_dict_autoload_talloc_t* _fr_dict_autoload_talloc | ( | TALLOC_CTX * | ctx, |
fr_dict_t const ** | out, | ||
char const * | proto, | ||
char const * | dependent | ||
) |
Autoload a dictionary and bind the lifetime to a talloc chunk.
Mainly useful for resolving "forward" references from unlang immediately.
[in] | ctx | to bind the dictionary lifetime to. |
[out] | out | pointer to the loaded dictionary. |
[in] | proto | to load. |
[in] | dependent | to register this reference to. Will be dupd. |
Definition at line 4223 of file dict_util.c.
fr_dict_t* fr_dict_alloc | ( | char const * | proto_name, |
unsigned int | proto_number | ||
) |
Definition at line 3212 of file dict_tokenize.c.
int fr_dict_attr_acopy_local | ( | fr_dict_attr_t const * | dst, |
fr_dict_attr_t const * | src | ||
) |
Definition at line 1060 of file dict_util.c.
int fr_dict_attr_add | ( | fr_dict_t * | dict, |
fr_dict_attr_t const * | parent, | ||
char const * | name, | ||
unsigned int | attr, | ||
fr_type_t | type, | ||
fr_dict_attr_flags_t const * | flags | ||
) |
Add an attribute to the dictionary.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | parent | to add attribute under. |
[in] | name | of the attribute. |
[in] | attr | number. |
[in] | type | of attribute. |
[in] | flags | to set in the attribute. |
Definition at line 1712 of file dict_util.c.
int fr_dict_attr_add_initialised | ( | fr_dict_attr_t * | da | ) |
A variant of fr_dict_attr_t that allows a pre-allocated, populated fr_dict_attr_t to be added.
Definition at line 1590 of file dict_util.c.
int fr_dict_attr_add_name_only | ( | fr_dict_t * | dict, |
fr_dict_attr_t const * | parent, | ||
char const * | name, | ||
fr_type_t | type, | ||
fr_dict_attr_flags_t const * | flags | ||
) |
Add an attribute to the dictionary.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | parent | to add attribute under. |
[in] | name | of the attribute. |
[in] | type | of attribute. |
[in] | flags | to set in the attribute. |
Definition at line 1738 of file dict_util.c.
int fr_dict_attr_autoload | ( | fr_dict_attr_autoload_t const * | to_load | ) |
Process a dict_attr_autoload element to load/verify a dictionary attribute.
[in] | to_load | attribute definition |
Definition at line 4090 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_by_name | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const * | parent, | ||
char const * | name | ||
) |
Locate a fr_dict_attr_t by its name.
[out] | err | Why the lookup failed. May be NULL. |
[in] | parent | containing the namespace we're searching in. |
[in] | name | of the attribute to locate. |
Definition at line 3263 of file dict_util.c.
fr_slen_t fr_dict_attr_by_name_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_attr_t const * | parent, | ||
fr_sbuff_t * | name, | ||
fr_sbuff_term_t const * | tt | ||
) |
fr_dict_attr_t const* fr_dict_attr_by_oid | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const * | parent, | ||
char const * | oid | ||
) |
Resolve an attribute using an OID string.
[out] | err | The parsing error that occurred. |
[in] | parent | Where to resolve relative attributes from. |
[in] | oid | string to parse. |
Definition at line 2373 of file dict_util.c.
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.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[out] | attr | Number we parsed. |
[in,out] | parent | attribute (or root of dictionary). Will be updated to the parent directly beneath the leaf. |
[in] | oid | string to parse. |
Definition at line 2125 of file dict_util.c.
fr_slen_t fr_dict_attr_by_oid_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_attr_t const * | parent, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt | ||
) |
Resolve an attribute using an OID string.
[out] | err | The parsing error that occurred. |
[out] | out | The deepest attribute we resolved. |
[in] | parent | Where to resolve relative attributes from. |
[in] | in | string to parse. |
[in] | tt | Terminal strings. |
Definition at line 2324 of file dict_util.c.
bool fr_dict_attr_can_contain | ( | fr_dict_attr_t const * | parent, |
fr_dict_attr_t const * | child | ||
) |
See if a structural da is allowed to contain another da.
We have some complex rules with different structural types, different protocol dictionaries, references to other protocols, etc.
[in] | parent | The parent da, must be structural |
[in] | child | The alleged child |
Definition at line 4875 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_child_by_num | ( | fr_dict_attr_t const * | parent, |
unsigned int | attr | ||
) |
Check if a child attribute exists in a parent using an attribute number.
[in] | parent | to check for child in. |
[in] | attr | number to look for. |
Definition at line 3328 of file dict_util.c.
|
inlinestatic |
|
inlinestatic |
Compare two dictionary attributes by their contents.
[in] | a | First attribute to compare. |
[in] | b | Second attribute to compare. |
Definition at line 640 of file dict.h.
fr_dict_attr_t const* fr_dict_attr_common_parent | ( | fr_dict_attr_t const * | a, |
fr_dict_attr_t const * | b, | ||
bool | is_ancestor | ||
) |
Find a common ancestor that two TLV type attributes share.
[in] | a | first TLV attribute. |
[in] | b | second TLV attribute. |
[in] | is_ancestor | Enforce a->b relationship (a is parent or ancestor of b). |
Definition at line 2037 of file dict_util.c.
void fr_dict_attr_debug | ( | fr_dict_attr_t const * | da | ) |
Definition at line 250 of file dict_print.c.
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.
|
inlinestatic |
fr_dict_attr_t const* fr_dict_attr_iterate_children | ( | fr_dict_attr_t const * | parent, |
fr_dict_attr_t const ** | prev | ||
) |
Iterate over children of a DA.
[in] | parent | the parent da to iterate over |
[in,out] | prev | pointer to NULL to start, otherwise pointer to the previously returned child |
Definition at line 4696 of file dict_util.c.
fr_slen_t fr_dict_attr_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.
[out] | out | Where to write the OID. |
[in] | ancestor | If not NULL, only print OID portion between ancestor and da. |
[in] | da | to print OID string for. |
[in] | numeric | print the OID components as numbers, not attribute names. |
Definition at line 188 of file merged_model.c.
fr_slen_t fr_dict_attr_search_by_name_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | name, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a fr_dict_attr_t by its name in the top level namespace of a dictionary.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute in the top level namespace.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | name | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3004 of file dict_util.c.
fr_slen_t fr_dict_attr_search_by_oid_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by a dictionary using a non-qualified OID string.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | in | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3062 of file dict_util.c.
fr_slen_t fr_dict_attr_search_by_qualified_name_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | name, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by its name and a dictionary qualifier.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute in the top level namespace.
This attribute may be qualified with <protocol>.
to selection an attribute in a specific case.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | name | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 2975 of file dict_util.c.
fr_dict_attr_t const* fr_dict_attr_search_by_qualified_oid | ( | fr_dict_attr_err_t * | err, |
fr_dict_t const * | dict_def, | ||
char const * | name, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by its name and a dictionary qualifier.
[out] | err | Why parsing failed. May be NULL. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | name | Dictionary/Attribute name. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3081 of file dict_util.c.
fr_slen_t fr_dict_attr_search_by_qualified_oid_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_t const * | dict_def, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt, | ||
bool | internal, | ||
bool | foreign | ||
) |
Locate a qualified fr_dict_attr_t by a dictionary qualified OID string.
This function will search through all loaded dictionaries, or a subset of loaded dictionaries, for a matching attribute.
[out] | err | Why parsing failed. May be NULL. |
[out] | out | Dictionary found attribute. |
[in] | dict_def | Default dictionary for non-qualified dictionaries. |
[in] | in | Dictionary/Attribute name. |
[in] | tt | Terminal strings. |
[in] | internal | If true, fallback to the internal dictionary. |
[in] | foreign | If true, fallback to foreign dictionaries. |
Definition at line 3033 of file dict_util.c.
fr_dict_attr_t* fr_dict_attr_unconst | ( | fr_dict_attr_t const * | da | ) |
Coerce to non-const.
Definition at line 4597 of file dict_util.c.
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.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | unknown | attribute to add. |
Definition at line 38 of file dict_unknown.c.
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.
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:
[in] | ctx | to alloc new attribute in. |
[out] | out | Where to write the head of the chain unknown dictionary attributes. |
[in] | parent | Attribute to use as the root for resolving OIDs in. Usually the root of a protocol dictionary. |
[in] | in | OID string to parse |
[in] | type | data type of the unknown attribute |
Definition at line 378 of file dict_unknown.c.
|
inlinestatic |
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.
[in] | da | to free. |
Definition at line 148 of file dict_unknown.c.
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.
[in] | da | to fixup. |
[in] | parent | to assign. If NULL, we will attempt to resolve the parent in the dictionary the current unknown attribute extends. |
Definition at line 511 of file dict_unknown.c.
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.
[in] | ctx | to allocate the attribute in. |
[in] | da | of the unknown attribute. |
Definition at line 352 of file dict_unknown.c.
|
inlinestatic |
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.
[in] | dict | to search in. |
[in] | da | Nested tlv structure to convert. |
Definition at line 564 of file dict_unknown.c.
|
inlinestatic |
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.
[in] | ctx | to allocate the attribute in. |
[in] | parent | of the unknown attribute (may also be unknown). |
[in] | num | of the unknown attribute. |
[in] | type | data type |
[in] | raw | is it raw, i.e. bad value, versus unknown? |
Definition at line 271 of file dict_unknown.c.
|
inlinestatic |
void fr_dict_attr_verify | ( | char const * | file, |
int | line, | ||
fr_dict_attr_t const * | da | ||
) |
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.
[in] | da | To get the containing dictionary for. |
Definition at line 2606 of file dict_util.c.
fr_dict_t const* fr_dict_by_protocol_name | ( | char const * | name | ) |
Lookup a protocol by its name.
[in] | name | of the protocol to locate. |
Definition at line 2577 of file dict_util.c.
fr_dict_t const* fr_dict_by_protocol_num | ( | unsigned int | num | ) |
Lookup a protocol by its number.
Returns the fr_dict_t belonging to the protocol with the specified number if any have been registered.
[in] | num | to search for. |
Definition at line 2590 of file dict_util.c.
fr_slen_t fr_dict_by_protocol_substr | ( | fr_dict_attr_err_t * | err, |
fr_dict_t const ** | out, | ||
fr_sbuff_t * | name, | ||
fr_dict_t const * | dict_def | ||
) |
Look up a protocol name embedded in another string.
[out] | err | Parsing error. |
[out] | out | the resolve dictionary or NULL if the dictionary couldn't be resolved. |
[in] | name | string start. |
[in] | dict_def | The dictionary to return if no dictionary qualifier was found. |
Definition at line 2497 of file dict_util.c.
See if two dictionaries have the same end parent.
[in] | dict1 | one dictionary |
[in] | dict2 | two dictionary |
Definition at line 2619 of file dict_util.c.
int fr_dict_const_free | ( | fr_dict_t const ** | dict, |
char const * | dependent | ||
) |
Decrement the reference count on a previously loaded dictionary.
[in] | dict | to free. |
[in] | dependent | that originally allocated this dictionary. |
Definition at line 4008 of file dict_util.c.
void fr_dict_debug | ( | fr_dict_t const * | dict | ) |
Definition at line 258 of file dict_print.c.
int fr_dict_dependent_add | ( | fr_dict_t const * | dict, |
char const * | dependent | ||
) |
Manually increase the reference count for a dictionary.
This is useful if a previously loaded dictionary needs to be bound to the lifetime of an additional object.
[in] | dict | to increase the reference count for. |
[in] | dependent | requesting the loading of the dictionary. |
Definition at line 3691 of file dict_util.c.
int fr_dict_enum_add_name | ( | fr_dict_attr_t * | da, |
char const * | name, | ||
fr_value_box_t const * | value, | ||
bool | coerce, | ||
bool | takes_precedence | ||
) |
Add a value name.
Aliases are textual (string) names for a given value.
Value names are not limited to integers, and may be added for any non-structural attribute type.
[in] | da | to add enumeration value to. |
[in] | name | Name of value name. |
[in] | value | to associate with name. |
[in] | coerce | if the type of the value does not match the type of the da, attempt to cast it to match the type of the da. If this is false and there's a type mismatch, we fail. We also fail if the value cannot be coerced to the attribute type. |
[in] | takes_precedence | This name should take precedence over previous names for the same value, when resolving value to name. |
Definition at line 1941 of file dict_util.c.
int fr_dict_enum_add_name_next | ( | fr_dict_attr_t * | da, |
char const * | name | ||
) |
Add an name to an integer attribute hashing the name for the integer value.
If the integer value conflicts with an existing name, it's incremented until we find a free value.
Definition at line 1953 of file dict_util.c.
int fr_dict_enum_autoload | ( | fr_dict_enum_autoload_t const * | to_load | ) |
Process a dict_attr_autoload element to load/verify a dictionary attribute.
[in] | to_load | attribute definition |
Definition at line 4051 of file dict_util.c.
fr_dict_enum_value_t* fr_dict_enum_by_name | ( | fr_dict_attr_t const * | da, |
char const * | name, | ||
ssize_t | len | ||
) |
Definition at line 3395 of file dict_util.c.
fr_slen_t fr_dict_enum_by_name_substr | ( | fr_dict_enum_value_t ** | out, |
fr_dict_attr_t const * | da, | ||
fr_sbuff_t * | in | ||
) |
fr_dict_enum_value_t* fr_dict_enum_by_value | ( | fr_dict_attr_t const * | da, |
fr_value_box_t const * | value | ||
) |
Lookup the structure representing an enum value in a fr_dict_attr_t.
[in] | da | to search in. |
[in] | value | to search for. |
Definition at line 3349 of file dict_util.c.
|
inlinestatic |
char const* fr_dict_enum_name_by_value | ( | fr_dict_attr_t const * | da, |
fr_value_box_t const * | value | ||
) |
Lookup the name of an enum value in a fr_dict_attr_t.
[in] | da | to search in. |
[in] | value | number to search for. |
Definition at line 3382 of file dict_util.c.
fr_slen_t fr_dict_enum_name_from_substr | ( | fr_sbuff_t * | out, |
fr_sbuff_parse_error_t * | err, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt | ||
) |
Extract an enumeration name from a string.
This function defines the canonical format for an enumeration name.
An enumeration name is made up of one or more fr_dict_attr_allowed_chars with at least one character in the sequence not being a special character i.e. [-+/_] or a number.
This disambiguates enumeration identifiers from mathematical expressions.
If we allowed enumeration names consisting of sequences of numbers separated by special characters it would not be possible to determine if the special character were an operator in a subexpression.
For example take:
&My-Enum-Attr == 01234-5678
Without having access to the enumeration values of My-Enum-Attr (which we might not have during tokenisation), we cannot tell if this is:
(&My-Enum-Attr == 01234-5678)
OR
((&My-Enum-Attr == 01234) - 5678)
If an alpha character occurs anywhere in the string i.e:
(&My-Enum-Attr == 01234-A5678)
we know 01234-A5678 can't be a mathematical sub-expression because the second potential operand can no longer be parsed as an integer constant.
[out] | out | The name string we managed to extract. May be NULL in which case only the length of the name will be returned. |
[out] | err | Type of parsing error which occurred. May be NULL. |
[in] | in | The string containing the enum identifier. |
[in] | tt | If non-null verify that a terminal sequence occurs after the enumeration name. |
Definition at line 3515 of file dict_util.c.
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.
int fr_dict_free | ( | fr_dict_t ** | dict, |
char const * | dependent | ||
) |
Decrement the reference count on a previously loaded dictionary.
[in] | dict | to free. |
[in] | dependent | that originally allocated this dictionary. |
Definition at line 4024 of file dict_util.c.
void fr_dict_global_ctx_debug | ( | fr_dict_gctx_t const * | gctx | ) |
Dump information about currently loaded dictionaries.
Intended to be called from a debugger
Definition at line 4530 of file dict_util.c.
char const* fr_dict_global_ctx_dir | ( | void | ) |
int fr_dict_global_ctx_dir_set | ( | char const * | dict_dir | ) |
Allow the default dict dir to be changed after initialisation.
[in] | dict_dir | New default dict dir to use. |
Definition at line 4483 of file dict_util.c.
int fr_dict_global_ctx_free | ( | fr_dict_gctx_t const * | gctx | ) |
Explicitly free all data associated with a global dictionary context.
[in] | gctx | To set. |
Definition at line 4469 of file dict_util.c.
fr_dict_gctx_t* fr_dict_global_ctx_init | ( | TALLOC_CTX * | ctx, |
bool | free_at_exit, | ||
char const * | dict_dir | ||
) |
Initialise the global protocol hashes.
[in] | ctx | to allocate global resources in. |
[in] | free_at_exit | Install an at_exit handler to free the global ctx. This is useful when dictionaries are held by other libraries which free them using atexit handlers. |
[in] | dict_dir | the default location for the dictionaries. |
Definition at line 4392 of file dict_util.c.
fr_dict_t* fr_dict_global_ctx_iter_init | ( | fr_dict_global_ctx_iter_t * | iter | ) |
Iterate protocols by name.
Definition at line 4567 of file dict_util.c.
fr_dict_t* fr_dict_global_ctx_iter_next | ( | fr_dict_global_ctx_iter_t * | iter | ) |
Definition at line 4574 of file dict_util.c.
void fr_dict_global_ctx_perm_check | ( | fr_dict_gctx_t * | gctx, |
bool | enable | ||
) |
Set whether we check dictionary file permissions.
[in] | gctx | to alter. |
[in] | enable | Whether we should check file permissions as they're loaded. |
Definition at line 4444 of file dict_util.c.
void fr_dict_global_ctx_read_only | ( | void | ) |
Mark all dictionaries and the global dictionary ctx as read only.
Any attempts to add new attributes will now fail.
Definition at line 4503 of file dict_util.c.
void fr_dict_global_ctx_set | ( | fr_dict_gctx_t const * | gctx | ) |
Set a new, active, global dictionary context.
[in] | gctx | To set. |
Definition at line 4453 of file dict_util.c.
fr_dict_t const* fr_dict_internal | ( | void | ) |
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.
[out] | out | Where to write pointer to the internal dictionary. |
[in] | dict_subdir | name of the internal dictionary dir (may be NULL). |
[in] | dependent | Either C src file, or another dictionary. |
Definition at line 2966 of file dict_tokenize.c.
void fr_dict_namespace_debug | ( | fr_dict_attr_t const * | da | ) |
fr_slen_t fr_dict_oid_component | ( | fr_dict_attr_err_t * | err, |
fr_dict_attr_t const ** | out, | ||
fr_dict_attr_t const * | parent, | ||
fr_sbuff_t * | in, | ||
fr_sbuff_term_t const * | tt | ||
) |
Parse an OID component, resolving it to a defined attribute.
[out] | err | The parsing error that occurred. |
[out] | out | The deepest attribute we resolved. |
[in] | parent | Where to resolve relative attributes from. |
[in] | in | string to parse. |
[in] | tt | Terminal strings. |
Definition at line 2229 of file dict_util.c.
int fr_dict_oid_component_legacy | ( | unsigned int * | out, |
char const ** | oid | ||
) |
Process a single OID component.
[out] | out | Value of component. |
[in] | oid | string to parse. |
Definition at line 2080 of file dict_util.c.
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.
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.
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.
[out] | out | Where to write a pointer to the new dictionary. Will free existing dictionary if files have changed and *out is not NULL. |
[in] | proto_name | that we're loading the dictionary for. |
[in] | proto_dir | Explicitly set where to hunt for the dictionary files. May be NULL. |
[in] | dependent | Either C src file, or another dictionary. |
Definition at line 3103 of file dict_tokenize.c.
Allocate a new local dictionary.
[in] | parent | parent dictionary and talloc ctx |
This dictionary cannot define vendors, or inter-dictionary dependencies. However, we initialize the relevant fields just in case. We should arguably just skip initializing those fields, and just allow the server to crash if programmers do something stupid with it.
Definition at line 3961 of file dict_util.c.
int fr_dict_read | ( | fr_dict_t * | dict, |
char const * | dir, | ||
char const * | filename | ||
) |
Read supplementary attribute definitions into an existing dictionary.
[in] | dict | Existing dictionary. |
[in] | dir | dictionary is located in. |
[in] | filename | of the dictionary. |
Definition at line 3247 of file dict_tokenize.c.
fr_dict_attr_t const* fr_dict_root | ( | fr_dict_t const * | dict | ) |
Return the root attribute of a dictionary.
dict | to return root for. |
Definition at line 2400 of file dict_util.c.
int fr_dict_str_to_argv | ( | char * | str, |
char ** | argv, | ||
int | max_argc | ||
) |
Coerce to non-const.
Definition at line 4585 of file dict_util.c.
fr_dict_attr_t const* fr_dict_unlocal | ( | fr_dict_attr_t const * | da | ) |
fr_dict_vendor_t const* fr_dict_vendor_by_da | ( | fr_dict_attr_t const * | da | ) |
Look up a vendor by one of its child attributes.
[in] | da | The vendor attribute. |
Definition at line 2635 of file dict_util.c.
fr_dict_vendor_t const* fr_dict_vendor_by_name | ( | fr_dict_t const * | dict, |
char const * | name | ||
) |
Look up a vendor by its name.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | name | to search for. |
Definition at line 2657 of file dict_util.c.
fr_dict_vendor_t const* fr_dict_vendor_by_num | ( | fr_dict_t const * | dict, |
uint32_t | vendor_pen | ||
) |
Look up a vendor by its PEN.
[in] | dict | of protocol context we're operating in. If NULL the internal dictionary will be used. |
[in] | vendor_pen | to search for. |
Definition at line 2680 of file dict_util.c.
fr_dict_attr_t const* fr_dict_vendor_da_by_num | ( | fr_dict_attr_t const * | vendor_root, |
uint32_t | vendor_pen | ||
) |
Return vendor attribute for the specified dictionary and pen.
[in] | vendor_root | of the vendor root attribute. Could be 26 (for example) in RADIUS. |
[in] | vendor_pen | to find. |
Definition at line 2695 of file dict_util.c.
int fr_dict_walk | ( | fr_dict_attr_t const * | da, |
fr_dict_walk_t | callback, | ||
void * | uctx | ||
) |
Definition at line 4777 of file dict_util.c.
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 | ||
) |
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.
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.