Ethereal-dev: Re: [Ethereal-dev] MGCP plugin

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

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Tue, 14 Nov 2000 23:16:45 -0800
On Thu, Nov 09, 2000 at 01:57:21PM +0100, andreas.sikkema@xxxxxxxxxxx wrote:
> If only you could call an Ethereal basic function which returns the address 
> of the protocol dissector from a plugin, f.i.:
>   dissector_q931 = get_dissector_address("Q.931");

Well, you can't do things in *exactly* that fashion.

However, you now *can*, as of my recent checkin, do

	static dissector_handle_t sdp_handle;

and do

	sdp_handle = find_dissector("sdp");

in a dissector's "reg_handoff" routine and then do

	call_dissector(sdp_handle, tvb, pinfo, tree);

to call that dissector with the specified arguments.

There's also an "old_call_dissector()" routine, which takes old-style
dissector arguments and does the appropriate conversion.

Dissectors would be registered in the dissector's "register" routine,
with a call such as

	register_dissector("sdp", dissect_sdp);

(I don't support registering old-style dissectors - I'd prefer that
people tvbuffify their dissectors, but, if a dissector needs to be
registered soon but a tvbuffication would take a long time, an
"old_register_dissector()" could be added, and "call_dissector()" could
be made to do the appropriate argument translation (and
"old_call_dissector()" made not to do it if an old-style dissector is
being called.)

(The reason why you find the dissector in the "reg_handoff" routine is
because you can't rely on "find_dissector()" working until the
"register" routine for the dissector you're finding has been called; if
you were to use "find_dissector()" in a "register" routine, that
wouldn't work unless that "register" routine was called after the
"register" routine for the dissector you're finding, which is not
guaranteed to happen.)

Calling through a handle could, with some additional work, let
"{old_}call_dissector()" - and "{old_}dissector_try_port()" and
"{old_"dissector_try_heuristic()" - do the checks currently done by
"{OLD_}CHECK_DISPLAY_AS_DATA()" and do the setting of
"pinfo->current_proto", so that dissectors won't all have to do that
stuff themselves.

(I have some ideas about how to do this, by

	having "proto_register_protocol()" take an abbreviation - of the
	sort that would be put in, for example, "pinfo->current_proto" -
	as an argument;

	having the calls to register dissectors take an index returned
	by "proto_register_protocol()" as an argument.

The abbreviation could be used elsewhere as well, e.g. in the "Decoding"
tab of the "Edit->Protocols" dialog box, and in a GUI for constructing
protocol filters.  Watch this space.)

The SDP dissector now registers itself; "dissect_sdp()" is now static to
"packet-sdp.c", and is always called through a handle.