Eduard Lascu wrote:
I have these types:
TYPE1 ::= SEQUENCE { x1 [0] INTEGER,
x2 [1] TYPE2,
x3 [2] TYPE3 }
TYPE2 ::= SEQUENCE { y1 [0] INTEGER OPTIONAL,
y2 [1] INTEGER OPTIONAL,
y3 [2] SEQUENCE { yy1 [0] INTEGER,
yy2 [1] INTEGER } OPTIONAL }
TYPE3 ::= CHOICE { z1 [0] INTEGER,
z2 [1] INTEGER,
z3 [2] INTEGER }
Is the tagging that I entered correct or it has to be, in fact like this:
The above tagging is correct.
Yet, tagging of x1, yy1 and yy2 is not strictly necessary.
TYPE1 ::= SEQUENCE { x1 [0] INTEGER,
x2 [1] TYPE2,
x3 [7] TYPE3 }
TYPE2 ::= SEQUENCE { y1 [2] INTEGER OPTIONAL,
y2 [3] INTEGER OPTIONAL,
y3 [4] SEQUENCE { yy1 [5] INTEGER,
yy2 [6] INTEGER } OPTIONAL }
TYPE3 ::= CHOICE { z1 [8] INTEGER,
z2 [9] INTEGER,
z3 [10] INTEGER }
}
This would be a bad decision.
The reason I am asking is that in my first case, I am confused about how the
chosen value from the CHOICE type should be encoded under BER.
If AUTOMATIC TAGS clause is not used in the module header, it is recommended
to add a tag of class context-specific before every CHOICE type.
If TYPE2 is skipping its y3 member (whose encoding should have started with
[A2] - context specific, constructed, unique id 2 within TYPE 2), next comes
the encoding of TYPE 3 which also starts with [A2] - context specific,
constructed, unique id 2 within TYPE 1.
No. The TYPE2 decoder knows how many bytes the SEQUENCE occupies,
including the space needed to encode the optional y3 member.
Obviously, this creates confusion on the decoding side.
No, it does not confuse decoder, because the y3 is taken care of during
processing of TYPE2, and when TYPE3 decoding is started it is already
known whether there was y3 member or now.
I guess this all
boils down to the following question: Those unique tags must be unique at
the sequence/choice level or at a "global" level?
They have to be unique at the "appropriate level". For example, the
following is correct:
Type1 ::= SEQUENCE {
member1 SEQUENCE { a INTEGER OPTIONAL },
member2 SEQUENCE { a INTEGER OPTIONAL },
member3 CHOICE { a INTEGER },
member4 CHOICE { a INTEGER } OPTIONAL
}
and the following is NOT correct:
Type2 ::= SEQUENCE {
member5 CHOICE { a INTEGER } OPTIONAL,
member6 CHOICE { a INTEGER }
}
and the following is again correct:
Type3 ::= SEQUENCE {
member7 INTEGER,
member8 INTEGER OPTIONAL,
member9 [0] INTEGER,
member10 INTEGER
}
Any help would be greatly appreciated.
Thanks,
Eddie
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1
--
Lev Walkin
[EMAIL PROTECTED]
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1