ASN.1
Previous: Recursion
Up: Additional Features
Next: Information Objects and Table Constraints
NOTE: Macros were depreciated in 1994 and were replaced by Information Objects.
Macros in ASN.1 are similar to macros in application software, they provide the capability of defining types and values that are not included in the standard repertoire. This capability is not commonly implemented in ASN.1, however, because all of the macros' grammatical rules must be known by a compiler before it can compile the module containing the macros. Their definition is found in Annex A of ISO 8824, but discussions are underway to replace macros with built-in data types.
Macros can be reduced to ASN.1 types (another reason why macros are not common), even though macros are not themselves types. One significant use of ASN.1 macros is in OSI application protocol standards, specifically for defining remote operations and object classes. In this section, we include two macros, ERROR and OPERATOR, that appear in the common service elements in a later Chapter.
The template for an ASN.1 macro is
<macro name> MACRO ::= BEGIN TYPE NOTATION ::= <user-defined type notation> VALUE NOTATION ::= <user-defined value notation> <supporting syntax> END
where MACRO is the keyword that indicates a definition of the macro named <macro name>; BEGIN and END delimit the body of the macro definition; TYPE NOTATION and VALUE NOTATION, respectively, introduce the production rules for the user-defined types and their values; and <supporting syntax> gives details about the types in the body of the macro.
The following ERROR macro defined in X.219 provides a specific instance of the general template.
ERROR MACRO ::= BEGIN TYPE NOTATION ::= Parameter VALUE NOTATION ::= value (VALUE CHOICE { localValue INTEGER, globalValue OBJECT IDENTIFIER }) Parameter ::= ``PARAMETER'' NamedType | empty NamedType ::= identifier type | type END
In this definition, details of Parameter and NamedType are in the supporting syntax. Parameter consists of the keyword ``PARAMETER'' followed by a named type; it may not have an entry. The value notation is a choice of INTEGER or OBJECT IDENTIFIER. The definition allows users to define operation errors. For example, the ERROR macro is used in the Remote Operations Service Element (ROSE) of a following Chapter to define BadQueueName as follows:
BadQueueName ERROR PARAMETER QueueName ::= 0
BadQueueName has type ERROR, one parameter ``QueueName'' (identified elsewhere as type IA5String), and value 0. In the remote operation, only the value 0 is transmitted, the other terms in the definition are for the user's benefit.
As a second instance of the macro template, we consider the following OPERATION macro definition, used by application protocol designers to define remote operations.
OPERATION MACRO ::= BEGIN TYPE NOTATION ::= Argument Result Errors LinkedOps VALUE NOTATION ::= value (VALUE CHOICE { localValue INTEGER, globalValue OBJECT IDENTIFIER }) Argument ::= ``ARGUMENT'' NamedType | empty Result ::= ``RESULT'' ResultType | empty ResultType ::= NamedType | empty Errors ::= ``ERRORS'' ``(ErrorNames)'' | empty LinkedOpts ::= ``LINKED'' ``(LinkedOpNames)'' | empty ErrorNames ::= ErrorList | empty ErrorList ::= Error | ErrorList``,''Error Error ::= value(ERROR) | type LinkedOptNames ::= OperationalList | empty OperationList ::= Operation | OperationList``,''Operation Operation ::= value(OPERATION) | type NamedType ::= type | identifier type END
In this definition, TYPE NOTATION has four production rules, each of which is refined in the supporting syntax. We note that each of them may or may not be present in a specific instance. As in the definition of the ERROR macro, there is a choice for value notation, either INTEGER or OBJECT IDENTIFIER.
In the following example, the OPERATION macro is used to define getcount as type OPERATION with three parameters and value 0.
getcount OPERATION ARGUMENT QueueName RESULT Count ERRORS {BadQueueName, QueueNotAvailable, Other} ::= 0
Previous: Recursion Up: Additional Features Next: Information Objects and Table Constraints
This site was developed from: Computer Networks and Open Systems An Application Development Perspective by Lillian N. Cassel Richard H. Austing Jones & Bartlett Publisher ISBN 0-7637-1122-5 |
This site is hosted by: Real World ASN.1 and XML Solutions |