23 RCSID(
"$Id: c3b38c7d10c338e0cbdb74ad1862c902139cd14c $")
25 #include <freeradius-devel/radius/defs.h>
26 #include <freeradius-devel/util/conf.h>
27 #include <freeradius-devel/util/dict_fixup_priv.h>
28 #include <freeradius-devel/util/file.h>
29 #include <freeradius-devel/util/rand.h>
30 #include <freeradius-devel/util/strerror.h>
31 #include <freeradius-devel/util/syserror.h>
32 #include <freeradius-devel/util/value.h>
50 #define MAX_STACK (32)
74 #define CURRENT_FRAME(_dctx) (&(_dctx)->stack[(_dctx)->stack_depth])
85 if (argc >= max_argc)
break;
95 while ((*str ==
' ') ||
119 int unsigned ret = 0;
121 static char const *tab =
"0123456789";
123 if ((str[0] ==
'0') &&
124 ((str[1] ==
'x') || (str[1] ==
'X'))) {
125 tab =
"0123456789abcdef";
134 if (*str ==
'.')
break;
136 c = memchr(tab, tolower((
uint8_t)*str), base);
195 p = strchr(
name,
'[');
201 q = strchr(p + 1,
']');
221 if ((length == 0) || (length > 255)) {
229 if (strcmp(
name,
"octets") == 0) {
232 }
else if (strcmp(
name,
"string") == 0) {
235 }
else if (strcmp(
name,
"struct") == 0) {
238 }
else if (strcmp(
name,
"bit") == 0) {
249 }
else if (length <= 8) {
251 }
else if (length <= 16) {
253 }
else if (length <= 32) {
255 }
else if (length <= 56) {
269 flags->flag_byte_offset = length;
272 fr_strerror_const(
"Only 'octets', 'string', 'struct', or 'bit' types can have a 'length' parameter");
301 char *p, *next = NULL;
313 for (p =
name; p && *p !=
'\0' ; p = next) {
322 if (ctx->
dict->subtype_table) {
340 for (next = p + 1; *next && (*next !=
'=') && (*next !=
','); next++) {
362 for (; *next; next++) {
375 if (strcmp(key,
"internal") == 0) {
378 }
else if (strcmp(key,
"array") == 0) {
381 }
else if (strcmp(key,
"counter") == 0) {
384 }
else if (strcmp(key,
"secret") == 0) {
387 }
else if (strcmp(key,
"offset") == 0) {
396 fr_strerror_const(
"The 'offset' flag can only be used in combination with 'length=uint8' or 'length=uint16'");
405 offset = atoi(
value);
406 if ((offset <= 0) || (offset > 255)) {
412 }
else if (strcmp(key,
"key") == 0) {
414 fr_strerror_const(
"The 'key' flag can only be used for attributes of type 'uint8', 'uint16', or 'uint32'");
426 }
else if (strcmp(key,
"length") == 0) {
432 if (strcmp(
value,
"uint8") == 0) {
436 }
else if (strcmp(
value,
"uint16") == 0) {
450 if ((strncmp(key,
"uint", 4) == 0) ||
451 (strncmp(key,
"int", 3) == 0)) {
507 flags->flag_time_res = precision;
510 }
else if (strcmp(key,
"ref") == 0) {
529 }
else if (strcmp(key,
"clone") == 0) {
536 fr_strerror_const(
"'clone=...' references can only be used for 'tlv' and 'struct' types");
548 }
else if (strcmp(key,
"enum") == 0) {
606 }
else if (ctx->
dict->subtype_table) {
623 if (subtype < 0)
goto unknown_option;
707 if (strncmp(argv[0],
"Attr-", 5) == 0) {
752 self->dict = ctx->
dict;
756 namespace = dict_attr_namespace(parent);
787 ref, talloc_array_length(ref) - 1) < 0) {
803 da_ref = ctx->
dict->root;
819 if (da_ref)
goto set;
851 bool set_relative_attr;
861 if ((argc < 3) || (argc > 4)) {
869 if (strncmp(argv[0],
"Attr-", 5) == 0) {
874 memcpy(&flags, base_flags,
sizeof(flags));
888 if (argv[1][0] !=
'.') {
895 if (strchr(argv[1],
'.') == 0) {
903 if (slen <= 0)
return -1;
920 if (slen <= 0)
return -1;
922 set_relative_attr =
false;
931 fr_strerror_printf(
"Member %s of ATTRIBUTE %s type 'struct' MUST use the \"MEMBER\" keyword",
945 #ifdef WITH_DICTIONARY_WARNINGS
950 if (!vendor && (attr < 256) &&
951 !strstr(fn,
"rfc") && !strstr(fn,
"illegal")) {
952 fprintf(stderr,
"WARNING: Illegal attribute %s in %s\n",
957 #ifdef STATIC_ANALYZER
958 if (!ctx->
dict)
return -1;
966 ctx->
dict->vsa_parent = attr;
1018 if ((argc < 2) || (argc > 3)) {
1026 if (strncmp(argv[0],
"Attr-", 5) == 0) {
1035 memcpy(&flags, base_flags,
sizeof(flags));
1066 fr_strerror_printf(
"Member %s of parent %s type 'struct' MUST use the \"MEMBER\" keyword",
1080 #ifdef STATIC_ANALYZER
1081 if (!ctx->
dict)
return -1;
1136 if (strncmp(argv[0],
"Attr-", 5) == 0) {
1141 flags = *base_flags;
1145 flags.is_enum =
true;
1177 #ifdef STATIC_ANALYZER
1178 if (!ctx->
dict)
return -1;
1210 char const *dir_name,
char const *filename,
1211 char const *src_file,
int src_line);
1225 if ((argv[0][8] !=
'\0') && ((argv[0][8] !=
'-') || (argv[0][9] !=
'\0'))) {
1240 if (strncmp(argv[1],
"${dictdir}/", 11) != 0) {
1246 if ((rcode == -2) && (argv[0][8] ==
'-')) {
1292 if ((argc < 2) || (argc > 3)) {
1305 if (strncmp(argv[0],
"Attr-", 5) == 0) {
1310 memcpy(&flags, base_flags,
sizeof(flags));
1329 #ifdef STATIC_ANALYZER
1330 if (!ctx->
dict)
return -1;
1350 if (previous->flags.extra && (previous->flags.subtype ==
FLAG_BIT_FIELD)) {
1357 flags.flag_byte_offset = (flags.
length + previous->flags.flag_byte_offset) & 0x07;
1360 if (previous->flags.flag_byte_offset != 0) {
1377 fr_strerror_printf(
"'struct' %s has fixed size %u, we cannot add a variable-sized member.",
1402 fr_strerror_printf(
"'struct' %s has a 'length' field %s, and cannot end with a TLV %s",
1416 type, &flags) < 0)
return -1;
1452 fr_strerror_printf(
"'struct' %s has fixed size %u, but member %s overflows that length",
1465 ref, talloc_array_length(ref) - 1);
1468 if (ret < 0)
return -1;
1539 argv[0], strlen(argv[0]),
1540 argv[1], strlen(argv[1]),
1541 argv[2], strlen(argv[2]),
parent) < 0) {
1558 argv[2], strlen(argv[2]),
1593 if (strcmp(p,
"internal") == 0) {
1618 char *key_attr = argv[1];
1619 char *
name = argv[0];
1621 if ((argc < 3) || (argc > 4)) {
1674 memset(&flags, 0,
sizeof(flags));
1691 attr =
value.vb_uint8;
1695 attr =
value.vb_uint16;
1699 attr =
value.vb_uint32;
1738 bool continuation =
false;
1747 if ((strlen(p) < 3) ||
1751 (p[3] && (p[3] !=
','))) {
1757 type = (int)(p[0] -
'0');
1758 length = (int)(p[2] -
'0');
1765 if ((length != 0) && (length != 1) && (length != 2)) {
1777 if ((p[4] !=
'c') ||
1783 continuation =
true;
1785 if ((
type != 1) || (length != 1)) {
1793 *pcontinuation = continuation;
1804 unsigned int type_size = 0;
1807 bool require_dl =
false;
1808 bool string_based =
false;
1810 if ((argc < 2) || (argc > 3)) {
1811 fr_strerror_const(
"Missing arguments after PROTOCOL. Expected PROTOCOL <num> <name>");
1844 if (strcmp(argv[2],
"verify=lib") == 0) {
1849 if (strcmp(argv[2],
"format=string") == 0) {
1851 string_based =
true;
1856 fr_strerror_printf(
"Invalid format for PROTOCOL. Expected 'format=', got '%s'", argv[2]);
1861 type_size = strtoul(p, &q, 10);
1862 if (q != (p + strlen(p))) {
1874 #ifdef STATIC_ANALYZER
1875 if (!
dict->root)
return -1;
1885 #ifdef STATIC_ANALYZER
1886 if (!
dict->root || !
dict->root->name || !argv[0])
return -1;
1891 dict->root->name, argv[0],
dict->root->attr);
1900 if (type_size && (
dict->root->flags.type_size != type_size)) {
1901 fr_strerror_printf(
"Conflicting flags for PROTOCOL \"%s\" (current %d versus new %d)",
1902 dict->root->name,
dict->root->flags.type_size, type_size);
1929 dict->string_based = string_based;
1931 mutable->flags.type_size =
dict->default_type_size;
1932 mutable->flags.length =
dict->default_type_length;
1934 mutable->flags.type_size = type_size;
1935 mutable->flags.length = 1;
1948 bool continuation =
false;
1952 if ((argc < 2) || (argc > 3)) {
1985 mutable->type =
type;
1986 mutable->length = length;
1987 mutable->continuation = continuation;
2017 char const *dir_name,
char const *filename,
2018 char const *src_file,
int src_line)
2021 char dir[256], fn[256];
2025 bool was_member =
false;
2027 struct stat statbuf;
2039 if ((strlen(dir_name) + 3 + strlen(filename)) >
sizeof(dir)) {
2051 if (!FR_DIR_IS_RELATIVE(filename)) {
2052 strlcpy(dir, filename,
sizeof(dir));
2053 p = strrchr(dir, FR_DIR_SEP);
2057 strlcat(dir,
"/",
sizeof(dir));
2060 strlcpy(fn, filename,
sizeof(fn));
2062 strlcpy(dir, dir_name,
sizeof(dir));
2063 p = strrchr(dir, FR_DIR_SEP);
2065 if (p[1])
strlcat(dir,
"/",
sizeof(dir));
2067 strlcat(dir,
"/",
sizeof(dir));
2069 strlcat(dir, filename,
sizeof(dir));
2070 p = strrchr(dir, FR_DIR_SEP);
2074 strlcat(dir,
"/",
sizeof(dir));
2077 p = strrchr(filename, FR_DIR_SEP);
2079 snprintf(fn,
sizeof(fn),
"%s%s", dir, p);
2081 snprintf(fn,
sizeof(fn),
"%s%s", dir, filename);
2087 if ((fp = fopen(fn,
"r")) == NULL) {
2101 if (fstat(fileno(fp), &statbuf) < 0) {
2109 if (!S_ISREG(statbuf.st_mode)) {
2121 "Refusing to start due to insecure configuration", fn);
2126 memset(&base_flags, 0,
sizeof(base_flags));
2128 while (fgets(buf,
sizeof(buf), fp) != NULL) {
2145 p = strchr(buf,
'#');
2149 if (argc == 0)
continue;
2177 &base_flags) == -1)
goto error;
2199 if (da->flags.length &&
2201 fr_strerror_printf(
"MEMBERs of 'struct' %s do not exactly fill the fixed-size structure",
2228 argv + 1, argc - 1) == -1)
goto error;
2238 &base_flags) == -1)
goto error;
2248 &base_flags) == -1)
goto error;
2258 &base_flags) == -1)
goto error;
2326 if (
strcasecmp(argv[0],
"BEGIN-PROTOCOL") == 0) {
2368 found->loading =
true;
2380 if (
strcasecmp(argv[0],
"END-PROTOCOL") == 0) {
2394 if (found != ctx->
dict) {
2396 argv[1], found->root->name);
2519 if (
strcasecmp(argv[0],
"BEGIN-VENDOR") == 0) {
2544 if (strncmp(argv[2],
"parent=", 7) != 0) {
2558 "Attribute '%s' should be 'vsa' but is '%s'", p,
2565 }
else if (ctx->
dict->vsa_parent) {
2576 }
else if (ctx->
dict->string_based) {
2577 vsa_da = ctx->
dict->root;
2581 ctx->
dict->root->name);
2598 memset(&flags, 0,
sizeof(flags));
2601 flags.
length = ctx->
dict->default_type_length;
2611 (vsa_da->parent->flags.is_root)) {
2646 if (
strcasecmp(argv[0],
"END-VENDOR") == 0) {
2707 char const *dir_name,
char const *filename,
2708 char const *src_file,
int src_line)
2713 memset(&ctx, 0,
sizeof(ctx));
2754 char *dict_path = NULL;
2762 fr_strerror_const(
"fr_dict_global_ctx_init() must be called before loading dictionary files");
2775 dict_path = dict_subdir ?
2796 TALLOC_FREE(dict_path);
2863 box.vb_uint8 = p->
value;
2890 char *dict_dir = NULL;
2897 fr_strerror_const(
"fr_dict_global_ctx_init() must be called before loading dictionary files");
2902 fr_strerror_const(
"Internal dictionary must be initialised before loading protocol dictionaries");
2933 dict->loaded =
true;
2965 fr_strerror_printf(
"Dictionary \"%s\" missing \"BEGIN-PROTOCOL %s\" declaration", dict_dir, proto_name);
2972 dict->loaded =
true;
2973 if (
dict->proto &&
dict->proto->init) {
2974 if (
dict->proto->init() < 0)
goto error;
2976 dict->loading =
false;
3002 fr_strerror_printf(
"fr_dict_global_ctx_init() must be called before loading dictionary files");
3010 if (!
dict)
return NULL;
3041 if (!
dict->vendors_by_name) {
3042 fr_strerror_printf(
"%s: Must initialise dictionary before calling fr_dict_read()", __FUNCTION__);
3063 if (argc == 0)
return 0;
3066 memset(&ctx, 0,
sizeof(ctx));
3084 argv[1],
dict->root->name);
3088 if (ret < 0)
goto error;
3090 }
else if (
strcasecmp(argv[0],
"ATTRIBUTE") == 0) {
3093 memset(&base_flags, 0,
sizeof(base_flags));
3096 argv + 1, argc - 1, &base_flags);
3097 if (ret < 0)
goto error;
3098 }
else if (
strcasecmp(argv[0],
"VENDOR") == 0) {
3100 if (ret < 0)
goto error;
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
#define fr_cond_assert_msg(_x, _fmt,...)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
size_t type
Length of type data.
fr_dict_attr_t const * fr_dict_attr_by_oid(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *oid))
Resolve an attribute using an OID string.
char const * fr_dict_global_ctx_dir(void)
unsigned int name_only
this attribute should always be referred to by name, not by number
fr_slen_t fr_dict_enum_name_from_substr(fr_sbuff_t *out, fr_sbuff_parse_error_t *err, fr_sbuff_t *in, fr_sbuff_term_t const *tt)
Extract an enumeration name from a string.
int fr_dict_enum_add_name(fr_dict_attr_t *da, char const *name, fr_value_box_t const *value, bool coerce, bool replace)
Add a value name.
char const * name
Vendor name.
fr_dict_attr_t * fr_dict_attr_unconst(fr_dict_attr_t const *da)
Coerce to non-const.
fr_dict_vendor_t const * fr_dict_vendor_by_num(fr_dict_t const *dict, uint32_t vendor_pen)
Look up a vendor by its PEN.
unsigned int is_root
Is root of a dictionary.
@ FLAG_LENGTH_UINT8
string / octets type is prefixed by uint8 of length
@ FLAG_LENGTH_UINT16
string / octets type is prefixed by uint16 of length
@ FLAG_KEY_FIELD
this is a key field for a subsequent struct
@ FLAG_BIT_FIELD
bit field inside of a struct
fr_dict_attr_t const * fr_dict_attr_common_parent(fr_dict_attr_t const *a, fr_dict_attr_t const *b, bool is_ancestor)
Find a common ancestor that two TLV type attributes share.
unsigned int array
Pack multiples into 1 attr.
unsigned int secret
this attribute should be omitted in debug mode
unsigned int extra
really "subtype is used by dict, not by protocol"
unsigned int internal
Internal attribute, should not be received in protocol packets, should not be encoded.
fr_slen_t fr_dict_attr_by_oid_legacy(fr_dict_t const *dict, fr_dict_attr_t const **parent, unsigned int *attr, char const *oid)
Get the leaf attribute of an OID string.
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
uint32_t pen
Private enterprise number.
#define da_is_length_field(_da)
uint8_t type_size
For TLV2 and root attributes.
size_t length
Length of length data.
@ FR_DICT_ATTR_EXT_ENUMV
Enumeration values.
unsigned int is_known_width
is treated as if it has a known width for structs
unsigned int is_unsigned
hackity hack for dates and time deltas
fr_dict_vendor_t const * fr_dict_vendor_by_name(fr_dict_t const *dict, char const *name)
Look up a vendor by its name.
#define fr_dict_attr_is_key_field(_da)
uint8_t subtype
protocol-specific values, OR key fields
uint8_t length
length of the attribute
unsigned int is_alias
This isn't a real attribute, it's a reference to to one.
unsigned int counter
integer attribute is actually an impulse / counter
int fr_dict_attr_add(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, fr_dict_attr_flags_t const *flags))
Add an attribute to the dictionary.
Values of the encryption flags.
static void * fr_dict_attr_ext(fr_dict_attr_t const *da, fr_dict_attr_ext_t ext)
static fr_dict_attr_t const * fr_dict_attr_ref(fr_dict_attr_t const *da)
Return the reference associated with a group type attribute.
fr_hash_table_t * value_by_name
Lookup an enumeration value by name.
Attribute extension - Holds enumeration values.
static int dict_attr_ref_set(fr_dict_attr_t const *da, fr_dict_attr_t const *ref)
int dict_fixup_apply(dict_fixup_ctx_t *fctx)
Apply all outstanding fixes to a set of dictionaries.
int dict_fixup_group(dict_fixup_ctx_t *fctx, char const *filename, int line, fr_dict_attr_t *da, char const *ref)
Resolve a group reference.
int dict_fixup_enumv(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.
int dict_fixup_init(TALLOC_CTX *ctx, dict_fixup_ctx_t *fctx)
Initialise a fixup ctx.
int dict_fixup_clone(dict_fixup_ctx_t *fctx, char const *filename, int line, fr_dict_attr_t *parent, fr_dict_attr_t *da, char const *ref, size_t ref_len)
Clone one area of a tree into another.
TALLOC_CTX * pool
Temporary pool for fixups, reduces holes.
int dict_attr_enum_add_name(fr_dict_attr_t *da, char const *name, fr_value_box_t const *value, bool coerce, bool replace, fr_dict_attr_t const *child_struct)
#define INTERNAL_IF_NULL(_dict, _ret)
Set the internal dictionary if none was provided.
bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, UNUSED char const *name, int *attr, fr_type_t type, fr_dict_attr_flags_t *flags))
fr_dict_t * dict_by_protocol_num(unsigned int num)
Internal version of fr_dict_by_protocol_num.
int dict_attr_add_to_namespace(fr_dict_attr_t const *parent, fr_dict_attr_t *da)
Add an attribute to the name table for an attribute.
fr_dict_t * dict_by_protocol_name(char const *name)
Internal version of fr_dict_by_protocol_name.
int dict_attr_child_add(fr_dict_attr_t *parent, fr_dict_attr_t *child)
Add a child to a parent.
fr_dict_t * dict_alloc(TALLOC_CTX *ctx)
Allocate a new dictionary.
int dict_vendor_add(fr_dict_t *dict, char const *name, unsigned int num)
Add a vendor to the dictionary.
fr_dict_attr_t * dict_attr_child_by_num(fr_dict_attr_t const *parent, unsigned int attr)
Internal version of fr_dict_attr_child_by_num.
int dict_dlopen(fr_dict_t *dict, char const *name)
fr_dict_t * internal
Magic internal dictionary.
int dict_dependent_add(fr_dict_t *dict, char const *dependent)
Record a new dependency on a dictionary.
fr_dict_attr_t * dict_attr_alloc(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, char const *name, int attr, fr_type_t type, dict_attr_args_t const *args)
Allocate a dictionary attribute on the heap.
int dict_protocol_add(fr_dict_t *dict)
Add a protocol to the global protocol table.
fr_dict_gctx_t * dict_gctx
Top level structure containing global dictionary state.
bool perm_check
Whether we should check dictionary file permissions as they're loaded.
fr_dict_attr_t * dict_attr_by_name(fr_dict_attr_err_t *err, fr_dict_attr_t const *parent, char const *name)
bool dict_attr_fields_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, char const *name, int *attr, fr_type_t type, fr_dict_attr_flags_t *flags)
Validate a new attribute definition.
Optional arguments for initialising/allocating attributes.
static fr_dict_attr_t const * dict_gctx_unwind(dict_tokenize_ctx_t *ctx)
dict_nest_t nest
for manual vs automatic begin / end things
fr_dict_attr_t * value_attr
Cache of last attribute to speed up value processing.
dict_tokenize_frame_t stack[MAX_STACK]
stack of attributes to track
int member_num
structure member numbers
static int dict_process_ref(dict_tokenize_ctx_t *ctx, fr_dict_attr_t const *parent, fr_dict_attr_t const *da, char *ref)
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_gctx_push(dict_tokenize_ctx_t *ctx, fr_dict_attr_t const *da)
fr_dict_t * fr_dict_alloc(char const *proto_name, unsigned int proto_number)
ssize_t struct_size
size of the struct.
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
int fr_dict_str_to_argv(char *str, char **argv, int max_argc)
static int dict_read_sscanf_i(unsigned int *pvalue, char const *str)
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_parse_format(char const *format, int *ptype, int *plength, bool *pcontinuation)
static dict_tokenize_frame_t const * dict_gctx_find_frame(dict_tokenize_ctx_t *ctx, dict_nest_t nest)
static int dict_from_file(fr_dict_t *dict, char const *dir_name, char const *filename, char const *src_file, int src_line)
fr_dict_attr_t const * da
the da we care about
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.
fr_dict_t * dict
The dictionary before the current BEGIN-PROTOCOL block.
char * filename
name of the file we're reading
static int dict_read_process_value(dict_tokenize_ctx_t *ctx, char **argv, int argc)
Process a value alias.
fr_dict_t * dict
Protocol dictionary we're inserting attributes into.
static int dict_read_process_struct(dict_tokenize_ctx_t *ctx, char **argv, int argc)
Process a STRUCT name attr value.
fr_dict_attr_t const * relative_attr
for ".82" instead of "1.2.3.82".
int line
line number of this file
static int dict_process_flag_field(dict_tokenize_ctx_t *ctx, char *name, fr_type_t type, fr_dict_attr_flags_t *flags, char **ref)
static int dict_finalise(dict_tokenize_ctx_t *ctx)
static int dict_read_process_enum(dict_tokenize_ctx_t *ctx, char **argv, int argc, fr_dict_attr_flags_t const *base_flags)
int fr_dict_read(fr_dict_t *dict, char const *dir, char const *filename)
Read supplementary attribute definitions into an existing dictionary.
static int dict_read_process_vendor(fr_dict_t *dict, char **argv, int argc)
int fr_dict_parse_str(fr_dict_t *dict, char *buf, fr_dict_attr_t const *parent)
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_alias(dict_tokenize_ctx_t *ctx, char **argv, int argc)
int fr_dict_internal_afrom_file(fr_dict_t **out, char const *dict_subdir, char const *dependent)
(Re-)Initialize the special internal dictionary
#define CURRENT_FRAME(_dctx)
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.
#define MAX_STACK
Parser context for dict_from_file.
static int dict_read_process_flags(UNUSED fr_dict_t *dict, char **argv, int argc, fr_dict_attr_flags_t *base_flags)
int stack_depth
points to the last used stack frame
static int dict_process_type_field(dict_tokenize_ctx_t *ctx, char const *name, fr_type_t *type_p, fr_dict_attr_flags_t *flags)
static int dict_root_set(fr_dict_t *dict, char const *name, unsigned int proto_number)
Set a new root dictionary attribute.
char const * fr_cwd_strip(char const *filename)
Intended to be used in logging functions to make output more readable.
bool fr_hash_table_insert(fr_hash_table_t *ht, void const *data)
Insert data into a hash table.
static char * stack[MAX_STACK]
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_INT64
64 Bit signed integer.
@ FR_TYPE_INT16
16 Bit signed integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
@ FR_TYPE_INT32
32 Bit signed integer.
@ FR_TYPE_VENDOR
Attribute that represents a vendor in the attribute tree.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
int strncasecmp(char *s1, char *s2, int n)
int strcasecmp(char *s1, char *s2)
#define FR_SBUFF_IN(_start, _len_or_end)
PUBLIC int snprintf(char *string, size_t length, char *format, va_alist)
fr_aka_sim_id_type_t type
size_t strlcat(char *dst, char const *src, size_t siz)
size_t strlcpy(char *dst, char const *src, size_t siz)
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
char const * str
Literal string.
An element in an arbitrarily ordered array of name to num mappings.
char * talloc_typed_asprintf(TALLOC_CTX *ctx, char const *fmt,...)
Call talloc vasprintf, setting the type on the new chunk correctly.
fr_table_num_ordered_t const fr_time_precision_table[]
#define FR_DICTIONARY_FILE
void fr_strerror_clear(void)
Clears all pending messages from the talloc pools.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_printf_push(_fmt,...)
Add a message to an existing stack of messages at the tail.
#define fr_strerror_const_push(_msg)
#define fr_strerror_const(_msg)
fr_table_num_ordered_t const fr_type_table[]
Map data types to names representing those types.
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
#define fr_type_is_null(_x)
#define fr_type_is_leaf(_x)
static fr_type_t fr_type_from_str(char const *type)
Return the constant value representing a type.
ssize_t fr_value_box_from_str(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t dst_type, fr_dict_attr_t const *dst_enumv, char const *in, size_t inlen, fr_sbuff_unescape_rules_t const *erules, bool tainted)
void fr_value_box_clear(fr_value_box_t *data)
Clear/free any existing value and metadata.
#define FR_VALUE_BOX_INITIALISER_NULL(_vb)
A static initialiser for stack/globally allocated boxes.
#define fr_value_box_init(_vb, _type, _enumv, _tainted)
Initialise a fr_value_box_t.
int format(printf, 5, 0))
static size_t char ** out