IBM
Contents Index Previous Next



Support for External ASN.1 in the TTCN Suite


The ASN.1 Utilities are also used by the TTCN Suite if a TTCN test suite contains data types and constraints that are defined in the tables "ASN.1 Type Definitions By Reference" and "ASN.1 Constraints By Reference". For more information, see ASN.1 External Type/Value References.

Since TTCN is based on the older X.228 standard, while the ASN.1 Utilities are based on the new X.680 standard, users should be careful to use the common subset of X.680 and X.228 if an ASN.1 module is to be used in TTCN. In particular there are a number of differences:

General

Keywords substitution

ASN.1 generators can be configured to be sensitive to a certain number of identifiers. There is a special text file named `asn1util_kwd.txt' that contains a list of identifiers and a list of their substitution during mapping. By default this file is used to configure target languages keywords substitution. It can be edited to get another functionality or another set of keywords to be replaced.

`asn1util_kwd.txt' should contain pairs of identifiers where the first one is the identifier from the original ASN.1 specification that will be replaced by the second identifier during generation. `asn1util_kwd.txt' should conform to the following syntax:

Example 63 Configuration file syntax

<identifier1>   <identifier1 substitution>
<identifier2>   <identifier2 substitution>
	      ...
<identifierN>   <identifierN substitution>

ASN.1 Utility reads the first configuration file it finds. It searches for `asn1util_kwd.txt' file first in the current folder, then in the home folder and finally in the installation. If a configuration file named `asn1util_kwd.txt' is put in the home folder or in the current working folder, it will override the default configuration file from the installation. The configuration file to be used can also be specified in the command line with the `-K' option (see Command-Line Interface), for example,

Example 64 Configuration file specification

asn1util -K my_config.txt -i File.ttcn File.asn

`asn1util_kwd.txt' is always present in the installation and it is configured to replace keywords from the SDL, TTCN, C and C++ languages: the ASN.1 identifier name, that is a keyword in SDL, TTCN or C++, is replaced by name_SDL_KEYWORD, name_TTCN_KEYWORD or name_CPP_KEYWORD to avoid syntax errors in the target languages (see Appendix A: List of recognized keywords). If an original ASN.1 identifier has been modified, a warning message is reported. See ERROR 2077 ASN.1 identifier #1 is a keyword, it will be replaced by #2).

Example 65 Keywords default substitution

For these ASN.1 definitions:


CASE ::= ENUMERATED { upper, lower }

T ::= SEQUENCE {
	 int INTEGER,
	 explicit BOOLEAN,
	 case     CASE,
	 signal   INTEGER
}

value1 T ::= {
	 int 5,
	 explicit TRUE,
	 case lower,
	 signal 27 }

With default keywords substitution file the following TTCN is generated:

CASE_TTCN_KEYWORD ::=
  ENUMERATED {upper(0), lower(1)}

T ::= SEQUENCE {
	 int_CPP_KEYWORD INTEGER, 
	 explicit_CPP_KEYWORD BOOLEAN, 
	 case_CPP_KEYWORD CASE_TTCN_KEYWORD, 
	 signal_SDL_KEYWORD INTEGER
}

value1 T ::= {
  int_CPP_KEYWORD 5,
  explicit_CPP_KEYWORD TRUE,
  case_CPP_KEYWORD lower,
  signal_SDL_KEYWORD 27
}

A configuration file allows user to control the set of keywords to be replaced. Removing lines with SDL keywords, for example, will switch off SDL keywords sensitivity. Providing an empty configuration file will result in switching off keywords substitution completely.

Automatic tagging

If 'AUTOMATIC TAGS' is written in the header of an external ASN.1 module, then implicit tags are inserted into SET, SEQUENCE and CHOICE types. During the TTCN generation they are inserted in the type definitions explicitly.

Example 66

M1
DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
T ::= SEQUENCE
{
   a INTEGER OPTIONAL,
   b INTEGER DEFAULT 5
}

C ::= CHOICE 
  {
    x INTEGER,
    y BOOLEAN,
    z REAL 
  }
END

is translated to TTCN

SEQUENCE
{
  a [0] INTEGER OPTIONAL, 
  b [1] INTEGER DEFAULT 5
}

CHOICE
{
  x [0] INTEGER, 
  y [1] BOOLEAN, 
  z [2] REAL
}

COMPONENTS OF Type notation

COMPONENTS OF Type can appear in SET or SEQUENCE field types. Instead of COMPONENTS OF Type a list of components of the referenced type is included, except extension addition components.

Example 67

 S1 ::= SEQUENCE 
{
  x INTEGER,
  g NULL,
  ... ,
  [[ 
     y BOOLEAN, 
     z BIT STRING 
  ]],
  [[ 
     c IA5String 
  ]],
  d SET OF 
    INTEGER OPTIONAL,
  ... ,
  f REAL
}

S2 ::= SEQUENCE 
 {
   a IA5String,
   COMPONENTS OF S1,
   b OCTET STRING
 }

Type S2 is translated to TTCN

SEQUENCE
{
  a IA5String, 
  x INTEGER, 
  g NULL, 
  f REAL, 
  b OCTET STRING
}

Selection types

A selection type is mapped to the type it denotes.

Example 68

C ::= CHOICE 
 {
   a INTEGER,
   b BOOLEAN
 }

T1 ::= a < C

T1 is translated to TTCN

INTEGER

T2 ::= b < C

T2 is translated to TTCN

BOOLEAN

Enumerated types

Enumerated items can be defined using "identifier" notation or "identifier and number" notation. For "identifier" notations, implicit numbers are assigned to the identifiers according to the rules described in X.680 (1997), 19.

For TTCN, all enumeration items are generated with their corresponding numbers using "identifier and number" notation, and they are arranged according to their number values in ascending order in the generated enumeration.

Extension markers are ignored.

Example 69

A ::= ENUMERATED { a, b, c(0), d, e(2) }

is translated to TTCN

ENUMERATED { c(0), a(1), e(2), b(3), d(4) }

B ::= ENUMERATED { a, b(3), ... , c(1) }

is translated to TTCN

ENUMERATED { a(0), c(1), b(3) }

Extensibility

Extensibility was introduced in X.680 (1997). In ASN.1 extensibility is represented with extension markers and extension addition groups, that can be specified inside SET, SEQUENCE, CHOICE, ENUMERATED types and constraints.

Extension markers are not visible in TTCN translation. All square brackets are ignored and all components from extension addition groups are translated into TTCN as individual fields. All required components from extension additions, individual or from extension addition groups, are mapped to optional ones.

Example 70

S1 ::= SET 
{ 
  x [100] INTEGER,
  ... ,
  [[ 
     gr11 REAL 
  ]],
  t BIT STRING,
  [[ 
     gr21 BOOLEAN OPTIONAL, 
     gr22 SET OF INTEGER 
  ]],
  ... ,
  y INTEGER
}

is translated to TTCN

SET 
 {
   x [100] INTEGER,
   gr11 REAL OPTIONAL,
   t BIT STRING OPTIONAL,
   gr21 BOOLEAN OPTIONAL,
   gr22 SET OF INTEGER OPTIONAL,
   y INTEGER
 }

Note:

TTCN translation removes the borders of additional groups and makes all required components optional. The semantics for assigning values to types with additional groups is: either the whole addition group ( [[ .... ]] ) is absent, or it is all present unless components inside the group are optional. This is not checked in TTCN tools but inconsistency will cause errors in ASN.1 encoding.

Extension markers are ignored in constraints. If 
both root and additional constraints are present, 
they are translated to the union constraint.

Example 71

T1 ::= INTEGER ( 1..10 ^ 2..20, ... , 12 )

is translated to TTCN

INTEGER (( 1..10 ^ 2..20 ) | ( 12 ) )

T2 ::= INTEGER (1 | 3, ... )

is translated to TTCN

INTEGER (1 | 3 )

Information from Object Classes, Objects and Object Sets

Object classes, object and objects sets are not translated to TTCN. Only types and values are translated to TTCN, but it is possible in ASN.1 to use information from object classes, objects and object sets when specifying types and values. This information is translated into TTCN.

ObjectClassFieldType

ObjectClassFieldType is a reference to an object class and a field in that class. The translation to TTCN depends on the kind of field name used.

An open type is defined if the field name references a type field, a variable type value field or variable type value set field. An open type can be any ASN.1 type. Open types are translated to OCTET STRING types in TTCN.

Example 72

OPERATION ::= CLASS {
   &ArgumentType,
   &arg &ArgumentType
}

T1 ::= SEQUENCE { a OPERATION.&ArgumentType }

is translated to TTCN

SEQUENCE { a  OCTET STRING }

T2 ::= OPERATION.&arg

is translated to TTCN

OCTET STRING

If the field name in the class references a fixed type value or fixed type value set fields, then the fixed type is used when translated to TTCN.

Example 73

OPERATION ::= CLASS {
      &ValueSet INTEGER   
   }

T ::= OPERATION.&ValueSet

is translated to TTCN

INTEGER

ObjectClassFieldType with table constraint (object set constraint)

A table constraint applied to ObjectClassFieldType restricts the set of possible types or values to those specified in a column of the table. A table corresponds to an object set. The columns of the table correspond to the object class fields and the rows correspond to the objects in the set.

If the field name in ObjectClassFieldType is a type field and constrained with a table, then it is translated to a CHOICE type with fields of the types specified in the table column. The names of the fields in the choice are the same as the names of the types in the column but the first letter is changed from upper case to lower case.

Note:

If the type in the field is inline then the name in the field will be an implicitly generated inline name, like t_INLINE_4.

If the field name in ObjectClassFieldType is a fixed type value or a fixed type value set, then this is translated to a constrained type where only values that are specified in the table column are permitted.

If the field name in ObjectClassFieldType is a variable type value or variable type value set field, then this is translated to a CHOICE type with types, that are constrained to have values specified in the corresponding cell in the same row of the table.

Example 74

OPERATION ::= CLASS {
       &ArgumentType,
       &operationCode INTEGER UNIQUE,
       &ValueSet INTEGER,
       &ArgSet &ArgumentType
   }


The My-Operations object set:

Object name &ArgumentType &operationCode &ValueSet &ArgSet

operationA

INTEGER

1

{1 | 2 | 5 .. 8}

{ 111..444 }

operationB

SET OF INTEGER

2

{ 2 .. 8 }

{ {1,2,3} |

{ 888 } }

C1 ::= OPERATION.&ArgumentType ( {My-Operations} )

is translated to TTCN

CHOICE {
  integer INTEGER, 
  c1_INLINE_2 SET OF INTEGER
}


C2 ::= OPERATION.&operationCode ( {My-Operations} )

is translated to TTCN

INTEGER ( 1 | 2 )

C3 ::= OPERATION.&ValueSet ( {My-Operations} )

is translated to TTCN

INTEGER ( ( 1 | 2 | 5..8 ) | ( 2..8 ) )

C4 ::= OPERATION.&ArgSet ( {My-Operations} )

is translated to TTCN

CHOICE {
  c4_INLINE_1 INTEGER ( (111..444) ), 
  c4_INLINE_2 SET OF INTEGER ( ( {1,2,3} | {888} ) ) 
}

If an open type is constrained by the table for which all type settings are omitted, then it is translated to TTCN OCTET STRING instead of an empty CHOICE type.

Example 75

MY-CLASS ::= CLASS {
       &id INTEGER,
       &OpenType OPTIONAL
   }


The My-Set object set:

Object name &id &OpenType

object1

1

-

object2

2

-

S ::= SEQUENCE {
        id  MY-CLASS.&id({My-Set}),
        val MY-CLASS.&OpenType({My-Set}{@id})
}

is translated to TTCN

SEQUENCE {
  id    INTEGER ( 1 | 2 ), 
  val   OCTET STRING
}

TypeFromObject

TypeFromObject is a reference to an object and a type field in that object. This is simply translated to the that type in TTCN. If the field is optional in the class and not set in the object, then TypeFromObject cannot be translated.

Example 76

OPERATION ::= CLASS {
       &ArgumentType,
       &ResultType 
   }

operationA OPERATION ::= {
      &ArgumentType INTEGER,
       &ResultType BOOLEAN	 
   }

O1 ::= operationA.&ArgumentType

is translated to TTCN

INTEGER

O2 ::= operationB.&ResultType

is translated to TTCN

BOOLEAN

ValueSetFromObject

ValueSetFromObject is a reference to an object and a field with a set of values in that object. This is translated to a constrained type in TTCN, allowing only values from the value set.

Example 77

OPERATION ::= CLASS {
       &ValueSet INTEGER
   }

operationA OPERATION ::= {
       &ValueSet { 1 | 2 | 5..8 } 
  }

V1 ::= operationA.&ValueSet

is translated to TTCN

INTEGER ( 1 | 2 | 5..8 )

ValueFromObject

ValueFromObject is a reference to an object and a field with a value in that object. This is translated to the same value in TTCN.

Example 78

OPERATION ::= CLASS {
      &operationCode INTEGER UNIQUE
   }

operationA OPERATION ::= { &operationCode 1 }

val2 INTEGER ::= operationA.&operationCode

is translated to TTCN

val2 of type INTEGER equal to 1

CONSTRAINED BY notation

CONSTRAINED BY is treated like a comment and is not translated to TTCN.

Parameterization

Wherever a parameterized type or value is used, it is translated to TTCN after all dummy references are replaced by the actual parameters. A parameterized value is also translated after all dummy references are replaced by the actual parameters.

Parameterized assignments are ignored when translating to TTCN.

Example 79

Container { ElemType, INTEGER : maxelements } ::=
SET SIZE (0..maxelements ) OF ElemType

Intcontainer ::= Container {INTEGER, 25}

is mapped to TTCN

SET SIZE ( 0..25 ) OF INTEGER


http://www.ibm.com/rational
Contents Index Previous Next