ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] Don't need the chaff

From: Jaap Keuter <jaap.keuter@xxxxxxxxx>
Date: Mon, 6 Nov 2006 15:34:04 +0100 (CET)
Hi,

See this blurb in README.developer

bitmask
-------
If the field is a bitfield, then the bitmask is the mask which will
leave only the bits needed to make the field when ANDed with a value.
The proto_tree routines will calculate 'bitshift' automatically
from 'bitmask', by finding the rightmost set bit in the bitmask.
If the field is not a bitfield, then bitmask should be set to 0.

This is a snippet of code I use:

proto_tree_add_item(option_tree, hf_option_gain, tvb, offset, 1, FALSE);

Where the gain is stored in the high nibble. To get at that value I've
defined the field like this:

	static hf_register_info hf[] =
	{
		{
			&hf_option_gain,
			{
				"Gain", "option.gain",
				FT_UINT8, BASE_DEC,
				VALS(option_gain_vals), 0xF0,
				"", HFILL
			}
		}

Thanx,
Jaap

On Mon, 6 Nov 2006 Andrew.Martin@xxxxxxxxxxxxxxxxxxxxxx wrote:

> Hi,
>
> I'm developing a dissector, now within a packet header there are 2
> bytes, 5 bits relate to flags and 3 bits refer to the message. I've
> managed to seperate the flags into their individual bits, but I need all
> three of the remaining bits.
>
> How do I do that?
>
> Cheers
>
>
>