The ASN.1 Utilities perform two main functions in Telelogic Tau:
Note: ASN.1 support in ITEX The ITEX C Code Generator supports only a limited subset of ASN.1. See C Code Generator for further details on the restrictions that apply. |
This chapter is the reference manual for the ASN.1 Utilities.
This chapter describes the ASN.1 Utilities. It is assumed that the reader is familiar with ASN.1.
The main foreseen applications of the ASN.1 Utilities are the following:
The ASN.1 Utilities support the following main functions:
In normal cases, the ASN.1 Utilities are completely hidden for the user by the SDT Analyzer and the ITEX Analyzer.
From the SDT user's point of view, an ASN.1 module is very similar to an SDL package: ASN.1 data types can be defined in a module, and then be used within SDL, using operators that are defined in ITU Recommendation Z.105. When an SDL system containing ASN.1 modules is analyzed, the Analyzer will order the ASN.1 Utilities to translate these modules into corresponding SDL packages.
In ITEX, indirect use of the ASN.1 Utilities is made by the ASN.1-by-reference table. When such a table is analyzed, ITEX orders the ASN.1 Utilities to extract the ASN.1 types and values in a specified ASN.1 module. For more information about this functionality, see ASN.1 External Type/Value References.
The ASN.1 Utilities are implemented in the executable asn1util
. asn1util
can be used in two ways:
Usage: asn1util {options} <file> {options}
Option | Meaning |
---|---|
|
append the output to an existing file instead of creating a new file |
|
generate SDL body only, i.e. do not generate package headings (makes it possible to import generated SDL with #INCLUDE) |
|
display a help message |
|
search for IMPORT-files in specified directories |
|
wait for commands via the PostMaster (see PostMaster Interface) |
|
generate references (#SDTREF) to source file |
|
generate SDL output in |
|
put generated code in directory |
|
display version number |
asn1util -ttarget -r myfile.asn
The above command translates myfile.asn
to an SDL package myfile.pr
, which will be put in directory target
. The generated package will contain backward references to the source file myfile.asn
.
The ASN.1 Utilities can also be invoked via the PostMaster. An example of this is when an SDL system that uses ASN.1 modules is analyzed. The Analyzer will then order the ASN.1 Utilities, via the PostMaster, to perform a translation of the ASN.1 modules to SDL packages. For a complete description of the PostMaster, see The PostMaster.
On UNIX, the PostMaster communication may also be invoked by starting asn1util
with the -post
command-line option. asn1util
will then wait for commands sent to it from the PostMaster.
This section describes the detailed translation rules from ASN.1 to SDL that are implemented in the ASN.1 Utilities. The translation rules all conform to Z.105, except for the cases described in Restrictions to Z.105.
Note: Since named numbers, named bits, and integer values are all mapped to integer synonyms, the same name should not be used more than once, because this will lead to name conflicts in SDL. |
long-name
in ASN.1 is transformed to long_name
in SDL.A.a
is mapped to <<package A>> a
. Also a use clause (use A;
) is generated.DefinitiveIdentifier
(object identifier after module name) is ignored. The tag default is also ignored.EXPORTS
is mapped to a corresponding interface
-clause.IMPORTS
is mapped to a corresponding package reference clause. The AssignedIdentifier
(object identifier after module name) is ignored.
Note: On UNIX, the |
MyModule DEFINITIONS ::= BEGIN EXPORTS A, b, C; IMPORTS X, Y, z FROM SomeModule { iso 3 0 8 } ... END
is mapped to
package MyModule; interface newtype A, synonym b, newtype C; use SomeModule / newtype X, newtype Y, synonym z; ... endpackage;
A type assignment is mapped to a newtype or a syntype, depending on the type on the right-hand side of the `::=
'. Tags are ignored. An ASN.1 value assignment is mapped to a synonym.
T1 ::= INTEGER T2 ::= [APPLICATION 28] T1 a BOOLEAN ::= TRUE
is mapped to
syntype T1 = Integer endsyntype; syntype T2 = T1 endsyntype; synonym a Boolean = True;
BOOLEAN, NULL,
and REAL
are mapped to the corresponding SDL types. Value notations for these types are mapped as follows:
BIT STRING
is mapped to the Z.105-specific type Bit_String
. Named bits are mapped to integer synonyms. Values for bit strings are mapped to hexstr
/bitstr
expressions.
B ::= BIT STRING { bit0(0), bit23(23) } b1 BIT STRING ::= `0110 1110'B b2 BIT STRING ::= `3AFC'H
is mapped to
syntype B = Bit_String endsyntype; synonym bit0 Integer = 0; synonym bit23 Integer = 23; synonym b1 Bit_String = bitstr(`0110 1110'); synonym b2 Bit_String = hexstr(`3AFC');
Note that Bit_String
, as opposed to most other string types in SDL, has indices starting with 0! Type Bit
is a Z.105 specific type with literals 0 and 1, and with boolean operators.
Available operators:
BitStr : Charstring -> Bit_String; /* converts a Charstring consisting of `0' and `1'-s to a Bit_String */ HexStr : Charstring -> Bit_String; /* converts a Charstring consisting of hexadecimal characters to a Bit_String */ "NOT" : Bit_String -> Bit_String; "AND" : Bit_String, Bit_String -> Bit_String; "OR" : Bit_String, Bit_String -> Bit_String; "XOR" : Bit_String, Bit_String -> Bit_String; "=>" : Bit_String, Bit_String -> Bit_String; /* bitwise logical operators */ MkString : Bit -> Bit_String; Length : Bit_String -> Integer; First : Bit_String -> Bit; Last : Bit_String -> Bit; "//" : Bit_String, Bit_String -> Bit_String; Extract : Bit_String, Integer -> Bit; Modify! : Bit_String, Integer, Bit-> Bit_String; SubString : Bit_String, Integer, Integer -> Bit_String; /* normal String operators, except that index starts with 0; see also Sequence of Types */
PrintableString
, NumericString
, VisibleString
, and IA5String
(i.e. all ASN.1 character string types with character sets that are a subset of ASCII) are mapped to syntypes of SDL Charstring
. Values for these strings are mapped to corresponding Charstring
synonyms in SDL.
The same operators as for Charstring
are available for these types, and values of these types can be assigned freely to each other without need for conversion operators.
For example, in SDL an IA5String
value can be assigned to a NumericString
variable (given that the IA5String
only contains numeric characters).
A CHOICE
type is mapped to the choice-construct that is described in more detail in Choice.
C ::= CHOICE { a INTEGER, b BOOLEAN} c C ::= a:7
is mapped to
newtype C choice a integer; b boolean; endnewtype; synonym c C = a:7
The operators that are available for a CHOICE
type are (assuming that C
is defined as in Example 31 above):
aExtract! : C -> Integer; /* e.g. c!a returns 7 */ bExtract! : C -> Boolean; /* but c!b gives dynamic error! */ aMake! : Integer -> C; bMake! : Boolean -> C; /* build choice value, e.g. in SDL it is possible to write b:True */ aModify! : C, Integer -> C; /* e.g. var!a := -5 */ bModify! : C, Boolean -> C; presentExtract! : C -> xxx; /* returns the selected field. xxx is an anonymous type with values a and b. E.g. c!present gives a */
An ENUMERATED
type is mapped to a newtype with a set of literals plus some operators. The list of literals that is generated is reordered in accordance with the associated integer values.
N ::= ENUMERATED { yellow(5), red(0), blue(6) }
is mapped to (only signature of operators shown)
newtype N literals red, yellow, blue /* note that the literals have been reordered! */ operators ordering; Num: N -> Integer; First: N -> N; Last: N -> N; Succ: N -> N; Pred: N -> N; endnewtype,
The operators that are available for an ENUMERATED
type are (assuming that N
is defined as in Example 32 above):
Num : N -> Integer; /* Num(yellow)=5, Num(red)=0, Num(blue)=6 */ "<" : N, N -> Boolean; "<=": N, N -> Boolean; ">" : N, N -> Boolean; ">=": N, N -> Boolean; /* comparison based on Num, i.e. red < yellow */ Pred: N -> N; Succ: N -> N; /* predecessor/successor based on Num, i.e. Succ(red)=yellow, Succ(yellow)=blue, Pred(red) gives a dynamic error */ First: N -> N; Last : N -> N; /* first/last element based on Num, i.e. First(red)=red, Last(red)=blue */
INTEGER
is mapped to the SDL Integer
type, and ASN.1 integer values are mapped to corresponding SDL values.
Named numbers are mapped to synonyms.
A ::= INTEGER { a(5), b(7) }
is mapped to
syntype A = Integer endsyntype; synonym a Integer = 5; synonym b Integer = 7;
OBJECT IDENTIFIER
is mapped to the Z.105-specific type Object_Identifier
. The normal String operators are available for Object_Identifier
, listed also in Sequence of Types. Indices start as usual with 1.
OCTET STRING
is mapped to the Z.105-specific type Octet_String
. Octet_String
is based on type Octet
. This type is further described in SDL Predefined Types. The mapping for the octet string value notation to SDL is identical to bit strings, see Bit String.
Note that Octet_String
, as opposed to most other string types in SDL, has indices starting with 0!
Operators available:
BitStr : Charstring -> Octet_String; HexStr : Charstring -> Octet_String; /* conversion from Charstring to Octet_String, see also Bit String*/ Bit_String : Octet_String -> Bit_String; Octet_String: Bit_String -> Octet_String; /* conversion operators Octet_String <-> Bit_String */ MkString : Octet -> Octet_String; Length : Octet_String -> Integer; First : Octet_String -> Octet; Last : Octet_String -> Octet; "//" : Octet_String, Octet_String -> Octet_String; Extract! : Octet_String, Integer -> Octet; Modify! : Octet_String, Integer, Octet -> Octet_String; SubString : Octet_String, Integer, Integer -> Octet_String; /* normal String operators, see also Sequence of Types */
SEQUENCE
and SET
are both mapped to SDL struct. From an SDL point of view there is no difference between SEQUENCE
and SET
. In order to support optional and default components, SDL has been extended with corresponding concepts.
Note: Optional and default fields in struct are both non-standardized extensions to SDL. |
Values are mapped to the "(. ... .)" construct (= Make!
operator). Values for optional and default components are not supported. Instead, SDL tasks should be used to assign optional and default components.
S ::= SEQUENCE { a INTEGER OPTIONAL, b BOOLEAN, c IA5String DEFAULT "xyx" } s S ::= { b TRUE }
is mapped to
newtype S struct a Integer optional; b Boolean; c IA5String := `xyz'; endnewtype; synonym s S = (. True .);
The operators that are available for a SEQUENCE
or SET
type are (assuming that S
is defined as in Example 34 above):
Make! : Boolean -> S; /* builds a value for S */ aExtract!: S -> Integer; bExtract!: S -> Boolean; cExtract!: S -> IA5String; /* Extract operators. Note that aExtract! gives dynamic error if the field has not been set */ aModify! : S, Integer -> S; bModify! : S, Boolean -> S; cModify! : S, IA5String -> S; /* Modify operators change one component in a Sequence/Set */ aPresent : S -> Boolean; /* gives True if component a has been assigned a value, e.g. aPresent(s) = False */
SEQUENCE OF
is mapped to the String
generator. Values are mapped to corresponding synonyms.
S ::= SEQUENCE OF INTEGER s1 S ::= { 3, 2, 5 } s2 S ::= {}
is mapped to
newtype S String (Integer, Emptystring) endnewtype; synonym s1 S = Mkstring(3)//Mkstring(2)//Mkstring(5); synonym s2 S = Emptystring;
The normal String operators are available for Sequence types. Indices start at 1.
The operators that are available for a SEQUENCE OF
type are (assuming that S
is defined as in Example 35 above):
MkString : Integer -> S; /* make a sequence of one item */ Length : S -> Integer; /* returns number of elements in sequence */ First : S -> Integer; /* returns first element in sequence */ Last : S -> Integer; /* returns last element in sequence "//" : S, S -> S; /* returns concatenation of two sequences */ Extract! : S, Integer -> Integer; /* returns the indexed element */ Modify! : S, Integer, Integer -> S; /* modify the indexed element */ SubString : S, Integer, Integer -> S; /* Substring(S, i, l) returns substring of S of length l, starting at index i */
SET OF
is mapped to the Z.105 specific Bag
generator. For a more complete description of the Bag generator, see Bag.
S ::= SET OF INTEGER s1 S ::= { 2, 2, 5 } s2 S ::= {}
is mapped to
newtype S Bag (Integer) endnewtype; synonym s1 S = Incl(5, Incl(2, Makebag(2))); synonym s2 S = Empty;
The operators that are available for a SET OF
type are (assuming that S
is defined as in Example 36 above):
Incl : Integer, S -> S; /* add an element to the bag */ Del : Integer, S -> S; /* delete one element */ Length : S -> Integer; /* returns number of elements */ Take : S -> Integer; /* return some element from the bag */ Take : S, Integer -> Integer; /* return the indexed element in the bag */ Makebag : Integer -> S; /* build a bag of one element */ "IN" : Integer, S -> Boolean; /* gives true if the element is in the bag */ "<" : S, S -> Boolean; ">" : S, S -> Boolean; "<=" : S, S -> Boolean; ">=" : S, S -> Boolean; /* subset/superset comparison operators */ "AND" : S, S -> S; "OR" : S, S -> S; /* intersection/union operators */
Subtypes are ignored by the ASN.1 Utilities.
Sub1 ::= INTEGER (0..5 | 10 ) Sub2 ::= Sub1 (3..10)
is mapped to
syntype Sub1 = Integer endsyntype; syntype Sub2 = Sub1 endsyntype;
The types GeneralizedTime
and UTCTime
have been defined in terms of ASN.1 as specified in X.680. It follows from their definition in X.680, together with the information about the translation rules given in this chapter, which operators are available in SDL for these types.
The ASN.1 Utilities are also used by ITEX 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". Form 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 the following differences:
ENUMERATED
types, a value must be supplied for all values. For example:E ::= ENUMERATED { a, b }should be replaced by
E ::= ENUMERATED { a(0), b(1) }
ALL
, EXCEPT
, UNION
, and INTERSECTION
.SET
or SEQUENCE
), an identifier must be provided for every component (according to X.680), while in X.228 identifiers can be omitted. For example:S ::= SEQUENCE { INTEGER } -- valid X.228This is invalid according to X.680. The following should be used instead:
S ::= SEQUENCE { field1 INTEGER }
This section contains a list of the error and warning messages in the ASN.1 Utilities. Each message has a short explanation and, where applicable, a reference to the appropriate section of the recommendations X.680 or Z.105.
Some messages include a reference to the object that is the source of the diagnostic. These messages adhere to the format adopted in SDT. See SDT References for a reference to this format and for examples.
ERROR 2000 Unknown option `#1' (UNIX only)
This error message indicates that the ASN.1 Utilities were started with an unknown option. See Command-Line Interface (UNIX only) for an overview of the valid options.
ERROR 2001 Option #1 requires #2 (UNIX only)
This error message indicates that the ASN.1 Utilities were started with an illegal combination of options. See Command-Line Interface (UNIX only) for an overview of the valid options.
This error message indicates that the maximum number of errors was reached when analyzing an ASN.1 module. The analysis has been aborted by the ASN.1 Utilities.
ERROR 2003 Multiple #1 paths (UNIX only)
This error message indicates an incorrect usage of the options of the ASN.1 Utilities. Probably the same option occurred more than once in the command that started the ASN.1 Utilities.
ERROR 2004 No source file specified
This error message indicates that no ASN.1 source file was specified in the command that started the ASN.1 Utilities.
ERROR 2005 Multiple source files
This error message indicates that an attempt was made to analyze more than one ASN.1 module at the same time. The ASN.1 Utilities can only handle one ASN.1 module at a time.
This error message indicates that an error occurred when the ASN.1 Utilities attempted to open a file. Modify, if necessary, the file protection and try to run the ASN.1 Utilities again. If the error persists, contact Telelogic Customer Support. Contact information for Telelogic Customer Support can be found in How to Contact Customer Support.
ERROR 2007 File `#1' already opened, cannot open it for write
This error message indicates that an error occurred when the ASN.1 Utilities attempted to open a file that was already open. Close the file and try to run the ASN.1 Utilities again.
ERROR 2008 Too long source line, max is 500
This error message indicates that there was a line in an ASN.1 module that is longer than the ASN.1 Utilities can handle. Try to split the line.
ERROR 2009 Unexpected end-of-file in #1
This error message indicates that the ASN.1 module is not complete.
ERROR 2010 Assignment (::=) expected
This error message indicates that there is a syntax error in the ASN.1 module.
ERROR 2011 Too long cstring, max is 512
This error message indicates that the character string is longer than the ASN.1 Utilities can handle. This could be caused because a `"' at the end of the string is missing.
ERROR 2012 Too long string, max is 512
This error message indicates that the string is longer than the ASN.1 Utilities can handle. This could be caused because a `"' at the end of the string is missing.
ERROR 2013 Too long number, max is 512
This error message indicates that the number is longer than the ASN.1 Utilities can handle.
ERROR 2014 Too long identifier, max is 512
This error message indicates that the identifier is longer than the ASN.1 Utilities can handle. Try to change the identifier to have a shorter name.
ERROR 2015 Illegal characters in bstring
This message indicates that an ASN.1 binary string item (used in BIT STRING
and OCTET STRING
) contains illegal characters. The only characters allowed are `0', `1' and white space characters.
(X.680: 9.9)
For example: '0110 1111 1 0 0 0 'B
is a valid binary string item.
ERROR 2016 Illegal characters in hstring
This message indicates that an ASN.1 hexadecimal string item (used in BIT STRING
and OCTET STRING
) contains illegal characters. The only characters allowed are `0'-'9', `A'-'F' and white space characters.
(X.680: 9.10)
For example: 'F30C 973D'H
is a valid hexadecimal string item.
ERROR 2017 `H' or `B' expected
ASN.1 BIT STRING
and OCTET STRING
values should be ended with a `B
or an `H
.
(X.680: 9.9 and 9.10).
For example: '0110'B
or '1AFC'H
are valid values for BIT STRING
and OCTET STRING
.
WARNING 2018 Unknown token `#1'
This warning indicates a syntax error in the ASN.1 module. If the token is `@', this could also mean that information object specification construct from X.681 is used in the ASN.1 module. X.681 is not supported by the ASN.1 Utilities.
This message indicates a syntax error in the ASN.1 module with regard to Recommendation X.680. This could be caused by a misspelling. It could also be the case that the ASN.1 module contains constructs of X.228 that are not part of X.680, or that constructs of X.681-X.683 have been used. Only X.680 is supported by the ASN.1 Utilities.
This message indicates that the ASN.1 Utilities ran out of memory. Try to make the ASN.1 module smaller or supply more memory. If that does not help, contact Telelogic Customer Support. Contact information for Telelogic Customer Support can be found in How to Contact Customer Support.
WARNING 2021 No semantic support for `#1'
This warning indicates that an ASN.1 construct is used that is not supported by the ASN.1 Utilities. The construct will be ignored by the ASN.1 Utilities.
ERROR 2022 Identifier expected
This message indicates a syntax error in the ASN.1 module: an identifier is required at the identified place according to X.680.
ERROR 2023 Export-file `#1' corrupt
This message indicates that the export file format of an ASN.1 module was corrupt or unknown. This error should normally not occur. Contact Telelogic Customer Support. Contact information for Telelogic Customer Support can be found in How to Contact Customer Support.
This message indicates that an ASN.1 construct of the older X.228 recommendation is used that has been superseded in the X.680 Recommendation.
For example:
S ::= SEQUENCE { INTEGER }
is old ASN.1. Correct X.680 ASN.1 is:
S ::= SEQUENCE { field1 INTEGER }
This error message indicates that #2 is not a valid ASN.1 value for type #1. If the #1 value is defined at a place that is located after the indicated error position, then this error message could be caused by a restriction in the ASN.1 Utilities. Try, in that case, to move the definition of the #1 value to a place before the indicated error position.
ERROR 2026 Identifier `#1.#2' is already defined
This error message indicates that the ASN.1 module contains more than one definition of type or value #2 in module #1.
ERROR 2027 Trying to take COMPONENTS OF from type `#1' and insert in type `#2'
This error message indicates that ASN.1 type #2 uses COMPONENTS OF
type #1, but type #1 is not compatible with #2. #1 and #2 should both be SEQUENCE
types, or both be SET
types.
ERROR 2028 Recursive expansion of COMPONENTS OF in type #1
This error message indicates that the ASN.1 type uses directly or indirectly COMPONENTS OF
itself. This is not supported by the ASN.1 Utilities.
ERROR 2029 Identifier `#1' not defined
This error message indicates that ASN.1 identifier #1 is not defined.
ERROR 2030 Value `#1' is not possible to represent
This error could be caused by restrictions in the ASN.1 Utilities. Not all possible legal ASN.1 values are supported. It could also be a syntax error in the ASN.1 module.
ERROR 2031 Value `#1' not defined for type #2
This message indicates that ASN.1 type #2 makes use of value #1, but this value has not been defined.
ERROR 2032 Recursive definition for `#1'
This message indicates that the ASN.1 type is recursively defined (for example T1 ::= T2 T2 ::= T1
). This is not supported by the ASN.1 Utilities.
ERROR 2033 Construct not yet implemented: `#1'
This error message indicates that an ASN.1 construct has been used that is not implemented in the ASN.1 Utilities.
ERROR 2034 No value given for component `#1' in type `#2'
This error message indicates that a component is missing in an ASN.1 value for a structured type.
WARNING 2035 Value given for #1 component
This warning indicates that a value has been given to an optional or default component of an ASN.1 SEQUENCE
or SET
type. Values for optional and default components cannot be translated to SDL.
ERROR 2036 Value for `#1' can not be #2
This error message indicates a semantic error in the ASN.1 module.
ERROR 2037 Selection type `#1' must be based on CHOICE, was based on #2
This error message indicates that the ASN.1 selection type construct is used for a component type that is not a CHOICE
type.
(X.680: 27.1)
ERROR 2038 Component type `#1' has no component named `#2'
This error message indicates that a non-existing component of a structured ASN.1 type is used. This could be a misspelling of #2.
ERROR 2039 Type `#1' unknown, cannot parse value for it
This error message indicates that a value is given for a type, but the definition of this type is not known by the ASN.1 Utilities. It could be the case that the type is defined in another module. Value notations for types defined in other modules are not supported by the ASN.1 Utilities.
For example:
myVal MyType ::= 3
will generate the above error message if MyType
is defined in another module.
As a work-around for this error, try to define the value in the same module where the type also is defined.
ERROR 2040 Multiple tags for TaggedType
This error message indicates an error with tagging the ASN.1 type.
This error message indicates that an ASN.1 value is missing at the indicated place.
ERROR 2042 Underscores not allowed in identifiers #1
This error message indicates that underscores (`_') have been used in ASN.1 names. This is not allowed; hyphens (`-') should be used instead. The hyphens will be transformed to underscores in the conversion to SDL or TTCN.
(X.680: 9.2.1, 9.3)
WARNING 2043 Construct `#1' has no mapping in SDL
This warning indicates that an ASN.1 construct is used that can not be mapped to SDL.
Examples of ASN.1 constructs that cannot be mapped to SDL:
S1 SEQUENCE ::= { } -- empty SEQUENCE/SET s SEQUENCE { a INTEGER OPTIONAL } ::= {} -- value for SEQUENCE/SET without components
WARNING 2044 Constraints ignored. This warning suppressed from now on
ASN.1 constraints are parsed, but they are ignored. This warning is only given once per ASN.1 module.
ERROR 2045 Ambiguous reference, symbol `#1' imported more than once
A value is used that is imported more than once. Use an external value reference to specify unambiguously the module of the value that you want to use.
The ASN.1 Utilities handle most constructs of ASN.1 as defined in ITU-T recommendation X.680. The ASN.1 constructs defined in ITU-T Recommendations X.681-683 are not supported. There is no support for features defined in the old ASN.1 version X.208 that have been superseded in X.680.
For a list of restrictions to X.680 and Z.105, see ASN.1 Utilities.