Ethereal-dev: Re: [Ethereal-dev] need help with tvb exceptions

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxx>
Date: Sun, 14 Nov 2004 22:43:40 -0800
Andy Howell wrote:

I think my problem was from messing up the "reported length" in the tvb_new_subset.

In almost all cases, the last two arguments to "tvb_new_subset()" should be -1; the *ONLY* reason to pass anything other than -1 is if you're cutting data off the *end* of the tvbuff - if you just want to take all data starting at offset X to the end of the packet, do

	tvb_new_subset(tvb, X, -1, -1)

Don't waste any time using "tvb_length()" or "tvb_length_remaining()" or "tvb_reported_length()" or "tvb_reported_length_remaining()" to compute the last two argument values in that case.

If you *are* cutting data off at the end, you should compute the last argument based on the "tvb_reported_length()" or "tvb_reported_length_remaining()" value, and then compute the third argument as the minimum of that value and a value based on "tvb_length()" or "tvb_length_remaining()".