There are two examples to illustrates how you can do it.
The decomp example is a very simple one and is tailored to handle a particular ASN.1 syntax, TAP3. It does not use the OSS IAAPI. See the comments in the decomp.c file to better understand what is done.
The parsedec example is more generic and can handle any raw BER data. It uses the OSS IAAPI. (Note that the IAAPI is meant for a very special purpose, where the application cannot know in advance which ASN.1 specification is being used and must be written in a generic manner. This would apply, by way of example, to a protocol analyzer.) First, the BER-encoder is called to create an encoded PDU. Then the OSS IAAPI is used to parse the raw BER-encoded PDU for both DEFINITE- and INDEFINITE-length cases. After a given tag sequence is found, the decoder is called to decode the component found as a stand-alone encoded PDU. See the comments in decodenested.c for more information.
These examples are available as a Windows VC++ project zip file or as a UNIX project zip file. They can easily be run as is with some minor setting adjustments based on your installation of the OSS ASN.1 Tools.
If you target an operating system other than Windows or UNIX, you can also use either of these zip files and discard the Windows- or UNIX-specific files.
Click on any one of the following files below:
The samples included with some of the Knowledge Center answers are meant for your general understanding of the OSS products. Different versions of the products might produce slightly different outputs. Consult the products documentation and samples for the most up-to-date products information and code examples.
Test drive the OSS Nokalva ASN.1, LTE, and XML Tools now! Your trial includes complete software, documentation, sample programs, free 24x7 technical support and more.
Our expert personnel can help you learn ASN.1!
We offer 4-day ASN.1 courses at our headquarters or your premises.