The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions
dict_fixup.c File Reference

Code to apply fctx and finalisation steps to a dictionary. More...

#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/sbuff.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/types.h>
#include <freeradius-devel/util/talloc.h>
#include <freeradius-devel/util/value.h>
#include "dict_fixup_priv.h"
+ Include dependency graph for dict_fixup.c:

Go to the source code of this file.

Data Structures

struct  dict_fixup_alias_t
 Add an enumeration value to an attribute that wasn't defined at the time the value was parsed. More...
 
struct  dict_fixup_clone_t
 Clone operation from one tree node to another. More...
 
struct  dict_fixup_common_t
 Common fields for every fixup structure. More...
 
struct  dict_fixup_enumv_t
 Add an enumeration value to an attribute that wasn't defined at the time the value was parsed. More...
 
struct  dict_fixup_group_t
 Resolve a group reference. More...
 
struct  dict_fixup_hash_t
 Dictionary attribute namespaces need their hash tables finalised. More...
 
struct  dict_fixup_vsa_t
 Run fixup callbacks for a VSA. More...
 

Macros

#define APPLY_FIXUP(_fctx, _list, _func, _type)
 

Functions

static int _dict_attr_fixup_hash_tables (fr_dict_attr_t const *da, UNUSED void *uctx)
 Fixup all hash tables in the dictionary so they're suitable for threaded access. More...
 
static int dict_fixup_alias_apply (UNUSED dict_fixup_ctx_t *fctx, dict_fixup_alias_t *fixup)
 
int dict_fixup_alias_enqueue (dict_fixup_ctx_t *fctx, char const *filename, int line, fr_dict_attr_t *alias_parent, char const *alias, fr_dict_attr_t *ref_parent, char const *ref)
 Resolve a group reference. More...
 
int dict_fixup_apply (dict_fixup_ctx_t *fctx)
 Apply all outstanding fixes to a set of dictionaries. More...
 
int dict_fixup_clone (fr_dict_attr_t **dst_p, fr_dict_attr_t const *src)
 Clone a dictionary attribute from a ref. More...
 
static int dict_fixup_clone_apply (UNUSED dict_fixup_ctx_t *fctx, dict_fixup_clone_t *fixup)
 Clone one are of a tree into another. More...
 
int dict_fixup_clone_enqueue (dict_fixup_ctx_t *fctx, fr_dict_attr_t *da, char const *ref)
 Clone one area of a tree into another. More...
 
static int dict_fixup_clone_enum_apply (UNUSED dict_fixup_ctx_t *fctx, dict_fixup_clone_t *fixup)
 Clone one are of a tree into another. More...
 
int dict_fixup_clone_enum_enqueue (dict_fixup_ctx_t *fctx, fr_dict_attr_t *da, char const *ref)
 Clone enumeration values from one attribute to another. More...
 
static int dict_fixup_common (fr_dlist_head_t *fixup_list, dict_fixup_common_t *common)
 Initialise common fields in fixup struct, and add it to a fixup list. More...
 
static int dict_fixup_enumv_apply (UNUSED dict_fixup_ctx_t *fctx, dict_fixup_enumv_t *fixup)
 Add a previously defined enumeration value to an existing attribute. More...
 
int dict_fixup_enumv_enqueue (dict_fixup_ctx_t *fctx, char const *filename, int line, char const *attr, size_t attr_len, char const *name, size_t name_len, char const *value, size_t value_len, fr_dict_attr_t const *parent)
 Add an enumeration value to an attribute which has not yet been defined. More...
 
static int dict_fixup_group_apply (UNUSED dict_fixup_ctx_t *fctx, dict_fixup_group_t *fixup)
 Resolve a group reference. More...
 
int dict_fixup_group_enqueue (dict_fixup_ctx_t *fctx, fr_dict_attr_t *da, char const *ref)
 Resolve a group reference. More...
 
int dict_fixup_init (TALLOC_CTX *ctx, dict_fixup_ctx_t *fctx)
 Initialise a fixup ctx. More...
 
static int dict_fixup_vsa_apply (UNUSED dict_fixup_ctx_t *fctx, dict_fixup_vsa_t *fixup)
 Run VSA fixups. More...
 
int dict_fixup_vsa_enqueue (dict_fixup_ctx_t *fctx, fr_dict_attr_t *da)
 Push a fixup for a VSA. More...
 
void dict_hash_tables_finalise (fr_dict_t *dict)
 Walk a dictionary finalising the hash tables in all attributes with a distinct namespace. More...
 
fr_dict_attr_t const * dict_protocol_reference (fr_dict_attr_t const *root, char const *ref)
 Resolve a ref= or copy= value to a dictionary. More...
 

Detailed Description

Code to apply fctx and finalisation steps to a dictionary.

Definition in file dict_fixup.c.


Data Structure Documentation

◆ dict_fixup_alias_t

struct dict_fixup_alias_t

Add an enumeration value to an attribute that wasn't defined at the time the value was parsed.

Definition at line 46 of file dict_fixup.c.

+ Collaboration diagram for dict_fixup_alias_t:
Data Fields
char * alias we need to create.
fr_dict_attr_t * alias_parent Where to add the alias.
dict_fixup_common_t common Common fields.
char * filename where the line being fixed up.
int line ditto.
char * ref what the alias references.
fr_dict_attr_t * ref_parent Parent attribute to resolve the 'attribute' string in.

◆ dict_fixup_clone_t

struct dict_fixup_clone_t

Clone operation from one tree node to another.

Definition at line 89 of file dict_fixup.c.

+ Collaboration diagram for dict_fixup_clone_t:
Data Fields
dict_fixup_common_t common Common fields.
fr_dict_attr_t * da to populate with cloned information.
char * ref the target attribute to clone

◆ dict_fixup_common_t

struct dict_fixup_common_t

Common fields for every fixup structure.

Definition at line 39 of file dict_fixup.c.

+ Collaboration diagram for dict_fixup_common_t:
Data Fields
fr_dlist_t entry Entry in linked list of fctx.

◆ dict_fixup_enumv_t

struct dict_fixup_enumv_t

Add an enumeration value to an attribute that wasn't defined at the time the value was parsed.

Definition at line 62 of file dict_fixup.c.

+ Collaboration diagram for dict_fixup_enumv_t:
Data Fields
char * attribute we couldn't find (and will need to resolve later).
dict_fixup_common_t common Common fields.
char * filename where the line being fixed up.
int line ditto.
char * name Raw enum name.
fr_dict_attr_t const * parent Parent attribute to resolve the 'attribute' string in.
char * value Raw enum value.

We can't do anything with this until we know the attribute type, which we only find out later.

◆ dict_fixup_group_t

struct dict_fixup_group_t

Resolve a group reference.

Definition at line 79 of file dict_fixup.c.

+ Collaboration diagram for dict_fixup_group_t:
Data Fields
dict_fixup_common_t common Common fields.
fr_dict_attr_t * da FR_TYPE_GROUP to fix.
char * ref the reference name

◆ dict_fixup_hash_t

struct dict_fixup_hash_t

Dictionary attribute namespaces need their hash tables finalised.

Definition at line 108 of file dict_fixup.c.

+ Collaboration diagram for dict_fixup_hash_t:
Data Fields
dict_fixup_common_t common Common fields.
fr_hash_table_t * hash We need to finalise.

◆ dict_fixup_vsa_t

struct dict_fixup_vsa_t

Run fixup callbacks for a VSA.

Definition at line 99 of file dict_fixup.c.

+ Collaboration diagram for dict_fixup_vsa_t:
Data Fields
dict_fixup_common_t common Common fields.
fr_dict_attr_t * da FR_TYPE_VSA to fix.

Macro Definition Documentation

◆ APPLY_FIXUP

#define APPLY_FIXUP (   _fctx,
  _list,
  _func,
  _type 
)
Value:
do { \
_type *_fixup; \
while ((_fixup = fr_dlist_head(&(_fctx)->_list))) { \
if (_func(_fctx, _fixup) < 0) return -1; \
fr_dlist_remove(&(_fctx)->_list, _fixup); \
talloc_free(_fixup); \
} \
} while (0)
while(1)
Definition: acutest.h:856
static void * fr_dlist_head(fr_dlist_head_t const *list_head)
Return the HEAD item of a list or NULL if the list is empty.
Definition: dlist.h:486
static void * fr_dlist_remove(fr_dlist_head_t *list_head, void *ptr)
Remove an item from the list.
Definition: dlist.h:638
talloc_free(reap)
return
Definition: module.c:174

Function Documentation

◆ _dict_attr_fixup_hash_tables()

static int _dict_attr_fixup_hash_tables ( fr_dict_attr_t const *  da,
UNUSED void *  uctx 
)
static

Fixup all hash tables in the dictionary so they're suitable for threaded access.

Definition at line 865 of file dict_fixup.c.

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

◆ dict_fixup_alias_apply()

static int dict_fixup_alias_apply ( UNUSED dict_fixup_ctx_t fctx,
dict_fixup_alias_t fixup 
)
inlinestatic

Definition at line 780 of file dict_fixup.c.

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

◆ dict_fixup_alias_enqueue()

int dict_fixup_alias_enqueue ( dict_fixup_ctx_t fctx,
char const *  filename,
int  line,
fr_dict_attr_t alias_parent,
char const *  alias,
fr_dict_attr_t ref_parent,
char const *  ref 
)

Resolve a group reference.

This is required as the reference may point to another dictionary which hasn't been loaded yet.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]filenamethis fixup relates to.
[in]linethis fixup relates to.
[in]alias_parentwhere to add the alias.
[in]aliasalias to add.
[in]ref_parentattribute that should contain the reference.
[in]refOID string representing what the group references.
Returns
  • 0 on success.
  • -1 on out of memory.

Definition at line 754 of file dict_fixup.c.

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

◆ dict_fixup_apply()

int dict_fixup_apply ( dict_fixup_ctx_t fctx)

Apply all outstanding fixes to a set of dictionaries.

Definition at line 824 of file dict_fixup.c.

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

◆ dict_fixup_clone()

int dict_fixup_clone ( fr_dict_attr_t **  dst_p,
fr_dict_attr_t const *  src 
)

Clone a dictionary attribute from a ref.

Parameters
[in]dst_pwill either be inserted directly, with fields from the clone, or will be cloned, and then inserted. In this case the original dst da will be freed and the new cloned attribute will be written back to dst_p.
[in]srcto clone.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 416 of file dict_fixup.c.

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

◆ dict_fixup_clone_apply()

static int dict_fixup_clone_apply ( UNUSED dict_fixup_ctx_t fctx,
dict_fixup_clone_t fixup 
)
inlinestatic

Clone one are of a tree into another.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]fixupContaining source/destination of the clone.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 566 of file dict_fixup.c.

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

◆ dict_fixup_clone_enqueue()

int dict_fixup_clone_enqueue ( dict_fixup_ctx_t fctx,
fr_dict_attr_t da,
char const *  ref 
)

Clone one area of a tree into another.

These must be processed later to ensure that we've finished building an attribute by the time it has been cloned.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]daThe group dictionary attribute.
[in]refOID string representing what the group references..
Returns
  • 0 on success.
  • -1 on out of memory.

Definition at line 383 of file dict_fixup.c.

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

◆ dict_fixup_clone_enum_apply()

static int dict_fixup_clone_enum_apply ( UNUSED dict_fixup_ctx_t fctx,
dict_fixup_clone_t fixup 
)
inlinestatic

Clone one are of a tree into another.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]fixupContaining source/destination of the clone.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 623 of file dict_fixup.c.

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

◆ dict_fixup_clone_enum_enqueue()

int dict_fixup_clone_enum_enqueue ( dict_fixup_ctx_t fctx,
fr_dict_attr_t da,
char const *  ref 
)

Clone enumeration values from one attribute to another.

These must be processed later to ensure that we've finished building an attribute by the time it has been cloned.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]daThe group dictionary attribute.
[in]refOID string representing what the group references..
Returns
  • 0 on success.
  • -1 on out of memory.

Definition at line 592 of file dict_fixup.c.

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

◆ dict_fixup_common()

static int dict_fixup_common ( fr_dlist_head_t fixup_list,
dict_fixup_common_t common 
)
inlinestatic

Initialise common fields in fixup struct, and add it to a fixup list.

Parameters
[in]fixup_listto add fixup to.
[in]commoncommon header to populate.
Returns
  • 0 on success.
  • -1 on out of memory.

Definition at line 122 of file dict_fixup.c.

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

◆ dict_fixup_enumv_apply()

static int dict_fixup_enumv_apply ( UNUSED dict_fixup_ctx_t fctx,
dict_fixup_enumv_t fixup 
)
inlinestatic

Add a previously defined enumeration value to an existing attribute.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]fixupHash table to fill.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 272 of file dict_fixup.c.

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

◆ dict_fixup_enumv_enqueue()

int dict_fixup_enumv_enqueue ( dict_fixup_ctx_t fctx,
char const *  filename,
int  line,
char const *  attr,
size_t  attr_len,
char const *  name,
size_t  name_len,
char const *  value,
size_t  value_len,
fr_dict_attr_t const *  parent 
)

Add an enumeration value to an attribute which has not yet been defined.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]filenamethis fixup relates to.
[in]linethis fixup relates to.
[in]attrThe OID string pointing to the attribute to add the enumeration value to.
[in]attr_lenThe length of the attr string.
[in]nameThe name of the enumv.
[in]name_lenLength of the name string.
[in]valueValue string. This is kept as a string until we know what type we want to transform it into.
[in]value_lenLength of the value string.
[in]parentof this attribute.
Returns
  • 0 on success.
  • -1 on out of memory.

Definition at line 235 of file dict_fixup.c.

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

◆ dict_fixup_group_apply()

static int dict_fixup_group_apply ( UNUSED dict_fixup_ctx_t fctx,
dict_fixup_group_t fixup 
)
inlinestatic

Resolve a group reference.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]fixupHash table to fill.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 344 of file dict_fixup.c.

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

◆ dict_fixup_group_enqueue()

int dict_fixup_group_enqueue ( dict_fixup_ctx_t fctx,
fr_dict_attr_t da,
char const *  ref 
)

Resolve a group reference.

This is required as the reference may point to another dictionary which hasn't been loaded yet.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]daThe group dictionary attribute.
[in]refOID string representing what the group references.
Returns
  • 0 on success.
  • -1 on out of memory.

Definition at line 319 of file dict_fixup.c.

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

◆ dict_fixup_init()

int dict_fixup_init ( TALLOC_CTX *  ctx,
dict_fixup_ctx_t fctx 
)

Initialise a fixup ctx.

Parameters
[in]ctxto allocate the fixup pool in.
[in]fctxto initialise.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 805 of file dict_fixup.c.

+ Here is the caller graph for this function:

◆ dict_fixup_vsa_apply()

static int dict_fixup_vsa_apply ( UNUSED dict_fixup_ctx_t fctx,
dict_fixup_vsa_t fixup 
)
inlinestatic

Run VSA fixups.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]fixupentry for fixup
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 718 of file dict_fixup.c.

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

◆ dict_fixup_vsa_enqueue()

int dict_fixup_vsa_enqueue ( dict_fixup_ctx_t fctx,
fr_dict_attr_t da 
)

Push a fixup for a VSA.

This is required so that we can define VENDORs for all VSAs, even if the dictionary doesn't contain VENDOR children for that VSA. This fixup means that we can define VENDORs elsewhere, and then use them in all VSA definitions. It means that we don't have to do these lookups at run-time.

Parameters
[in]fctxHolds current dictionary parsing information.
[in]daThe group dictionary attribute.
Returns
  • 0 on success.
  • -1 on out of memory.

Definition at line 694 of file dict_fixup.c.

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

◆ dict_hash_tables_finalise()

void dict_hash_tables_finalise ( fr_dict_t dict)

Walk a dictionary finalising the hash tables in all attributes with a distinct namespace.

Parameters
[in]dictto finalise namespaces for.

Definition at line 891 of file dict_fixup.c.

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

◆ dict_protocol_reference()

fr_dict_attr_t const* dict_protocol_reference ( fr_dict_attr_t const *  root,
char const *  ref 
)

Resolve a ref= or copy= value to a dictionary.

Definition at line 130 of file dict_fixup.c.

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