Download Procedure for Calling C Decode Functions
Transcript
SEQUENCE
DEFAULT keyword
The DEFAULT keyword allows a default value to be specified for elements within the SEQUENCE. ASN1C will parse this specification and treat it as it does an optional element. Note
that the value specification is only parsed in simple cases for primitive values. It is up to the programmer to provide the value in complex cases. For BER encoding, a value must be specified be
it the default or other value.
For DER or PER, it is a requirement that no value be present in the encoding for the default value.
For integer and boolean default values, the compiler automatically generates code to handle this
requirement based on the value in the structure. For other values, an optional present flag bit is
generated. The programmer must set this bit to false on the encode side to specify default value
selected. If this is done, a value is not encoded into the message. On the decode side, the developer
must test for present bit not set. If this is the case, the default value specified in the ASN.1 specification must be used and the value in the structure ignored.
Extension Elements
If the SEQUENCE type contains an open extension field (i.e., a ... at the end of the specification or
a ..., ... in the middle), a special element will be inserted to capture encoded extension elements for
inclusion in the final encoded message. This element will be of type OSRTDList and have the name
extElem1. This is a linked list of open type fields. Each entry in the list is of type ASN1OpenType.
The fields will contain complete encodings of any extension elements that may have been present
in a message when it is decoded. On subsequent encode of the type, the extension fields will be
copied into the new message.
The -noOpenExt command line option can be used to alter this default behavior. If this option is
specified, the extElem1 element is not included in the generated code and extension data that may
be present in a decoded message is simply dropped.
If the SEQUENCE type contains an extension marker and extension elements, then the actual
extension elements will be present in addition to the extElem1 element. These elements will be
treated as optional elements whether they were declared that way or not. The reason is because a
version 1 message could be received that does not contain the elements.
Additional bits will be generated in the bit mask if version brackets are present. These are groupings
of extended elements that typically correspond to a particular version of a protocol. An example
would be as follows:
TestSequence ::= SEQUENCE {
item-code
INTEGER (0..254),
item-name
IA5String (SIZE (3..10)) OPTIONAL,
... ! 1,
urgency
ENUMERATED { normal, high } DEFAULT normal,
[[ alternate-item-code
INTEGER (0..254),
alternate-item-name
IA5String (SIZE (3..10)) OPTIONAL
]]
59