Download Procedure for Calling C Decode Functions
Transcript
Open Type
It is also possible to allocate dynamic memory for the CHOICE union option variable; but one must
be careful to release this memory when done with the structure. If the built in memory-management
functions/macros are used (rtxMem), all memory used for the variables is automatically released
when rtxMemFree is called.
Open Type
Note
The X.680 Open Type replaces the X.208 ANY or ANY DEFINED BY constructs. An
ANY or ANY DEFINED BY encountered within an ASN.1 module will result in the generation of code corresponding to the Open Type described below.
An Open Type as defined in the X.680 standard is specified as a reference to a Type Field in an
Information Object Class. The most common form of this is when the Type field in the built-in
TYPE-IDENTIFIER class is referenced as follows:
TYPE-IDENTIFIER.&Type
See the section in this document on Information Objects for a more detailed explanation.
The Open Type is converted into a C or C++ structure used to model a dynamic OCTET STRING
type. This structure contains a pointer and length field. The pointer is assumed to point at a string of
previously encoded ASN.1 data. When a message containing an open type is decoded, the address
of the open type contents field is stored in the pointer field and the length of the component is
stored in the length field.
The general mapping of an Open Type to C/C++ is as follows:
ASN.1 production:
<name> ::= ANY
Generated C code:
typedef ASN1OpenType <name>;
Generated C++ code:
typedef ASN1TOpenType <name>;
The difference between the two types is the C++ version contains constructors to initialize the
value to zero or to a given open type value.
If the -tables command line option is selected and the ASN.1 type definition references a table
constraint, the code generated is different. In this case, ASN1OpenType above is replaced with
ASN1Object (or ASN1TObject for C++). This is defined in asn1type.h as follows:
typedef struct { /* generic table constraint value holder */
ASN1OpenType encoded;
void*
decoded;
69