Asn1Compiler

Asn1Compiler translates the data description of a protocol, written using the ASN.1 language, to Java or C# language.

The developer integrates the generated code and the ASN.1 runtime into his application. The runtime is in charge of encoding and decoding the basic types in compliance with the BER/DER, PER (aligned/non aligned), XER, E-XER rules.

Asn1Compiler is a full Java application and thus can be installed on any machine with a Java Virtual Machine.

Free trialRequest for quotesCustomer cases

Compliance

Asn1Compiler is compliant with ASN.1 1997/2002/2008 standards :

  • Specification of basic notation (ITU-T X.680 / ISO/IEC 8824-1)
  • Information object specification (ITU-T X.681 / ISO/IEC 8824-2)
  • Constraint specification (ITU-T X.682 / ISO/IEC 8824-3)
  • Parameterization of ASN.1 specifications (ITU-T X.683 / ISO/IEC 8824-4)

Asn1Compiler handles the Time types specified by Amendement 3 of X680 enabling a complete support of the time types defined by ISO 8601-2004.

Asn1Compiler supports the Extended-XER encoding rules. These rules enable encoding of "full XML" including all the specificities of XML (attributes, namespaces...).

Highlights

Automatic handling of information objects classes and sets as well as relation constraints to enable automatic decoding of open types with no extra code in the application.

Automatic handling of content constraints applied on BIT STRING and OCTET STRING as well as subtype constraints on open types so that content is automatically decoded with no extra code in the application.

Huge PDU handling (TAP3 PDU may reach 200MB) with post-decoding/pre-encoding on SET OF/SEQUENCE OF types to reduce storage usage.

Generated code

Creation of one Java package or C#  namespace for each ASN.1 module.

Documented classes generation (javadoc and  XML .NET documentation formats).

Automatic generation of example files enabling to encode and decode any type chosen in the ASN.1 schema.

The ASN.1 runtime

The runtime is a Java or C# library that includes the methods for encoding and decoding the basic types.

It is provided with Asn1Compiler.

The encoding rules supported by the runtime are:

  • Specification of Basic Encoding Rules (BER/DER, ITU-T X.690 / ISO/IEC 8825-1)
  • Specification of Packed Encoding Rules (PER aligned and unaligned, ITU-T X.691 / ISO/IEC 8825-2)
  • XML Encoding Rules (Basic XER/Canonical XER/Extended XER, ITU-T X.693 + Amendement-1 / ISO/IEC 8825-4)

The runtime offers many features including:

  • the possibility to easily change the encoding rules simply changing the encoder/decoder
  • an error diagnostic
  • the support of clone/equals/hashcode/toString methods
  • serialisation

Example

Here is an example of generation from the ASN.1 schema in sample.asn1:

SampleModule
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
MainStruct ::= SEQUENCE {
name IA5String,
age INTEGER
}
END

The generation configuration is defined in sample.arg file:

  • the generated API name is "Sample"
  • the encoding rules are ExtendedXER and AlignedBasicPER
  • the API is generated for Java (or cSharp)
  • by default, the code is generated in Sample/src/java (or Sample/src/cSharp)
# specify the asn1 files
asn1ToXml.inputFile.1=sample.asn1
# specify the Asn1API name
asn1API.name=Sample
# lists the encoding rules to be used
asn1API.encodingRules=ExtendedXER, AlignedBasicPER
# specify the language (Java or C#)
javaGenerator=true
#cSharpGenerator=true

The command to start the compilation and generation is:

Asn1Compiler sample.arg 

The result is:

- compilation in progress...
- # input file : sample.asn1
- 1 ASN.1 module compiled : 0 errors, 0 warnings.

- Java source code generation...
- ASN.1 module : SampleModule
- writing generation...
- source code generation complete (7 files created).

The example showing how to use the generated API is provided here.