if (flags->is_extensions) {
if (da->type != FR_TYPE_GROUP) {
- fr_strerror_printf("Extensions must be type 'group'");
+ fr_strerror_printf("Extensions must be type 'group', and not '%s'",
+ fr_type_to_str(da->type));
return false;
}
if (!flags->max) flags->max = UINT64_MAX;
}
+ /*
+ * Packed structures can only be bit strings, they can't be sequences or sets.
+ */
+ if ((da->type == FR_TYPE_STRUCT) && (flags->der_type != FR_DER_TAG_BITSTRING)) {
+ fr_strerror_printf("A 'struct' must be encoded as 'bitstring', and not as '%s'",
+ fr_der_tag_to_str(flags->der_type));
+ return false;
+ }
+
return true;
}
vp = fr_dcursor_current(cursor);
PAIR_VERIFY(vp);
- fr_assert(fr_type_is_group(vp->vp_type) || fr_type_is_struct(vp->vp_type) || fr_type_is_tlv(vp->vp_type));
+ fr_assert(fr_type_is_group(vp->vp_type) || fr_type_is_tlv(vp->vp_type));
/*
* ISO/IEC 8825-1:2021
* The encoding of a set value or sequence value shall not include an encoding for any component
* value which is equal to its default value.
*/
-
- if (fr_type_is_struct(vp->vp_type)) {
- fr_proto_da_stack_build(&da_stack, vp->da);
-
- FR_PROTO_STACK_PRINT(&da_stack, depth);
-
- slen = fr_struct_to_network(&our_dbuff, &da_stack, depth, cursor, encode_ctx, encode_value, encode_pair);
- if (slen < 0) {
- fr_strerror_printf("Failed to encode struct: %s", fr_strerror());
- return -1;
- }
-
- return fr_dbuff_set(dbuff, &our_dbuff);
- }
-
if (fr_type_is_group(vp->vp_type)) {
/*
* Groups could be also be a pair, so we need to check for that.
vp = fr_dcursor_current(cursor);
PAIR_VERIFY(vp);
- fr_assert(fr_type_is_group(vp->vp_type) || fr_type_is_struct(vp->vp_type) || fr_type_is_tlv(vp->vp_type));
+ fr_assert(fr_type_is_group(vp->vp_type) || fr_type_is_tlv(vp->vp_type));
/*
* ISO/IEC 8825-1:2021
* encodings.
*/
- if (fr_type_is_struct(vp->vp_type)) {
- /*
- * Note: Structures should be in the correct order in the dictionary.
- * if they are not, the dictionary loader should complain.
- */
-
- fr_proto_da_stack_build(&da_stack, vp->da);
-
- FR_PROTO_STACK_PRINT(&da_stack, depth);
-
- slen = fr_struct_to_network(&our_dbuff, &da_stack, depth, cursor, encode_ctx, encode_value, encode_pair);
- if (slen < 0) {
- fr_strerror_printf("Failed to encode struct: %s", fr_strerror());
- return -1;
- }
-
- return fr_dbuff_set(dbuff, &our_dbuff);
- }
-
if (fr_type_is_group(vp->vp_type)) {
/*
* Groups could be also be a pair, so we need to check for that.
DEFINE Test-Integer integer
-DEFINE Foo struct der_type=sequence
+DEFINE Foo sequence
BEGIN Foo
-MEMBER Test-Integer integer
+DEFINE Test-Integer integer
END Foo
-DEFINE Bar struct
+DEFINE Bar sequence
BEGIN Bar
-MEMBER Test-Boolean bool
+DEFINE Test-Boolean bool
END Bar
-DEFINE Foo-Bar struct der_type=sequence
+DEFINE Foo-Bar sequence
BEGIN Foo-Bar
-MEMBER Test-Integer integer has_default
+DEFINE Test-Integer integer has_default
VALUE Test-Integer DEFAULT 1
-MEMBER Test-Boolean bool
+DEFINE Test-Boolean bool
END Foo-Bar
-DEFINE Test-Bitstring octets der_type=bitstring
+DEFINE Test-Bitstring bitstring
-DEFINE Seq-Bitstring-Octets struct
+DEFINE Seq-Bitstring-Octets sequence
BEGIN Seq-Bitstring-Octets
-MEMBER Test-Bitstring octets
+DEFINE Test-Bitstring bitstring
END Seq-Bitstring-Octets
DEFINE Bitstring-Struct struct der_type=bitstring
MEMBER foo-bar bit[4]
END Bitstring-Struct-7
-DEFINE Octetstring octets
+DEFINE Octetstring octetstring
-DEFINE Seq-Octetstring struct
+DEFINE Seq-Octetstring sequence
BEGIN Seq-Octetstring
-MEMBER Octetstring octets
+DEFINE Octetstring octetstring
END Seq-Octetstring
DEFINE Test-NULL null
-DEFINE Seq-Null struct
+DEFINE Seq-Null sequence
BEGIN Seq-Null
-MEMBER Test-Null null
+DEFINE Test-Null null
END Seq-Null
-DEFINE Seq-Integer-Null struct
+DEFINE Seq-Integer-Null sequence
BEGIN Seq-Integer-Null
-MEMBER Test-Integer integer
-MEMBER Test-Null null
+DEFINE Test-Integer integer
+DEFINE Test-Null null
END Seq-Integer-Null
DEFINE Test-Oid oid
-DEFINE Seq-Oid struct der_type=sequence
+DEFINE Seq-Oid sequence
BEGIN Seq-Oid
-MEMBER Test-Oid oid
+DEFINE Test-Oid oid
END Seq-Oid
DEFINE Test-Enumerated enumerated
DEFINE Test-String-Universal universalstring
-DEFINE Seq-String struct
+DEFINE Seq-String sequence
BEGIN Seq-String
-MEMBER Test-String string
+DEFINE Test-String string
END Seq-String
DEFINE Test-Date date
DEFINE Test-Generalized-Time generalizedtime
-DEFINE Seq-Date struct
+DEFINE Seq-Date sequence
BEGIN Seq-Date
-MEMBER Test-Date date
+DEFINE Test-Date date
END Seq-Date
-DEFINE Set-Bool-Integer struct
+DEFINE Set-Bool-Integer set
BEGIN Set-Bool-Integer
-MEMBER Test-Bool bool
-MEMBER Test-Integer integer
+DEFINE Test-Bool bool
+DEFINE Test-Integer integer
END Set-Bool-Integer
DEFINE Test-Context-Specific bool option=0
DEFINE Test-Sequence-GROUP group der_type=sequence,ref=Test-TLV
-DEFINE Test-Set-Struct struct der_type=set
+DEFINE Test-Set-Struct set
BEGIN Test-Set-Struct
-MEMBER Test-Boolean bool
-MEMBER Test-Integer integer
+DEFINE Test-Boolean bool
+DEFINE Test-Integer integer
END Test-Set-Struct
-DEFINE Test-Set-Bad-Struct struct der_type=set
+DEFINE Test-Set-Bad-Struct set
BEGIN Test-Set-Bad-Struct
-MEMBER Test-Integer integer
-MEMBER Test-Boolean bool
+DEFINE Test-Integer integer
+DEFINE Test-Boolean bool
END Test-Set-Bad-Struct
DEFINE Test-Set-TLV set