Wireshark-dev: [Wireshark-dev] Unable to Display Simple Protocol Tree
From: "Dix, Steven E" <Steven.E.Dix@xxxxxxxxxx>
Date: Fri, 20 Mar 2009 15:12:25 -0500
I've been trying to get dissector plugin that I'm coding to display
subtree information that it has parsed.  I can get it to look through
the tvb buffer and extract the data, but I can't get it to display even
the top level protocol name beneath the UDP line.  As a debugging aid, I
dropped in code lifted and slightly modified from the AMIN protocol
CodeProject web article (link:
http://www.codeproject.com/KB/IP/custom_dissector.aspx).

I macroed the code so that if macro AMIN is defined, the AMIN code runs.
Otherwise, my dissector runs.  The AMIN code does display the protocol
name.  With what looks like an identical proto_tree_add_item call, my
dissector won't display the protocol name.

I don't understand why the code doesn't work.  I've stepped through it
in the debugger, and verified that the structure pointed to by the tree
has a new last_child as a result of the proto_tree_add_item call, and
its finfo element has reasonable looking contents that match what I
expected for this protocol.  The tree's last_child appears to be changed
identically for the AMIN dissector (which works) and for my dissector
(which doesn't) when I flip the #define AMIN macro to #undef AMIN and
rebuild the plugin.

I've included a code snippet from the dissector below.

#ifndef AMIN
static void
dissect_x2d(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	static guint32 packetCounter = 0;
	static proto_item* x2d_item = NULL;
	proto_item* x2d_sub_item = NULL;
	static proto_tree* x2d_tree = NULL;
	static proto_tree* x2d_header_tree = NULL;
	ParserNode* topClonePtr = 0;

	ParseInfo* regPtr; /* To retain the result of the parse
operation */

	guint32 ofst = 0; /* Tracks through tvb */
	/* Debug only */
#ifdef DBG
	if (bailoutPacket <= ++packetCounter)
	{
		return;
	}
#endif
	/* Debug only */

	if (check_col(pinfo->cinfo, COL_PROTOCOL))
	{
		col_set_str(pinfo->cinfo, COL_PROTOCOL, "x2d");
	}
	/* Clear out stuff in the info column */
	if (check_col(pinfo->cinfo,COL_INFO))
	{
		col_clear(pinfo->cinfo,COL_INFO);
	}

	if (tree)
	{
		x2d_item = proto_tree_add_item(tree, proto_x2d, tvb, 0,
-1, FALSE);
		return;
	}

I'd appreciate any help possible on this.



Steve Dix
407-399-5578, Fax 407-249-3599
steven.e.dix@xxxxxxxxxx