The format of the name of each generated 3GPP layer 3 encode function is as follows:
x3GL3Enc_[<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 encode function names begin with
'NASEnc_' instead of 'x3GL3Enc_'.
The calling sequence for each encode function is as follows:
status = x3GL3Enc_<name> (OSCTXT* pctxt, <name>[*] value);
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
encode 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 value
argument contains the value to be encoded or holds a pointer
to the value to be encoded. This variable is of the type generated from the ASN.1
production. The object is passed by value if it is a primitive ASN.1 data type such as
BOOLEAN, INTEGER, ENUMERATED, etc.. It is passed using a pointer reference if it is a
structured ASN.1 type value. Check the generated function prototype in the header file
to determine how the value argument is to be passed for a given function.
The function result variable stat
returns the status of the encode
operation. Status code 0 (0) indicates the function was successful. Note that this
return value differs from that of BER encode functions in that the encoded length of the
message component is not returned – only an OK status indicating encoding was
successful. A negative value indicates encoding failed. Return status values are defined
in the "asn1type.h" include file. The error text and a stack trace can be displayed
using the rtxErrPrint function.
It is possible to add extra arguments to 3GPP Layer 3 encode functions through the use of the <addarg> configuration setting. This is normally done to pass data from container type member variables into an encode function.