Maybe we should separate display functionality from dissect functionality. I
mean that we would call a "study" method for
conversation/session/subdissection work, and then call one or more display
methods for the actual protocol tree costruction if required.
And maybe we can still provide the situation "as is" for complex protocols
and/or to have all dissector code still functional.
The simplest solution is to define a process_XXX() method for the work which
always needs to be done, and then call one or more display_XXX() method for
displaying the packet internals (or applying display filters). One would
call both methods from within the existing dissect_XXX() method registered
within the protocol:
static void
dissect_PROTO(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
study_PROTO(tvb, pinfo, tree);
if (tree)
display_PROTO(tvb, pinfo, tree);
}
We can tackle more complex protocols by defining per-protocol data
structures which are partly filled in by the study_PROTO() method. One could
have study_PROTO() return a gpointer to such a structure, and have
display_PROTO() use this pointer as 4th argument.
Regards,
Olivier
| -----Original Message-----
| From: Guy Harris
|
| On Dec 16, 2003, at 12:51 PM, Biot Olivier wrote:
|
| > If I remember correctly, one does not need to write an
| > if (tree) { } around all proto_XXX_add_YYY() as this is
| > already dealt with in the proto_XXX_add_YYY() functions,
| > right?
|
| One does not need to do so. However, if you have a large chunk of
| dissection code that only puts stuff into the protocol tree, and
| doesn't get any data or update any offsets necessary for calling
| subdissectors (which is the case for just about everything in a
| dissector that has no subdissectors, and may be true for
| stuff even in
| a dissector that has subdissectors), it might be less
| expensive to skip
| all that work rather than calling the "proto_XXX_add_YYY" functions -
| especially if it's a "proto_XXX_add_YYY_format" function and
| there's a
| significant amount of work involved in preparing the arguments to use
| with the format string.