27RCSID(
"$Id: 04b067b7413c7309880109fe634b7925e045b6cc $")
 
   29#include <freeradius-devel/util/net.h> 
   30#include <freeradius-devel/util/proto.h> 
   31#include <freeradius-devel/util/table.h> 
   32#include <freeradius-devel/util/dict_ext_priv.h> 
   85#define ALL_STRINGS ((1 << FR_DER_TAG_BMP_STRING) | (1 << FR_DER_TAG_GENERAL_STRING) | \ 
   86                     (1 << FR_DER_TAG_IA5_STRING) | (1 << FR_DER_TAG_PRINTABLE_STRING) | \ 
   87                     (1 << FR_DER_TAG_T61_STRING) | (1 << FR_DER_TAG_UTF8_STRING) | \ 
   88                     (1 << FR_DER_TAG_VISIBLE_STRING)) 
 
  231                fr_strerror_printf(
"Cannot use 'class' for attribute %s DER type %s - the parent must be 'sequence'",
 
  237                fr_strerror_printf(
"Cannot use 'class' for attribute %s - the attribute number must be 0..30",
 
  238                                   (*da_p)->parent->name);
 
  254        flags->
class = tag_class;
 
 
  274        if (!flags->default_value) 
return -1;
 
 
  333        if (strcmp(
value, 
"oid_and_value") == 0) {
 
  346        flags->sequence_of = 
type;
 
 
  367        if (strcmp(
value, 
"oid_and_value") == 0) {
 
  388        flags->set_of = 
type;
 
 
  429        char const *p = 
value;
 
  440        if ((p[0] == 
'.') && (p[1] == 
'.')) 
goto check_max;
 
  442        num = strtoul(p, &end, 10);
 
  443        if (num == ULONG_MAX) {
 
  460                if (!num) 
goto invalid;
 
  469                        (*da_p)->flags.length = num;
 
  476                flags->
min = flags->
max = num;
 
  480        if ((end[0] != 
'.') || (end[1] != 
'.')) {
 
  496        num = strtoul(p, &end, 10);
 
  497        if (num == ULONG_MAX) 
goto invalid;
 
 
  515        num = strtoul(
value, &end, 10);
 
  516        if (*end || !num || (num == ULONG_MAX)) {
 
 
  536        if (!(*da_p)->parent->flags.is_root &&
 
  538                fr_strerror_printf(
"Cannot use 'option' for attribute %s DER type %s - the parent must be 'sequence' or 'set'",
 
  549                if (!(*da_p)->state.attr_set || (*da_p)->attr > 0x1f) {
 
  561        if ((*da_p)->state.attr_set) {
 
  571        num = strtoul(
value, &end, 10);
 
  572        if ((num == ULONG_MAX) || *end) {
 
 
  599        if (!(*da_p)->parent->flags.is_root &&
 
  601                fr_strerror_printf(
"Cannot use 'optional' for attribute %s DER type %s - the parent must be 'sequence' or 'set'",
 
 
  651        static size_t type_table_len = 
NUM_ELEMENTS(type_table);
 
  676        static size_t der_tag_table_len = 
NUM_ELEMENTS(der_tag_table);
 
  763        if (strcmp(
name, 
"x509_extensions") == 0) {
 
 
  840                fr_strerror_printf(
"Attribute %s of type %s is not allowed represent a collection of choices.",
 
  857            !da->flags.internal &&
 
  881                        fr_strerror_const(
"Attribute is 'x509_extensions', but is missing 'ref=OID-Tree'");
 
  889                if (!flags->
max) flags->
max = UINT64_MAX;
 
  969                if ((
parent->restrictions & (1 << flags->
option)) != 0) {
 
  970                        fr_strerror_printf(
"Parent %s already has a child with option %u - duplicates are not allowed",
 
  971                                           da->parent->name, flags->
option);
 
  984                        fr_strerror_printf(
"Parent %s already has a child with tag %s - duplicates are not allowed",
 
  991        } 
else if (
parent->is_sequence_of) {
 
 1004        } 
else if (
parent->is_set_of) {
 
 
 1019               .default_type_size   = 4,
 
 1020               .default_type_length = 4,
 
 
#define L(_str)
Helper for initialising arrays of string literals.
fr_der_tag_t
Enumeration describing the data types in a DER encoded structure.
@ FR_DER_TAG_IA5_STRING
String of IA5 (7bit) chars.
@ FR_DER_TAG_SEQUENCE
A sequence of DER encoded data (a structure).
@ FR_DER_TAG_SET
A set of DER encoded data (a structure).
@ FR_DER_TAG_BMP_STRING
String of BMP chars.
@ FR_DER_TAG_INTEGER
Arbitrary width signed integer.
@ FR_DER_TAG_BOOLEAN
Boolean true/false.
@ FR_DER_TAG_CHOICE
A choice of types. Techically not a DER tag, but used to represent a choice.
@ FR_DER_TAG_UTF8_STRING
String of UTF8 chars.
@ FR_DER_TAG_UTC_TIME
A time in UTC "YYMMDDhhmmssZ" format.
@ FR_DER_TAG_GENERALIZED_TIME
A time in "YYYYMMDDHHMMSS[.fff]Z" format.
@ FR_DER_TAG_INVALID
Invalid tag.
@ FR_DER_TAG_NULL
An empty value.
@ FR_DER_TAG_OCTETSTRING
String of octets (length field specifies bytes).
@ FR_DER_TAG_VISIBLE_STRING
String of visible chars.
@ FR_DER_TAG_BITSTRING
String of bits (length field specifies bits).
@ FR_DER_TAG_T61_STRING
String of T61 (8bit) chars.
@ FR_DER_TAG_ENUMERATED
An enumerated value.
@ FR_DER_TAG_UNIVERSAL_STRING
String of universal chars.
@ FR_DER_TAG_PRINTABLE_STRING
String of printable chars.
@ FR_DER_TAG_GENERAL_STRING
String of general chars.
@ FR_DER_TAG_OID
Reference to an OID based attribute.
bool optional
optional, we MUST already have set 'option'
bool is_extensions
a list of X.509 extensions
#define fr_der_flag_der_type(_da)
fr_der_tag_t der_type
the DER type, which is different from the FreeRADIUS type
bool is_option
has an option defined
bool is_sequence_of
sequence_of has been defined
bool is_set_of
set_of has been defined
uint32_t restrictions
for choice of options and tags - no dups allowed
bool is_oid_and_value
is OID+value
bool is_choice
DER name "choice".
#define FR_DER_TAG_VALUE_MAX
tags >=max can't exist
uint8_t option
an "attribute number" encoded in the tag field.
bool has_default_value
a default value exists
fr_der_tag_class_t class
tag Class
uint64_t max
maximum count of items in a sequence, set, or string.
@ FR_DER_CLASS_APPLICATION
fr_dict_t * fr_dict_unconst(fr_dict_t const *dict)
Coerce to non-const.
#define fr_dict_autofree(_to_free)
int fr_dict_attr_set_group(fr_dict_attr_t **da_p)
fr_dict_t const  ** out
Where to write a pointer to the loaded/resolved fr_dict_t.
int fr_dict_attr_autoload(fr_dict_attr_autoload_t const *to_load)
Process a dict_attr_autoload element to load/verify a dictionary attribute.
@ FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC
Protocol specific extensions.
#define fr_dict_autoload(_to_load)
#define DICT_AUTOLOAD_TERMINATOR
char const  * name
name of this protocol
Specifies an attribute which must be present for the module to function.
Specifies a dictionary which must be loaded/loadable for the module to function.
Protocol specific custom flag definitnion.
Protocol-specific callbacks in libfreeradius-PROTOCOL.
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_DICT_ATTR_REF_ALIAS
The attribute is an alias for another attribute.
static int dict_attr_ref_set(fr_dict_attr_t const *da, fr_dict_attr_t const *ref, fr_dict_attr_ref_type_t type)
static uint32_t instance_count
HIDDEN fr_dict_t const  * dict_der
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_FLOAT32
Single precision floating point.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_INT8
8 Bit signed integer.
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_ETHERNET
48 Bit Mac-Address.
@ FR_TYPE_IPV6_PREFIX
IPv6 Prefix.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_MAX
Number of defined data types.
@ 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_COMBO_IP_PREFIX
IPv4 or IPv6 address prefix depending on length.
@ FR_TYPE_VALUE_BOX
A boxed value.
@ 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_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_IPV4_PREFIX
IPv4 Prefix.
@ FR_TYPE_BOOL
A truth value.
@ FR_TYPE_VSA
Vendor-Specific, for RADIUS attribute 26.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
@ FR_TYPE_IFID
Interface ID.
@ FR_TYPE_OCTETS
Raw octets.
@ FR_TYPE_GROUP
A grouping of other attributes.
@ FR_TYPE_FLOAT64
Double precision floating point.
static int dict_flag_is_oid_leaf(fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
static int dict_flag_optional(fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
bool fr_der_tags_compatible(fr_der_tag_t tag1, fr_der_tag_t tag2)
void fr_der_global_free(void)
static const uint64_t der_tags_compatible[FR_DER_TAG_MAX]
static const fr_dict_flag_parser_t der_flags[]
static int dict_flag_der_type(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
static int dict_flag_max(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
static const fr_der_tag_t fr_type_to_der_tag_defaults[FR_TYPE_MAX+1]
static int dict_flag_sequence_of(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
static int dict_flag_default_value(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
int fr_der_global_init(void)
static int dict_flag_class(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
fr_dict_protocol_t libfreeradius_der_dict_protocol
bool fr_type_to_der_tag_valid(fr_type_t type, fr_der_tag_t tag)
static bool type_parse(fr_type_t *type_p, fr_dict_attr_t **da_p, char const *name)
static int dict_flag_set_of(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
fr_dict_attr_autoload_t libfreeradius_der_dict_attr[]
static int dict_flag_is_extensions(fr_dict_attr_t **da_p, UNUSED char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
fr_der_tag_t fr_type_to_der_tag_default(fr_type_t type)
char const * fr_der_tag_to_str(fr_der_tag_t tag)
static int dict_flag_option(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
fr_dict_autoload_t libfreeradius_der_dict[]
static size_t tag_name_to_number_len
static const bool * fr_type_to_der_tags[FR_DER_TAG_MAX]
static fr_table_num_sorted_t const tag_name_to_number[]
static int dict_flag_size(fr_dict_attr_t **da_p, char const *value, UNUSED fr_dict_flag_parser_rule_t const *rules)
static bool attr_valid(fr_dict_attr_t *da)
fr_aka_sim_id_type_t type
#define fr_table_value_by_str(_table, _name, _def)
Convert a string to a value using a sorted or ordered table.
#define fr_table_str_by_value(_table, _number, _def)
Convert an integer to a string.
An element in a lexicographically sorted array of name to num mappings.
char const * fr_strerror(void)
Get the last library error.
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
#define fr_strerror_const(_msg)
#define fr_type_is_variable_size(_x)
#define fr_type_is_structural(_x)
#define fr_type_is_integer_except_bool(_x)
#define fr_type_is_tlv(_x)
#define fr_type_is_leaf(_x)
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
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)
#define fr_value_box_alloc(_ctx, _type, _enumv)
Allocate a value box of a specific type.