Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] proto_add_tree_item versus proto_add_tree_string

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 12 Mar 2007 18:13:07 -0700

On Mar 12, 2007, at 5:46 PM, Neely Grady-W30566 wrote:

I built a function called tvb_get_bits8 based on some work someone else has done, and it handles incrementing the tvb offset and grabbing the bits I want, even if the straddle byte boundaries. However, this only works if I retrieve the value. Seems like their ought to be a way to do this without retrieving the value and printing it via a proto_add_text or _string.

There is - retrieving the value and adding it to the tree with proto_tree_add_uint().

That way:

	1) it's a registered field;

	2) it's an integral field, not a string;

	3) you don't have to worry about bit masks in the fields.

The fields, in this case, would *not* have bit masks, and would have a size that's the size of the field rounded up to the lowest of (8, 16, 24, 32, 64).