Can you give me an example to show when to use an enumeration and when to use a choice type with ASN.1?
A:
CHOICE and ENUMERATED are used for different purposes, as different as "enum" and "union" in C.
ENUMERATED only lists a set of elements :
MyFruit ::= ENUMERATED { banana, apple, pear }
CHOICE allows to select one element from a list, and define its attributes:
MyCHOICE ::= CHOICE { a INTEGER, b BOOLEAN, c SEQUENCE (SIZE(1..10)) OF MyFruit }
If you use the ASN.1 value notation to declare variables of these types it would look like:
aFruit MyFruit ::= banana
aChoice MyCHOICE ::= c:{banana, apple, banana, pear}
anotherChoice MyCHOICE ::= a:10
See? The CHOICE allows to use the same typename to store different types (thus values). Like the "union" in C.
Hope this helps.
Maxime
2010-08-20 10:22:36