* @note New extension structures should also be added to the appropriate table in dict_ext.c
*/
typedef enum {
- FR_DICT_ENUM_EXT_UNION_REF = 0, //!< Reference to a union/subs-struct.
+ FR_DICT_ENUM_EXT_KEY_CHILD_REF = 0, //!< Reference to a child associated with this key
FR_DICT_ENUM_EXT_MAX
} fr_dict_enum_ext_t;
uint8_t ext[FR_DICT_ENUM_EXT_MAX]; //!< Extensions to the dictionary attribute.
- fr_dict_attr_t const *child_struct[]; //!< for key fields
+ fr_dict_attr_t const *key_child_ref[]; //!< for key fields
} fr_dict_enum_value_t CC_HINT(aligned(FR_EXT_ALIGNMENT));
/** Private enterprise
for (enumv = fr_hash_table_iter_init(src_ext->value_by_name, &iter);
enumv;
enumv = fr_hash_table_iter_next(src_ext->value_by_name, &iter)) {
- fr_dict_attr_t *child_struct;
+ fr_dict_attr_t *key_child_ref;
if (!has_child) {
- child_struct = NULL;
+ key_child_ref = NULL;
} else {
- fr_dict_t *dict = dict_by_da(enumv->child_struct[0]);
+ fr_dict_t *dict = dict_by_da(enumv->key_child_ref[0]);
/*
- * Copy the child_struct, and all if it's children recursively.
+ * Copy the key_child_ref, and all if it's children recursively.
*/
- child_struct = dict_attr_acopy(dict->pool, enumv->child_struct[0], NULL);
- if (!child_struct) return -1;
+ key_child_ref = dict_attr_acopy(dict->pool, enumv->key_child_ref[0], NULL);
+ if (!key_child_ref) return -1;
- child_struct->parent = da_dst; /* we need to re-parent this attribute */
+ key_child_ref->parent = da_dst; /* we need to re-parent this attribute */
- if (dict_attr_children(enumv->child_struct[0])) {
- if (dict_attr_acopy_children(dict, child_struct, enumv->child_struct[0]) < 0) return -1;
+ if (dict_attr_children(enumv->key_child_ref[0])) {
+ if (dict_attr_acopy_children(dict, key_child_ref, enumv->key_child_ref[0]) < 0) return -1;
}
}
if (dict_attr_enum_add_name(da_dst, enumv->name, enumv->value,
- true, true, child_struct) < 0) return -1;
+ true, true, key_child_ref) < 0) return -1;
}
return 0;
};
static fr_table_num_ordered_t const dict_enum_ext_table[] = {
- { L("union_ref"), FR_DICT_ENUM_EXT_UNION_REF }
+ { L("key_child_ref"), FR_DICT_ENUM_EXT_KEY_CHILD_REF }
};
static size_t dict_enum_ext_table_len = NUM_ELEMENTS(dict_enum_ext_table);
.name_table_len = &dict_enum_ext_table_len,
.max = FR_DICT_ENUM_EXT_MAX,
.info = (fr_ext_info_t[]){ /* -Wgnu-flexible-array-initializer */
- [FR_DICT_ENUM_EXT_UNION_REF] = {
- .min = sizeof(fr_dict_enum_ext_union_ref_t),
+ [FR_DICT_ENUM_EXT_KEY_CHILD_REF] = {
+ .min = sizeof(fr_dict_enum_ext_key_child_ref_t),
.can_copy = true
},
[FR_DICT_ENUM_EXT_MAX] = {}
*
*/
typedef struct {
- fr_dict_attr_t const *union_ref; //!< The union da this value points into.
-} fr_dict_enum_ext_union_ref_t;
+ fr_dict_attr_t const *ref; //!< the child structure referenced by this value of key
+} fr_dict_enum_ext_key_child_ref_t;
/** @name Add extension structures to attributes
*
int dict_attr_enum_add_name(fr_dict_attr_t *da, char const *name,
fr_value_box_t const *value,
bool coerce, bool takes_precedence,
- fr_dict_attr_t const *child_struct)
+ fr_dict_attr_t const *key_child_ref)
{
size_t len;
fr_dict_enum_value_t *enumv = NULL;
/*
* If the parent isn't a key field, then we CANNOT add a child struct.
*/
- if (!fr_dict_attr_is_key_field(da) && child_struct) {
- fr_strerror_const("Child structures cannot be defined for VALUEs which are not for 'key' attributes");
+ if (!fr_dict_attr_is_key_field(da) && key_child_ref) {
+ fr_strerror_const("Child attributes cannot be defined for VALUEs which are not 'key' attributes");
return -1;
}
+#if 0
+ /*
+ * Commented out becuase of share/dictionary/dhcpv6/dictionary.rfc6607.
+ *
+ * That dictionary defines a value which is associated with a zero-sized child.
+ * In order to enforce this check, we need to support zero-sized structures.
+ *
+ * Perhaps this can be done as a special case after we convert to UNIONs? Because then
+ * we can allow ATTRIBUTE Global-VPN 255 struct[0].
+ */
+ if (fr_dict_attr_is_key_field(da) && !key_child_ref) {
+ fr_strerror_const("Child attribute must be defined for VALUEs associated with a 'key' attribute");
+ return -1;
+ }
+#endif
+
if (fr_type_is_structural(da->type) || (da->type == FR_TYPE_STRING)) {
fr_strerror_printf("Enumeration names cannot be added for data type '%s'", fr_type_to_str(da->type));
return -1;
* Allocate a structure to map between
* the name and value.
*/
- enumv = talloc_zero_size(da, sizeof(fr_dict_enum_value_t) + sizeof(enumv->child_struct[0]) * fr_dict_attr_is_key_field(da));
+ enumv = talloc_zero_size(da, sizeof(fr_dict_enum_value_t) + sizeof(enumv->key_child_ref[0]) * fr_dict_attr_is_key_field(da));
if (!enumv) {
oom:
fr_strerror_printf("%s: Out of memory", __FUNCTION__);
enumv->name = talloc_typed_strdup(enumv, name);
enumv->name_len = len;
- if (child_struct) enumv->child_struct[0] = child_struct;
+ if (key_child_ref) enumv->key_child_ref[0] = key_child_ref;
enum_value = fr_value_box_alloc(enumv, da->type, NULL);
if (!enum_value) goto oom;
}
enumv = fr_dict_enum_by_value(key_vp->da, &key_vp->data);
- if (enumv) child = enumv->child_struct[0];
+ if (enumv) child = enumv->key_child_ref[0];
if (!child) {
unknown_child: