Using CSN.1 and ASN.1 Together

Our tool lets you use the CSN.1 and ASN.1 notations in tandem, in a straightforward way. A few simple example files should suffice to illustrate.

Example 18.1. main.csn1

ASN1MODULE : Main;

<My Pdu> ::= <Name> <Location> <FooBar> <Marker>;

<Marker> ::= <m1 : bit(5)> <m2: bit(3)>; 
            

Example 18.2. main.asn1

Main DEFINITIONS AUTOMATIC TAGS BEGIN

IMPORTS
Name, Location FROM Common;

FooBar ::= SEQUENCE {
    foo INTEGER(0..3),
    bar BOOLEAN,
    marker Marker
}

END  
            

Example 18.3. common.csn1

ASN1MODULE : Common;

<Name> ::= <octet(5)>;
            

Example 18.4. common.asn1

Common DEFINITIONS AUTOMATIC TAGS BEGIN

Location ::= ENUMERATED { city(1), suburbs(2), rural(3) }

END  
            

Looking first at common.asn1 and common.csn1, we find that both are using the ASN.1 module "Common". So, the ASN.1 module called "Common" will have both of these types: "Name" and "Location".

Next, we look at main.asn1. This imports "Name" and "Location" from the Common module into the Main module. It does not matter that one of those was defined using CSN.1 and the other using ASN.1. You can see this file defines "FooBar" in module Main. It also references "Marker", which is defined in the same ASN.1 module, but using CSN.1 notation (see main.csn1).

Finally, we look at main.csn1. This file defines "My-Pdu" (the ASN.1 name resulting from "My Pdu") and "Marker" in ASN.1 module "Main". It refers to "Name", "Location", "FooBar", and "Marker". We consider each of these in turn. "Marker" is defined locally in the same file. "FooBar" is defined in the same ASN.1 module, but using ASN.1 notation. Finally, "Name" and "Location", which belong to another ASN.1 module, are referenced. This is legal because those types were imported for the Main module by main.asn1.

In conclusion, the definitions for an ASN.1 module may be split into multiple files using different notations, but in the end, it is as if everything were specified in ASN.1. A CSN.1 file may contain references to types in other ASN.1 modules by using the ASN.1 notation to specify imports.

A caveat: our tool does not accept ASN.1-based definitions of ASN.1 modules that have no ASN.1 definitions. That means that if you create an ASN.1 file to do nothing more than define imports, you will need to define at least one type, such as Dummy ::= NULL;