Skip to content

Commit

Permalink
Get rid of a bunch of stuff that was there to support non-tvbuffified
Browse files Browse the repository at this point in the history
dissectors and that's no longer needed.

svn path=/trunk/; revision=4112
  • Loading branch information
guyharris committed Oct 31, 2001
1 parent c132bad commit dffa2a9
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 167 deletions.
40 changes: 6 additions & 34 deletions epan/conversation.c
Original file line number Diff line number Diff line change
@@ -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 <gerald@ethereal.com>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/*
Expand All @@ -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;
Expand Down
14 changes: 4 additions & 10 deletions epan/conversation.h
Original file line number Diff line number Diff line change
@@ -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 <gerald@ethereal.com>
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
84 changes: 13 additions & 71 deletions epan/packet.c
Original file line number Diff line number Diff line change
@@ -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 <gerald@ethereal.com>
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -364,18 +325,16 @@ 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 */
g_hash_table_insert( sub_dissectors, GUINT_TO_POINTER( pattern),
(gpointer)dtbl_entry);
}

/* Reset a dissector in a sub-dissector table to its initial value. */
void
dissector_reset(const char *name, guint32 pattern)
{
Expand All @@ -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));
Expand Down Expand Up @@ -443,35 +402,18 @@ 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;
} else
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)
{
Expand Down
15 changes: 6 additions & 9 deletions epan/packet.h
Original file line number Diff line number Diff line change
@@ -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 <gerald@ethereal.com>
Expand All @@ -22,7 +22,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/


#ifndef __PACKET_H__
#define __PACKET_H__

Expand All @@ -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)

Expand Down Expand Up @@ -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);
Expand All @@ -113,18 +112,17 @@ 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);

/* Add a sub-dissector to a dissector table. Called by the protocol routine */
/* 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
Expand Down Expand Up @@ -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);


Expand Down
9 changes: 1 addition & 8 deletions epan/proto.h
Original file line number Diff line number Diff line change
@@ -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 <gerald@ethereal.com>
Expand Down Expand Up @@ -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); \
Expand Down
Loading

0 comments on commit dffa2a9

Please sign in to comment.