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

Wireshark-dev: [Wireshark-dev] Problem with a flag in a 32 bit field

From: Graham Bloice <graham.bloice@xxxxxxxxxxxxx>
Date: Thu, 14 Oct 2010 14:39:16 +0100
I'm having trouble picking out a bit flag from a 32 bit field.  Can anyone point out where I'm going wrong?

The field is transmitted on the wire in little endian order; b0 b1 b2 b3, bits 0 - 30 are a block number and the flag I'm interested is bit 31, the top bit of b3.

I add the item to the tree with:

  proto_tree_add_item(point_tree, hf_item, tvb, offset, 4, ENC_LITTLE_ENDIAN);
 
and the hf def is:

  { &hf_item,
  { "A flag", "dissector.flag", FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x8000, "A flag", HFILL }},
 
but when looking at the item I see the field displayed in the hex window as "00 00 00 80", but the flag isn't set in the tree.

Similar code to the above works with 16 bit fields,

-- 
Regards,

Graham Bloice