IBM
Contents Index Previous Next



Using the ASN.1 Utilities


The ASN.1 Utilities are implemented in the executable asn1util. asn1util can be used in two ways:

  1. Stand-alone from the organizer (command-line interface).
  2. Via the PostMaster

Command-Line Interface

Usage: asn1util [options] { <file> [options] }*

Option Meaning

-h

display a help message

-v

display version

-q

be quiet, suppress some output messages

-c

generate encode/decode type information for the SDL Suite and asn1_cfg.h configuration file

-g

generate coder information for TTCN Suite

-B

set BER as default encoding

-P

set PER as default encoding

-N <name>

set <name> as default encoding

-m

include module name in encode/decode type nodes and macros

-n <name>

use <name> for the name of the interface (*.ifc) files

-S <config>

use <config> for type names configuration in (*.ifc) files

-s <file>

generate SDL output in <file>

-a

append the output to an existing file instead of creating a new file

-b

generate SDL body only, i.e. do not generate package headings (makes it possible to import generated SDL with #INCLUDE)

-r

generate references (#SDTREF) to source file

-e

generate all operators for the SDL enumerated type as listed in Z.105. Default is to emit some of the operators in Z.105

-O

generate values for SDL Make operator with optional and default support

-u <package>

add "use <package>;" to all generated SDL packages

-J <name> <files>

Join all ASN.1 modules from <files> into one SDL package <name> (see Example 32)

-K <file>

Perform substitution for keywords listed in <file> (see Keywords substitution)

-i <file>

generate TTCN output to <file>

-l <file>

take command line from <file>

-post

wait for commands via the PostMaster (see PostMaster Interface)

-T <dir>

put generated code in directory <dir>

-x <prefix>

add <prefix> to the names of generated encode/decode functions.

In the generated ASN.1 coder structures specified prefix is added after the standard yASN1_ prefix, for example:

CHOICE_TYPE_DECL(EXTERN_INFO, yASN1_<prefix>_NetworkAddress);


CHOICE_TYPE_DEF(GLOBAL_INFO, yASN1_<prefix>_NetworkAddress, EXTMARKER_ABSENT, NONE_EXTMARKER, ... );

Example 30

asn1util -r -s myfile.pr -c myfile.asn 
(myfile.asn contains ASN.1 module MyModule)

The command in the example translates the module MyModule in file myfile.asn to an SDL package MyModule in file 'myfile.pr'. The generated package will contain backward references to the source file 'myfile.asn'. Encode/decode type nodes are generated in C-source file 'MyModule_asn1coder.c' and C-header file 'MyModule_asn1coder.h'. A configuration file "asn1_cfg."' with compile switches for coder related files is generated.

Example 31

asn1util AsnModule1.asn AsnModule2.asn

If no options are specified, then asn1util only performs syntactic and global semantic analysis for AsnModule1.asn and AsnModule2.asn, no output is generated.

If no input file is specified, then asn1util does nothing except showing help or version number if correspondent options are specified.

Example 32 Joining modules

asn1util -J Join-Module -s my.pr my1.asn my2.asn 

The ASN.1 modules from the files my1.asn and my2.asn will be joined together in the SDL package Join_Module. Name clashes may occur if the same name is available in different ASN.1 modules the filed are joined. These problems are resolved according to a set of name clash resolving rules, see Joining modules.

Configuration file generation

For the -c option encode and decode type information is generated to C-files. Also asn1util performs the analysis of ASN.1 types and some features used in the specification and generates file asn1_cfg.h.

This file contains compile switches that are referenced from inside the coders code. When asn1_cfg.h is used by the build process the preprocessor automatically throws away useless parts of the code from encoding and decoding related files. This helps to reduce the code size and improve the performance of encoding and decoding procedures.

For example, if the ASN.1 file does not contain OCTET STRING and SET OF types in the module, the following definitions

#ifdef CODER_AUTOMATIC_CONFIG
#define CODER_NOUSE_OCTET_STRING
#define CODER_NOUSE_SET_OF
#endif

will be included in the configuration file.

This feature can be turned on by the CODER_AUTOMATIC_CONFIG compile switch. For more information about available compile switches for the configuration see Encoding configuration.

PostMaster Interface

The ASN.1 Utilities can also be invoked via the PostMaster. An example of this is when an SDL system that uses ASN.1 modules is analyzed. The Analyzer will then order the ASN.1 Utilities, via the PostMaster, to perform a translation of the ASN.1 modules to SDL packages. For a complete description of the PostMaster, see The PostMaster.

On UNIX, the PostMaster communication may also be invoked by starting asn1util with the -post command-line option. asn1util will then wait for commands sent to it from the PostMaster.


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