Wireshark mailing list archives

Re: Correct and efficient way of displaying bit fields?


From: Glenn Matthews <glenn.matthews () cisco com>
Date: Mon, 10 Oct 2011 08:48:22 -0400


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

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe


Current thread: