Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
stats_tree.h
Go to the documentation of this file.
1
11#ifndef __STATS_TREE_H
12#define __STATS_TREE_H
13
14#include <epan/epan.h>
15#include <epan/packet_info.h>
16#include <epan/tap.h>
17#include <epan/stat_groups.h>
18#include "ws_symbol_export.h"
19
20#ifdef __cplusplus
21extern "C" {
22#endif /* __cplusplus */
23
24#define STAT_TREE_ROOT "root"
25#define STATS_TREE_MENU_SEPARATOR "//"
26
27/* stats_tree specific flags. When registering, these are used together
28 * with the TL_ flags defined in tap.h, so make sure they don't overlap!
29 * (Yes, that applies even to the flags that apply to nodes instead of
30 * the entire tree, and should not be passed in stats_tree_register.
31 * XXX - Why? These flags should be reworked at some point.)
32 */
33
34/* Flags on child nodes for internal use only */
35#define ST_FLG_AVERAGE 0x10000000 /* Calculate averages for nodes, rather than totals */
36#define ST_FLG_ROOTCHILD 0x20000000 /* This node is a direct child of the root node */
37
38/* Flags set on child nodes via stat_node_set_flags */
39#define ST_FLG_DEF_NOEXPAND 0x01000000 /* This node should not be expanded by default */
40#define ST_FLG_SORT_TOP 0x00400000 /* When sorting always keep these lines on of list */
41
42/* Flags for the entire stat_tree, set via stats_tree_register[_plugin] */
43#define ST_FLG_SORT_DESC 0x00800000 /* When sorting, sort descending instead of ascending */
44#define ST_FLG_SRTCOL_MASK 0x000F0000 /* Mask for sort column ID */
45#define ST_FLG_SRTCOL_SHIFT 16 /* Number of bits to shift masked result */
46
47#define ST_FLG_MASK (ST_FLG_AVERAGE|ST_FLG_ROOTCHILD|ST_FLG_DEF_NOEXPAND| \
48 ST_FLG_SORT_TOP|ST_FLG_SORT_DESC|ST_FLG_SRTCOL_MASK)
49
50#define ST_SORT_COL_NAME 1 /* Sort nodes by node names */
51#define ST_SORT_COL_COUNT 2 /* Sort nodes by node count */
52#define ST_SORT_COL_AVG 3 /* Sort nodes by node average */
53#define ST_SORT_COL_MIN 4 /* Sort nodes by minimum node value */
54#define ST_SORT_COL_MAX 5 /* Sort nodes by maximum node value */
55#define ST_SORT_COL_BURSTRATE 6 /* Sort nodes by burst rate */
56
57/* obscure information regarding the stats_tree */
58typedef struct _stats_tree stats_tree;
59
60/* tap packet callback for stats_tree */
61typedef tap_packet_status (*stat_tree_packet_cb)(stats_tree*,
64 const void *,
65 tap_flags_t flags);
66
67/* stats_tree initialization callback */
68typedef void (*stat_tree_init_cb)(stats_tree *);
69
70/* stats_tree cleanup callback */
71typedef void (*stat_tree_cleanup_cb)(stats_tree *);
72
73typedef enum _stat_node_datatype {
74 STAT_DT_INT,
75 STAT_DT_FLOAT
76} stat_node_datatype;
77
78typedef struct _stats_tree_cfg stats_tree_cfg;
79
90WS_DLL_PUBLIC stats_tree_cfg *stats_tree_register(const char *tapname,
91 const char *abbr,
92 const char *path,
93 unsigned flags,
94 stat_tree_packet_cb packet,
95 stat_tree_init_cb init,
96 stat_tree_cleanup_cb cleanup);
97
108WS_DLL_PUBLIC stats_tree_cfg *stats_tree_register_plugin(const char *tapname,
109 const char *abbr,
110 const char *path,
111 unsigned flags,
112 stat_tree_packet_cb packet,
113 stat_tree_init_cb init,
114 stat_tree_cleanup_cb cleanup);
115
120WS_DLL_PUBLIC void stats_tree_set_group(stats_tree_cfg *st_config, register_stat_group_t stat_group);
121
127WS_DLL_PUBLIC void stats_tree_set_first_column_name(stats_tree_cfg *st_config, const char *column_name);
128
129
130WS_DLL_PUBLIC int stats_tree_parent_id_by_name(stats_tree *st, const char *parent_name);
131
132/* Creates a node in the tree (to be used in the in init_cb)
133 * st: the stats_tree in which to create it
134 * name: the name of the new node
135 * parent_name: the name of the parent_node (NULL for root)
136 * datatype: datatype used for the value of the node
137 * with_children: true if this node will have "dynamically created" children
138 */
139WS_DLL_PUBLIC int stats_tree_create_node(stats_tree *st,
140 const char *name,
141 int parent_id,
142 stat_node_datatype datatype,
143 bool with_children);
144
145/* creates a node using its parent's tree name */
146WS_DLL_PUBLIC int stats_tree_create_node_by_pname(stats_tree *st,
147 const char *name,
148 const char *parent_name,
149 stat_node_datatype datatype,
150 bool with_children);
151
152/* creates a node in the tree, that will contain a ranges list.
153 example:
154 stats_tree_create_range_node(st,name,parent,
155 "-99","100-199","200-299","300-399","400-", NULL);
156*/
157WS_DLL_PUBLIC int stats_tree_create_range_node(stats_tree *st,
158 const char *name,
159 int parent_id,
160 ...);
161
162WS_DLL_PUBLIC int stats_tree_create_range_node_string(stats_tree *st,
163 const char *name,
164 int parent_id,
165 int num_str_ranges,
166 char** str_ranges);
167
168WS_DLL_PUBLIC int stats_tree_range_node_with_pname(stats_tree *st,
169 const char *name,
170 const char *parent_name,
171 ...);
172
173/* increases by one the ranged node and the sub node to whose range the value belongs */
174WS_DLL_PUBLIC int stats_tree_tick_range(stats_tree *st,
175 const char *name,
176 int parent_id,
177 int value_in_range);
178
179#define stats_tree_tick_range_by_pname(st,name,parent_name,value_in_range) \
180 stats_tree_tick_range((st),(name),stats_tree_parent_id_by_name((st),(parent_name),(value_in_range)))
181
182/* */
183WS_DLL_PUBLIC int stats_tree_create_pivot(stats_tree *st,
184 const char *name,
185 int parent_id);
186
187WS_DLL_PUBLIC int stats_tree_create_pivot_by_pname(stats_tree *st,
188 const char *name,
189 const char *parent_name);
190
191WS_DLL_PUBLIC int stats_tree_tick_pivot(stats_tree *st,
192 int pivot_id,
193 const char *pivot_value);
194
195extern void stats_tree_cleanup(void);
196
197
198/*
199 * manipulates the value of the node whose name is given
200 * if the node does not exist yet it's created (with counter=1)
201 * using parent_name as parent node (NULL for root).
202 * with_children=true to indicate that the created node will be a parent
203 */
204typedef enum _manip_node_mode {
205 MN_INCREASE,
206 MN_SET,
207 MN_AVERAGE,
208 MN_AVERAGE_NOTICK,
209 MN_SET_FLAGS,
210 MN_CLEAR_FLAGS
211} manip_node_mode;
212WS_DLL_PUBLIC int stats_tree_manip_node_int(manip_node_mode mode,
213 stats_tree *st,
214 const char *name,
215 int parent_id,
216 bool with_children,
217 int value);
218
219WS_DLL_PUBLIC int stats_tree_manip_node_float(manip_node_mode mode,
220 stats_tree *st,
221 const char *name,
222 int parent_id,
223 bool with_children,
224 float value);
225
226#define increase_stat_node(st,name,parent_id,with_children,value) \
227 (stats_tree_manip_node_int(MN_INCREASE,(st),(name),(parent_id),(with_children),(value)))
228
229#define tick_stat_node(st,name,parent_id,with_children) \
230 (stats_tree_manip_node_int(MN_INCREASE,(st),(name),(parent_id),(with_children),1))
231
232#define set_stat_node(st,name,parent_id,with_children,value) \
233 (stats_tree_manip_node_int(MN_SET,(st),(name),(parent_id),(with_children),value))
234
235#define zero_stat_node(st,name,parent_id,with_children) \
236 (stats_tree_manip_node_int(MN_SET,(st),(name),(parent_id),(with_children),0))
237
238/*
239 * Add value to average calculation WITHOUT ticking node. Node MUST be ticked separately!
240 *
241 * Intention is to allow code to separately tick node (backward compatibility for plugin)
242 * and set value to use for averages. Older versions without average support will then at
243 * least show a count instead of 0.
244 */
245#define avg_stat_node_add_value_notick(st,name,parent_id,with_children,value) \
246 (stats_tree_manip_node_int(MN_AVERAGE_NOTICK,(st),(name),(parent_id),(with_children),value))
247
248/* Tick node and add a new value to the average calculation for this stats node. */
249#define avg_stat_node_add_value_int(st,name,parent_id,with_children,value) \
250 (stats_tree_manip_node_int(MN_AVERAGE,(st),(name),(parent_id),(with_children),value))
251
252#define avg_stat_node_add_value_float(st,name,parent_id,with_children,value) \
253 (stats_tree_manip_node_float(MN_AVERAGE,(st),(name),(parent_id),(with_children),value))
254
255/* Set flags for this node. Node created if it does not yet exist. */
256#define stat_node_set_flags(st,name,parent_id,with_children,flags) \
257 (stats_tree_manip_node_int(MN_SET_FLAGS,(st),(name),(parent_id),(with_children),flags))
258
259/* Clear flags for this node. Node created if it does not yet exist. */
260#define stat_node_clear_flags(st,name,parent_id,with_children,flags) \
261 (stats_tree_manip_node_int(MN_CLEAR_FLAGS,(st),(name),(parent_id),(with_children),flags))
262
263#ifdef __cplusplus
264}
265#endif /* __cplusplus */
266
267#endif /* __STATS_TREE_H */
268
269/*
270 * Editor modelines - https://www.wireshark.org/tools/modelines.html
271 *
272 * Local variables:
273 * c-basic-offset: 4
274 * tab-width: 8
275 * indent-tabs-mode: nil
276 * End:
277 *
278 * vi: set shiftwidth=4 tabstop=8 expandtab:
279 * :indentSize=4:tabSize=8:noTabs=true:
280 */
enum register_stat_group_e register_stat_group_t
WS_DLL_PUBLIC void stats_tree_set_first_column_name(stats_tree_cfg *st_config, const char *column_name)
Definition stats_tree.c:346
WS_DLL_PUBLIC void stats_tree_set_group(stats_tree_cfg *st_config, register_stat_group_t stat_group)
Definition stats_tree.c:339
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:285
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:326
Definition packet_info.h:43
Definition stats_tree_priv.h:136
unsigned flags
Definition stats_tree_priv.h:152
stat_tree_packet_cb packet
Definition stats_tree_priv.h:147
Definition stats_tree_priv.h:102
Definition packet-epl-profile-parser.c:83
Definition epan_dissect.h:28
tap_packet_status
Definition tap.h:25