Ethereal-dev: [ethereal-dev] Old-style and tvbuffified dissectors can now be registered

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: Sun, 6 Aug 2000 20:35:43 -0700
I just checked in some changes to:

	rename the current routines for registering dissectors for
	ports, and heuristic dissectors, by adding "old_" to the
	beginnings of their names;

	add new routines, with the original names, that take a pointer
	to a tvbuffified dissector as the dissector-pointer argument;

	store, as part of the entry in the dissector tables, a flag
	indicating whether the dissector is an old-style or tvbuffified
	dissector;

	rename the current routines for looking up dissectors in tables
	and calling them by adding "old_" to the beginnings of their
	names;

	add new routines, with the original names, that take new-style
	dissector arguments (i.e., arguments including a "tvbuff *",
	rather than "pd" and "offset" arguments, and a "packet_info *"
	rather than a "frame_data *" argument);

	made both the old and new "look up a dissector and, if found,
	call it" routines check whether the dissector is an old-style or
	new-style one and, if the arguments passed to the routine don't
	match the arguments to be passed to the dissector, translate
	them;

	added a dissector type flag to the conversation structure, and
	made its dissector pointer a union, and replaced the routine to
	look for a conversation and, if found, return its dissector
	pointer with routines, one with old-style and one with new-style
	arguments, to look for a conversation and, if found and it has a
	dissector pointer, call the dissector - that routine also does
	argument translation.

This means that one can now have dissectors that take new-style
arguments called, via one of those lookup-and-call routines, from a
dissector that takes old-style arguments, and *vice versa*; this allowed
me to get rid of the hack wherein some new-style dissectors actually
took old-style arguments and translated the arguments themselves.

This should make it more convenient to convert dissectors one at a time;
I shall probably look at converting the IP dissector at some point, and
then will probably convert the TCP and UDP dissectors, unless somebody
else does so first.  (When the TCP and UDP dissectors are converted,
I'll probably also convert the plugin API/API so that plugins are
expected to be new-style dissectors.)

I also renamed "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()", to reflect the fact that the
former should go away once all dissectors have been converted to use
tvbuffs.

Note, BTW, that tvbuffified dissectors do *NOT* have to check, before
fetching data from the frame, whether they're going past the end of the
frame; the tvbuff code does it for you.

(In fact, checking whether they're past the end of the *captured* data
in the frame is the *wrong* thing to do - at least if you're not past
the end of the frame, you *want* the tvbuff code to throw an exception
if you're past the end of the captured data, so that it puts into the
protocol tree an entry that should indicate that it *could've* dissected
more had you used a bigger snapshot length....)