|
ASN1C is a source code generation tool. It translates
ASN.1 or XML schema definition (XSD) files into equivalent source code in a
computer language such as C, C++, C#, or Java.
The code produced by the compiler consists of type
definitions and encode/decode functions (or methods). This provides a complete
Application Programming Interface (API) for working with all of the message
definitions contained within an ASN.1 specification.
In addition to the compiler, a run-time library of common
encode/decode functions is also part of the package. This library contains
routines to encode and decode ASN.1 primitives (BOOLEAN, INTEGER, etc.). The
ASN1C compiler assembles a series of calls to these functions to accomplish the
encoding or decoding of more complex message types.
All that a programmer needs to do to get an
encoder/decoder up and running is to:
- Run ASN1C to generate code for a given ASN.1 or XSD
specification,
- Develop an application to call functions/methods within
the generated code,
- Compile/link the application, generated code, and
run-time libraries.
To assist with items 2 and 3, the compiler also has the
capability to generate sample reader and writer programs as well as a makefile
to build all of the generated code.
ASN.1 to C or C++
ASN1C is capable of generating C and/or C++ source code.
Both the C and C++ version use a common base run-time library consisting of a
set of low-level primitive C functions for encoding and decoding the base
types. The code generation is done predominantly in C and provides a complete
set of C API functions for all defined ASN.1 types.
The C++ code generation capability adds a set of class
"wrappers" that hide most of the details in invoking the encode/decode
functions. These wrappers provide additional services specific to C++. These
include automatic initialization of variables of generated types through
constructors, easier assignment and testing of data through operator
overloading, and virtual callback interfaces through the event handling
mechanism.
Please click on one of the following links for additional
information:
ASN.1 to Java or C#
The ASN1C compiler is also capable of generating Java or
C# code. The generated Java code consists of a series of Java source files -
one for each production (type) defined within an ASN.1 specification. Each of
these Java files contains (at a minimum) the following items:
- A public member data variable (or variables) to hold
data of the generated type.
- A constructor (or constructors) to initialize the
variable.
- An encode method.
- A decode method.
- A print method to print the contents of the object to a
given output stream.
There is also a run-time library for Java. This consists
of a series of classes for encoding and decoding the primitive ASN.1 types. For
example, the Asn1Integer class will encode or decode a variable of the ASN.1
INTEGER type. The compiler will extend these base classes to form higher level
types derived directly from the base types, or assemble a series of these lower
level objects to form constructed types (SEQUENCE, for example).
Generation of C# code is now available in version 5.7.
This code generation is very similar to the Java generation described above. A
separate C# class is generated for each production defined in an ASN.1
specification. This contains constructors and methods for encoding and decoding
an instance of the class using any of the ASN.1 encoding rules.
Java or C# embedded development kits are available which
support the Java MicroEdition (J2ME) or C# compact edition libraries. For
further information on the Java or C# version of the ASN1C compiler, please
click on one of the following links:
Java and all Java-related products are
registered Trademarks of Sun Microsystems |