Open MemoTrap opened 6 years ago
Looks like function asn1constraint_pullup() calling _remove_extensions(arg, ct_expr, 1); removes extension part of constraint SIZE(1..8,...).
Though simply removing the calling of _remove_extensions(arg, ct_expr, 1); can add APC_EXTENSIBLE flag to asn_PER_type_ReferenceDenms_constr_1, it also break several regression tests when perform make check
.
I don't have enough knowledge to verdict whether these regression tests need to be revised ? Or asn1constraint_pullup() should only call _remove_extensions(arg, ct_expr, 1); under certain condition ?
@velichkov do you have any idea why it would ever make sense to remove extensions if they were specified?
@vlm any comment here?
Thanks!
@mouse07410 , according to X.680, I.4.2.3 & I.4.4, there must be some conditions that extension additions are to be discarded, but related code logic might need be revised.
I.4.2.3
There are two key points in the serial application of constraints:
– If a constrained type is extensible (and perhaps extended), the "extensible" flag and all extension
additions are discarded if a further constraint is subsequently serially applied. The extensibility of a
constrained type (and any extension additions) depends solely on the last constraint that is applied, which
can reference only values in the root of the type that is being further constrained (the parent type). Values
included in the root or the extension additions of the resulting type can only be values that are in the root
of the parent type.
– The serial application of constraints is (for complex cases) not the same as a set arithmetic intersection,
even when there is no extensibility involved. Firstly, the environment in which MIN and MAX are
interpreted, and secondly the abstract values that can be referenced in the second constraint are very
different in serial application from the situation where the two constraints are specified as an intersection
of values from a common parent.
I.4.4
Use of the Contained Subtype notation
A contained subtype may or may not be extensible, but when it is used in set arithmetic it is always
treated as not extensible, and all its extension additions are discarded.
@brchiu the above seems to imply that the same ASN.1 file could produce encoding with member constraints either honored or dropped, depending on what format is used?
DENM v1.3.1 defines ReferenceDenms ::= SEQUENCE (SIZE(1..8, ...)) OF ActionID
. Please note the additional parentheses around SIZE(1..8, ...)
compared to the original definition given by @MemoTrap.
Interestingly, asn1c seems to add APC_EXTENSIBLE
only if these parentheses are present while other tools such as ffasn1c and https://asn1.io/asn1playground/ are less picky.
To be honest, I don't know at the moment which one is right.
I am working with asn1c for half a year meanwhile. It's an excellent tool. Many thanks for it.
I may have found a generator bug now. The (ETSI ITS) DENM ASN.1 spec (attached) has a definition:
It carries the extension marker. ActionID is a sequence of two elements, a complex type. In this combination it appears to be the only one of this kind in the entire DENM ASN.1 spec (and the imported ITS Common spec, included as integrated part in the attachment here).
In the C code produced by the asn1c generator for PER constraints I get
I encoded with asn1c UPER and I tried to decode with http://asn1-playground.oss.com/ without success. ReferenceDenms (RoadworksContainer in AlacarteContainer) and everything hereafter is out of sync and asn1-playground reports an error.
I then manually added the extension flag:
And now it all works, asn1-playground is happy.
ITS DENM v1.2.2.asn.zip