Wireshark-dev: Re: [Wireshark-dev] tvb_reported_length() vs tvb_length()

From: Bill Meier <wmeier@xxxxxxxxxxx>
Date: Thu, 24 Sep 2009 16:08:45 -0400
Jeff Morriss wrote:

After having made many a comment (on new dissectors) about using the wrong function, I start to wonder:

Should we rename tvb_length() to, say, tvb_captured_length() and tvb_reported_length() to tvb_length()?

Looking at it from the point of the TVB API it doesn't make much sense, but since [it appears that] many dissector writers tend to not think of snapshot lengths when dealing with TVBs, it might be the best way to prevent this problem going forward.

Or maybe just rename tvb_length() to tvb_captured_length() ?

Actually: I guess I should take a step back ?

I see that there are over 400 dissectors which use tvb_length... (> 2400 usages).

What are the cases where the use of tvb_length... in a dissctors is valid ?

Looking at README.developer in detrail I see that:

1. tvb_length is shown as being used before doing a heuristics check in
   new-style (and presumably heuristics) dissectors.
   In fact: I now see that the return is shown as
   tvb_length not tvb_reported_length.
   (Given this, I made an incorrect commit in a recent commit).

2. When calling tvb_new-subset.

Others ?

Bill