Download ASN.1 Compiler Version 5.7 C/C++ Compiler User`s Manual
Transcript
BOOLEAN The ASN.1 BOOLEAN type is converted into a C type named "ASN1BOOL". In the global include file "asn1type.h", ASN1BOOL is defined to be an "unsigned character". ASN.1 production: <name> ::= BOOLEAN Generated C code: typedef ASN1BOOL <name>; Generated C++ code: typedef ASN1BOOL ASN1T_<name>; For example, if “B ::= [PRIVATE 10] BOOLEAN” was defined as an ASN.1 production, the generated C type definition would be “typedef ASN1BOOL B”. Note that the tag information is not represented in the type definition. It is handled within the generated encode/decode functions. The only difference between the C and C++ mapping is the addition of the ‘ASN1T_’ prefix on the C++ type. INTEGER The ASN.1 INTEGER type is converted into one of several different C types depending on constraints specified on the type. By default, an INTEGER with no constraints results in the generation of an “ASN1INT” type. In the global include file "asn1type.h", ASN1INT is defined to be an "int” which is normally a signed 32-bit integer value on most computer systems. ASN.1 production: <name> ::= INTEGER Generated C code: typedef ASN1INT <name>; Generated C++ code: typedef ASN1INT ASN1T_<name>; Value range constraints can be used to alter the C type used to represent a given integer value. For example, the following declaration from the SNMP SMI specification would cause an ASN1UINT type (mapped to a C unsigned int) to be used: Counter ::= [APPLICATION 1] IMPLICIT INTEGER (0..4294967295) In this case, an ASN1INT could not be used because all values within the given range could not be represented. Other value ranges would cause different integer types to be used that provide the most efficient amount of storage. The following table shows the types that would be used for the different range values: Min Lower Bound -128 Max Upper Bound 127 ASN1C Type ASN1CHAR 0 255 ASN1OCTET -32768 32767 ASN1SINT 0 65535 ASN1USINT ASN1C V5.7 C Type char (signed 8-bit int) unsigned char (unsigned 8-bit number) short (signed 16-bit int) unsigned short (unsigned 16-bit int) 35