Ethereal-dev: Re: [Ethereal-dev] [patch] packet-radisu

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Fri, 22 Feb 2002 13:39:05 -0800
On Fri, Feb 22, 2002 at 12:48:01PM -0500, Adam wrote:
> there's updated version. cosmetic change -- forgot to include extern
> for dissect-eap.

> +extern void dissect_eap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
> +

If you're going to call a routine from another module, you shouldn't
put a declaration of the routine into the other module - you should put
it into a header file, and have it included both by the module that
defines the routine and the modules that call the routine, so that if
you change the calling sequence of the routine, the code won't compile
until you change it in the header file.  That way, the code *still*
won't compile until you fix the calls for the new calling sequence;
detecting bugs at compile time is better than detecting them at run
time.

However, in this particular case, there's no need to declare the routine
at all.  There's already a mechanism in Ethereal to use if one dissector
has to directly call another - the called dissector can register itself
by name in its register routine, with a call to "register_dissector()",
and the calling dissector can fetch a handle for that dissector in its
"reg_handoff" routine, with a call to "find_dissector()", and can then
call it with a call to "call_dissector()".

"call_dissector()" does some additional work that's needed when you call
a dissector, such as checking for disabled protocols; it may do more
work that may be necessary in the future.

I checked in your patch, with a change to make the RADIUS dissector use
that mechanism for calling the EAP dissector; I'll be changing the EAPOL
dissector to do so as well.