tebbutt@RHINO.NCSL.NIST.GOV (John Tebbutt) (03/20/91)
I have a problem relating to how an application can discern between an OPTIONAL SEQUENCE which is present but empty, and one which is absent, based on the pepy decoder generated local C structure. For example, if I have an ASN.1 definition: DistributedOperationsArgument ::= SET { originator[0] DistinguishedName OPTIONAL, targetObject[1] DistinguishedName OPTIONAL, ... } ...where DistinguishedName ::= SEQUENCE OF SomethingOrOther, the corresponding pepy generated struct looks like this: struct DistributedOperationsArgument { int optionals; #define opt_DistributedOperationsArgument_aliasedRDNs (000000001) struct DistinguishedName *originator; struct DistinguishedName *targetObject; ... }; Now, if originator == (struct DistinguishedName *)NULL, does that mean (a) that originator was not present in the encoding, (b) that originator was present but empty, or (c) either/both? In the case of (a) or (b), what value of originator would indicate the converse? Many thanks in advance for any insights. JT
mdeslauriers@ccrit.doc.ca (Michel Deslauriers) (03/20/91)
Hi, concerning your problem with OPTIONAL SEQUENCES. The following example should give an answer. Isode 6.0 was used for it. The ASN.1 definition (similar to yours) is ========================================== X DEFINITIONS ::= BEGIN Pdu ::= SET { ele1 [0] T1 OPTIONAL, ele2 [1] T1 OPTIONAL } T1 ::= SEQUENCE OF INTEGER END The "C" structures file generated is ==================================== /* automatically generated by posy 6.0 #1 (faucon), do not edit! */ #ifndef _module_X_defined_ #define _module_X_defined_ #include <isode/psap.h> #include <isode/pepy/UNIV-types.h> struct type_X_Pdu { struct type_X_T1 *ele1; struct type_X_T1 *ele2; }; int free_X_Pdu (); struct type_X_T1 { integer element_X_0; struct type_X_T1 *next; }; int free_X_T1 (); #endif The field element_X_0 must indicate the number of elements in the SEQUENCE OF. So an empty one will have a non-NULL ele1 pointer to a type_X_T1 structure but will have the field element_X_0 to 0. An a NULL ele1 pointer will indicate that ele1 wasn't present in the encoding. I build a small application that decode a stream and that print it using the Isode pretty print. I send two streams, the first one with ele1 an empty SEQUENCE OF and the second with no ele1. Pretty print of the first decoded stream ======================================== { ele1 {}, ele2 { 1, 2, 3 } } Pretty print of the second decoded stream ========================================= { ele2 { 1, 2, 3 } } Hope it helps ... /md
tebbutt@RHINO.NCSL.NIST.GOV (John Tebbutt) (03/28/91)
This is a reposting of something I put out a week ago which was immediately met with a deafening silence! Since it generated so much interest the first time around, it occurred to me that you all might like to see it again, so here it is ;^) PS I figure the reason I got so few responses was either that I was way wide of the mark and had missed some fundamental truth or that I had inadvertantly discovered a genuine problem with pepy which has had all the ISODE people scratching their heads ever since. My money is on the former, but I would appreciate any feedback whatsoever - even RTFMs! ----- Begin Included Message ----- I have a problem relating to how an application can discern between an OPTIONAL SEQUENCE which is present but empty, and one which is absent, based on the pepy decoder generated local C structure. For example, if I have an ASN.1 definition: DistributedOperationsArgument ::= SET { originator[0] DistinguishedName OPTIONAL, targetObject[1] DistinguishedName OPTIONAL, ... } ...where DistinguishedName ::= SEQUENCE OF SomethingOrOther, the corresponding pepy generated struct looks like this: struct DistributedOperationsArgument { struct DistinguishedName *originator; struct DistinguishedName *targetObject; ... }; Now, if originator == (struct DistinguishedName *)NULL, does that mean (a) that originator was not present in the encoding, (b) that originator was present but empty, or (c) either/both? In the case of (a) or (b), what value of originator would indicate the converse? Many thanks in advance for any insights. JT ----- End Included Message -----
j.onions@xtel.co.uk (Julian Onions) (03/28/91)
If the OPTIONAL part is not present the pointer will be NULL If it is present, it will allocate a structure only if there are members in the SEQUENCE OF. If the SEQUENCE OF turns out to have 0 elements in it it will be the same as if the SEQUENCE OF was not encoded. You cannot distinguish between these two cases with posy/pepsy. Either the element is there and has 1 or more components or it is treated as abesnt. Julian.