On Oct 7, 2011, at 5:22 PM, Kaul wrote:
> I'm struggling for some time now with displaying bitfields, I'm sure there must be something I'm overlooking, or it's just a bit difficult to do in Wireshark.
>
> I have a 32bit, little endian field, which I'd like to parse the bits (as set/not set):
> Example:
> 05 00 00 00
>
> 1 0 0 0 .... Feature A - set
> 0 0 0 0 ... Feature B - not set
> 0 0 1 0 ... Feature C - Set
>
>
> 1. Do I really have to create a hf_xxx for each? And use something like proto_tree_add_bits_item() ? I was hoping to do it in a single proto_tree_add_xxx() and pass it a single HF that would hold a VALS(...) which will describe all the attributes.
Take a look at proto_tree_add_bitmask(). You still have to create each hf_xxx since each bit (or group of bits) is a different parameter, but then a single call to proto_tree_add_bitmask will set up the subtree for the whole bitfield.
Glenn