From bebb63bea9cf58665a31c78abcbbe82658b1e49d Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Thu, 14 Jan 2016 11:47:04 -0800 Subject: Keep comments from stealing hierarchy statistics. If a packet has a comment, the Protocol Hierarchy Statistics dialog will add its stats to a top-level "Packet comments" node instead of the "Frame" node. Add a check for the pkt_comment protocol ID and skip over it if we find it. Affects Wireshark 2.0, 1.12, 1.10, and probably earlier versions. As an alternative we could always force "Frame" to be the first item in the tree. Change-Id: If7cd817071caf6219515f5d8121b3a1a2c0d79a6 Reviewed-on: https://code.wireshark.org/review/13297 Reviewed-by: Gerald Combs --- ui/proto_hier_stats.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'ui/proto_hier_stats.c') diff --git a/ui/proto_hier_stats.c b/ui/proto_hier_stats.c index 4857052496..dea3c3e92c 100644 --- a/ui/proto_hier_stats.c +++ b/ui/proto_hier_stats.c @@ -26,7 +26,8 @@ #include "frame_tvbuff.h" #include "ui/proto_hier_stats.h" #include "ui/progress_dlg.h" -#include +#include "epan/epan_dissect.h" +#include "epan/proto.h" #include @@ -36,6 +37,7 @@ #define STAT_NODE_STATS(n) ((ph_stats_node_t*)(n)->data) #define STAT_NODE_HFINFO(n) (STAT_NODE_STATS(n)->hfinfo) +static int pc_proto_id = -1; static GNode* find_stat_node(GNode *parent_stat_node, header_field_info *needle_hfinfo) @@ -122,7 +124,16 @@ process_tree(proto_tree *protocol_tree, ph_stats_t* ps, guint pkt_len) { proto_node *ptree_node; + /* + * If our first item is a comment, skip over it. This keeps + * us from having a top-level "Packet comments" item that + * steals items from "Frame". + */ ptree_node = ((proto_node *)protocol_tree)->first_child; + if (ptree_node && ptree_node->finfo->hfinfo->id == pc_proto_id) { + ptree_node = ptree_node->next; + } + if (!ptree_node) { return; } @@ -189,6 +200,8 @@ ph_stats_new(capture_file *cf) if (!cf) return NULL; + pc_proto_id = proto_get_id_by_filter_name("pkt_comment"); + /* Initialize the data */ ps = g_new(ph_stats_t, 1); ps->tot_packets = 0; -- cgit v1.2.1