A compiler from ASN.1 to C++ code and run-time library for encoding/decoding data using BER/DER. Run-time library can be used independently from ASN.1 compiler.
The top directory consists of these sub-directories:
- compiler -- A Java ASN.1 to C++ compiler
- runtime -- C++ runtime library for encoding/decoding of the data
The Java ASN.1 to C++ compiler depends on JavaCC ASN.1 grammar, this grammar is a bit modified comparing to original one. It is far from complete (e.g. does not parse Information objects). However, ASN.1 compiler generates C++ code using that grammar.
An experimental Antlr4 ASN.1 grammar with partial support of notations from X.680, X.681, X.682 and X.683 is available as an option of ASN.1 compiler. Right now, compiler does not produce any C++ code if you this grammar is selected.
Several ASN.1 files and generated C++ code is available for protocols:
- SNMPv3 -- https://github.com/tysonite/asn1-compiler/tree/master/runtime/tests/snmpv3-example
- CMPv2 (RFC 4210 / 4211) -- https://github.com/tysonite/asn1-compiler/tree/master/runtime/tests/rfc4210
Compile & Test runtime library
The runtime library uses CMake to build itself. As a result of compilation static and shared libraries will be produced.
- Ensure that you are located in the directory with runtime library sources;
- Create a temporary build directory (e.g. build) with help of 'mkdir' command:
- Change current working to build directory:
- Execute CMake to create Makefile:
- Execute GNU make to build static and shared libraries:
Unit tests can be built during library compilation, if CMake command line contains option
-DBUILD_UNIT_TESTS=1. Unit tests require Boost test framework, on Windows set environment
variable BOOST_ROOT equal to your Boost installation path (e.g. BOOST_ROOT="c:\boost_1_55_0").
Coverage data can be calculated, if CMake command line contains option
is no need to specify
-DBUILD_UNIT_TESTS=1 if you are going to see coverage data, because it
will be enabled automatically. For example, to compile unit tests and collect coverage data
during their running, execute
cmake -DDO_COVERAGE=1 .. instead of command in step 4 above.
To run unit tests execute command:
Running ASN.1 compiler
- Move to
- Move to
targetdirectory if no errors
java -jar asn1-compiler-<...>.jarand follow on-screen instructions
Generate Debian/Ubuntu runtime package
The runtime library uses CPack (feature of CMake) to generate an installable Debian package. If
compilation of runtime library was successful, execute
make package to create package.
If this project helped you, please, consider to make a donation.