Is there a way to use multiple ASN.1 protocols in the same program and to add a new protocol on the fly without rebuilding the program?

Multiprot is a sample that demonstrates how to handle three separate protocols in a single program.

In order to build and run the sample, you will need the OSS ASN.1/C Tools on Linux or Windows. You can download a trial version of the Tools from this link:
https://www.oss.com/asn1/products/asn1-download.html.

After you successfully install the OSS ASN.1/C Tools, unzip the multiprot.zip file in the samples/advanced directory of the OSS ASN.1/C Tools installation. You will notice a new multiprot subdirectory that contains the sample program. Note that on a Linux/UNIX platform you can unzip the file in a different location. If you choose to do so, edit the makefile and change OSSASN1 to point to the location where you installed the OSS ASN.1/C Tools.

The sample can be built and run by issuing the make command at the shell prompt. The makefile builds three shared libraries: librrc.so, libs1ap.so, and libtap3.so. These libraries are like plug-ins that the application can load on-the-fly. The multiprot.c file contains the main program that loads these shared libraries one at a time to decode the message of the protocol the shared library was built for.

The sample can be run in two modes. When DEC_AND_ENC is defined, the program decodes the binary message and encodes the decoded value to XML or JSON. When it is not defined, only decoding is performed. The performance achieved in the latter scenario is equivalent to what you would get when decoding to compiler-generated structures.

ENC_BUF_SIZE, DEC_BUF_SIZE, and TMP_BUF_SIZE are three other defines that you can use to pre-allocate an encoder output buffer, a decoder output buffer, or a temporary memory buffer to be used by the runtime. If they are undefined, the OSS runtime will dynamically allocate memory during the encoding/decoding process. You can achieve better encoding/decoding performance with the pre-allocated buffer mode.


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.



Contact Support
contact Our office hours
24 hours/day, 7 days/week

  • Phone: 1-888-OSS-2761 (USA and Canada)
  • Phone: 1-732-302-9669 (International)
  • Fax: 1-732-302-0023
  • Email: support@oss.com
Free Trial
download

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.




Learn ASN.1
Learn ASN.1

Our expert personnel can help you learn ASN.1!

We offer 4-day ASN.1 courses at our headquarters or your premises.