All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
dict.c File Reference
#include <freeradius-devel/libradius.h>
#include <freeradius-devel/dhcp.h>
#include <ctype.h>
+ Include dependency graph for dict.c:

Go to the source code of this file.

Data Structures

struct  dict_stat_t
 
struct  fr_dict
 Vendors and attribute names. More...
 
struct  value_fixup_t
 

Macros

#define FLAG_SET(_flag)
 
#define FNV_MAGIC_INIT   (0x811c9dc5)
 
#define FNV_MAGIC_PRIME   (0x01000193)
 
#define INTERNAL_IF_NULL(_dict)   if (!_dict) _dict = fr_dict_internal
 
#define MAX_ARGV   (16)
 

Typedefs

typedef struct dict_stat_t dict_stat_t
 
typedef struct value_fixup_t value_fixup_t
 

Functions

static int dict_attr_combo_cmp (void const *one, void const *two)
 
static uint32_t dict_attr_combo_hash (void const *data)
 
static int dict_attr_name_cmp (void const *one, void const *two)
 
static uint32_t dict_attr_name_hash (void const *data)
 
static int dict_enum_name_cmp (void const *one, void const *two)
 
static uint32_t dict_enum_name_hash (void const *data)
 
static int dict_enum_value_cmp (void const *one, void const *two)
 
static uint32_t dict_enum_value_hash (void const *data)
 
static uint32_t dict_hash_name (char const *name)
 
size_t dict_print_attr_oid (char *buffer, size_t outlen, fr_dict_attr_t const *ancestor, fr_dict_attr_t const *da)
 Build the tlv_stack for the specified DA and encode the path in OID form. More...
 
static int dict_read_init (fr_dict_t *dict, char const *dir_name, char const *filename, char const *src_file, int src_line)
 
static int dict_read_parse_format (char const *format, unsigned int *pvalue, int *ptype, int *plength, bool *pcontinuation)
 
static int dict_read_process_attribute (fr_dict_t *dict, fr_dict_attr_t const *parent, unsigned int block_vendor, char **argv, int argc)
 
static int dict_read_process_value (fr_dict_t *dict, char **argv, int argc)
 
static int dict_read_process_vendor (fr_dict_t *dict, char **argv, int argc)
 
static int dict_read_sscanf_i (char const *str, unsigned int *pvalue)
 
static void dict_stat_add (fr_dict_t *dict, struct stat const *stat_buf)
 Add an entry to the list of stat buffers. More...
 
static int dict_stat_check (fr_dict_t *dict, char const *dir, char const *file)
 See if any dictionaries have changed. More...
 
static int dict_vendor_name_cmp (void const *one, void const *two)
 
static uint32_t dict_vendor_name_hash (void const *data)
 
static int dict_vendor_value_cmp (void const *one, void const *two)
 
static uint32_t dict_vendor_value_hash (void const *data)
 
int fr_dict_attr_add (fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, PW_TYPE type, fr_dict_attr_flags_t flags)
 Add an attribute to the dictionary. More...
 
static fr_dict_attr_tfr_dict_attr_alloc (TALLOC_CTX *ctx, char const *name, unsigned int vendor, int attr, PW_TYPE type, fr_dict_attr_flags_t flags)
 
fr_dict_attr_t const * fr_dict_attr_by_name (fr_dict_t *dict, char const *name)
 Locate a fr_dict_attr_t by its name. More...
 
fr_dict_attr_t const * fr_dict_attr_by_name_substr (fr_dict_t *dict, char const **name)
 Look up a dictionary attribute by a name embedded in another string. More...
 
fr_dict_attr_t const * fr_dict_attr_by_num (fr_dict_t *dict, unsigned int vendor, unsigned int attr)
 Lookup a fr_dict_attr_t by its vendor and attribute numbers. More...
 
ssize_t fr_dict_attr_by_oid (fr_dict_t *dict, fr_dict_attr_t const **parent, unsigned int *vendor, unsigned int *attr, char const *oid)
 Get the leaf attribute of an OID string. More...
 
fr_dict_attr_t const * fr_dict_attr_by_type (fr_dict_t *dict, unsigned int vendor, unsigned int attr, PW_TYPE type)
 Lookup a attribute by its its vendor and attribute numbers and data type. More...
 
static int fr_dict_attr_child_add (fr_dict_attr_t *parent, fr_dict_attr_t *child)
 Add a child to a parent. More...
 
fr_dict_attr_t const * fr_dict_attr_child_by_da (fr_dict_attr_t const *parent, fr_dict_attr_t const *child)
 Check if a child attribute exists in a parent using a pointer (da) More...
 
fr_dict_attr_t const * fr_dict_attr_child_by_num (fr_dict_attr_t const *parent, unsigned int attr)
 Check if a child attribute exists in a parent using an attribute number. More...
 
int fr_dict_enum_add (fr_dict_t *dict, char const *attr, char const *alias, int value)
 
fr_dict_enum_tfr_dict_enum_by_da (fr_dict_t *dict, fr_dict_attr_t const *da, int value)
 Lookup the structure representing an enum value in a fr_dict_attr_t. More...
 
fr_dict_enum_tfr_dict_enum_by_name (fr_dict_t *dict, fr_dict_attr_t const *da, char const *name)
 
char const * fr_dict_enum_name_by_da (fr_dict_t *dict, fr_dict_attr_t const *da, int value)
 Lookup the name of an enum value in a fr_dict_attr_t. More...
 
int fr_dict_init (TALLOC_CTX *ctx, fr_dict_t **out, char const *dir, char const *fn, char const *name)
 (re)initialize a protocol dictionary More...
 
int fr_dict_oid_component (unsigned int *out, char const **oid)
 Process a single OID component. More...
 
fr_dict_attr_t const * fr_dict_parent_common (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...
 
int fr_dict_parse_str (fr_dict_t *dict, char *buf, fr_dict_attr_t const *parent, unsigned int vendor)
 
void fr_dict_print (fr_dict_attr_t const *da, int depth)
 
int fr_dict_read (fr_dict_t *dict, char const *dir, char const *filename)
 
fr_dict_attr_t const * fr_dict_root (fr_dict_t const *dict)
 Return the root attribute of a dictionary. More...
 
static void fr_dict_snprint_flags (char *out, size_t outlen, fr_dict_attr_flags_t flags)
 
int fr_dict_str_to_argv (char *str, char **argv, int max_argc)
 
static fr_dict_attr_tfr_dict_unknown_acopy (TALLOC_CTX *ctx, fr_dict_attr_t const *da)
 Copy a known or unknown attribute to produce an unknown attribute. 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_fields (TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int vendor, unsigned int attr)
 Allocates an unknown attribute. More...
 
fr_dict_attr_t const * fr_dict_unknown_afrom_oid (TALLOC_CTX *ctx, fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name)
 Create a fr_dict_attr_t from an ASCII attribute and value. More...
 
void fr_dict_unknown_free (fr_dict_attr_t const **da)
 Free dynamically allocated (unknown attributes) More...
 
int fr_dict_unknown_from_fields (fr_dict_attr_t *da, fr_dict_attr_t const *parent, unsigned int vendor, unsigned int attr)
 Initialises an unknown attribute. More...
 
int fr_dict_unknown_from_oid (fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict_attr_t *da, fr_dict_attr_t const *parent, char const *name)
 Initialise a fr_dict_attr_t from an ASCII attribute and value. More...
 
int fr_dict_unknown_from_suboid (fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict_attr_t *da, fr_dict_attr_t const *parent, char const **name)
 Create a dictionary attribute by name embedded in another string. More...
 
int fr_dict_unknown_vendor_afrom_num (TALLOC_CTX *ctx, fr_dict_attr_t const **out, fr_dict_attr_t const *parent, unsigned int vendor)
 Build an unknown vendor, parented by a VSA or EVS attribute. More...
 
int fr_dict_valid_name (char const *name)
 
int fr_dict_vendor_add (fr_dict_t *dict, char const *name, unsigned int num)
 Add a vendor to the dictionary. More...
 
int fr_dict_vendor_by_name (fr_dict_t *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 *dict, int vendorpec)
 Look up a vendor by its PEN. More...
 
void fr_dict_verify (char const *file, int line, fr_dict_attr_t const *da)
 
static int hash_null_callback (UNUSED void *ctx, UNUSED void *data)
 
static void hash_pool_free (void *to_free)
 

Variables

const size_t dict_attr_sizes [PW_TYPE_MAX][2]
 Map data types to min / max data sizes. More...
 
const FR_NAME_NUMBER dict_attr_types []
 Map data types to names representing those types. More...
 
const int fr_dict_attr_allowed_chars [256]
 
fr_dict_tfr_dict_internal = NULL
 Internal server dictionary. More...
 

Data Structure Documentation

struct dict_stat_t

Definition at line 42 of file dict.c.

+ Collaboration diagram for dict_stat_t:
Data Fields
struct dict_stat_t * next
struct stat stat_buf
struct fr_dict

Vendors and attribute names.

It's very likely that the same vendors will operate in multiple protocol spaces, but number their attributes differently, so we need per protocol dictionaries.

There would also be conflicts for DHCP(v6)/RADIUS attributes etc...

Definition at line 61 of file dict.c.

+ Collaboration diagram for fr_dict:
Data Fields
fr_hash_table_t * attributes_by_name Allow attribute lookup by unique name.
fr_hash_table_t * attributes_combo Lookup variants of polymorphic attributes.
TALLOC_CTX * pool Talloc memory pool to reduce mallocs.
fr_dict_attr_t * root Root attribute of this dictionary.
dict_stat_t * stat_head
dict_stat_t * stat_tail
value_fixup_t * value_fixup
fr_hash_table_t * values_by_da Lookup an attribute enum value by integer value.
fr_hash_table_t * values_by_name Lookup an attribute enum value by name.
fr_hash_table_t * vendors_by_name Lookup vendor by name.
fr_hash_table_t * vendors_by_num Lookup vendor by PEN.
struct value_fixup_t

Definition at line 47 of file dict.c.

+ Collaboration diagram for value_fixup_t:
Data Fields
char attrstr[FR_DICT_ATTR_MAX_NAME_LEN]
fr_dict_enum_t * dval
struct value_fixup_t * next

Macro Definition Documentation

#define FLAG_SET (   _flag)
Value:
do { \
if (flags._flag) {\
p += strlcpy(p, STRINGIFY(_flag)",", end - p);\
if (p >= end) return;\
}\
} while (0)
#define STRINGIFY(x)
Definition: build.h:34
size_t strlcpy(char *dst, char const *src, size_t siz)
Definition: strlcpy.c:38
#define FNV_MAGIC_INIT   (0x811c9dc5)

Definition at line 170 of file dict.c.

#define FNV_MAGIC_PRIME   (0x01000193)

Definition at line 171 of file dict.c.

#define INTERNAL_IF_NULL (   _dict)    if (!_dict) _dict = fr_dict_internal

Definition at line 179 of file dict.c.

#define MAX_ARGV   (16)

Definition at line 36 of file dict.c.

Typedef Documentation

typedef struct dict_stat_t dict_stat_t
typedef struct value_fixup_t value_fixup_t

Function Documentation

static int dict_attr_combo_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 237 of file dict.c.

+ Here is the caller graph for this function:

static uint32_t dict_attr_combo_hash ( void const *  data)
static

Definition at line 227 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 219 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint32_t dict_attr_name_hash ( void const *  data)
static

Definition at line 214 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 287 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint32_t dict_enum_name_hash ( void const *  data)
static

Definition at line 278 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 308 of file dict.c.

+ Here is the caller graph for this function:

static uint32_t dict_enum_value_hash ( void const *  data)
static

Definition at line 299 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint32_t dict_hash_name ( char const *  name)
static

Definition at line 195 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t dict_print_attr_oid ( char *  buffer,
size_t  outlen,
fr_dict_attr_t const *  ancestor,
fr_dict_attr_t const *  da 
)

Build the tlv_stack for the specified DA and encode the path in OID form.

Parameters
[out]bufferWhere to write the OID.
[in]outlenLength of the output buffer.
[in]ancestorIf not NULL, only print OID portion between ancestor and da.
[in]dato print OID string for.
Returns
the number of bytes written to the buffer.

Definition at line 2525 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dict_read_init ( fr_dict_t dict,
char const *  dir_name,
char const *  filename,
char const *  src_file,
int  src_line 
)
static

Definition at line 1733 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dict_read_parse_format ( char const *  format,
unsigned int *  pvalue,
int *  ptype,
int *  plength,
bool *  pcontinuation 
)
static

Definition at line 1597 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dict_read_process_attribute ( fr_dict_t dict,
fr_dict_attr_t const *  parent,
unsigned int  block_vendor,
char **  argv,
int  argc 
)
static

Definition at line 1375 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dict_read_process_value ( fr_dict_t dict,
char **  argv,
int  argc 
)
static

Definition at line 1575 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dict_read_process_vendor ( fr_dict_t dict,
char **  argv,
int  argc 
)
static

Definition at line 1665 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dict_read_sscanf_i ( char const *  str,
unsigned int *  pvalue 
)
static

Definition at line 1341 of file dict.c.

+ Here is the caller graph for this function:

static void dict_stat_add ( fr_dict_t dict,
struct stat const *  stat_buf 
)
static

Add an entry to the list of stat buffers.

Definition at line 322 of file dict.c.

+ Here is the caller graph for this function:

static int dict_stat_check ( fr_dict_t dict,
char const *  dir,
char const *  file 
)
static

See if any dictionaries have changed.

If not, don't do anything

Definition at line 341 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 256 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint32_t dict_vendor_name_hash ( void const *  data)
static

Definition at line 251 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int dict_vendor_value_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 270 of file dict.c.

+ Here is the caller graph for this function:

static uint32_t dict_vendor_value_hash ( void const *  data)
static

Definition at line 264 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Add an attribute to the dictionary.

Todo:
we need to check length of none vendor attributes.
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 582 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static fr_dict_attr_t* fr_dict_attr_alloc ( TALLOC_CTX *  ctx,
char const *  name,
unsigned int  vendor,
int  attr,
PW_TYPE  type,
fr_dict_attr_flags_t  flags 
)
static

Definition at line 543 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_attr_t const* fr_dict_attr_by_name ( fr_dict_t dict,
char const *  name 
)

Locate a fr_dict_attr_t by its name.

Note
Unlike attribute numbers, attribute names are unique to the dictionary.
Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]nameof the attribute to locate.
Returns
  • Attribute matching name.
  • NULL if no matching attribute could be found.

Definition at line 3493 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_attr_t const* fr_dict_attr_by_name_substr ( fr_dict_t dict,
char const **  name 
)

Look up a dictionary attribute by a name embedded in another string.

Find the first invalid attribute name char in the string pointed to by name.

Copy the characters between the start of the name string and the first none dict_attr_allowed_char to a buffer and perform a dictionary lookup using that value.

If the attribute exists, advance the pointer pointed to by name to the first none dict_attr_allowed_char char, and return the DA.

If the attribute does not exist, don't advance the pointer and return NULL.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in,out]namestring start.
Returns
  • Attribute matching name.
  • NULL if no matching attribute could be found.

Definition at line 3445 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_attr_t const* fr_dict_attr_by_num ( fr_dict_t dict,
unsigned int  vendor,
unsigned int  attr 
)

Lookup a fr_dict_attr_t by its vendor and attribute numbers.

Note
This is a deprecated function, new code should use fr_dict_attr_child_by_num.
Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]vendornumber of the attribute.
[in]attrnumber of the attribute.
Returns
  • Attribute matching vendor/attr.
  • NULL if no matching attribute could be found.

Definition at line 3519 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ssize_t fr_dict_attr_by_oid ( fr_dict_t dict,
fr_dict_attr_t const **  parent,
unsigned int *  vendor,
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]vendornumber of attribute.
[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 3263 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_attr_t const* fr_dict_attr_by_type ( fr_dict_t dict,
unsigned int  vendor,
unsigned int  attr,
PW_TYPE  type 
)

Lookup a attribute by its its vendor and attribute numbers and data type.

Note
Only works with PW_TYPE_COMBO_IP
Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]vendornumber of the attribute.
[in]attrnumber of the attribute.
[in]typeVariant of attribute to lookup.
Returns
  • Attribute matching vendor/attr/type.
  • NULL if no matching attribute could be found.

Definition at line 3549 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int fr_dict_attr_child_add ( fr_dict_attr_t parent,
fr_dict_attr_t child 
)
inlinestatic

Add a child to a parent.

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

Definition at line 467 of file dict.c.

+ Here is the caller graph for this function:

fr_dict_attr_t const* fr_dict_attr_child_by_da ( fr_dict_attr_t const *  parent,
fr_dict_attr_t const *  child 
)
inline

Check if a child attribute exists in a parent using a pointer (da)

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

Definition at line 3570 of file dict.c.

fr_dict_attr_t const* fr_dict_attr_child_by_num ( fr_dict_attr_t const *  parent,
unsigned int  attr 
)
inline

Check if a child attribute exists in a parent using an attribute number.

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

Definition at line 3611 of file dict.c.

+ Here is the caller graph for this function:

int fr_dict_enum_add ( fr_dict_t dict,
char const *  attr,
char const *  alias,
int  value 
)

Definition at line 1153 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_enum_t* fr_dict_enum_by_da ( fr_dict_t dict,
fr_dict_attr_t const *  da,
int  value 
)

Lookup the structure representing an enum value in a fr_dict_attr_t.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]dato search in.
[in]valuenumber to search for.
Returns

Definition at line 3654 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_enum_t* fr_dict_enum_by_name ( fr_dict_t dict,
fr_dict_attr_t const *  da,
char const *  name 
)

Definition at line 3703 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const* fr_dict_enum_name_by_da ( fr_dict_t dict,
fr_dict_attr_t const *  da,
int  value 
)

Lookup the name of an enum value in a fr_dict_attr_t.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]dato search in.
[in]valuenumber to search for.
Returns
  • Name of value.
  • NULL if no matching value could be found.

Definition at line 3688 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_dict_init ( TALLOC_CTX *  ctx,
fr_dict_t **  out,
char const *  dir,
char const *  fn,
char const *  name 
)

(re)initialize a protocol dictionary

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

First dictionary initialised will be set as the default internal dictionary.

Parameters
[in]ctxto allocate the dictionary from.
[out]outWhere to write a pointer to the new dictionary. Will free existing dictionary if files have changed and *out is not NULL.
[in]dirto read dictionary files from.
[in]fnfile name to read.
[in]nameto use for the root attributes.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2148 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_dict_oid_component ( 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 3217 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_attr_t const* fr_dict_parent_common ( 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
afirst TLV attribute.
bsecond TLV attribute.
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 3174 of file dict.c.

+ Here is the caller graph for this function:

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

Definition at line 2306 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_dict_print ( fr_dict_attr_t const *  da,
int  depth 
)

Definition at line 3113 of file dict.c.

+ Here is the call graph for this function:

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

Definition at line 2291 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 2339 of file dict.c.

+ Here is the caller graph for this function:

static void fr_dict_snprint_flags ( char *  out,
size_t  outlen,
fr_dict_attr_flags_t  flags 
)
static

Definition at line 3068 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1304 of file dict.c.

+ Here is the caller graph for this function:

static fr_dict_attr_t* fr_dict_unknown_acopy ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  da 
)
static

Copy a known or unknown attribute to produce an unknown attribute.

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

Definition at line 2348 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

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]oldunknown attribute to add.
Returns
  • Existing fr_dict_attr_t if old was found in a dictionary.
  • A new entry representing old.

Definition at line 2384 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Allocates an unknown attribute.

Initialises an unknown attribute.

Note
If vendor != 0, an unknown vendor (may) also be created, parented by the correct EVS or VSA attribute. This is accessible via vp->parent, and will be use the unknown da as its talloc parent.
Parameters
[in]ctxto allocate DA in.
[in]parentof the unknown attribute (may also be unknown).
[in]attrnumber.
[in]vendornumber.
Returns
0 on success.

Definition at line 2613 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_attr_t const* fr_dict_unknown_afrom_oid ( TALLOC_CTX *  ctx,
fr_dict_t dict,
fr_dict_attr_t const *  parent,
char const *  name 
)

Create a fr_dict_attr_t from an ASCII attribute and value.

Where the attribute name is in the form:

  • Attr-d
  • Attr-d.d.d...
  • Vendor-d-Attr-d
  • VendorName-Attr-d

Initialises an unknown attribute.

Note
If vendor != 0, an unknown vendor (may) also be created, parented by the correct EVS or VSA attribute. This is accessible via vp->parent, and will be use the unknown da as its talloc parent.
Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]ctxto alloc new attribute in.
[in]parentAttribute to use as the root for resolving OIDs in. Usually the root of a protocol dictionary.
[in]nameof attribute.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2957 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
dato free.

Definition at line 2426 of file dict.c.

+ Here is the caller graph for this function:

int fr_dict_unknown_from_fields ( fr_dict_attr_t da,
fr_dict_attr_t const *  parent,
unsigned int  vendor,
unsigned int  attr 
)

Initialises an unknown attribute.

Initialises a dict attr for an unknown attribute/vendor/type without adding it to dictionary pools/hashes.

Unknown attributes are used to transparently pass undecodeable attributes when we proxy requests.

Parameters
[in,out]dastruct to initialise, must be at least FR_DICT_ATTR_SIZE bytes.
[in]parentof the unknown attribute (may also be unknown).
[in]attrnumber.
[in]vendornumber.
Returns
0 on success.

Definition at line 2571 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_dict_unknown_from_oid ( fr_dict_t dict,
fr_dict_attr_t vendor_da,
fr_dict_attr_t da,
fr_dict_attr_t const *  parent,
char const *  name 
)

Initialise a fr_dict_attr_t from an ASCII attribute and value.

Where the attribute name is in the form:

  • Attr-d
  • Attr-d.d.d...
  • Vendor-d-Attr-d
  • VendorName-Attr-d

Initialises an unknown attribute.

Note
We can't validate attribute numbers here as a dictionary lookup is required to determine if the attribute has been marked as internal. Even validating numbers based on dv_type which is the length of the vendor field is wrong. Attribute number checks must be done by the caller.
Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[in]vendor_dato initialise.
[in]dato initialise.
[in]parentof the unknown attribute (may also be unknown).
[in]nameof attribute.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2705 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_dict_unknown_from_suboid ( fr_dict_t dict,
fr_dict_attr_t vendor_da,
fr_dict_attr_t da,
fr_dict_attr_t const *  parent,
char const **  name 
)

Create a dictionary attribute by name embedded in another string.

Find the first invalid attribute name char in the string pointed to by name.

Copy the characters between the start of the name string and the first none dict_attr_allowed_char to a buffer and initialise da as an unknown attribute.

Parameters
[in]dictof protocol context we're operating in. If NULL the internal dictionary will be used.
[out]vendor_dawill be filled in if a vendor is found.
[out]dawill be filled in with the da at the end of the OID chain.
[in]parentAttribute to use as the root for resolving OIDs in. Usually the root of a protocol dictionary.
[in,out]namestring start.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 3034 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Build an unknown vendor, parented by a VSA or EVS 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.
[out]outWhere to write point to new unknown dict attr representing the unknown vendor.
[in]parentof the vendor attribute, either an EVS or VSA attribute.
[in]vendorid.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 2459 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_dict_valid_name ( char const *  name)

Definition at line 3730 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_dict_vendor_add ( fr_dict_t dict,
char const *  name,
unsigned int  num 
)

Add a vendor to the dictionary.

Inserts a vendor entry into the vendor hash table. This must be done before adding attributes under a VSA.

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

Definition at line 399 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_dict_vendor_by_name ( fr_dict_t 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 regitered for this protocol.

Definition at line 3386 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_dict_vendor_t const* fr_dict_vendor_by_num ( fr_dict_t dict,
int  vendorpec 
)

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]vendorpecto search for.
Returns
  • The vendor.
  • NULL if no vendor with that number was regitered for this protocol.

Definition at line 3412 of file dict.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3748 of file dict.c.

static int hash_null_callback ( UNUSED void *  ctx,
UNUSED void *  data 
)
static

Definition at line 185 of file dict.c.

+ Here is the caller graph for this function:

static void hash_pool_free ( void *  to_free)
static

Definition at line 190 of file dict.c.

+ Here is the caller graph for this function:

Variable Documentation

const size_t dict_attr_sizes[PW_TYPE_MAX][2]
Initial value:
= {
[PW_TYPE_INVALID] = {~0, 0},
[PW_TYPE_STRING] = {0, ~0},
[PW_TYPE_INTEGER] = {4, 4 },
[PW_TYPE_IPV4_ADDR] = {4, 4},
[PW_TYPE_DATE] = {4, 4},
[PW_TYPE_ABINARY] = {32, ~0},
[PW_TYPE_OCTETS] = {0, ~0},
[PW_TYPE_IFID] = {8, 8},
[PW_TYPE_IPV6_ADDR] = {16, 16},
[PW_TYPE_IPV6_PREFIX] = {2, 18},
[PW_TYPE_BYTE] = {1, 1},
[PW_TYPE_SHORT] = {2, 2},
[PW_TYPE_ETHERNET] = {6, 6},
[PW_TYPE_SIGNED] = {4, 4},
[PW_TYPE_COMBO_IP_ADDR] = {4, 16},
[PW_TYPE_TLV] = {2, ~0},
[PW_TYPE_EXTENDED] = {2, ~0},
[PW_TYPE_LONG_EXTENDED] = {3, ~0},
[PW_TYPE_EVS] = {6, ~0},
[PW_TYPE_INTEGER64] = {8, 8},
[PW_TYPE_IPV4_PREFIX] = {6, 6},
[PW_TYPE_VSA] = {4, ~0},
[PW_TYPE_VENDOR] = {0, 0}
}
128 Bit IPv6 Address.
Definition: radius.h:40
Ascend binary format a packed data structure.
Definition: radius.h:37
32 Bit signed integer.
Definition: radius.h:45
WiMAX IPv4 or IPv6 address depending on length.
Definition: radius.h:46
IPv6 Prefix.
Definition: radius.h:41
Long extended attribute space attribute.
Definition: radius.h:49
8 Bit unsigned integer.
Definition: radius.h:42
Interface ID.
Definition: radius.h:39
48 Bit Mac-Address.
Definition: radius.h:44
Attribute that represents a vendor in the attribute tree.
Definition: radius.h:54
Invalid (uninitialised) attribute type.
Definition: radius.h:32
32 Bit unsigned integer.
Definition: radius.h:34
64 Bit unsigned integer.
Definition: radius.h:51
Vendor-Specific, for RADIUS attribute 26.
Definition: radius.h:53
32 Bit Unix timestamp.
Definition: radius.h:36
Extended attribute space attribute.
Definition: radius.h:48
IPv4 Prefix.
Definition: radius.h:52
String of printable characters.
Definition: radius.h:33
Contains nested attributes.
Definition: radius.h:47
32 Bit IPv4 Address.
Definition: radius.h:35
16 Bit unsigned integer.
Definition: radius.h:43
Raw octets.
Definition: radius.h:38
Extended attribute, vendor specific.
Definition: radius.h:50

Map data types to min / max data sizes.

Definition at line 119 of file dict.c.

const FR_NAME_NUMBER dict_attr_types[]

Map data types to names representing those types.

Definition at line 85 of file dict.c.

const int fr_dict_attr_allowed_chars[256]
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 145 of file dict.c.

fr_dict_t* fr_dict_internal = NULL

Internal server dictionary.

Definition at line 81 of file dict.c.