我要评分
获取效率
正确性
完整性
易理解

Other Applications

Table 1 Other applications of ASN.1

Other Applications

Supported (Y/N)

Example

Constraints

Value assignment

Y

MyType ::= INTEGER

value MyType ::= 10

None

Alias

Y

MyInt1 ::= INTEGER(0..128)

MyInt2 ::= MyInt1

MyInt3 ::= MyInt2

None

IMPORTS

Y

-- Define module A.

A DEFINITIONS ::= BEGIN

MyType ::= INTEGER

END

-- Define module B that introduces MyType of module A.

B DEFINITIONS ::= BEGIN

IMPORTS MyType FROM A;

MyOtherType ::= MyType

END

The IMPORTS statement does not take effect. By default, all types are exported.

EXPORTS

Y

EXPORTS ALL; -- Export all types.

EXPORTS Type; -- Export a specified type from a module.

The EXPORTS statement does not take effect. By default, all types are exported.

Different modules that are compiled together cannot have the same type definition.

Recursive definition

N

RecursiveSeq ::= SEQUENCE {

data INTEGER(0..128),

next RecursiveSeq

}

None

Circular reference

N

CircularSequence1 ::= SEQUENCE { name OCTET STRING, cs2 CircularSequence2 OPTIONAL }

CircularSequence2 ::= SEQUENCE { cs1 CircularSequence1 }

None

Inner type constraints

Y

InnerTypeCstrType ::= SEQUENCE {

a OCTET STRING(SIZE(1..3)),

b INTEGER(10..20),

c BOOLEAN OPTIONAL

}

InnerTypeCstrSeqType ::= InnerTypeCstrType (WITH COMPONENTS {

a ABSENT,

b (15..20) PRESENT,

c OPTIONAL

})

A type with an inner type constraint is used as a reference type and the constraint is invalid.

Content constraints

Y

ContentCstrType ::= SEQUENCE {

data OCTET STRING (CONTAINING ContentCstrBoolType)

}

ContentCstrBoolType ::= BOOLEAN

The content of a member with content constraints is not verified during encoding and decoding.

Complex type nesting

Y

MySeq ::= SEQUENCE {

a SEQUENCE {}

}

Complex types (SEQUENCE, CHOICE, and SEQUENCE OF) support a maximum nesting depth of 30 layers.

Constraints referencing predefined values

Y

max INTEGER ::= 128

MyInt ::= INTEGER(0..max)

value MyInt ::= 10

Only INTEGER constraints support referring to predefined values.