On Tue, Jan 09, 2001 at 02:44:02PM +0100, micmac@xxxxxxxxxxxxxxx wrote:
> So, should I rely on you and assume that
> dissector_try_port returns false, if there is no
> dissector registered for that port number or is
> currently disabled (DISPLAY_AS_DATA)?
I've just checked in a change to implement that (it also works in
"old_dissector_try_port()").
The change also causes "dissector_try_heuristic()" to check whether a
protocol is enabled before calling a heuristic dissector, and changes
"{old_}call_dissector()" to check whether a protocol is enabled before
calling a dissector - if it's not, it calls "{old_}dissect_data()"
instead.
This should obviate the need for most of the
"{OLD_}CHECK_DISPLAY_AS_DATA()" calls in dissectors; only if a dissector
is called directly, rather than via any of those routines, is that call
necessary.
(We also set "pinfo->current_proto" before calling the dissector in
"{old_}dissector_try_port()" and in "{old_}call_dissector()"; however,
we don't do so in "dissector_try_heuristic()", as we don't know whether
the dissector in question will actually dissect the packet. Perhaps
what we should have is separate routines to
test whether the packet is a packet for a given protocol,
returning TRUE or FALSE, but doing no dissection (and throwing
no exceptions - it must do its own checks of the captured length
of the packet before accessing data in the packet with routines
that might throw an exception, as is currently the case for
stuff in a heuristic dissector that does tests to see whether
the packet is for it or not);
dissect the packet;
with the latter routine always dissecting the packet and returning
nothing. (This might also let us more easily associate a dissector with
a protocol in "proto_register_dissector()", as all dissectors would then
return "void".)