Ethereal-dev: Re: [Ethereal-dev] Adding Dissector

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

From: "Lars Roland" <Lars.Roland@xxxxxxx>
Date: Mon, 06 Feb 2006 19:45:31 +0100
Am 03.02.2006, 18:40 Uhr, schrieb Jasim Tariq <jasimtariqjt@xxxxxxxxxxx>:


But Now Im back to the same story. I get an error similar to the one I got
when I installed the dissecgtor as a plugin. Ethereal does not start. On the
sratrup it gives me these errors:

1)  A message box appears with box title "error" and the following content:
"unspecified fatal error encountered, aborting."

Pressing OK gives another error:
2) Another message box pops up with title"Microsoft Visual C++ Runtime
Library" and the following content:
"Runtime Error!
Program: C:\Program Files\Ethereal\ethereal.exe
This application has requested the runtime to terminate it in an unusual
way.
Please contact the application's support team for more information."

The message boxes are also attached with this email.
Please help. Im almost there. I guess...

I'm glad you didn't sent them as bmp. But anyway, they doesn't tell anything about the reason of the crash.

OK. I should have had a closer look on your source before.

I noticed two issues. The first makes ethereal crash:
There is already a protocol registered as "srt". It is part of the h223 plugin.

Resolution: Register your protocol with a different name, e.g.:
proto_srp = proto_register_protocol("Server Relay Protocol", "SERV-RP", "serv-rp");

The strange thing here is that proto_register_protocol should print an useful error message indicating the reason of the error. Instead, ethereal just crashes.


The second issue might explain some of the strange behaviour like dissection working only under certain circumstances.
From Ethereal Developers Guide:

Example 8.3. Plugin Handoff.


void
proto_reg_handoff_foo(void)
{
	static int Initialized=FALSE;

	if (!Initialized) {
		foo_handle = create_dissector_handle(dissect_foo, proto_foo);
		dissector_add("udp.port", global_foo_port, foo_handle);
	}
}

So your reg_handoff routine should be:

void
proto_reg_handoff_srp(void)
{
	static int srp_initialized = FALSE;
	dissector_handle_t srp_handle;

	if(!srp_initialized) {
		srp_handle = create_dissector_handle(dissect_srp, proto_srp);
		dissector_add("tcp.port", TCP_PORT_SRP, srp_handle);
	}
}

Regards,
Lars