| 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#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
21 extern "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 */
58 typedef struct _stats_tree stats_tree;
59
60/* tap packet callback for stats_tree */
61 typedef tap_packet_status (*stat_tree_packet_cb)(stats_tree*,
62 packet_info *,
63 epan_dissect_t *,
64 const void *,
65 tap_flags_t flags);
66
67/* stats_tree initialization callback */
68 typedef void (*stat_tree_init_cb)(stats_tree *);
69
70/* stats_tree cleanup callback */
71 typedef void (*stat_tree_cleanup_cb)(stats_tree *);
72
73 typedef enum _stat_node_datatype {
74 STAT_DT_INT,
75 STAT_DT_FLOAT
76} stat_node_datatype;
77
78 typedef struct _stats_tree_cfg stats_tree_cfg;
79
82 extern void stats_tree_init(void);
83
94WS_DLL_PUBLIC stats_tree_cfg *stats_tree_register(const char *tapname,
95 const char *abbr,
96 const char *path,
97 unsigned flags,
98 stat_tree_packet_cb packet,
99 stat_tree_init_cb init,
100 stat_tree_cleanup_cb cleanup);
101
112WS_DLL_PUBLIC stats_tree_cfg *stats_tree_register_plugin(const char *tapname,
113 const char *abbr,
114 const char *path,
115 unsigned flags,
116 stat_tree_packet_cb packet,
117 stat_tree_init_cb init,
118 stat_tree_cleanup_cb cleanup);
119
124WS_DLL_PUBLIC void stats_tree_set_group(stats_tree_cfg *st_config, register_stat_group_t stat_group);
125
131WS_DLL_PUBLIC void stats_tree_set_first_column_name(stats_tree_cfg *st_config, const char *column_name);
132
133
134WS_DLL_PUBLIC int stats_tree_parent_id_by_name(stats_tree *st, const char *parent_name);
135
136/* Creates a node in the tree (to be used in the in init_cb)
137 * st: the stats_tree in which to create it
138 * name: the name of the new node
139 * parent_name: the name of the parent_node (NULL for root)
140 * datatype: datatype used for the value of the node
141 * with_children: true if this node will have "dynamically created" children
142 */
143WS_DLL_PUBLIC int stats_tree_create_node(stats_tree *st,
144 const char *name,
145 int parent_id,
146 stat_node_datatype datatype,
147 bool with_children);
148
149/* creates a node using its parent's tree name */
150WS_DLL_PUBLIC int stats_tree_create_node_by_pname(stats_tree *st,
151 const char *name,
152 const char *parent_name,
153 stat_node_datatype datatype,
154 bool with_children);
155
156/* creates a node in the tree, that will contain a ranges list.
157 example:
158 stats_tree_create_range_node(st,name,parent,
159 "-99","100-199","200-299","300-399","400-", NULL);
160*/
161WS_DLL_PUBLIC int stats_tree_create_range_node(stats_tree *st,
162 const char *name,
163 int parent_id,
164 ...);
165
166WS_DLL_PUBLIC int stats_tree_create_range_node_string(stats_tree *st,
167 const char *name,
168 int parent_id,
169 int num_str_ranges,
170 char** str_ranges);
171
172WS_DLL_PUBLIC int stats_tree_range_node_with_pname(stats_tree *st,
173 const char *name,
174 const char *parent_name,
175 ...);
176
177/* increases by one the ranged node and the sub node to whose range the value belongs */
178WS_DLL_PUBLIC int stats_tree_tick_range(stats_tree *st,
179 const char *name,
180 int parent_id,
181 int value_in_range);
182
183#define stats_tree_tick_range_by_pname(st,name,parent_name,value_in_range) \
184 stats_tree_tick_range((st),(name),stats_tree_parent_id_by_name((st),(parent_name),(value_in_range)))
185
186/* */
187WS_DLL_PUBLIC int stats_tree_create_pivot(stats_tree *st,
188 const char *name,
189 int parent_id);
190
191WS_DLL_PUBLIC int stats_tree_create_pivot_by_pname(stats_tree *st,
192 const char *name,
193 const char *parent_name);
194
195WS_DLL_PUBLIC int stats_tree_tick_pivot(stats_tree *st,
196 int pivot_id,
197 const char *pivot_value);
198
199 extern void stats_tree_cleanup(void);
200
201
202/*
203 * manipulates the value of the node whose name is given
204 * if the node does not exist yet it's created (with counter=1)
205 * using parent_name as parent node (NULL for root).
206 * with_children=true to indicate that the created node will be a parent
207 */
208 typedef enum _manip_node_mode {
209 MN_INCREASE,
210 MN_SET,
211 MN_AVERAGE,
212 MN_AVERAGE_NOTICK,
213 MN_SET_FLAGS,
214 MN_CLEAR_FLAGS
215} manip_node_mode;
216WS_DLL_PUBLIC int stats_tree_manip_node_int(manip_node_mode mode,
217 stats_tree *st,
218 const char *name,
219 int parent_id,
220 bool with_children,
221 int value);
222
223WS_DLL_PUBLIC int stats_tree_manip_node_float(manip_node_mode mode,
224 stats_tree *st,
225 const char *name,
226 int parent_id,
227 bool with_children,
228 float value);
229
230#define increase_stat_node(st,name,parent_id,with_children,value) \
231 (stats_tree_manip_node_int(MN_INCREASE,(st),(name),(parent_id),(with_children),(value)))
232
233#define tick_stat_node(st,name,parent_id,with_children) \
234 (stats_tree_manip_node_int(MN_INCREASE,(st),(name),(parent_id),(with_children),1))
235
236#define set_stat_node(st,name,parent_id,with_children,value) \
237 (stats_tree_manip_node_int(MN_SET,(st),(name),(parent_id),(with_children),value))
238
239#define zero_stat_node(st,name,parent_id,with_children) \
240 (stats_tree_manip_node_int(MN_SET,(st),(name),(parent_id),(with_children),0))
241
242/*
243 * Add value to average calculation WITHOUT ticking node. Node MUST be ticked separately!
244 *
245 * Intention is to allow code to separately tick node (backward compatibility for plugin)
246 * and set value to use for averages. Older versions without average support will then at
247 * least show a count instead of 0.
248 */
249#define avg_stat_node_add_value_notick(st,name,parent_id,with_children,value) \
250 (stats_tree_manip_node_int(MN_AVERAGE_NOTICK,(st),(name),(parent_id),(with_children),value))
251
252/* Tick node and add a new value to the average calculation for this stats node. */
253#define avg_stat_node_add_value_int(st,name,parent_id,with_children,value) \
254 (stats_tree_manip_node_int(MN_AVERAGE,(st),(name),(parent_id),(with_children),value))
255
256#define avg_stat_node_add_value_float(st,name,parent_id,with_children,value) \
257 (stats_tree_manip_node_float(MN_AVERAGE,(st),(name),(parent_id),(with_children),value))
258
259/* Set flags for this node. Node created if it does not yet exist. */
260#define stat_node_set_flags(st,name,parent_id,with_children,flags) \
261 (stats_tree_manip_node_int(MN_SET_FLAGS,(st),(name),(parent_id),(with_children),flags))
262
263/* Clear flags for this node. Node created if it does not yet exist. */
264#define stat_node_clear_flags(st,name,parent_id,with_children,flags) \
265 (stats_tree_manip_node_int(MN_CLEAR_FLAGS,(st),(name),(parent_id),(with_children),flags))
266
267#ifdef __cplusplus
268}
269#endif /* __cplusplus */
270
271#endif /* __STATS_TREE_H */
272
273/*
274 * Editor modelines - https://www.wireshark.org/tools/modelines.html
275 *
276 * Local variables:
277 * c-basic-offset: 4
278 * tab-width: 8
279 * indent-tabs-mode: nil
280 * End:
281 *
282 * vi: set shiftwidth=4 tabstop=8 expandtab:
283 * :indentSize=4:tabSize=8:noTabs=true:
284 */
epan.h
packet_info.h
stat_groups.h
register_stat_group_t
enum register_stat_group_e register_stat_group_t
stats_tree_set_first_column_name
WS_DLL_PUBLIC void stats_tree_set_first_column_name(stats_tree_cfg *st_config, const char *column_name)
Definition stats_tree.c:352
stats_tree_init
void stats_tree_init(void)
Definition stats_tree.c:284
stats_tree_set_group
WS_DLL_PUBLIC void stats_tree_set_group(stats_tree_cfg *st_config, register_stat_group_t stat_group)
Definition stats_tree.c:345
stats_tree_register
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
stats_tree_register_plugin
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
_packet_info
Definition packet_info.h:43
_stats_tree_cfg
Definition stats_tree_priv.h:145
_stats_tree_cfg::flags
unsigned flags
Definition stats_tree_priv.h:161
_stats_tree_cfg::packet
stat_tree_packet_cb packet
Definition stats_tree_priv.h:156
_stats_tree
Definition stats_tree_priv.h:111
datatype
Definition packet-epl-profile-parser.c:79
epan_dissect
Definition epan_dissect.h:28
tap.h
tap_packet_status
tap_packet_status
Definition tap.h:25