Wireshark-dev: Re: [Wireshark-dev] What do you use to get a boolean
From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Thu, 12 Jul 2007 18:37:20 -0400

This bit me (again?) today so I've checked in your proposed text (modified slightly): rev 22293.

Jaap Keuter wrote:
Hi,

Reading from README.developer it states:
<quote>
For proto_tree_add_boolean(), the 'value' argument is a 32-bit integer;
zero means "false", and non-zero means "true".
</quote>
That is misleading. You have to take into account the field info to
determine the interpretation of this value (see epan/proto.c :
proto_tree_set_uint() ). You can define a mask of the relevant bit(s) and
this will be applied (mask AND shift) before adding the value to the tree.
So how about this text for README.developer:
<quote>
For proto_tree_add_boolean(), the 'value' argument is a 32-bit integer.
It is masked and shifted as defined by the field info, then zero means
"false", and non-zero means "true".
</quote>

Thanx,
Jaap

On Mon, 26 Feb 2007, Hal Lander wrote:

Steve,

Its more what the documentation does not say that caused me the problem.

The function is called 'add_boolean' and it has a parameter 'value'.
I had assumed, incorrectly, that 'value' would be a 1 or a 0.
It is not, it is the value of the packet byte that requires to be masked and
shifted to get the boolean. It would be helpful if the documentation defined
'value' more explicitly.

Also Wireshark has functions which do the masking and shifting to get the
boolean value.
It would be helpful if these functions were exposed in the API so that
dissector writers can use them. If I want to find the actual boolean value
of the field I have to write my own functions for masking and shifting. That
is not a big issue, but it is duplicating existing code, requires testing
and is another source of bugs - better to use the Wireshark functions if
they could be made available.

I hope this is helpful, the effort required to generate documentation is
much appreciated and how Wireshark works is gradually starting to clik into
place in my mind.

Hal.


From: Stephen Fisher <stephentfisher@xxxxxxxxx>
Reply-To: Developer support list for Wireshark
<wireshark-dev@xxxxxxxxxxxxx>
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Subject: Re: [Wireshark-dev] What do you use to get a boolean
Date: Wed, 21 Feb 2007 23:25:44 -0800

On Mon, Feb 12, 2007 at 06:15:43AM -0900, Hal Lander wrote:
It does look like the value you pass to
proto_tree_add_boolean(tree, id, tvb, start, length, value);
is not a 1 or a 0 it is the raw data byte containing the boolean at the
position defined by the mask.

If I am correct this makes the documentation a bit missleading.
As Guy said, you have to do the masking yourself.  What part of the
documentation did you find misleading?  I ask so that we can take a look
at improving it.


Steve

_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev
_________________________________________________________________
Play Flexicon: the crossword game that feeds your brain. PLAY now for FREE.�
  http://zone.msn.com/en/flexicon/default.htm?icid=flexicon_hmtagline




------------------------------------------------------------------------

_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev