It is perfectly clear, but brings up another thing. You were right assuming that my understanding was that for OPTIONAL of DEFAULT VALUE members I would still have the T and L fields. You say this is wrong and I believe you. But then how would you identify which member is present and which one is missing when decoding a structure that has three real number members and each one is OPTIONAL. Suppose the encoded image only contains two real numbers encoded. Which ones will be decoded of the three real numbers? In OER (which I used more extensively, hence the Id and contents field names) I have the preamble that tells you which field is present and which one is missing. I went through the standard document again and there is nothing to tell me explicitly how to deal with such cases. My assumption was that only the V field will be absent (while the L field would have a value of 0) and this way you could tell the member has the default value or is optional.
I hope I was able to articulate my new confusion. Thank you for your time, Eddie Lascu -----Original Message----- From: Conrad Sigona [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 20, 2005 9:24 AM To: Eduard Lascu Cc: [email protected] Subject: Re: [ASN1] Encoding of a real with default value in BER > I have this confusion that I hope somebody can shed some light into it. > According to the BER standard (ISO/IEC 8825-1), "if a real variable has the > value zero, there shall be no contents octets in the encoding". However, > when reading the rules for encoding structures (sequences), I could see that > OPTIONAL or DEFAULT VALUE members can skip the contents octets. > > Therefore, considering a structure that has a member of real type that can > have a default value of 2, if the encoding is like this: > > Id field - 0x09 > Length field - 0x00 > > What conclusion do I draw when decoding it: Is it the default value 2 that > caused the contents octets to be skipped or it is the value 0 for the real > variable that caused the length of the contents octets to be zero? > > Any advice will be greatly appreciated, Dear Mr. Lascu: It would appear you are confusing the skipping of the value octets (what you call the contents octets) with skipping the entire TLV. When an element is optional and absent, it does not appear in the encoded BER data at all. There is no tag field (what you call Id field), nor a length field. Similarly, the entire TLV is missing when the element has a default and takes the default value. On the other hand, when the value is 0, the tag and length is encoded, but the value is not. In summary (T=tag, L=length, V=value), - a typical element is encoded as TLV - an absent optional element is not encoded (no TLV, nothing) - an element which takes its default is not encoded (no TLV, nothing) - a pure zero REAL is encoded as TL Thus, your example 09 00 would represent a 0, not a 2. If it were 2, the 09 00 would not be there. If my explanation is not quite clear, please forgive me and ask again. ===================================================================== Conrad Sigona Voice Mail : 1-732-302-9669 x400 OSS Nokalva Fax : 1-614-388-4156 [EMAIL PROTECTED] My direct line : 1-315-845-1773 _______________________________________________ ASN1 mailing list [email protected] http://lists.asn1.org/mailman/listinfo/asn1
