diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-11-27 07:13:32 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-11-27 07:13:32 +0000 |
commit | 07b2709f8a32951cc2503d2e048d662a01cb472c (patch) | |
tree | 21d265bf7402a2739905bd87227383ae0a9f78ab /epan | |
parent | fd456eaf0b5af46449882983b95529e073fd989f (diff) | |
download | wireshark-07b2709f8a32951cc2503d2e048d662a01cb472c.tar.gz wireshark-07b2709f8a32951cc2503d2e048d662a01cb472c.tar.bz2 wireshark-07b2709f8a32951cc2503d2e048d662a01cb472c.zip |
Change "conversation_set_dissector()" to take a dissector handle, rather
than a pointer to a dissector function, as an argument.
This means that the conversation dissector is called through
"call_dissector()", so the dissector itself doesn't have to worry about
checking whether the protocol is enabled or setting
"pinfo->current_proto", so get rid of the code that does that in
conversation dissectors. Also, make the conversation dissectors static.
Get rid of some direct calls to dissectors; replace them with calls
through handles, and, again, get rid of code to check whether a protocol
is enabled and set "pinfo->current_proto" where that code isn't needed.
Make those dissectors static if they aren't already static.
Add a routine "create_dissector_handle()" to create a dissector handle
without registering it by name, if the dissector isn't used outside the
module in which it's defined.
svn path=/trunk/; revision=4281
Diffstat (limited to 'epan')
-rw-r--r-- | epan/conversation.c | 15 | ||||
-rw-r--r-- | epan/conversation.h | 7 | ||||
-rw-r--r-- | epan/packet.c | 16 | ||||
-rw-r--r-- | epan/packet.h | 6 |
4 files changed, 32 insertions, 12 deletions
diff --git a/epan/conversation.c b/epan/conversation.c index 036a94ddc2..527119fe65 100644 --- a/epan/conversation.c +++ b/epan/conversation.c @@ -1,7 +1,7 @@ /* conversation.c * Routines for building lists of packets that are part of a "conversation" * - * $Id: conversation.c,v 1.15 2001/11/21 01:00:37 guy Exp $ + * $Id: conversation.c,v 1.16 2001/11/27 07:13:31 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -462,8 +462,8 @@ conversation_new(address *addr1, address *addr2, port_type ptype, conversation->index = new_index; conversation->data_list = NULL; -/* clear dissector pointer */ - conversation->dissector = NULL; +/* clear dissector handle */ + conversation->dissector_handle = NULL; /* set the options and key pointer */ conversation->options = options; @@ -902,9 +902,9 @@ conversation_delete_proto_data(conversation_t *conv, int proto) void conversation_set_dissector(conversation_t *conversation, - dissector_t dissector) + dissector_handle_t handle) { - conversation->dissector = dissector; + conversation->dissector_handle = handle; } /* @@ -923,9 +923,10 @@ try_conversation_dissector(address *addr_a, address *addr_b, port_type ptype, port_b, 0); if (conversation != NULL) { - if (conversation->dissector == NULL) + if (conversation->dissector_handle == NULL) return FALSE; - (*conversation->dissector)(tvb, pinfo, tree); + call_dissector(conversation->dissector_handle, tvb, pinfo, + tree); return TRUE; } return FALSE; diff --git a/epan/conversation.h b/epan/conversation.h index bf4c6fb13f..517af05e8f 100644 --- a/epan/conversation.h +++ b/epan/conversation.h @@ -1,7 +1,7 @@ /* conversation.h * Routines for building lists of packets that are part of a "conversation" * - * $Id: conversation.h,v 1.8 2001/11/04 03:55:52 guy Exp $ + * $Id: conversation.h,v 1.9 2001/11/27 07:13:32 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -57,7 +57,8 @@ typedef struct conversation { struct conversation *next; /* pointer to next conversation on hash chain */ guint32 index; /* unique ID for conversation */ GSList *data_list; /* list of data associated with conversation */ - dissector_t dissector; /* protocol dissector client can associate with conversation */ + dissector_handle_t dissector_handle; + /* handle for protocol dissector client associated with conversation */ guint options; /* wildcard flags */ conversation_key *key_ptr; /* pointer to the key for this conversation */ } conversation_t; @@ -76,7 +77,7 @@ extern void *conversation_get_proto_data(conversation_t *conv, int proto); extern void conversation_delete_proto_data(conversation_t *conv, int proto); extern void conversation_set_dissector(conversation_t *conversation, - dissector_t dissector); + dissector_handle_t handle); extern gboolean try_conversation_dissector(address *addr_a, address *addr_b, port_type ptype, guint32 port_a, guint32 port_b, tvbuff_t *tvb, packet_info *pinfo, diff --git a/epan/packet.c b/epan/packet.c index a1701bb38e..ad0e9a69c1 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.42 2001/11/26 05:41:12 hagbard Exp $ + * $Id: packet.c,v 1.43 2001/11/27 07:13:32 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -790,6 +790,20 @@ find_dissector(const char *name) return g_hash_table_lookup(registered_dissectors, name); } +/* Create an anonymous handle for a dissector. */ +dissector_handle_t +create_dissector_handle(dissector_t dissector, int proto) +{ + struct dissector_handle *handle; + + handle = g_malloc(sizeof (struct dissector_handle)); + handle->name = NULL; + handle->dissector = dissector; + handle->proto_index = proto; + + return handle; +} + /* Register a dissector by name. */ void register_dissector(const char *name, dissector_t dissector, int proto) diff --git a/epan/packet.h b/epan/packet.h index c9cfc5bca6..6af0d154af 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.41 2001/11/26 05:41:13 hagbard Exp $ + * $Id: packet.h,v 1.42 2001/11/27 07:13:32 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -194,6 +194,10 @@ extern void register_dissector(const char *name, dissector_t dissector, /* Find a dissector by name. */ extern dissector_handle_t find_dissector(const char *name); +/* Create an anonymous handle for a dissector. */ +extern dissector_handle_t create_dissector_handle(dissector_t dissector, + int proto); + /* Call a dissector through a handle. */ extern void call_dissector(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); |