TOC PREV NEXT INDEX


SEQUENCE OF



The ASN.1 SEQUENCE OF type is converted into one of the following C/C++ types:

The linked list option is the default for constructed types. An array is used for a sequence of primitive types. The allocation for the contents field of the array depends on how the SEQUENCE OF is specified in the ASN.1 definition. If a size constraint is used, a static array of that size is generated; otherwise, a pointer variable is generated to hold a dynamically allocated array of values. The decoder will automatically allocate memory to hold parsed SEQUENCE OF data values.

The type used for a given SEQUENCE OF construct can be modified by the use of a configuration item. The <storage> qualifier with the `dynamic' keyword can be used at the global, module, or production level to specify that dynamic memory (i.e., a pointer) is used for the array. The syntax of this qualifier is as follows:

	<storage>dynamic</storage>
 

The `list' keyword can also be used in a similar fashion to specify the use of a linked-linked structure to hold the elements:

	<storage>list</storage>
 

See the section entitled Compiler Configuration File for further details on setting up a configuration file.

Dynamic SEQUENCE OF Type

    ASN.1 production:     <name> ::= SEQUENCE OF <type>
 

    Generated C code:      typedef struct {
 
 			       int        n;
 
 			       <type>*    elem;
 
			     } <name>;
 

    Generated C++ code:	    typedef struct {
 
 			       int        n;
 
			       <type>*    elem;
 
			     } ASN1T_<name>;
 

Note that parsed values can be accessed from the dynamic data variable just as they would be from a static array variable; i.e., an array subscript can be used (ex: elem[0], elem[1]...).

Static (sized) SEQUENCE OF Type

    ASN.1 production:    <name> ::= SEQUENCE SIZE <len> OF <type>
 

    Generated C code:     typedef struct {
 
			      int        n;
 
			      <type>     elem[<len>];
 
		          } <name>;
 

    Generated C++ code:   typedef struct {
 
			      int        n;
 
			      <type>     elem[<len>];
 
		          } ASN1T_<name>;
 

List-based SEQUENCE OF Type

A doubly-linked list header type (Asn1RTDList) is used for the typedef if the list storage configuration setting is used (see above). This can be used for either a sized or unsized SEQUENCE OF construct. The generated C or C++ code is as follows:

          Generated C code:   typedef Asn1RTDList <name>;
 

          Generated C++ code: typedef ASN1TSeqOfList ASN1T_<name>;
 

The type definition of the Asn1RTDList structure can be found in the asn1type.h header file. The common run-time utility functions beginning with the prefix rtDList are available for initializing and adding elements to the list. See the Common Run-time Functions section for a full description of these functions.

In addition to the Asn1RTDList C structure and C functions, a C++ class is provided for linked list support. This is the ASN1CSeqOfList class. This class provides methods for adding and deleting elements to and from lists and an iterator interface for traversing lists. See the ASN1CSeqOfList section in the C++ Run-Time Classes area for details on all of the methods available in this class.


Generation of Temporary Types for SEQUENCE OF Elements

As with other constructed types, the <type> variable can reference any ASN.1 type, including other ASN.1 constructed types. Therefore, it is possible to have a SEQUENCE OF SEQUENCE, SEQUENCE OF CHOICE, etc.

When a constructed type or type that maps to a C structured type is referenced, a temporary type is generated for use in the final production. The format of this temporary type name is as follows:

	<prodName>_element
 

In this definition, <prodName> refers to the name of the production containing the SEQUENCE OF type.

For example, a simple (and very common) single level nested SEQUENCE OF construct might be as follows:

A ::= SEQUENCE OF SEQUENCE { INTEGER a, BOOLEAN b }

In this case, a temporary type is generated for the element of the SEQUENCE OF construct. This results in the following two equivalent ASN.1 types:

	A-element ::= SEQUENCE { INTEGER a, BOOLEAN b }
 

	A ::= SEQUENCE OF A-element
 

These types are then converted into the equivalent C or C++ typedefs using the standard mapping that was previously described.


Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX