![]() |
![]() |
![]() |
![]() |
![]() |
Creating the Abstract Syntax
When creating the abstract syntax you must perform the following tasks:
- Adding ASN.1 modules to your project
- Importing the ASN.1 modules in your SDL diagrams.
- Assigning values to the data types.
Adding ASN.1 Modules to your Project
An ASN.1 module is a file containing the ASN.1 data type definitions. If you are implementing a standard communication protocol, it is very likely that pre-defined ASN.1 modules are available. The modules can be obtained from standardization organizations, RFCs, etc. In Example 7 and the following examples ASN.1 modules that define data structures for SNMP protocol are presented, RFC1155-SMI based on RFC 1155, RFC1157-SNMP based on RFC 1157 and RFCxxxx-MIBs containing references to different objects from various Managed Information Bases.
Should a pre-defined module not be available for your type of application, you must create your own module. ASN.1 modules can be created in a simple text editor. It must contain a header and a footer. Definitions should be inserted inside, for example:
MyModule DEFINITIONS AUTOMATIC TAGS ::=BEGIN-- Definitions should be inserted here, for example,T-Age ::= INTEGER ( 0 .. 150 )T-City ::= ENUMERATED { moscow, malmo, new-york }MyType ::= SEQUENCE {name VisibleString,surname VisibleString,age T-Age OPTIONAL,city T-City DEFAULT moscow}-- Other definitions etc.ENDThe header of the module can contain global settings for the module. In the example above we use AUTOMATIC TAGS which can be omitted but is a recommended flag if you need to generate encode/decode procedures for this module.
For more details please see adequate ASN.1 literature for instructions and guidelines on creating ASN.1 modules.
Regardless how you obtain the ASN.1 modules, you must add the module to your project before the SDL Suite can include the data types.
Follow the instructions below to add the ASN.1 module to your project.
- Save your ASN.1 module in a subdirectory to your project. Make sure that you append the .asn file extension to the saved module.
- Open the Organizer and select the chapter where you want to include the module. This is done by clicking the chapter marker, for instance the Other Documents marker, see Figure 184.
- Click the folder image button in order to find your ASN.1 module. The Select file to add window opens.
- Select the directory you want to search and change the search filter, by typing *.asn in the Filter field. Click the Filter button. The available ASN.1 modules are now displayed in the Files window. Select module and click the OK button. The Select file to add window closes.
- The selected module is now displayed in the Add Existing window. Just click the OK button to add the module to your system. The module should now be visible in the Organizer in your selected chapter.
The ASN.1 modules are now added to your project.
Example 1 : Adding ASN.1 modules to SDL project
- In the SNMP example, the three modules RFC1155_SMI, RFC1157_SNMP and RFCxxxx-MIBs have been added to the project.
Importing ASN.1 Modules
After the modules have been added to the project, they must be made available to the SDL system. This is done by importing the modules to the SDL system file. When the modules have been imported, the ASN.1 data types can be used as regular SDL types.
Follow the instructions below to import the modules in the SDL diagrams:
- From the Organizer, open the system file, <system_name>.ssy.
- Add use of the added modules in the package reference frame, which is located outside the system frame. (See Figure 187).
- Save the diagram.
Example 2 : Importing ASN.1 modules
- In the SNMP example, the three modules RFC1155_SMI, RFC1157_SNMP and RFCxxxx-MIBs have been imported.
- ASN.1 modules are imported when you Analyze an SDL system that uses these modules.
- For each ASN.1 module an SDL package with the same name is created. It contains corresponding SDL definitions. SDL packages are saved into *.pr file in the target folder, for example:
use RFC1155_SMI/synonym mgmt,synonym enterprises,newtype NetworkAddress,newtype IpAddress,newtype Counter,newtype Gauge,newtype TimeTicks;........./*#SDTREF(TEXT,D:\Work\asn_snmp\RFC1157-SNMP.asn)*/package RFC1157_SNMP; /*#ASN.1 'RFC1157_SNMP'*/syntype Message_INLINE_0 = Integer endsyntype;synonym version_1 Message_INLINE_0 = 0;/*#SDTREF(TEXT,D:\Work\asn_snmp\RFC1157-SNMP.asn,10,1)*/newtype Message structversion Message_INLINE_0;community Octet_string;data PDUs;endnewtype;.................../*#SDTREF(TEXT,D:\Work\asn_snmp\RFC1157-SNMP.asn,123,1)*/newtype VarBind structname ObjectName;value ObjectSyntax;endnewtype;/*#SDTREF(TEXT,D:\Work\asn_snmp\RFC1157-SNMP.asn,130,1)*/newtype VarBindListString (VarBind, emptystring)endnewtype;endpackage RFC1157_SNMP;- SDL analogues of ASN.1 types and values from generated packages can be referenced from the SDL system.
Assigning Values to the Data Types
When the modules are imported to the SDL system, you are free to declare signal parameters and variables of ASN.1 data types. The parameters and variables are treated as regular SDL parameters and variables, and you assign values to them in the same manner as you normally do.
For the SNMP example signals snmp_request(Message) and snmp_reply(Message) are declared and they carry information that corresponds to the Message ASN.1 type. Value for the type Message is constructed in the SDL process, see Example 3.
Example 3 : Assigning values to variables
dcl reply, request Message;dcl requests VarBindList;dcl N, N_it Integer;synonym sysDescr_val Object_identifier = sysDescr // (. 0 .);synonym sysObjectID_val Object_identifier = sysObjectID // (. 0 .);..............append( requests, (. sysDescr_val, simple : empty : NULL .) );append( requests, (. sysObjectID_val, simple : empty : NULL .) );append( requests, (. sysUpTime // (. 0 .), simple : empty : NULL .) );append( requests, (. sysName // (. 0 .), simple : empty : NULL .) );append( requests, (. hp_print_internal_page // (. 0 .), simple : number : eDeviceDemoPage1ConfigurationPage .) );..........call PrepareRequest(requests(N_it),N_it,request);
- Message, VarBindList, PDUs, sysDescr and version_1 are types and values imported from ASN.1 modules. sysDescr is defined in the ASN.1 module RFCxxxx-MIBs.asn and it points to an object type corresponding to a textual description of the network entity.
sysDescr // (. 0 .) points to the value of the sysDescr object type and denotes a string with the real description of the network entity. By sending a get_request with sysDescr // (. 0 .) in the 'name' field and an empty 'value' field, network entity supporting SNMP should return the same get_request with the 'value' field holding the string with the description.- When your variables have been assigned values, you have created the abstract syntax.
- When the variables request and requests has been declared, you can use them in the SDL diagram as regular SDL variables. Figure 188 shows how request is used as the argument of a signal that is sent from the SDL system to the environment.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |