diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2001-12-07 03:39:26 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2001-12-07 03:39:26 +0000 |
commit | f1b64de80e5f4406cc35e7fade4696e8d9b5882e (patch) | |
tree | 633c3b2070f68284390eb2ae4d41784d0056363c | |
parent | 787a331ae6c64dd6413825224010639a1b238fab (diff) |
Dfilter code finds field under *any* parent's subtree, not just
the parent under which the field was registered.
This is the *unoptimized* version, to give developers something
to use while the optimized version is being created.
svn path=/trunk/; revision=4351
-rw-r--r-- | epan/proto.c | 31 | ||||
-rw-r--r-- | epan/proto.h | 10 |
2 files changed, 9 insertions, 32 deletions
diff --git a/epan/proto.c b/epan/proto.c index d2238f9d14..0db8366551 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -1,7 +1,7 @@ /* proto.c * Routines for protocol tree * - * $Id: proto.c,v 1.46 2001/12/03 04:00:15 guy Exp $ + * $Id: proto.c,v 1.47 2001/12/07 03:39:26 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -2567,7 +2567,6 @@ proto_registrar_get_length(int n) /* used when calling proto search functions */ typedef struct { header_field_info *target; - int parent; const guint8 *packet_data; guint packet_len; gboolean halt_on_first_hit; @@ -2590,9 +2589,7 @@ proto_find_protocol_multi(proto_tree* tree, GNodeTraverseFunc callback, g_node_traverse((GNode*)tree, G_IN_ORDER, G_TRAVERSE_ALL, 2, callback, (gpointer*)sinfo); } -/* Calls a traversal function for all subtrees where: - * 1. Subtree is immediate child of root node. That is, subtree is a "protocol" - * 2. Subtree has finfo such that finfo->hfinfo->id == sinfo->parent +/* Calls a traversal function for all subtrees. */ static gboolean traverse_subtree_for_field(GNode *node, gpointer data) @@ -2601,12 +2598,10 @@ traverse_subtree_for_field(GNode *node, gpointer data) proto_tree_search_info *sinfo = (proto_tree_search_info*) data; if (fi) { /* !fi == the top most container node which holds nothing */ - if (fi->hfinfo->id == sinfo->parent) { g_node_traverse(node, G_IN_ORDER, G_TRAVERSE_ALL, -1, sinfo->traverse_func, sinfo); if (sinfo->result.node) return sinfo->halt_on_first_hit; /* halt? continue? */ - } } return FALSE; /* keep traversing */ } @@ -2649,7 +2644,6 @@ proto_check_for_protocol_or_field(proto_tree* tree, int id) sinfo.target = hfinfo; sinfo.result.node = NULL; - sinfo.parent = -1; sinfo.traverse_func = check_for_protocol_or_field_id; sinfo.halt_on_first_hit = TRUE; @@ -2658,15 +2652,7 @@ proto_check_for_protocol_or_field(proto_tree* tree, int id) proto_find_protocol_multi(tree, check_for_protocol_or_field_id, &sinfo); } else { - /* find the field's parent protocol */ - sinfo.parent = proto_registrar_get_parent(id); - - /* Go through each protocol subtree, checking if the protocols - * is the parent protocol of the field that we're looking for. - * We may have protocols that occur more than once (e.g., IP in IP), - * so we do indeed have to check all protocol subtrees, looking - * for the parent protocol. That's why proto_find_protocol() - * is not used --- it assumes a protocol occurs only once. */ + /* Go through each protocol subtree. */ g_node_traverse((GNode*)tree, G_IN_ORDER, G_TRAVERSE_ALL, 2, traverse_subtree_for_field, &sinfo); } @@ -2721,7 +2707,6 @@ proto_get_finfo_ptr_array(proto_tree *tree, int id) sinfo.target = hfinfo; sinfo.result.ptr_array = NULL; - sinfo.parent = -1; sinfo.traverse_func = get_finfo_ptr_array; sinfo.halt_on_first_hit = FALSE; @@ -2730,15 +2715,7 @@ proto_get_finfo_ptr_array(proto_tree *tree, int id) proto_find_protocol_multi(tree, get_finfo_ptr_array, &sinfo); } else { - /* find the field's parent protocol */ - sinfo.parent = proto_registrar_get_parent(id); - - /* Go through each protocol subtree, checking if the protocols - * is the parent protocol of the field that we're looking for. - * We may have protocols that occur more than once (e.g., IP in IP), - * so we do indeed have to check all protocol subtrees, looking - * for the parent protocol. That's why proto_find_protocol() - * is not used --- it assumes a protocol occurs only once. */ + /* Go through each protocol subtree. */ sinfo.traverse_func = get_finfo_ptr_array; g_node_traverse((GNode*)tree, G_IN_ORDER, G_TRAVERSE_ALL, 2, traverse_subtree_for_field, &sinfo); diff --git a/epan/proto.h b/epan/proto.h index 8f031b905b..57ed884705 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -1,7 +1,7 @@ /* proto.h * Definitions for protocol display * - * $Id: proto.h,v 1.23 2001/12/03 04:00:15 guy Exp $ + * $Id: proto.h,v 1.24 2001/12/07 03:39:26 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -35,12 +35,14 @@ # include <winsock.h> #endif +#include <glib.h> + #include "ipv4.h" #include "nstime.h" #include "tvbuff.h" #include "ftypes/ftypes.h" -/* needs glib.h */ + typedef GNode proto_tree; typedef GNode proto_item; struct value_string; @@ -517,9 +519,7 @@ extern gint proto_registrar_get_length(int n); extern gboolean proto_check_for_protocol_or_field(proto_tree* tree, int id); /* Return GPtrArray* of field_info pointers for all hfindex that appear in - * tree. Assume that a field will only appear under its registered parent's - * subtree, and that the parent's subtree is a child of the - * [empty] root node. */ + * tree. */ extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex); /* Dumps a glossary of the protocol and field registrations to STDOUT */ |