Can you give me an example to show when to use an enumeration and when to use a choice type with ASN.1?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 (1), apple (2), pear (3) }
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.