Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
stats_tree.h
Go to the documentation of this file.
1
11#pragma once
12#include <epan/epan.h>
13#include <epan/packet_info.h>
14#include <epan/tap.h>
15#include <epan/stat_groups.h>
16#include "ws_symbol_export.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif /* __cplusplus */
21
22#define STAT_TREE_ROOT "root"
23#define STATS_TREE_MENU_SEPARATOR "//"
24
25/* stats_tree specific flags. When registering, these are used together
26 * with the TL_ flags defined in tap.h, so make sure they don't overlap!
27 * (Yes, that applies even to the flags that apply to nodes instead of
28 * the entire tree, and should not be passed in stats_tree_register.
29 * XXX - Why? These flags should be reworked at some point.)
30 */
31
32/* Flags on child nodes for internal use only */
33#define ST_FLG_AVERAGE 0x10000000 /* Calculate averages for nodes, rather than totals */
34#define ST_FLG_ROOTCHILD 0x20000000 /* This node is a direct child of the root node */
35
36/* Flags set on child nodes via stat_node_set_flags */
37#define ST_FLG_DEF_NOEXPAND 0x01000000 /* This node should not be expanded by default */
38#define ST_FLG_SORT_TOP 0x00400000 /* When sorting always keep these lines on of list */
39
40/* Flags for the entire stat_tree, set via stats_tree_register[_plugin] */
41#define ST_FLG_SORT_DESC 0x00800000 /* When sorting, sort descending instead of ascending */
42#define ST_FLG_SRTCOL_MASK 0x000F0000 /* Mask for sort column ID */
43#define ST_FLG_SRTCOL_SHIFT 16 /* Number of bits to shift masked result */
44
45#define ST_FLG_MASK (ST_FLG_AVERAGE|ST_FLG_ROOTCHILD|ST_FLG_DEF_NOEXPAND| \
46 ST_FLG_SORT_TOP|ST_FLG_SORT_DESC|ST_FLG_SRTCOL_MASK)
47
48#define ST_SORT_COL_NAME 1 /* Sort nodes by node names */
49#define ST_SORT_COL_COUNT 2 /* Sort nodes by node count */
50#define ST_SORT_COL_AVG 3 /* Sort nodes by node average */
51#define ST_SORT_COL_MIN 4 /* Sort nodes by minimum node value */
52#define ST_SORT_COL_MAX 5 /* Sort nodes by maximum node value */
53#define ST_SORT_COL_BURSTRATE 6 /* Sort nodes by burst rate */
54
55/* obscure information regarding the stats_tree */
56typedef struct _stats_tree stats_tree;
57
58/* tap packet callback for stats_tree */
59typedef tap_packet_status (*stat_tree_packet_cb)(stats_tree*,
62 const void *,
63 tap_flags_t flags);
64
65/* stats_tree initialization callback */
66typedef void (*stat_tree_init_cb)(stats_tree *);
67
68/* stats_tree cleanup callback */
69typedef void (*stat_tree_cleanup_cb)(stats_tree *);
70
78
79typedef struct _stats_tree_cfg stats_tree_cfg;
80
83extern void stats_tree_init(void);
84
95WS_DLL_PUBLIC stats_tree_cfg *stats_tree_register(const char *tapname,
96 const char *abbr,
97 const char *path,
98 unsigned flags,
99 stat_tree_packet_cb packet,
100 stat_tree_init_cb init,
101 stat_tree_cleanup_cb cleanup);
102
113WS_DLL_PUBLIC stats_tree_cfg *stats_tree_register_plugin(const char *tapname,
114 const char *abbr,
115 const char *path,
116 unsigned flags,
117 stat_tree_packet_cb packet,
118 stat_tree_init_cb init,
119 stat_tree_cleanup_cb cleanup);
120
126
132WS_DLL_PUBLIC void stats_tree_set_first_column_name(stats_tree_cfg *st_config, const char *column_name);
133
134
142WS_DLL_PUBLIC int stats_tree_parent_id_by_name(stats_tree *st, const char *parent_name);
143
154WS_DLL_PUBLIC int stats_tree_create_node(stats_tree *st,
155 const char *name,
156 int parent_id,
158 bool with_children);
159
167WS_DLL_PUBLIC int stats_tree_create_node_by_pname(stats_tree *st,
168 const char *name,
169 const char *parent_name,
171 bool with_children);
172
186WS_DLL_PUBLIC int stats_tree_create_range_node(stats_tree *st,
187 const char *name,
188 int parent_id,
189 ...);
190
202 const char *name,
203 int parent_id,
204 int num_str_ranges,
205 char** str_ranges);
206
215WS_DLL_PUBLIC int stats_tree_range_node_with_pname(stats_tree *st,
216 const char *name,
217 const char *parent_name,
218 ...);
219
220/* increases by one the ranged node and the sub node to whose range the value belongs */
230WS_DLL_PUBLIC int stats_tree_tick_range(stats_tree *st,
231 const char *name,
232 int parent_id,
233 int value_in_range);
234
235#define stats_tree_tick_range_by_pname(st,name,parent_name,value_in_range) \
236 stats_tree_tick_range((st),(name),stats_tree_parent_id_by_name((st),(parent_name),(value_in_range)))
237
246WS_DLL_PUBLIC int stats_tree_create_pivot(stats_tree *st,
247 const char *name,
248 int parent_id);
249
258WS_DLL_PUBLIC int stats_tree_create_pivot_by_pname(stats_tree *st,
259 const char *name,
260 const char *parent_name);
261
272WS_DLL_PUBLIC int stats_tree_tick_pivot(stats_tree *st,
273 int pivot_id,
274 const char *pivot_value);
275
281extern void stats_tree_cleanup(void);
282
283
299
311WS_DLL_PUBLIC int stats_tree_manip_node_int(manip_node_mode mode,
312 stats_tree *st,
313 const char *name,
314 int parent_id,
315 bool with_children,
316 int value);
317
329WS_DLL_PUBLIC int stats_tree_manip_node_float(manip_node_mode mode,
330 stats_tree *st,
331 const char *name,
332 int parent_id,
333 bool with_children,
334 float value);
335
336#define increase_stat_node(st,name,parent_id,with_children,value) \
337 (stats_tree_manip_node_int(MN_INCREASE,(st),(name),(parent_id),(with_children),(value)))
338
339#define tick_stat_node(st,name,parent_id,with_children) \
340 (stats_tree_manip_node_int(MN_INCREASE,(st),(name),(parent_id),(with_children),1))
341
342#define set_stat_node(st,name,parent_id,with_children,value) \
343 (stats_tree_manip_node_int(MN_SET,(st),(name),(parent_id),(with_children),value))
344
345#define zero_stat_node(st,name,parent_id,with_children) \
346 (stats_tree_manip_node_int(MN_SET,(st),(name),(parent_id),(with_children),0))
347
348/*
349 * Add value to average calculation WITHOUT ticking node. Node MUST be ticked separately!
350 *
351 * Intention is to allow code to separately tick node (backward compatibility for plugin)
352 * and set value to use for averages. Older versions without average support will then at
353 * least show a count instead of 0.
354 */
355#define avg_stat_node_add_value_notick(st,name,parent_id,with_children,value) \
356 (stats_tree_manip_node_int(MN_AVERAGE_NOTICK,(st),(name),(parent_id),(with_children),value))
357
358/* Tick node and add a new value to the average calculation for this stats node. */
359#define avg_stat_node_add_value_int(st,name,parent_id,with_children,value) \
360 (stats_tree_manip_node_int(MN_AVERAGE,(st),(name),(parent_id),(with_children),value))
361
362#define avg_stat_node_add_value_float(st,name,parent_id,with_children,value) \
363 (stats_tree_manip_node_float(MN_AVERAGE,(st),(name),(parent_id),(with_children),value))
364
365/* Set flags for this node. Node created if it does not yet exist. */
366#define stat_node_set_flags(st,name,parent_id,with_children,flags) \
367 (stats_tree_manip_node_int(MN_SET_FLAGS,(st),(name),(parent_id),(with_children),flags))
368
369/* Clear flags for this node. Node created if it does not yet exist. */
370#define stat_node_clear_flags(st,name,parent_id,with_children,flags) \
371 (stats_tree_manip_node_int(MN_CLEAR_FLAGS,(st),(name),(parent_id),(with_children),flags))
372
373#ifdef __cplusplus
374}
375#endif /* __cplusplus */
376
377/*
378 * Editor modelines - https://www.wireshark.org/tools/modelines.html
379 *
380 * Local variables:
381 * c-basic-offset: 4
382 * tab-width: 8
383 * indent-tabs-mode: nil
384 * End:
385 *
386 * vi: set shiftwidth=4 tabstop=8 expandtab:
387 * :indentSize=4:tabSize=8:noTabs=true:
388 */
enum register_stat_group_e register_stat_group_t
_manip_node_mode
Operation applied to a statistics tree node's value when it is manipulated.
Definition stats_tree.h:291
@ MN_AVERAGE_NOTICK
Definition stats_tree.h:295
@ MN_CLEAR_FLAGS
Definition stats_tree.h:297
@ MN_SET_FLAGS
Definition stats_tree.h:296
@ MN_SET
Definition stats_tree.h:293
@ MN_AVERAGE
Definition stats_tree.h:294
@ MN_INCREASE
Definition stats_tree.h:292
WS_DLL_PUBLIC void stats_tree_set_first_column_name(stats_tree_cfg *st_config, const char *column_name)
Definition stats_tree.c:352
WS_DLL_PUBLIC int stats_tree_range_node_with_pname(stats_tree *st, const char *name, const char *parent_name,...)
Increases by one the ranged node and the sub node to whose range the value belongs.
Definition stats_tree.c:925
void stats_tree_init(void)
Definition stats_tree.c:284
WS_DLL_PUBLIC int stats_tree_create_pivot_by_pname(stats_tree *st, const char *name, const char *parent_name)
Creates a pivot node in the statistics tree by name.
Definition stats_tree.c:1014
WS_DLL_PUBLIC int stats_tree_parent_id_by_name(stats_tree *st, const char *parent_name)
Retrieves the parent ID of a node in the stats tree by its name.
Definition stats_tree.c:913
WS_DLL_PUBLIC void stats_tree_set_group(stats_tree_cfg *st_config, register_stat_group_t stat_group)
Definition stats_tree.c:345
WS_DLL_PUBLIC int stats_tree_create_node_by_pname(stats_tree *st, const char *name, const char *parent_name, stat_node_datatype datatype, bool with_children)
Creates a node in the statistics tree using its parent's tree name.
Definition stats_tree.c:583
WS_DLL_PUBLIC int stats_tree_create_range_node(stats_tree *st, const char *name, int parent_id,...)
Creates a node in the stats tree that will contain a ranges list.
Definition stats_tree.c:872
void stats_tree_cleanup(void)
Cleans up the statistics tree registry.
Definition stats_tree.c:1523
enum _stat_node_datatype stat_node_datatype
Numeric data type stored in a statistics tree node's accumulator.
WS_DLL_PUBLIC int stats_tree_manip_node_float(manip_node_mode mode, stats_tree *st, const char *name, int parent_id, bool with_children, float value)
Manipulates a node in the statistics tree with a float value.
Definition stats_tree.c:745
enum _manip_node_mode manip_node_mode
Operation applied to a statistics tree node's value when it is manipulated.
WS_DLL_PUBLIC int stats_tree_tick_pivot(stats_tree *st, int pivot_id, const char *pivot_value)
Ticks a pivot node in the statistics tree.
Definition stats_tree.c:1029
WS_DLL_PUBLIC int stats_tree_create_node(stats_tree *st, const char *name, int parent_id, stat_node_datatype datatype, bool with_children)
Creates a node in the tree (to be used in the in init_cb)
Definition stats_tree.c:571
WS_DLL_PUBLIC stats_tree_cfg * stats_tree_register(const char *tapname, const char *abbr, const char *path, unsigned flags, stat_tree_packet_cb packet, stat_tree_init_cb init, stat_tree_cleanup_cb cleanup)
Definition stats_tree.c:291
WS_DLL_PUBLIC int stats_tree_create_range_node_string(stats_tree *st, const char *name, int parent_id, int num_str_ranges, char **str_ranges)
Creates a range node in the statistics tree with string ranges.
Definition stats_tree.c:890
WS_DLL_PUBLIC int stats_tree_tick_range(stats_tree *st, const char *name, int parent_id, int value_in_range)
Increment a statistic in a stats tree within a specified range.
Definition stats_tree.c:946
WS_DLL_PUBLIC int stats_tree_manip_node_int(manip_node_mode mode, stats_tree *st, const char *name, int parent_id, bool with_children, int value)
Manipulates a node in a statistics tree by increasing its integer value.
Definition stats_tree.c:683
WS_DLL_PUBLIC int stats_tree_create_pivot(stats_tree *st, const char *name, int parent_id)
Creates a new pivot node in the statistics tree.
Definition stats_tree.c:1003
WS_DLL_PUBLIC stats_tree_cfg * stats_tree_register_plugin(const char *tapname, const char *abbr, const char *path, unsigned flags, stat_tree_packet_cb packet, stat_tree_init_cb init, stat_tree_cleanup_cb cleanup)
Definition stats_tree.c:332
_stat_node_datatype
Numeric data type stored in a statistics tree node's accumulator.
Definition stats_tree.h:74
@ STAT_DT_FLOAT
Definition stats_tree.h:76
@ STAT_DT_INT
Definition stats_tree.h:75
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
Defines the static configuration and callbacks for a statistics tree type, shared across all instance...
Definition stats_tree_priv.h:142
unsigned flags
Definition stats_tree_priv.h:157
stat_tree_init_cb init
Definition stats_tree_priv.h:154
char * tapname
Definition stats_tree_priv.h:146
stat_tree_packet_cb packet
Definition stats_tree_priv.h:153
char * path
Definition stats_tree_priv.h:144
register_stat_group_t stat_group
Definition stats_tree_priv.h:148
stat_tree_cleanup_cb cleanup
Definition stats_tree_priv.h:155
char * abbr
Definition stats_tree_priv.h:143
Represents a live statistics tree instance, holding runtime state for accumulating and displaying tap...
Definition stats_tree_priv.h:117
Definition packet-epl-profile-parser.c:79
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
tap_packet_status
Definition tap.h:22