Wireshark-dev: Re: [Wireshark-dev] Dissecting multiple protocol headers in a single plugin
From: Bob Doolittle <Robert.Doolittle@xxxxxxx>
Date: Wed, 04 Apr 2007 10:48:01 -0400
Guy Harris wrote:
What's the code in the subdissector that adds the top-level entry for the protocol?

Sorry - I just realized you asked for the subdissector code, and I sent
the dissector code for the top-level protocol.  At least you can check that
I'm calling dissector_try_port properly...

Here's the subdissector code:

static int
dissect_alp_commonr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
   guint seqno = tvb_get_ntoh24(tvb, 0);

   if (check_col(pinfo->cinfo,COL_INFO)){
	col_append_fstr(pinfo->cinfo, COL_INFO, " CmdSeq=0x%x", seqno);
   }

   if (tree) { // we are being asked for details
	proto_item *ti = NULL;
	proto_tree *alp_commonr_tree = NULL;

	ti = proto_tree_add_item(tree, proto_alp_commonr, tvb, 0,
				 sizeof(struct n_basic_cmd), FALSE);
	proto_item_append_text(ti, ", CmdSeq: 0x%x", seqno);
	alp_commonr_tree = proto_item_add_subtree(ti, ett_alp_commonr);
	proto_tree_add_item(alp_commonr_tree, hf_alp_commonr_seq_num, tvb,
			    OFFANDSIZE(n_basic_cmd, cmd_seq),
			    FALSE);
	proto_tree_add_item(alp_commonr_tree, hf_alp_commonr_x, tvb,
			    OFFANDSIZE(n_basic_cmd, x),
			    FALSE);
	proto_tree_add_item(alp_commonr_tree, hf_alp_commonr_y, tvb,
			    OFFANDSIZE(n_basic_cmd, y),
			    FALSE);
	proto_tree_add_item(alp_commonr_tree, hf_alp_commonr_width, tvb,
			    OFFANDSIZE(n_basic_cmd, width),
			    FALSE);
	proto_tree_add_item(alp_commonr_tree, hf_alp_commonr_height, tvb,
			    OFFANDSIZE(n_basic_cmd, height),
			    FALSE);
   }
   return(sizeof(struct n_basic_cmd));
}	


I get the COL_INFO update, and I can trace that the code is going into
the branch where it's making the proto_tree_add_item() calls (and verified
that proto_alp_commonr is getting registered/initialized), but none of
that appears...

-Bob