From: Robert J. <rob...@di...> - 2003-09-10 06:05:08
|
Yes, I agree. If extendable is TRUE then constraint cannot be FixedConstraint, ergo the condition is oxymoronic. I have applied the patch as you suggest. Robert Jongbloed. > -----Original Message----- > From: ope...@li... > [mailto:ope...@li...] On Behalf > Of Greg Adams > Sent: Friday, 5 September 2003 11:20 PM > To: ope...@op...; ope...@li... > Subject: [Openh323-devel] RE: [OpenH323]ASN Encode bug with > Extendable Integers? > > > OK, here is what we have found: > > The problem is indeed with ExtendableConstaint integers. > > By looking at the decode we can see that if an > ExtendableConstaint integer is _not_ extended, then it is > decoded as a FixedConstaint (i.e. there is no length > prefixing the value). > > When we look at the Encode, we see that depending on the > result of a call to ConstaintEncode we will either encode > with the length, or not. > > ConstraintEncode looks like this: > --------------------------- > BOOL PASN_ConstrainedObject::ConstraintEncode(PPER_Stream & > strm, unsigned value) const { > if (!extendable) > return constraint != FixedConstraint; > > BOOL needsExtending = value > upperLimit; > > if (!needsExtending) { > if (lowerLimit < 0) { > if ((int)value < lowerLimit) > needsExtending = TRUE; > } > else { > if (value < (unsigned)lowerLimit) > needsExtending = TRUE; > } > } > > strm.SingleBitEncode(needsExtending); > > return needsExtending || constraint != FixedConstraint; > } > ---------------------- > > Only ExtendableConstraint objects have the extendable flag > set, so in most cases the first if condition is true and the > return value is correct. If it is an ExtendableConstraint > that has not been extended, then needsExtending is correctly > set to false. But the return code (needsExtending || > constraint != FixedConstraint) is incorrect as it will return > TRUE and force a length to be encoded prior to the value. > > We believe that the fix should be to remove the constraint != > FixedConstraint check, and just to return needsExtending. > > Modified code looks like this: > > ------------------- > BOOL PASN_ConstrainedObject::ConstraintEncode(PPER_Stream & > strm, unsigned value) const { > if (!extendable) > return constraint != FixedConstraint; > > BOOL needsExtending = value > upperLimit; > > if (!needsExtending) { > if (lowerLimit < 0) { > if ((int)value < lowerLimit) > needsExtending = TRUE; > } > else { > if (value < (unsigned)lowerLimit) > needsExtending = TRUE; > } > } > > strm.SingleBitEncode(needsExtending); > > return needsExtending; > } > -------------------- > > Robert/Craig do you agree with this? We have tested our > scenario here without a problem, but need some confirmation > that this is a valid fix in all conditions. > > Regards, > Greg Adams > > -----Original Message----- > From: Greg Adams > Posted At: 04 September 2003 17:54 > Posted To: ridgeway.reflector.OpenH323 > Conversation: ASN Encode bug with Extendable Integers? > Subject: [OpenH323]ASN Encode bug with Extendable Integers? > > > We have the following sample code that shows up an error when > encoding the integer which has an asn syntax of: > rfc-number INTEGER(1..32768, ...), > > When constructed, the print out shows the correct values, > when decoded back into a new class, the printout of this > class shows the incorrect value. We are still investigating, > but if anyone has any ideas or has seen this problem before, > then please let us know. > > Regards, > Greg Adams > > ------------ > Code Sample: > > H245_MediaPacketizationCapability mpc; > mpc.m_h261aVideoPacketization = TRUE; > mpc.IncludeOptionalField(H245_MediaPacketizationCapability::e_ > rtpPayload > Type); > mpc.m_rtpPayloadType.SetSize(1); > H245_RTPPayloadType& rtppt = mpc.m_rtpPayloadType[0]; > rtppt.m_payloadDescriptor.SetTag(H245_RTPPayloadType_payloadDe > scriptor:: > e_rfc_number); > PASN_Integer& rfc = rtppt.m_payloadDescriptor; > rfc = 2249; > > PStringStream strstrm2; > mpc.PrintOn(strstrm2); > OutputDebugString(strstrm2); > > PPER_Stream strm; > mpc.Encode(strm); > strm.CompleteEncoding(); > strm.ResetDecoder(); > > H245_MediaPacketizationCapability mpc2; > mpc2.Decode(strm); > > PStringStream strstrm; > mpc2.PrintOn(strstrm); > OutputDebugString(strstrm); > > > --------- > Output Produced: > > { > h261aVideoPacketization = TRUE > rtpPayloadType = 1 entries { > [0]={ > payloadDescriptor = rfc_number 2249 > } > } > }{ > h261aVideoPacketization = TRUE > rtpPayloadType = 1 entries { > [0]={ > payloadDescriptor = rfc_number 521 > } > } > } > > -------------------------------------------------------------- > ---------- > Check the FAQ before asking! - > http://www.openh323.org/~openh323/fom.cgi > The OpenH323 > Project mailing list, using Mailman. To unsubscribe or change > your subscription options, goto > http://www.openh323.org/mailman/listinfo/op> enh323 > Maintained > by Quicknet Technologies, Inc - > http://www.quicknet.net > -------------------------------------------------------------- > ---------- > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Openh323-devel mailing list Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openh323-devel > |