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

Wireshark-dev: Re: [Wireshark-dev] Boolean Field Registration Qurey

From: Bill Meier <wmeier@xxxxxxxxxxx>
Date: Thu, 15 Apr 2010 15:42:35 -0400
Jakub Zawadzki wrote:
Hi,

On Thu, Apr 15, 2010 at 02:48:41PM +0800, Tam�s Reg?s wrote:
In README.developer it says the general rules:
	static hf_register_info hf[] = {
		{ &hf_PROTOABBREV_FIELDABBREV,
			{ "FIELDNAME", "PROTOABBREV.FIELDABBREV",
			FIELDTYPE, FIELDBASE, FIELDCONVERT, BITMASK,
			"FIELDDESCR", HFILL }
		}
	};

In proto.h the FIELDBASE declared as enum:
typedef enum {
	BASE_NONE,	/**< none */
	BASE_DEC,	/**< decimal */
	BASE_HEX,	/**< hexadecimal */
	BASE_OCT,	/**< octal */
	BASE_DEC_HEX,	/**< decimal (hexadecimal) */
	BASE_HEX_DEC,	/**< hexadecimal (decimal) */
	BASE_CUSTOM	/**< call custom routine (in ->strings) to format */
} base_display_e;

If you are using FT_BOOLEAN, it's no longer BASE_* enum, but number of field bits.

From proto.h:
  int display;        /**< one of BASE_, or number of field bits for FT_BOOLEAN */



To clarify slightly:

The 'display'comment should actually be something like
"... or number of field bits for FT_BOOLEAN if BITMASK is non-zero".

From README.developer

"For FT_BOOLEAN fields that are also bitfields (i.e. 'bitmask' is non-zero), 'display' is used to tell the proto_tree how wide the parent bitfield is."

"With integers this is not needed since the type of integer itself
(FT_UINT8, FT_UINT16, FT_UINT24, FT_UINT32, etc.) tells the proto_tree how wide the parent bitfield is.".

and

"Additionally, BASE_NONE is used for 'display' as a NULL-value. That is, for non-integers other than FT_ABSOLUTE_TIME fields, and non-bitfield FT_BOOLEANs, you'll want to use BASE_NONE in the 'display' field. You may not use BASE_NONE for integers.


I've updated the comment in proto.h.