ASN.1
Previous: Additional Features Up: Additional Features Next: Recursion


Subtype Notation and Value Sets

  Frequently we encounter situations where only a portion of a finite set or sequence is of concern. For example, we may be interested only in the divisors of 24, values between two integers, or the first 9 people in a queue. ASN.1 allows subtyping, which enables a user to specify values within the range of values of a type, in much the same way as the syntax of a high-level programming language. The value notation of a subtype is that of the parent type. The type notation is the union of the value sets within parentheses and separated by the symbol | , which has the same meaning, ``or'', as in BNF.

ASN.1 defines six forms of notation for value sets. Examples of five of them - SingleValue, ContainedSubtype, ValueRange, PermittedAlphabet, and SizeConstraint - are in the following figure Figure. The sixth form, InnerType, is discussed separately.   

SingleValue:
Divisors-of-6 ::= INTEGER (1 | 2 | 3 | 6)

ContainedSubtype:
Divisors-of-18 ::= INTEGER (INCLUDES Divisors-of-6 | 9 | 18)

ValueRange:
TeenAgeYears ::= (13 .. 19)

Permitted Alphabet:
BooleanValue ::= IA5String (FROM ('T' | 'F'))

SizeConstraint:
BaseballTeamRoster ::= SET SIZE (1..25) OF PlayerNames

Figure: Examples of ASN.1 subtypes.


The keywords ``INCLUDES", ``FROM", and ``SIZE" are required in the subtype syntax. ``INCLUDES" must be followed by the value set of the parent type. In the example, the divisors of 18 are 18, 9, and all of the divisors of 6 (namely, 1,2,3,and 6 specified in the example of SingleValue). ``FROM'' must be followed by a subset of the specified character string. ``SIZE'' must be followed by the lower and upper end values of an interval. Values of ``MIN'' or ``MAX'' indicate that the range extends as far in that direction as the parent type allows. The interval is closed unless the symbol ``<'' follows the lower end value and precedes the upper end value, in which case the interval is open.

InnerType constrains the value ranges of structured types. In particular, it can change an OPTIONAL component of a structured type into one that is always PRESENT or always ABSENT. The type notation requires the keywords ``WITH COMPONENTS'' followed by the components of the structured type, each component with or without a constraint. For example, if AirlineFlight is the SEQUENCE structured type defined in the Structured Types Section, then the following definition allows only those flights of American and Delta Airlines that are nonstop to Los Angeles (LAX), have no more than 200 passengers, and are at least half filled:

  NonStopFlights ::= AirlineFlight
                   ( WITH COMPONENTS
                    {
      airline ("American" | "Delta"),
      flight,
      nonstopseats ::= seats
                   ( WITH COMPONENTS
                    {
                     maximum   (0..200),
                     occupied  (100..200),
                     vacant    (0..100)
                    }
                   ),
      nonstopairport ::= airport
                   ( WITH COMPONENTS
                    {
                     origin,
                     stop1       [0]    ABSENT,
                     stop2       [1]    ABSENT,
                     destination        ("LAX")
                    }
                   ),
       crewsize,
       cancel
      })

The following Table displays the subtype value sets that can be applied to specified ASN.1 built-in types. A ``Y'' entry indicates that the notation of the value set named in the column header can be applied to the parent type named in the row header or to a type derived from that parent type by tagging.

Type Single Value Contained Subtype Value Range Size Range Alphabet Limitation Inner Substring
Boolean Y Y N N N N
Integer Y Y Y N N N
Enumerated Y Y N N N N
Real Y Y Y N N N
Object Identifier Y Y N N N N
Bit String Y Y N Y N N
Octet String Y Y N Y N N
Character String Y Y N Y Y N
Sequence Y Y N N N Y
Sequence-of Y Y N Y N Y
Set Y Y N N N Y
Set-of Y Y N Y N Y
Any Y Y N N N N
Choice Y Y N N N Y

Table: Applicability of ASN.1 subtype value sets.


Previous: Additional Features Up: Additional Features Next: Recursion


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