From dffa2a989aab61cb9470154a8f7239dcd936f851 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 31 Oct 2001 05:59:20 +0000 Subject: [PATCH] Get rid of a bunch of stuff that was there to support non-tvbuffified dissectors and that's no longer needed. svn path=/trunk/; revision=4112 --- epan/conversation.c | 40 ++++----------------- epan/conversation.h | 14 +++----- epan/packet.c | 84 +++++++-------------------------------------- epan/packet.h | 15 ++++---- epan/proto.h | 9 +---- gtk/decode_as_dlg.c | 27 +++++---------- packet-data.c | 16 ++------- packet-socks.c | 5 +-- 8 files changed, 43 insertions(+), 167 deletions(-) diff --git a/epan/conversation.c b/epan/conversation.c index 214f1d3c1e8..ce8c99c3ac7 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.13 2001/09/03 10:33:12 guy Exp $ + * $Id: conversation.c,v 1.14 2001/10/31 05:59:19 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -463,7 +463,7 @@ conversation_new(address *addr1, address *addr2, port_type ptype, conversation->data_list = NULL; /* clear dissector pointer */ - conversation->dissector.new_d = NULL; + conversation->dissector = NULL; /* set the options and key pointer */ conversation->options = options; @@ -900,23 +900,11 @@ conversation_delete_proto_data(conversation_t *conv, int proto) conv->data_list = g_slist_remove(conv->data_list, item); } -/* - * Set the dissector for a conversation. - */ -void -old_conversation_set_dissector(conversation_t *conversation, - old_dissector_t dissector) -{ - conversation->is_old_dissector = TRUE; - conversation->dissector.old_d = dissector; -} - void conversation_set_dissector(conversation_t *conversation, dissector_t dissector) { - conversation->is_old_dissector = FALSE; - conversation->dissector.new_d = dissector; + conversation->dissector = dissector; } /* @@ -937,25 +925,9 @@ try_conversation_dissector(address *addr_a, address *addr_b, port_type ptype, port_b, 0); if (conversation != NULL) { - if (conversation->is_old_dissector) { - if (conversation->dissector.old_d == NULL) - return FALSE; - - /* - * New dissector calling old dissector; use - * "tvb_compat()" to remap. - * - * "is_old_dissector" won't be set unless - * "dissector.old_d" is set. - */ - tvb_compat(tvb, &pd, &offset); - (*conversation->dissector.old_d)(pd, offset, pinfo->fd, - tree); - } else { - if (conversation->dissector.new_d == NULL) - return FALSE; - (*conversation->dissector.new_d)(tvb, pinfo, tree); - } + if (conversation->dissector == NULL) + return FALSE; + (*conversation->dissector)(tvb, pinfo, tree); return TRUE; } return FALSE; diff --git a/epan/conversation.h b/epan/conversation.h index 4e278627629..c881eb18529 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.6 2001/09/03 10:33:12 guy Exp $ + * $Id: conversation.h,v 1.7 2001/10/31 05:59:19 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -55,13 +55,9 @@ typedef struct conversation_key { 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 */ - gboolean is_old_dissector; /* XXX - nuke when everybody tvbuffified */ - union { - old_dissector_t old_d; - dissector_t new_d; - } dissector; /* protocol dissector client can associate with conversation */ + 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 */ guint options; /* wildcard flags */ conversation_key *key_ptr; /* pointer to the key for this conversation */ } conversation_t; @@ -79,8 +75,6 @@ void conversation_add_proto_data(conversation_t *conv, int proto, void *conversation_get_proto_data(conversation_t *conv, int proto); void conversation_delete_proto_data(conversation_t *conv, int proto); -void old_conversation_set_dissector(conversation_t *conversation, - old_dissector_t dissector); void conversation_set_dissector(conversation_t *conversation, dissector_t dissector); gboolean diff --git a/epan/packet.c b/epan/packet.c index 6b53e6fe8cd..2dcf91a3395 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.36 2001/06/29 09:46:54 guy Exp $ + * $Id: packet.c,v 1.37 2001/10/31 05:59:19 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -216,22 +216,9 @@ dissect_packet(tvbuff_t **p_tvb, union wtap_pseudo_header *pseudo_header, static GHashTable *dissector_tables = NULL; -/* - * XXX - for now, we support having both "old" dissectors, with packet - * data pointer, packet offset, frame_data pointer, and protocol tree - * pointer arguments, and "new" dissectors, with tvbuff pointer, - * packet_info pointer, and protocol tree pointer arguments. - * - * Nuke this and go back to storing a pointer to the dissector when - * the last old-style dissector is gone. - */ typedef struct { - gboolean is_old_dissector; - union { - old_dissector_t old; - dissector_t new; - } dissector; - int proto_index; + dissector_t dissector; + int proto_index; } dissector_entry_t; struct dtbl_entry { @@ -252,30 +239,6 @@ find_dissector_table(const char *name) return g_hash_table_lookup( dissector_tables, name ); } -/* add an entry, lookup the dissector table for the specified field name, */ -/* if a valid table found, add the subdissector */ -void -old_dissector_add(const char *name, guint32 pattern, old_dissector_t dissector, - int proto) -{ - dissector_table_t sub_dissectors = find_dissector_table( name); - dtbl_entry_t *dtbl_entry; - -/* sanity check */ - g_assert( sub_dissectors); - - dtbl_entry = g_malloc(sizeof (dtbl_entry_t)); - dtbl_entry->current.is_old_dissector = TRUE; - dtbl_entry->current.dissector.old = dissector; - dtbl_entry->current.proto_index = proto; - dtbl_entry->initial = dtbl_entry->current; - proto_set_protocol_dissector(proto, dissector); - -/* do the table insertion */ - g_hash_table_insert( sub_dissectors, GUINT_TO_POINTER( pattern), - (gpointer)dtbl_entry); -} - void dissector_add(const char *name, guint32 pattern, dissector_t dissector, int proto) @@ -287,8 +250,7 @@ dissector_add(const char *name, guint32 pattern, dissector_t dissector, g_assert( sub_dissectors); dtbl_entry = g_malloc(sizeof (dtbl_entry_t)); - dtbl_entry->current.is_old_dissector = FALSE; - dtbl_entry->current.dissector.new = dissector; + dtbl_entry->current.dissector = dissector; dtbl_entry->current.proto_index = proto; dtbl_entry->initial = dtbl_entry->current; proto_set_protocol_dissector(proto, dissector); @@ -335,7 +297,7 @@ dissector_delete(const char *name, guint32 pattern, dissector_t dissector) void dissector_change(const char *name, guint32 pattern, dissector_t dissector, - gboolean old, int proto) + int proto) { dissector_table_t sub_dissectors = find_dissector_table( name); dtbl_entry_t *dtbl_entry; @@ -349,8 +311,7 @@ dissector_change(const char *name, guint32 pattern, dissector_t dissector, dtbl_entry = g_hash_table_lookup(sub_dissectors, GUINT_TO_POINTER(pattern)); if (dtbl_entry != NULL) { - dtbl_entry->current.is_old_dissector = old; - dtbl_entry->current.dissector.new = dissector ? dissector : dissect_null; + dtbl_entry->current.dissector = dissector ? dissector : dissect_null; dtbl_entry->current.proto_index = proto; return; } @@ -364,11 +325,8 @@ dissector_change(const char *name, guint32 pattern, dissector_t dissector, return; dtbl_entry = g_malloc(sizeof (dtbl_entry_t)); - dtbl_entry->initial.is_old_dissector = FALSE; - dtbl_entry->initial.dissector.old = NULL; dtbl_entry->initial.proto_index = -1; - dtbl_entry->current.is_old_dissector = old; - dtbl_entry->current.dissector.new = dissector; + dtbl_entry->current.dissector = dissector; dtbl_entry->current.proto_index = proto; /* do the table insertion */ @@ -376,6 +334,7 @@ dissector_change(const char *name, guint32 pattern, dissector_t dissector, (gpointer)dtbl_entry); } +/* Reset a dissector in a sub-dissector table to its initial value. */ void dissector_reset(const char *name, guint32 pattern) { @@ -397,7 +356,7 @@ dissector_reset(const char *name, guint32 pattern) /* * Found - is there an initial value? */ - if (dtbl_entry->initial.dissector.new != NULL) { + if (dtbl_entry->initial.dissector != NULL) { dtbl_entry->current = dtbl_entry->initial; } else { g_hash_table_remove(sub_dissectors, GUINT_TO_POINTER(pattern)); @@ -443,21 +402,11 @@ dissector_try_port(dissector_table_t sub_dissectors, guint32 port, saved_proto = pinfo->current_proto; saved_match_port = pinfo->match_port; pinfo->match_port = port; - if (dtbl_entry->current.is_old_dissector) { - /* - * New dissector calling old dissector; use - * "tvb_compat()" to remap. - */ - tvb_compat(tvb, &pd, &offset); - (*dtbl_entry->current.dissector.old)(pd, offset, pinfo->fd, - tree); - } else { - if (dtbl_entry->current.proto_index != -1) { - pinfo->current_proto = - proto_get_protocol_short_name(dtbl_entry->current.proto_index); - } - (*dtbl_entry->current.dissector.new)(tvb, pinfo, tree); + if (dtbl_entry->current.proto_index != -1) { + pinfo->current_proto = + proto_get_protocol_short_name(dtbl_entry->current.proto_index); } + (*dtbl_entry->current.dissector)(tvb, pinfo, tree); pinfo->current_proto = saved_proto; pinfo->match_port = saved_match_port; return TRUE; @@ -465,13 +414,6 @@ dissector_try_port(dissector_table_t sub_dissectors, guint32 port, return FALSE; } -gboolean -dissector_get_old_flag (dtbl_entry_t *dtbl_entry) -{ - g_assert(dtbl_entry); - return(dtbl_entry->current.is_old_dissector); -} - gint dissector_get_proto (dtbl_entry_t *dtbl_entry) { diff --git a/epan/packet.h b/epan/packet.h index 31e0dd0eb58..8d3243da1e4 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.35 2001/06/29 09:46:54 guy Exp $ + * $Id: packet.h,v 1.36 2001/10/31 05:59:19 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -22,7 +22,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #ifndef __PACKET_H__ #define __PACKET_H__ @@ -46,7 +45,8 @@ /* Useful when highlighting regions inside a dissect_*() function. With this * macro, you can highlight from an arbitrary offset to the end of the * packet (which may come before the end of the frame). - * See old_dissect_data() for an example. + * See the SMB dissector for an example. + * XXX - this goes when the SMB dissector is fully tvbuffified. */ #define END_OF_FRAME (pi.captured_len - offset) @@ -101,7 +101,6 @@ typedef void (*DATFunc) (gchar *table_name, gpointer key, gpointer value, gpoint /* Opaque structure - provides type checking but no access to components */ typedef struct dtbl_entry dtbl_entry_t; -gboolean dissector_get_old_flag (dtbl_entry_t *entry); gint dissector_get_proto (dtbl_entry_t * entry); gint dissector_get_initial_proto (dtbl_entry_t * entry); void dissector_table_foreach_changed (char *name, DATFunc func, gpointer user_data); @@ -113,8 +112,6 @@ dissector_table_t register_dissector_table(const char *name); /* Add a sub-dissector to a dissector table. Called by the protocol routine */ /* that wants to register a sub-dissector. */ -void old_dissector_add(const char *abbrev, guint32 pattern, - old_dissector_t dissector, int proto); void dissector_add(const char *abbrev, guint32 pattern, dissector_t dissector, int proto); @@ -122,9 +119,10 @@ void dissector_add(const char *abbrev, guint32 pattern, /* that wants to de-register a sub-dissector. */ void dissector_delete(const char *name, guint32 pattern, dissector_t dissector); -/* Reset a dissector in a sub-dissector table to its initial value. */ void dissector_change(const char *abbrev, guint32 pattern, - dissector_t dissector, gboolean old, int proto); + dissector_t dissector, int proto); + +/* Reset a dissector in a sub-dissector table to its initial value. */ void dissector_reset(const char *name, guint32 pattern); /* Look for a given port in a given dissector table and, if found, call @@ -228,7 +226,6 @@ void init_all_protocols(void); */ void dissect_packet(tvbuff_t **p_tvb, union wtap_pseudo_header *pseudo_header, const u_char *pd, frame_data *fd, proto_tree *tree); -void old_dissect_data(const u_char *, int, frame_data *, proto_tree *); void dissect_data(tvbuff_t *tvb, int, packet_info *pinfo, proto_tree *tree); diff --git a/epan/proto.h b/epan/proto.h index dedc478b2e0..68ab9cca661 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -1,7 +1,7 @@ /* proto.h * Definitions for protocol display * - * $Id: proto.h,v 1.17 2001/09/14 07:10:10 guy Exp $ + * $Id: proto.h,v 1.18 2001/10/31 05:59:19 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -56,13 +56,6 @@ struct value_string; #define TFS(x) (struct true_false_string*)(x) /* check protocol activation */ -#define OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree) {\ - if (!proto_is_protocol_enabled(index)) { \ - old_dissect_data(pd, offset, fd, tree); \ - return; \ - } \ - } - #define CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree) { \ if (!proto_is_protocol_enabled(index)) { \ dissect_data(tvb, 0, pinfo, tree); \ diff --git a/gtk/decode_as_dlg.c b/gtk/decode_as_dlg.c index d31b70e4517..e000ac1b3c6 100644 --- a/gtk/decode_as_dlg.c +++ b/gtk/decode_as_dlg.c @@ -1,6 +1,6 @@ /* decode_as_dlg.c * - * $Id: decode_as_dlg.c,v 1.10 2001/08/21 07:03:50 guy Exp $ + * $Id: decode_as_dlg.c,v 1.11 2001/10/31 05:59:20 guy Exp $ * * Routines to modify dissector tables on the fly. * @@ -20,7 +20,6 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * */ #ifdef HAVE_CONFIG_H @@ -112,9 +111,8 @@ enum srcdst_type { */ #define E_CLIST_S_PROTO_NAME 0 #define E_CLIST_S_TABLE 1 -#define E_CLIST_S_ISOLD 2 /* The following is for debugging in decode_add_to_clist */ -#define E_CLIST_S_ISCONV 3 +#define E_CLIST_S_ISCONV 2 #define E_CLIST_S_MAX E_CLIST_S_ISCONV #define E_CLIST_S_COLUMNS (E_CLIST_S_MAX + 1) @@ -482,21 +480,17 @@ static void decode_change_one_dissector (gchar *table_name, gint selector, GtkCList *clist) { dissector_t dissector; - gboolean old; - gchar *abbrev, *oldstring; + gchar *abbrev; gint row, proto_num; if (!clist->selection) { proto_num = -1; abbrev = "(NULL)"; - old = FALSE; dissector = NULL; } else { row = GPOINTER_TO_INT(clist->selection->data); proto_num = GPOINTER_TO_INT(gtk_clist_get_row_data(clist, row)); gtk_clist_get_text(clist, row, E_CLIST_S_PROTO_NAME, &abbrev); - gtk_clist_get_text(clist, row, E_CLIST_S_ISOLD, &oldstring); - old = (strcmp(oldstring, "TRUE") == 0); dissector = proto_get_protocol_dissector(proto_num); if ((proto_num != -1) && (dissector == NULL)) { simple_dialog(ESD_TYPE_CRIT, NULL, @@ -508,7 +502,7 @@ decode_change_one_dissector (gchar *table_name, gint selector, GtkCList *clist) if (strcmp(abbrev, "(default)") == 0) { dissector_reset(table_name, selector); } else { - dissector_change(table_name, selector, dissector, old, proto_num); + dissector_change(table_name, selector, dissector, proto_num); } } @@ -542,11 +536,10 @@ decode_debug (GtkCList *clist, gchar *leadin) row = GPOINTER_TO_INT(clist->selection->data); gtk_clist_get_text(clist, row, E_CLIST_S_PROTO_NAME, &text[E_CLIST_S_PROTO_NAME]); gtk_clist_get_text(clist, row, E_CLIST_S_TABLE, &text[E_CLIST_S_TABLE]); - gtk_clist_get_text(clist, row, E_CLIST_S_ISOLD, &text[E_CLIST_S_ISOLD]); proto_num = GPOINTER_TO_INT(gtk_clist_get_row_data(clist, row)); - sprintf(string, "%s clist row %d: proto %d, name %s, table %s, old %s", + sprintf(string, "%s clist row %d: proto %d, name %s, table %s", leadin, row, proto_num, text[E_CLIST_S_PROTO_NAME], - text[E_CLIST_S_TABLE], text[E_CLIST_S_ISOLD]); + text[E_CLIST_S_TABLE]); } else { sprintf(string, "%s clist row (none), aka do not decode", leadin); } @@ -1013,7 +1006,7 @@ decode_add_to_clist (gchar *table_name, gpointer key, gpointer value, gpointer user_data) { GtkCList *clist; - gchar *proto_name, *isold, *isconv; + gchar *proto_name, *isconv; gchar *text[E_CLIST_S_COLUMNS]; gint proto, row; decode_build_clist_info_t *info; @@ -1025,11 +1018,9 @@ decode_add_to_clist (gchar *table_name, gpointer key, clist = info->clist; if (info->conv) { proto = conv_dissector_get_proto(value); - isold = "FALSE"; isconv = "TRUE"; } else { proto = dissector_get_proto(value); - isold = dissector_get_old_flag(value) ? "TRUE" : "FALSE"; isconv = "FALSE"; } proto_name = proto_get_protocol_short_name(proto); @@ -1041,7 +1032,6 @@ decode_add_to_clist (gchar *table_name, gpointer key, text[E_CLIST_S_PROTO_NAME] = proto_name; text[E_CLIST_S_TABLE] = table_name; - text[E_CLIST_S_ISOLD] = isold; text[E_CLIST_S_ISCONV] = isconv; row = gtk_clist_prepend(clist, text); gtk_clist_set_row_data(clist, row, GINT_TO_POINTER(proto)); @@ -1066,7 +1056,7 @@ decode_clist_menu_start (GtkWidget *page, GtkCList **clist_p, GtkWidget **scrolled_win_p) { gchar *titles[E_CLIST_S_COLUMNS] = {"Short Name", "Table Name", - "Is Old", "Is Conversation"}; + "Is Conversation"}; GtkCList *clist; GtkWidget *window; gint column; @@ -1107,7 +1097,6 @@ decode_clist_menu_finish (GtkCList *clist) text[E_CLIST_S_PROTO_NAME] = "(default)"; text[E_CLIST_S_TABLE] = "(none)"; - text[E_CLIST_S_ISOLD] = "(who cares)"; text[E_CLIST_S_ISCONV] = "(who cares)"; row = gtk_clist_prepend(clist, text); gtk_clist_set_row_data(clist, row, GINT_TO_POINTER(-1)); diff --git a/packet-data.c b/packet-data.c index 46da3a1c6b8..bdb2545b63b 100644 --- a/packet-data.c +++ b/packet-data.c @@ -2,12 +2,11 @@ * Routines for raw data (default case) * Gilbert Ramirez * - * $Id: packet-data.c,v 1.21 2001/01/03 06:55:27 guy Exp $ + * $Id: packet-data.c,v 1.22 2001/10/31 05:59:18 guy Exp $ * * Ethereal - Network traffic analyzer - * By Gerald Combs + * By Gerald Combs * Copyright 1998 Gerald Combs - * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -40,17 +39,6 @@ */ int proto_data = -1; -/* Remove this once all dissectors are converted to use tvbuffs */ -void -old_dissect_data(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) -{ - if (IS_DATA_IN_FRAME(offset) && tree) { - proto_tree_add_protocol_format(tree, proto_data, NullTVB, offset, - END_OF_FRAME, "Data (%d byte%s)", END_OF_FRAME, - plurality(END_OF_FRAME, "", "s")); - } -} - void dissect_data(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) { diff --git a/packet-socks.c b/packet-socks.c index b52ca16ecc1..60b4bbf78f9 100644 --- a/packet-socks.c +++ b/packet-socks.c @@ -2,7 +2,7 @@ * Routines for socks versions 4 &5 packet dissection * Copyright 2000, Jeffrey C. Foster * - * $Id: packet-socks.c,v 1.26 2001/10/30 10:40:38 guy Exp $ + * $Id: packet-socks.c,v 1.27 2001/10/31 05:59:18 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -858,7 +858,8 @@ display_ping_and_tracert(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr col_append_str(pinfo->fd, COL_INFO, ", Results"); if ( tree){ - proto_tree_add_text(tree, tvb, offset, END_OF_FRAME, + proto_tree_add_text(tree, tvb, offset, + tvb_length_remaining(tvb, offset), (hash_info->command == PING_COMMAND) ? "Ping Results:" : "Traceroute Results");