IBM
Contents Index Previous Next



Structure and Configuration


An application with ASN.1 encoding or decoding support contains the following:

Note: ASCII coder

ASCII encoding and decoding, which is based on SDL Suite internal encoding rules is also available. ASCII encoding and decoding is described in SDL Data Encoding and Decoding, ASCII coder.

Files and File Descriptions

This section describes the static file structure of the coder directories in the installation.

Figure 513 : The coder directory

The coder directory contains five sub-directories which correspond to the functional modules in the coder library:

There are also several files included to the root coder directory:

Encoding rules sub-directory

Sub-directory coder/er contains three sub-directories corresponding to different types of encoding rules supported by the coder library:

BER sub-directory

Sub-directory coder/er/ber contains the following files:

PER sub-directory

Sub-directory coder/er/per contains the following files:

Buffer Management System sub-directory

Sub-directory coder/bms contains the following files:

Error Management System sub-directory

Sub-directory coder/ems contains the following files:

Memory Management System sub-directory

Sub-directory coder/mms contains the following files:

Value Management System sub-directory

Sub-directory coder/vms contains the following files:

Compilation switches

You can change the default properties and configure the BER and PER coders by setting the compilation switches. Some of these switches can be set by choosing options in the Targeting Expert, see The Targeting Expert.

Available compile switches can be separated onto several groups. Below there are descriptions of compile switches that can be used to configure the behavior of coder functions.

Encoding rules configuration

Removing runtime encoding rules availability

By default all the library included ascii, ber and per encoding rules to be present in the compiled object library.

Choosing default encoding rules

This compilation switches influence on which encoding rules will be applied when the coder function is called without specifying which type of encoding rules should be applied

The default setting is CODER_ER_DEFAULT_BER.

The default setting is CODER_BER_INDEFINITE.

The default setting is CODER_PER_UNALIGNED.

The default setting is CODER_BER_PRIMITIVE.

The default setting is CODER_BER_CONSTRUCTED_LENGTH=1000.

The default setting is CODER_BER_CANONICAL_ON.

Real values encoding

For encoding real values are divided into the following number values: (sign * 2^factor * number * base^exponent). It is the user option to choose which factor and which base should be used when encoding.

The default setting is CODER_BER_REAL_FACTOR_0 and CODER_REAL_BASE_2.

Error checking configuration

Note: Error checks in decoding functions

All decoding functions start with a check of type nodes and input values. These tests are not removed by defining the CODER_CHECK_NONE_DECODING macro. Checks in the buffer management are not affected by the macro either. You can remove these checks by using other macros in this list.

By default all checks are switched ON.

Encoding configuration

You can use the following switches to remove code for ASN.1 type from the compilation:
You can use the following switches to redefine C type for ASN.1 type information field:

These compile switches can be set automatically. asn1util generates asn1_cfg.h file for the -c option where the above compile switches are included after #define directives to minimize coder library code size automatically, see also Configuration file generation. To be able to use this asn1_cfg.h automatic configuration you should define the following compile switch:

Buffers configuration

The default is including only small buffers to the library. When all buffers are absent, then only a null buffer will be available (a null buffer is a stub buffer without any functionality).

Example 487 : Encoding in tiny mode

tCoder coder;
tBMSUserMemory UserMemory;

BufInitBuf(&coder, bms_SmallBuffer);
ASN1_ENCODE(&coder,
            (tASN1TypeInfo *)&yASN1_Message,
            encValue);
BufCloseBufToMemory(&coder, &UserMemory);
...
BufInitBufWithMemory(&coder, &UserMemory);
ASN1_DECODE(&coder,
            (tASN1TypeInfo *)&yASN1_Message,
            decValue);
BufCloseBuf(&coder);
CUCF_FREE(UserMemory.MemPtr, UserMemory.MemSize, 0);

Example 488 : tBuffer access type in tiny mode

tBuffer buf = NULL;
BufInitBuf(buf, bms_SmallBuffer);

Note:

The buffer value for this mode must be initialized by NULL before being used in buffer management. The behavior will otherwise be unpredictable.

Following buffer interfaces are not available in this mode:

BufGetMode, BufInNoMode, BufInReadMode, BufInWriteMode
BufCopyBuf
BufInitWriteMode, BufCloseWriteMode
BufInitReadMode, BufCloseReadMode, BufCloseDeleteReadMode
BufGetByte, BufPeekByte, BufPutByte
BufGetSeg, BufSkipSeg, BufPeekSeg, BufPutSeg
BufPutBit, BufGetBit, BufPutBits, BufGetBits

The default setting for the size is CODER_SMALLBUF_SIZE=0x1000.

Memory management configuration

By default standard malloc and free functions from <stdlib.h> are used.

Error output configuration

The default setting is CODER_EO_SDT.

Error handling configuration

User data configuration

Value management configuration

By default CODER_VMS_SDT is chosen.

Printing configuration

By default the coder library is compiled without debug printing functionality.

Generating Environment Files with Coding

You can call the encoding and decoding functions from the environment functions if you do not want to manipulate the encoded bit pattern explicitly in your SDL system.

The SDL Suite tools generate templates for the environment files that contains all necessary calls to buffer management functions, encoding functions and decoding functions. You can, of course, adapt this template to your needs or even write all the calls yourself. See Building an Application or The Cmicro SDL to C Compiler.

The template solution in the environment files has the following properties:

Compiling and Linking

The instructions you must perform in order to compile and link are listed in Tutorial: Using ASN.1 Data Types.


http://www.ibm.com/rational
Contents Index Previous Next