Wireshark-dev: Re: [Wireshark-dev] Help with Bit Fields
From: Mike Morrin <morrinmike@xxxxxxxxx>
Date: Sat, 03 Mar 2012 08:04:35 +0000
On 02/03/2012 23:14, Alex Lindberg wrote:
I have a bit oriented message defined:

<Base> <NumBits> <bits....>

Where Base defines a base value and NumBits determines the number of
bits following (in byte groups). Each bit defines the state of the item
# Base+Bit Number.

I want to create a display that will have the Item Number when the tree
is expanded like so, as an example, if the base is 11 then the 4th bit
is item 14 so the output should be:

...1 .... = Item 14 ON


I would use proto_tree_add_bits_ret_val() to get the values of Base and NumBits, then loop for numbits iterations with proto_tree_add_boolean_bits_format_value() for one bit at a time, defining the format to include the calculated item number.

regards,
Mike