The ASN.1 OBJECT IDENTIFIER type is converted into a C or C++ structured type to hold the subidentifier values that make up the object identifier.
ASN.1 production:
<name> ::= OBJECT IDENTIFIER
Generated C code:
typedef ASN1OBJID <name>;
Generated C++ code:
typedef ASN1TObjId ASN1T_<name>;
In this case, different base types are used for C and C++. The difference between the two is the C++ version includes constructors and assignment operators that make setting the value a bit easier.
The ASN1OBJID type (i.e., the type used in the C mapping) is defined in asn1type.h to be the following:
typedef struct { OSUINT32 numids; /* number of subidentifiers */ OSUINT32 subid[ASN_K_MAXSUBIDS];/* subidentifier values */ } ASN1OBJID;
The constant ASN_K_MAXSUBIDS specifies the maximum number of sub-identifiers that can be assigned to a value of the type. This constant is set to 128 as per the ASN.1 standard.
The ASN1TObjId type used in the C++ mapping is defined in ASN1TObjId.h. This class extends the C ASN1OBJID structure and adds many additional constructors and helper methods. See the ASN1C C/C++ Common Run-time Reference Manual for more details.
If an OBJECT IDENTIFIER type is configured to be dynamic either through use of the -dynamic command-line option or through use of the dynamic storage configuration variable, the following type is used in the generated code:
Generated C code:
typedef ASN1DynOBJID <name>;
Generated C++ code:
typedef ASN1TDynObjId ASN1T_<name>;
In this case, different base types are used for C and C++. The difference between the two is the C++ version includes constructors that initialize the value and methods for setting the value.
The ASN1DynOBJID type (i.e., the type used in the C mapping) is defined in the asn1type.h header file as follows:
typedef struct ASN1DynOBJID { OSBOOL memAllocated; OSUINT16 numids; OSUINT32* pSubIds; } ASN1DynOBJID;
The ASN1TDynObjId type is defined in the ASN1TDynObjId.h header file as follows:
struct ASN1TDynObjId : public ASN1DynOBJID { bool mbStdMem; ... } ASN1TDynObjId;
Note that memory management of the array containing the sub-identifiers is the responsibility of the user. The memAllocated flag and mbStdMem flag may be used to control how some memory free operations are done. memAllocated is typically set by the decoder to indicate memory was allocated using a context. If this is set, the generated memory free function will release this memory using the context-based memory free function. In the case of C++, the mbStdMem flag may be set in a constructor or assignment operation when assigning an OID value to the type. In this case, memory is allocated using the standard C++ new operator and released with delete.
OBJECT IDENTIFIER
values are represented using
C strings when the -oid-as-string
option is used.
The strings must be in dotted-number format (e.g. "0.5.1234").
Enclosing objects will own the string's memory.
The advantage of this representation is that arbitrarily large arc identifiers may be used.
A component in a SEQUENCE
that is OPTIONAL
will have a *Present
flag. If the *Present
flag is set, the string must not be null.
A component in a SEQUENCE
that has a DEFAULT
value will not
have an associated *Present
flag. You must provide some non-null
value for the component.
Generated C/C++ code:
typedef char* <name>;