Now everything makes perfect sense. M<ay confusion steamed from the fact that I thought CHOICE types can have their inner members declared as OPTIONAL or possibly having the DEFAULT VALUE.
Thank you everybody for all your time. Regards, Eddie Lascu -----Original Message----- From: John Larmouth [mailto:[EMAIL PROTECTED] Sent: Thursday, May 12, 2005 3:44 PM To: Eduard Lascu Subject: Re: [ASN1] BER encoding of a CHOICE type that has data members with DEFAULT value No, this is not valid either. DEFAULT can only be used with elements of a SEQUENCE or SET, not with alternatives of a CHOICE. You could, if you wanted to encode only the automatic tag for zero cases, write: CHOICE { deci-seconds SEQUENCE {a INTEGER (0..9) DEFAULT 0}, centi-seconds SEQUENCE {a INTEGER (0..99) DEFAULT 0}, milliseconds SEQUENCE {a INTEGER (0..999) DEFAULT 0} } Then whatever alternative was chosen (assuming the value of that alternative is zero), you would get only the automatic of that alternative, with a zero length and no "V" part. But that is ugly. If I understand what you are trying to do, a better solution is: time-SecondFractions CHOICE { none NULL, deci-seconds INTEGER (0..9), centi-seconds INTEGER (0..99), milliseconds INTEGER (0..999) } DEFAULT {none: NULL} You then get either an ecnoding of the context-specific zero automatic tag for the NULL (zero length, no "V"), or the context-specific 1, 2, or 3 for one of the other alternatives, with an L and a V according to the value. John L Eduard Lascu wrote: > I assumed that all along. However, > > time-SecondFractions CHOICE { > deci-seconds INTEGER (0..9) DEFAULT{0}, > centi-seconds INTEGER (0..99) DEFAULT{0}, > milliseconds INTEGER (0..999) DEFAULT{0} > } > > should be ok. How do I encode this so that the decoding end will figure it > out? > > > > -----Original Message----- > From: John Larmouth [mailto:[EMAIL PROTECTED] > Sent: Thursday, May 12, 2005 3:16 PM > To: Eduard Lascu > Cc: [email protected] > Subject: Re: [ASN1] BER encoding of a CHOICE type that has data members > with DEFAULT value > > > This is incorrect ASN.1 syntax. What follows the word DEFAULT has to be a > value > OF THE CHOICE TYPE. In other words, it should be something like "DEFAULT > {deci-seconds: 0}" or whatever, meaming that if time-SecondFractions is > missing, > then it is as if it had been encoded as the deci-seconds alternative with a > value of zero. > > The value notation "{0}" is not a value of the CHOICE type, and cannot be > used > after the word DEFAULT. > > John L > > Eduard Lascu wrote: > > >>Hello ASN.1 experts, >> >>I have a CHOICE type that is defined like this: >> >>time-SecondFractions CHOICE { >> deci-seconds INTEGER (0..9), >> centi-seconds INTEGER (0..99), >> milliseconds INTEGER (0..999) ) DEFAULT(0) >> >>I have a problem interpreting what the BER standard says about encoding > > such > >>a field. On one hand, members having the Default value are not to be >>encoded. In a SEQUENCE, the class of the members is context specific and > > the > >>tag numbers are used too determine which member is present and which is >>absent. >> >>On the other hand, BER says that the encoding of a choice value shall be > > the > >>same as the encoding of the value of the chosen type. If the inner members >>are not OPTIONAL and cannot have a DEFAULT VALUE everything is fine. But > > if > >>they are OPTIONAL or if they can have a DEFAULT VALUE (such as my case, >>above described) I am confused. >> >>If my chosen type has exactly the default value, how do I encode the > > Choice? > >>Any help would be highly appreciated. >> >>Best regards, >>Eddie >> >>_______________________________________________ >>ASN1 mailing list >>[email protected] >>http://lists.asn1.org/mailman/listinfo/asn1 >> >> > > > -- > Prof John Larmouth > Larmouth T&PDS Ltd > (Training and Protocol Development Services Ltd) > 1 Blueberry Road > Bowdon [EMAIL PROTECTED] > Cheshire WA14 3LS > England > Tel: +44 161 928 1605 Fax: +44 161 928 8069 > > > > > -- Prof John Larmouth Larmouth T&PDS Ltd (Training and Protocol Development Services Ltd) 1 Blueberry Road Bowdon [EMAIL PROTECTED] Cheshire WA14 3LS England Tel: +44 161 928 1605 Fax: +44 161 928 8069 _______________________________________________ ASN1 mailing list [email protected] http://lists.asn1.org/mailman/listinfo/asn1
