aboutsummaryrefslogtreecommitdiffstats
path: root/proto_hier_stats.c
diff options
context:
space:
mode:
authorgram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>2002-01-02 20:23:46 +0000
committergram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>2002-01-02 20:23:46 +0000
commit73755e034eedc2be7395254145590a75448613e0 (patch)
tree682ddd68c6e070efecd7419286913ec20b10e2d8 /proto_hier_stats.c
parent8d2350875eea58a8fb8b5609f4057e8f4df93566 (diff)
A proper fix for pulling the header_field_info* from a stat_node.
Gerald's fix wasn't the real problem; the original code was wrong in treating a GNode containing a ph_stats_node_t as a GNode that is part of a proto_tree; it worked because of the coincidental layout of the two structs. Now the code has been fixed, and some macros have been added for accessing the GNodes and some variables renamed so that the code is clearer. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4464 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'proto_hier_stats.c')
-rw-r--r--proto_hier_stats.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/proto_hier_stats.c b/proto_hier_stats.c
index c796d7089b..3ee1708ad2 100644
--- a/proto_hier_stats.c
+++ b/proto_hier_stats.c
@@ -1,7 +1,7 @@
/* proto_hier_stats.c
* Routines for calculating statistics based on protocol.
*
- * $Id: proto_hier_stats.c,v 1.9 2001/12/31 20:40:32 gerald Exp $
+ * $Id: proto_hier_stats.c,v 1.10 2002/01/02 20:23:46 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -39,21 +39,24 @@
/* Update the progress bar this many times when scanning the packet list. */
#define N_PROGBAR_UPDATES 100
+#define STAT_NODE_STATS(n) ((ph_stats_node_t*)(n)->data)
+#define STAT_NODE_HFINFO(n) (STAT_NODE_STATS(n)->hfinfo)
+
static GNode*
-find_stat_node(GNode *parent_node, header_field_info *needle_hfinfo)
+find_stat_node(GNode *parent_stat_node, header_field_info *needle_hfinfo)
{
- GNode *needle_node;
- field_info *finfo;
- ph_stats_node_t *stats;
+ GNode *needle_stat_node;
+ header_field_info *hfinfo;
+ ph_stats_node_t *stats;
- needle_node = g_node_first_child(parent_node);
+ needle_stat_node = g_node_first_child(parent_stat_node);
- while (needle_node) {
- finfo = GNODE_PNODE(needle_node);
- if (finfo && finfo->hfinfo && finfo->hfinfo->id == needle_hfinfo->id) {
- return needle_node;
+ while (needle_stat_node) {
+ hfinfo = STAT_NODE_HFINFO(needle_stat_node);
+ if (hfinfo && hfinfo->id == needle_hfinfo->id) {
+ return needle_stat_node;
}
- needle_node = g_node_next_sibling(needle_node);
+ needle_stat_node = g_node_next_sibling(needle_stat_node);
}
/* None found. Create one. */
@@ -66,9 +69,9 @@ find_stat_node(GNode *parent_node, header_field_info *needle_hfinfo)
stats->num_bytes_total = 0;
stats->num_bytes_last = 0;
- needle_node = g_node_new(stats);
- g_node_append(parent_node, needle_node);
- return needle_node;
+ needle_stat_node = g_node_new(stats);
+ g_node_append(parent_stat_node, needle_stat_node);
+ return needle_stat_node;
}
@@ -88,7 +91,7 @@ process_node(proto_item *ptree_node, GNode *parent_stat_node, ph_stats_t *ps, gu
/* Assert that the finfo is related to a protocol, not a field. */
g_assert(finfo->hfinfo->parent == -1);
- stats = stat_node->data;
+ stats = STAT_NODE_STATS(stat_node);
stats->num_pkts_total++;
stats->num_bytes_total += pkt_len;