From 60d6b05e2340ae90c09fbdd2f25b6513131a0bd1 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Fri, 29 Nov 2013 22:47:59 +0000 Subject: Stats_tree enhancements for sorting, averages and burst rate. Bug 9452 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9452) From Deon van der Westhuysen - Bug fix: object leak in stats_tree after a tap reset (for example apply statistics preferences with a stats_tree window open) - Bug fix: correct sample code in README.stats_tree - Add: slash in plug-in name now creates submenu as docs describe (was a bug?) - Add: menu separator before the stat_tree registered plug-ins - Add: stats_tree can now calculate averages for nodes; automatically calculated for range nodes. Add section in README.stats_tree describing averages. - Add: stats_tree can now calculate burst rate of each node (like rate but with a shorter, sliding time window) - Add: sorting for stats_tree plug-ins. Can sort on node name, count, average, min, max values and burst rate. - Add: preferences for stats_tree system (default sort column, burst calc params) - Add: stats_tree window copy to clipboard and export and plain text, csv and XML. - Added sample of new functionality in $srcdir/plugins/stats_tree/pinfo_stats_tree.c - Moved all stats_tree sample plug-ins to "IP Statistics" submenu. svn path=/trunk/; revision=53657 --- epan/stats_tree.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'epan/stats_tree.h') diff --git a/epan/stats_tree.h b/epan/stats_tree.h index 06db45f1dc..23e2c8175b 100644 --- a/epan/stats_tree.h +++ b/epan/stats_tree.h @@ -35,6 +35,24 @@ #define STAT_TREE_ROOT "root" +#define ST_FLG_AVERAGE 0x10000000 /* Calculate overages for nodes, rather than totals */ +#define ST_FLG_ROOTCHILD 0x20000000 /* This node is a direct child of the root node */ +#define ST_FLG_DEF_NOEXPAND 0x01000000 /* This node should not be expanded by default */ +#define ST_FLG_SORT_DESC 0x00800000 /* When sorting, sort ascending instead of decending */ +#define ST_FLG_SORT_TOP 0x00400000 /* When sorting always keep these lines on of list */ +#define ST_FLG_SRTCOL_MASK 0x000F0000 /* Mask for sort column ID */ +#define ST_FLG_SRTCOL_SHIFT 16 /* Number of bits to shift masked result */ + +#define ST_FLG_MASK (ST_FLG_AVERAGE|ST_FLG_ROOTCHILD|ST_FLG_DEF_NOEXPAND|\ + ST_FLG_SORT_TOP|ST_FLG_SORT_DESC|ST_FLG_SRTCOL_MASK) + +#define ST_SORT_COL_NAME 1 /* Sort nodes by node names */ +#define ST_SORT_COL_COUNT 2 /* Sort nodes by node count */ +#define ST_SORT_COL_AVG 3 /* Sort nodes by node average */ +#define ST_SORT_COL_MIN 4 /* Sort nodes by minimum node value */ +#define ST_SORT_COL_MAX 5 /* Sort nodes by maximum node value */ +#define ST_SORT_COL_BURSTRATE 6 /* Sort nodes by burst rate */ + /* obscure information regarding the stats_tree */ typedef struct _stats_tree stats_tree; @@ -168,7 +186,14 @@ WS_DLL_PUBLIC int stats_tree_tick_pivot(stats_tree *st, * using parent_name as parent node (NULL for root). * with_children=TRUE to indicate that the created node will be a parent */ -typedef enum _manip_node_mode { MN_INCREASE, MN_SET } manip_node_mode; +typedef enum _manip_node_mode { + MN_INCREASE, + MN_SET, + MN_AVERAGE, + MN_AVERAGE_NOTICK, + MN_SET_FLAGS, + MN_CLEAR_FLAGS +} manip_node_mode; WS_DLL_PUBLIC int stats_tree_manip_node(manip_node_mode mode, stats_tree *st, const gchar *name, @@ -188,4 +213,26 @@ WS_DLL_PUBLIC int stats_tree_manip_node(manip_node_mode mode, #define zero_stat_node(st,name,parent_id,with_children) \ (stats_tree_manip_node(MN_SET,(st),(name),(parent_id),(with_children),0)) +/* + * Add value to average calculation WITHOUT ticking node. Node MUST be ticked separately! + * + * Intention is to allow code to separately tick node (backward compatibility for plugin) + * and set value to use for averages. Older versions without average support will then at + * least show a count instead of 0. + */ +#define avg_stat_node_add_value_notick(st,name,parent_id,with_children,value) \ +(stats_tree_manip_node(MN_AVERAGE_NOTICK,(st),(name),(parent_id),(with_children),value)) + +/* Tick node and add a new value to the average calculation for this stats node. */ +#define avg_stat_node_add_value(st,name,parent_id,with_children,value) \ +(stats_tree_manip_node(MN_AVERAGE,(st),(name),(parent_id),(with_children),value)) + +/* Set flags for this node. Node created if it does not yet exist. */ +#define stat_node_set_flags(st,name,parent_id,with_children,flags) \ +(stats_tree_manip_node(MN_SET_FLAGS,(st),(name),(parent_id),(with_children),flags)) + +/* Clear flags for this node. Node created if it does not yet exist. */ +#define stat_node_clear_flags(st,name,parent_id,with_children,flags) \ +(stats_tree_manip_node(MN_CLEAR_FLAGS,(st),(name),(parent_id),(with_children),flags)) + #endif /* __STATS_TREE_H */ -- cgit v1.2.1