The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Parse dictionary files. More...
#include <freeradius-devel/radius/defs.h>
#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/dict_fixup_priv.h>
#include <freeradius-devel/util/dict_priv.h>
#include <freeradius-devel/util/dict.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/rand.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/table.h>
#include <freeradius-devel/util/types.h>
#include <freeradius-devel/util/value.h>
#include <sys/stat.h>
Go to the source code of this file.
Data Structures | |
struct | dict_tokenize_ctx_t |
struct | dict_tokenize_frame_t |
Macros | |
#define | CURRENT_FRAME(_dctx) (&(_dctx)->stack[(_dctx)->stack_depth]) |
#define | FLAG_FUNC(_name) |
Define a flag setting function, which sets one bit in a fr_dict_attr_flags_t. More... | |
#define | MAX_ARGV (16) |
#define | MAX_STACK (32) |
Parser context for dict_from_file. More... | |
Enumerations | |
enum | dict_nest_t { NEST_NONE = 0 , NEST_ROOT , NEST_PROTOCOL , NEST_VENDOR , NEST_TLV } |
Functions | |
static int | _dict_from_file (dict_tokenize_ctx_t *ctx, char const *dir_name, char const *filename, char const *src_file, int src_line) |
Parse a dictionary file. More... | |
static int | dict_attr_add_or_fixup (dict_fixup_ctx_t *fixup, fr_dict_attr_t **da_p) |
Add an attribute to the dictionary, or add it to a list of attributes to clone later. More... | |
static int | dict_attr_allow_dup (fr_dict_attr_t const *da) |
Check if this definition is a duplicate, and if it is, whether we should skip it error out. More... | |
static void | dict_attr_location_set (dict_tokenize_ctx_t *dctx, fr_dict_attr_t *da) |
static int | dict_filename_add (char **filename_out, fr_dict_t *dict, char const *filename) |
Maintain a linked list of filenames which we've seen loading this dictionary. More... | |
static bool | dict_filename_loaded (fr_dict_t *dict, char const *filename) |
See if we have already loaded the file,. More... | |
static int | dict_finalise (dict_tokenize_ctx_t *ctx) |
static int | dict_flag_clone (fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules) |
static int | dict_flag_enum (fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_flag_key (fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_flag_length (fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_flag_offset (fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_flag_precision (fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_flag_ref (fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_flag_secret (fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_flag_subtype (fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rule) |
static int | dict_from_file (fr_dict_t *dict, char const *dir_name, char const *filename, char const *src_file, int src_line) |
static dict_tokenize_frame_t const * | dict_gctx_find_frame (dict_tokenize_ctx_t *ctx, dict_nest_t nest) |
static int | dict_gctx_push (dict_tokenize_ctx_t *ctx, fr_dict_attr_t const *da) |
static fr_dict_attr_t const * | dict_gctx_unwind (dict_tokenize_ctx_t *ctx) |
static int | dict_process_type_field (dict_tokenize_ctx_t *ctx, char const *name, fr_dict_attr_t **da_p) |
static int | dict_read_parse_format (char const *format, int *ptype, int *plength, bool *pcontinuation) |
static int | dict_read_process_alias (dict_tokenize_ctx_t *ctx, char **argv, int argc) |
static int | dict_read_process_attribute (dict_tokenize_ctx_t *ctx, char **argv, int argc, fr_dict_attr_flags_t const *base_flags) |
static int | dict_read_process_common (dict_tokenize_ctx_t *ctx, fr_dict_attr_t **da_p, char const *name, char const *type_name, char *flag_name, fr_dict_attr_flags_t const *base_flags) |
static int | dict_read_process_define (dict_tokenize_ctx_t *ctx, char **argv, int argc, fr_dict_attr_flags_t const *base_flags) |
static int | dict_read_process_enum (dict_tokenize_ctx_t *ctx, char **argv, int argc, fr_dict_attr_flags_t const *base_flags) |
static int | dict_read_process_flags (UNUSED fr_dict_t *dict, char **argv, int argc, fr_dict_attr_flags_t *base_flags) |
static int | dict_read_process_include (dict_tokenize_ctx_t *ctx, char **argv, int argc, char const *dir, char *fn, int line) |
static int | dict_read_process_member (dict_tokenize_ctx_t *ctx, char **argv, int argc, fr_dict_attr_flags_t const *base_flags) |
static int | dict_read_process_protocol (char **argv, int argc) |
Register the specified dictionary as a protocol dictionary. More... | |
static int | dict_read_process_struct (dict_tokenize_ctx_t *ctx, char **argv, int argc) |
Process a STRUCT name attr value. More... | |
static int | dict_read_process_value (dict_tokenize_ctx_t *ctx, char **argv, int argc) |
Process a value alias. More... | |
static int | dict_read_process_vendor (fr_dict_t *dict, char **argv, int argc) |
static int | dict_read_sscanf_i (unsigned int *pvalue, char const *str) |
static int | dict_root_set (fr_dict_t *dict, char const *name, unsigned int proto_number) |
Set a new root dictionary attribute. More... | |
static int | dict_set_value_attr (dict_tokenize_ctx_t *ctx, fr_dict_attr_t *da) |
fr_dict_t * | fr_dict_alloc (char const *proto_name, unsigned int proto_number) |
int | fr_dict_internal_afrom_file (fr_dict_t **out, char const *dict_subdir, char const *dependent) |
(Re-)Initialize the special internal dictionary More... | |
int | fr_dict_parse_str (fr_dict_t *dict, char *buf, fr_dict_attr_t const *parent) |
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... | |
int | fr_dict_read (fr_dict_t *dict, char const *dir, char const *filename) |
Read supplementary attribute definitions into an existing dictionary. More... | |
int | fr_dict_str_to_argv (char *str, char **argv, int max_argc) |
static | TABLE_TYPE_NAME_FUNC_RPTR (table_sorted_value_by_str, fr_dict_flag_parser_t const *, fr_dict_attr_flag_to_parser, fr_dict_flag_parser_rule_t const *, fr_dict_flag_parser_rule_t const *) |
A lookup function for dictionary attribute flags. More... | |
Parse dictionary files.
Definition in file dict_tokenize.c.
struct dict_tokenize_ctx_t |
Definition at line 67 of file dict_tokenize.c.
Data Fields | ||
---|---|---|
fr_dict_t * | dict | Protocol dictionary we're inserting attributes into. |
dict_fixup_ctx_t | fixup | |
fr_dict_attr_t const * | relative_attr |
for ".82" instead of "1.2.3.82". only for parents of type "tlv" |
dict_tokenize_frame_t | stack[MAX_STACK] | stack of attributes to track |
int | stack_depth | points to the last used stack frame |
fr_dict_attr_t * | value_attr | Cache of last attribute to speed up value processing. |
struct dict_tokenize_frame_t |
Definition at line 56 of file dict_tokenize.c.
Data Fields | ||
---|---|---|
fr_dict_attr_t const * | da | the da we care about |
fr_dict_t * | dict | The dictionary before the current BEGIN-PROTOCOL block. |
char * | filename | name of the file we're reading |
int | line | line number of this file |
int | member_num | structure member numbers |
dict_nest_t | nest | for manual vs automatic begin / end things |
fr_dict_attr_t const * | struct_is_closed | no more members are allowed |
ssize_t | struct_size | size of the struct. |
#define CURRENT_FRAME | ( | _dctx | ) | (&(_dctx)->stack[(_dctx)->stack_depth]) |
Definition at line 80 of file dict_tokenize.c.
#define FLAG_FUNC | ( | _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.
Definition at line 302 of file dict_tokenize.c.
#define MAX_ARGV (16) |
Definition at line 41 of file dict_tokenize.c.
#define MAX_STACK (32) |
Parser context for dict_from_file.
Allows vendor and TLV context to persist across $INCLUDEs
Definition at line 55 of file dict_tokenize.c.
enum dict_nest_t |
Enumerator | |
---|---|
NEST_NONE | |
NEST_ROOT | |
NEST_PROTOCOL | |
NEST_VENDOR | |
NEST_TLV |
Definition at line 43 of file dict_tokenize.c.
|
static |
Parse a dictionary file.
[in] | ctx | Contains the current state of the dictionary parser. Used to track what PROTOCOL, VENDOR or TLV block we're in. Block context changes in $INCLUDEs should not affect the context of the including file. |
[in] | dir_name | Directory containing the dictionary we're loading. |
[in] | filename | we're parsing. |
[in] | src_file | The including file. |
[in] | src_line | Line on which the $INCLUDE or $NCLUDE- statement was found. |
Definition at line 2213 of file dict_tokenize.c.
|
static |
Add an attribute to the dictionary, or add it to a list of attributes to clone later.
[in] | fixup | context to add an entry to (if needed). |
[in] | da_p | to either add, or create a fixup for. |
Definition at line 752 of file dict_tokenize.c.
|
static |
Check if this definition is a duplicate, and if it is, whether we should skip it error out.
Definition at line 819 of file dict_tokenize.c.
|
inlinestatic |
|
inlinestatic |
Maintain a linked list of filenames which we've seen loading this dictionary.
This is used for debug messages, so we have a copy of the original file path that we can reference from fr_dict_attr_t without having the memory bloat of assigning a buffer to every attribute.
Definition at line 2163 of file dict_tokenize.c.
See if we have already loaded the file,.
Definition at line 2185 of file dict_tokenize.c.
|
static |
Definition at line 2147 of file dict_tokenize.c.
|
static |
Definition at line 311 of file dict_tokenize.c.
|
static |
Definition at line 329 of file dict_tokenize.c.
|
static |
|
static |
|
static |
|
static |
Definition at line 417 of file dict_tokenize.c.
|
static |
Definition at line 442 of file dict_tokenize.c.
|
static |
|
static |
Definition at line 476 of file dict_tokenize.c.
|
static |
Definition at line 2921 of file dict_tokenize.c.
|
static |
|
static |
Definition at line 648 of file dict_tokenize.c.
|
static |
|
static |
Definition at line 191 of file dict_tokenize.c.
|
static |
Definition at line 1889 of file dict_tokenize.c.
|
static |
Definition at line 686 of file dict_tokenize.c.
|
static |
Definition at line 937 of file dict_tokenize.c.
|
static |
Definition at line 884 of file dict_tokenize.c.
|
static |
Definition at line 1114 of file dict_tokenize.c.
|
static |
Definition at line 1230 of file dict_tokenize.c.
|
static |
|
static |
Definition at line 1336 of file dict_tokenize.c.
|
static |
Definition at line 1404 of file dict_tokenize.c.
|
static |
Register the specified dictionary as a protocol dictionary.
Allows vendor and TLV context to persist across $INCLUDEs
Definition at line 1956 of file dict_tokenize.c.
|
static |
Process a STRUCT name attr value.
Define struct 'name' when key 'attr' has 'value'.
Which MUST be a sub-structure of another struct
Definition at line 1730 of file dict_tokenize.c.
|
static |
Process a value alias.
Definition at line 1606 of file dict_tokenize.c.
|
static |
Definition at line 2099 of file dict_tokenize.c.
|
static |
|
static |
Set a new root dictionary attribute.
[in] | dict | to modify. |
[in] | name | of dictionary root. |
[in] | proto_number | The artificial (or IANA allocated) number for the protocol. This is only used for |
Definition at line 166 of file dict_tokenize.c.
|
static |
Definition at line 866 of file dict_tokenize.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_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.
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.
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.
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.
int fr_dict_str_to_argv | ( | char * | str, |
char ** | argv, | ||
int | max_argc | ||
) |
|
static |
A lookup function for dictionary attribute flags.
Definition at line 541 of file dict_tokenize.c.