All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
dict.h File Reference

Multi-protocol attribute dictionary API. More...

#include <freeradius-devel/libradius.h>
+ Include dependency graph for dict.h:

Go to the source code of this file.

Data Structures

struct  attr_flags
 Values of the encryption flags. More...
 
struct  dict_attr
 Dictionary attribute. More...
 
struct  dict_enum
 Value of an enumerated attribute. More...
 
struct  dict_vendor
 Private enterprise. More...
 

Macros

#define FR_DICT_ATTR_MAX_NAME_LEN   (128)
 
#define FR_DICT_ATTR_SIZE   (sizeof(fr_dict_attr_t) + FR_DICT_ATTR_MAX_NAME_LEN)
 Maximum dictionary attribute size. More...
 
#define FR_DICT_ENUM_MAX_NAME_LEN   (128)
 
#define FR_DICT_MAX_TLV_STACK   (FR_DICT_TLV_NEST_MAX + 5)
 Maximum TLV stack size. More...
 
#define FR_DICT_TLV_NEST_MAX   (24)
 Maximum level of TLV nesting allowed. More...
 
#define FR_DICT_VENDOR_MAX_NAME_LEN   (128)
 
#define VERIFY_DA(_x)   fr_assert(_x)
 

Typedefs

typedef struct attr_flags fr_dict_attr_flags_t
 Values of the encryption flags. More...
 
typedef struct dict_attr fr_dict_attr_t
 
typedef struct dict_enum fr_dict_enum_t
 Value of an enumerated attribute. More...
 
typedef struct fr_dict fr_dict_t
 
typedef struct dict_vendor fr_dict_vendor_t
 Private enterprise. More...
 

Functions

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...
 
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...
 
fr_dict_attr_t const * fr_dict_attr_by_name (fr_dict_t *dict, char const *attr)
 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...
 
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 *val)
 
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...
 
int fr_dict_str_to_argv (char *str, char **argv, int max_argc)
 
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) CC_HINT(nonnull)
 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) CC_HINT(nonnull)
 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 value)
 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 vendor)
 Look up a vendor by its PEN. More...
 
void fr_dict_verify (char const *file, int line, fr_dict_attr_t const *da)
 

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
 Internal server dictionary. More...
 

Detailed Description

Multi-protocol attribute dictionary API.

Id:
8e36574b4dae0534c60b810ba2cc11a187fb705e

Definition in file dict.h.


Data Structure Documentation

struct attr_flags

Values of the encryption flags.

Definition at line 40 of file dict.h.

Data Fields
__unnamed__
Data Fields
unsigned int array: 1 Pack multiples into 1 attr.
unsigned int compare: 1 has a paircompare registered
unsigned int concat: 1 concatenate multiple instances
enum attr_flags encrypt
unsigned int has_tag: 1 Tagged attribute.
unsigned int has_value: 1 Has a value.
unsigned virtual int: 1 for dynamic expansion
unsigned int internal: 1 Internal attribute, should not be received in protocol packets, should not be encoded.
unsigned int is_pointer: 1 data is a pointer
unsigned int is_root: 1 Is root of a dictionary.
unsigned int is_unknown: 1 Attribute number or vendor is unknown.
uint8_t length length of the attribute
uint8_t type_size for TLV2, size of the type
struct dict_attr

Dictionary attribute.

Definition at line 77 of file dict.h.

+ Collaboration diagram for dict_attr:
Data Fields
unsigned int attr Attribute number.
fr_dict_attr_t const ** children Children of this attribute.
unsigned int depth Depth of nesting for this attribute.
fr_dict_attr_flags_t flags Flags.
char name[1] Attribute name.
fr_dict_attr_t const * next Next child in bin.
fr_dict_attr_t const * parent Immediate parent of this attribute.
PW_TYPE type Value type.
unsigned int vendor Vendor that defines this attribute.
struct dict_enum

Value of an enumerated attribute.

Definition at line 94 of file dict.h.

+ Collaboration diagram for dict_enum:
Data Fields
fr_dict_attr_t const * da Dictionary attribute enum is associated with.
char name[1] Enum name.
int value Enum value.
struct dict_vendor

Private enterprise.

Definition at line 102 of file dict.h.

Data Fields
size_t flags Vendor flags.
size_t length Length of length data.
char name[1] Vendor name.
size_t type Length of type data.
unsigned int vendorpec Private enterprise number.

Macro Definition Documentation

#define FR_DICT_ATTR_MAX_NAME_LEN   (128)

Definition at line 115 of file dict.h.

#define FR_DICT_ATTR_SIZE   (sizeof(fr_dict_attr_t) + FR_DICT_ATTR_MAX_NAME_LEN)

Maximum dictionary attribute size.

Definition at line 127 of file dict.h.

#define FR_DICT_ENUM_MAX_NAME_LEN   (128)

Definition at line 113 of file dict.h.

#define FR_DICT_MAX_TLV_STACK   (FR_DICT_TLV_NEST_MAX + 5)

Maximum TLV stack size.

Definition at line 123 of file dict.h.

#define FR_DICT_TLV_NEST_MAX   (24)

Maximum level of TLV nesting allowed.

Definition at line 119 of file dict.h.

#define FR_DICT_VENDOR_MAX_NAME_LEN   (128)

Definition at line 114 of file dict.h.

#define VERIFY_DA (   _x)    fr_assert(_x)

Definition at line 35 of file dict.h.

Typedef Documentation

Values of the encryption flags.

typedef struct dict_attr fr_dict_attr_t

Definition at line 71 of file dict.h.

typedef struct dict_enum fr_dict_enum_t

Value of an enumerated attribute.

typedef struct fr_dict fr_dict_t

Definition at line 72 of file dict.h.

typedef struct dict_vendor fr_dict_vendor_t

Private enterprise.

Function Documentation

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:

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:

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:

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 *  val 
)

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:

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:

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.

Variable Documentation

const size_t dict_attr_sizes[PW_TYPE_MAX][2]

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]

Definition at line 145 of file dict.c.

fr_dict_t* fr_dict_internal

Internal server dictionary.

Definition at line 81 of file dict.c.