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, the default value is handled the same as an optional element (i.e., a null object reference indicates that nothing should be transmitted). The programmer must set the element object reference to null 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 a null object reference. If this is the case, the default value specified in the ASN.1 specification is used.