Generated C Function Format and Calling Parameters

The format of the name of each generated decode function is as follows:

   x3GL3Dec_[<prefix>]<prodName>

where <prodName> is the name of the ASN.1 production for which the function is being generated and <prefix> is an optional prefix that can be set via a configuration file setting. The configuration setting used to set the prefix is the <typePrefix> element. This element specifies a prefix that will be applied to all generated typedef names and function names for the production.

It is also possible to change the 'x3GL3' prefix at the beginning of the function name by using the <protocol> configuration setting. For example, an API was generated for the Non-Access Stratum (NAS) protocol within the ASN1C package. A protocol setting of NAS was used for this, so all decode function names begin with 'NASDec_' instead of 'x3GL3Dec_'.

The calling sequence for each decode function is as follows:

   status = x3GL3Dec_<name> (OSCTXT* pctxt, <name>* pvalue);

In this definition, <name> denotes the prefixed production name defined above.

The pctxt argument is used to hold a context pointer to keep track of decode parameters. This is a basic "handle" variable that is used to make the function reentrant so it can be used in an asynchronous or threaded application. The user is required to supply a pointer to a variable of this type declared somewhere in his or her program.

The pvalue argument is a pointer to a variable to hold the decoded result. This variable is of the type generated from the ASN.1 production. The decode function will automatically allocate dynamic memory for variable length fields within the structure. This memory is tracked within the context structure and is released when the context structure is freed.

The function result variable stat returns the status of the decode operation. Status code 0 (0) indicates the function was successful. A negative value indicates decoding failed. Return status values are defined in the "asn1ErrCodes.h" and "rtxErrCodes.h" header files. The reason text and a stack trace can be displayed using the rtxErrPrint function described later in this document.

It is possible to add extra arguments to 3GPP Layer 3 decode functions through the use of the <addarg> configuration setting. This is normally done to pass data from container type member variables into a decode function.