Wireshark-bugs: [Wireshark-bugs] [Bug 5812] Dissector for the Babel Routing Protocol (RFC 6126)

Date: Fri, 8 Apr 2011 08:52:31 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5812

--- Comment #18 from Stephen Fisher <steve@xxxxxxxxxxxxxxxxxx> 2011-04-08 09:52:30 MDT ---
(In reply to comment #13)
> While I have your ear -- what's the official interface for doing a
> human-readbale printout of a bit field (I'm thinking of the Flags field of the
> Update message.)

I usually use proto_tree_add_item() with a bitmask.  From doc/README.developer:

/* Setup list of header fields  See Section 1.6.1 for details*/
        static hf_register_info hf[] = {
                { &hf_PROTOABBREV_FIELDABBREV,
                        { "FIELDNAME",           "PROTOABBREV.FIELDABBREV",
                        FIELDTYPE, FIELDDISPLAY, FIELDCONVERT, BITMASK,
                        "FIELDDESCR", HFILL }

For an example, from epan/dissectors/packet-vnc.c:

        proto_tree_add_item(zrle_subencoding_tree, hf_vnc_zrle_rle,
                            uncomp_tvb, uncomp_offset, 1, FALSE);

        proto_tree_add_item(zrle_subencoding_tree,
                            hf_vnc_zrle_palette_size, uncomp_tvb,
                            uncomp_offset, 1, FALSE);

            { &hf_vnc_zrle_rle,
                  { "RLE", "vnc.zrle_rle",
                    FT_UINT8, BASE_DEC, VALS(yes_no_vs), 0x80, /* Upper bit */
                    "Specifies that data is run-length encoded", HFILL }
                },

                { &hf_vnc_zrle_palette_size,
                  { "Palette size", "vnc.zrle_palette_size",
                    FT_UINT8, BASE_DEC, NULL, 0x7F, /* Lower 7 bits */
                    NULL, HFILL }
                },

There are some other functions you can use such as tvb_get_bits[8|16|32|64] and
proto_tree_add_bitmask() and others.  See README.developer for more details.

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.