Wireshark-dev: Re: [Wireshark-dev] Correct and efficient way of displaying bit fields?
Am 07.10.2011 23:22, schrieb Kaul:
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.
When you add all these hf_info records you provide information that will
be displayed quite well. Additionally all these fields can be used in a
display filter expression. That's worth to add all the info.
When I have such one-bit fields I put them in an array and use a loop
over this field and call proto_tree_add_boolean for each iteration. This
saves code lines. But when the field size varies, you will need
individual code lines.
Helge