}
/*
- * Since there is no number, the attribute MUST be
- * internal, and cannot be encoded as a number.
+ * Since there is no number, the attribute cannot be
+ * encoded as a number.
*/
memcpy(&flags, base_flags, sizeof(flags));
flags.name_only = true;
* Certain structural types MUST have numbers.
*/
switch (type) {
- case FR_TYPE_STRUCT:
case FR_TYPE_VSA:
case FR_TYPE_VENDOR:
fr_strerror_printf("DEFINE cannot be used for type '%s'", argv[1]);
if (dict_process_ref(ctx, parent, da, ref) < 0) return -1;
- memcpy(&ctx->value_attr, &da, sizeof(da));
+ /*
+ * Adding an attribute of type 'struct' is an implicit
+ * BEGIN-STRUCT.
+ */
+ if (type == FR_TYPE_STRUCT) {
+ if (dict_gctx_push(ctx, da) < 0) return -1;
+ ctx->value_attr = NULL;
+ } else {
+ memcpy(&ctx->value_attr, &da, sizeof(da));
+ }
return 0;
}
* The parent has children by name only, not by number. Don't even bother trying to track
* numbers.
*/
- if (parent->flags.name_only) return 0;
+ if (parent->flags.name_only && (parent->type != FR_TYPE_STRUCT)) return 0;
/*
* We only allocate the pointer array *if* the parent has children.