Value Specifications
The compiler can parse any type of ASN.1 value specification, but will only generate code for certain types. In this release of the compiler, the following types of value specifications will result in generated code:
All value types except INTEGER cause an "extern" statement to be generated in the header file and a global value assignment to be added to the C or C++ source file. INTEGER value specifications cause #define statements to be generated.
The INTEGER type causes a #define statement to be generated in the header file of the form `ASN1V_<valueName>' where <valueName> would be replaced with the name in the ASN.1 source file. The reason for doing this is the common use of INTEGER values for size and value range constraints in the ASN.1 specifications. By generating #define statements, the symbolic names can be included in the source code making it easier to adjust the boundary values on the fly.
ivalue INTEGER ::= 5#define ASN1V_ivalue 5The reason the ASN1V_ prefix is added is to prevent collisions with INTEGER value declarations and other declarations such as enumeration items with the same name.
A BOOLEAN value causes an "extern" statement to be generated in the header file and a global declaration of type ASN1BOOL to be generated in the C or C++ source file. The mapping of ASN.1 declaration to global C or C++ value declaration is as follows:
ASN.1 production: <name> BOOLEAN ::= <value> Generated code: ASN1BOOL <name> = <value>;These value specifications cause two global C variables to be generated: a `numocts' variable describing the length of the string and a `data' variable describing the string contents. The mapping for a binary string is as follows (note: BIT STRING can also be used as the type in this type of declaration):
ASN.1 production: <name> OCTET STRING ::= `<bstring>'B Generated code: ASN1UINT <name>_numocts = <length>; ASN1OCTET <name>_data[] = <data>;ASN.1 production: <name> <string-type> ::= <value> Generated code: ASN1ConstCharPtr <name> = <value>;In this definition, <string-type> could be any of the standard 8-bit characters string types such as IA5String, PrintableString, etc. (note: this version of the compiler does not contain support for value declarations of larger character string type such as BMPString). The ASN1ConstCharPtr type used in the generated code is a type defined in asn1type.h designed to be a char* type for C or const char* type for C++.
Object identifier values are somewhat different in that they result in a structure being populated in the C or C++ source file.
ASN.1 production: <name> OBJECT IDENTIFIER ::= <value> Generated code: ASN1OBJID <name> = <value>;oid OBJECT IDENTIFIER ::= { ccitt b(5) 10 }ASN1OBJID oid = { 3, { 0, 5, 10 } } ;To populate a variable in a generated structure with this value, the rtSetOID utility function can be used (see the section in the run-time API guide for a full description of this function). In addition, the C++ base type for this construct (ASN1TObjId) contains constructors and assignment operators that allow direct assignment of values in this from to the target variable.
Objective Systems, Inc.102 Pickering Way, Suite #506Exton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |