Ethereal-dev: AW: [Ethereal-dev] dissector_add problem

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: HelgeKruse@xxxxxxxxxxx (Helge Kruse)
Date: Tue, 11 Jan 2005 07:06:58 +0100
Hello Ulf, thanks for reply.

I have removed everything from the registering function, except the
proto_register_protocol:

<COMPLETE_CODE>
void plugin_init(plugin_address_table_t *pat)
{
	plugin_address_table_init(pat);
	protoLogger = proto_register_protocol("My Genial Protocol",
"MyProtocol", "myproto");
}

void plugin_reg_handoff(void)
{
	dissector_handle_t hDissector;
	hDissector = create_dissector_handle(DissectorFunc, protoLogger);
	dissector_add("udp.port", 2001, hDissector);
	dissector_add("udp.port", 2002, hDissector);
}

void DissectFunc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
	char msg[200];
	// detect kind of packet
	wDestPort = pinfo->destport;
	wSourcePort = pinfo->srcport;

	wsprintf(msg, "Dissect(tvb=%x, pinfo=%x, tree=%x, src=%d,
dst=%d)\n", tvb, pinfo, tree, wSourcePort, wDestPort);
	OutputDebugString(msg);
}
</COMPLETE_CODE>

<OUTPUT>
Dissect(tvb=1896c14, pinfo=1896a88, tree=0, src=2001, dst=1305)
Dissect(tvb=1896c14, pinfo=1966330, tree=0, src=2001, dst=1305)
</OUTPUT>

So, the behaviour does not change. I am missing 100 Frames with src=2002 and
dst=1305 and two Frames with src=1305 and dst=2002. They are displayed as
UDP frames.

/Helge

-----Ursprüngliche Nachricht-----
Von: ethereal-dev-bounces@xxxxxxxxxxxx
[mailto:ethereal-dev-bounces@xxxxxxxxxxxx] Im Auftrag von Ulf Lamping
Gesendet: Dienstag, 11. Januar 2005 02:31
An: Ethereal development
Betreff: Re: [Ethereal-dev] dissector_add problem

Helge Kruse wrote:

> Hello,
>
> I write a dissector for a protocol on UDP. In the plugin_init function 
> I call
>
> myProtocol = proto_register_protocol("My Genial Protocol", 
> "MyProtocol", "myproto");
>
> I also register the subtree_array, and the subtree_arrays. In the 
> plugin_reg_handoff function, I call this:
>
> hDissector = create_dissector_handle(DissectorFunc, myProtocol); 
> dissector_add("udp.port", 2002, hDissector); dissector_add("udp.port", 
> 2001, hDissector);
>
> The DissectorFunc is called for all UDP packets from/to UDP port 2001 
> but for none UDP packet from/to port 2002. This does not change, when 
> I exchange the two dissector_add calls or remove the first call.
>
> When I select “Decode As” and assign the protocol to the UDP port 
> 2002, the DissectorFunc is called and the packet is displayed as expected.
>
> I have no clue, what is wrong. Can you give advise?
>
It seems to be ok what you are doing, some other dissectors are doing it 
the same way.

I would think you have a bug somewhere at registering the stuff in your 
proto_register_... function, so Ethereal's internal data gets a bit 
confused.

You may try to reduce the stuff in your registering function to a 
minimum and see if the problem still remains.

Regards, ULFL

_______________________________________________
Ethereal-dev mailing list
Ethereal-dev@xxxxxxxxxxxx
http://www.ethereal.com/mailman/listinfo/ethereal-dev