Ethereal-dev: Re: [Ethereal-dev] compare_proto_id taking up 20% of Ethereal's time

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

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Sun, 16 Nov 2003 00:35:21 -0800
On Sat, Nov 15, 2003 at 10:45:20PM -0800, Richard Sharpe wrote:
> We seem to be doing some silly things ... while it is useful to keep the 
> protocols in a glist, because we need to iterate over them, I don't see 
> why we are doing this:
> 
>         if (handle->proto_index != -1 &&
>             !proto_is_protocol_enabled(handle->proto_index)) {
>                 /*
>                  * The protocol isn't enabled.
>                  */
>                 return 0;
>         }
> 
> proto_index should be a void * that actually points to an instance of a 
> protocol_t. That way we can, in the epan/proto.c routines, simply 
> dereference it to get at the fields we need. 

No, we should replace "proto_index" with a "protocol_t *", and give it a
name that doesn't contain "index" (as it's a pointer, not an index).

A null "protocol_t" pointer would be equivalent to -1 as "proto_index". 
A "protocol_t" contains a protocol index, so
"dissector_handle_get_protocol_index()" could still work.

A dissector_handle_t is opaque outside "epan/packet.c", so we don't have
to worry about dragging in extra include files if we add a "protocol_t
*" to the dissector handle.  It does, however, require that we export
"protocol_t" from "epan/proto.c" to "epan/packet.c".