| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
plugin_if.h
Go to the documentation of this file.
1
17#ifndef EPAN_PLUGIN_IF_H
18#define EPAN_PLUGIN_IF_H
19
20#include "ws_symbol_export.h"
21#include "ws_attributes.h"
22
23#include <glib.h>
24#include <epan/epan.h>
25#include <epan/frame_data.h>
26#include <epan/cfile.h>
27
28#ifdef __cplusplus
29 extern "C" {
30#endif /* __cplusplus */
31
32 typedef enum
33{
34 EXT_MENUBAR_GTK_GUI,
35 EXT_MENUBAR_QT_GUI
36} ext_menubar_gui_type;
37
38/* menubar callback */
39 typedef void (*ext_menubar_action_cb)(ext_menubar_gui_type gui_type, void *gui_object, void *user_data);
40
41 typedef enum
42{
43 EXT_MENUBAR_MENU,
44 EXT_MENUBAR_ITEM,
45 EXT_MENUBAR_SEPARATOR,
46 EXT_MENUBAR_URL
47} ext_menubar_entry_t;
48
49 typedef struct _ext_menubar_t ext_menubar_t;
50 typedef ext_menubar_t ext_menu_t;
51
52 struct _ext_menubar_t
53{
54 ext_menubar_entry_t type;
55 ext_menu_t * parent;
56 int proto;
57 GList * children;
58 unsigned submenu_cnt;
59 unsigned item_cnt;
60
61 char * name;
62 char * label;
63
64 char * tooltip;
65 bool is_plugin;
66 void *user_data;
67
68 ext_menubar_action_cb callback;
69
70 char * parent_menu;
71};
72
73 typedef void (*ext_toolbar_action_cb)(void *toolbar_item, void *item_data, void *user_data);
74
75 typedef enum
76{
77 EXT_TOOLBAR_BAR,
78 EXT_TOOLBAR_ITEM
79} ext_toolbar_entry_t;
80
81 typedef enum
82{
83 EXT_TOOLBAR_BOOLEAN,
84 EXT_TOOLBAR_BUTTON,
85 EXT_TOOLBAR_STRING,
86 EXT_TOOLBAR_SELECTOR
87} ext_toolbar_item_t;
88
89 typedef struct _ext_toolbar_value_t
90{
91 char * value;
92 char * display;
93
94 bool is_default;
95
96} ext_toolbar_value_t;
97
98 typedef struct _ext_toolbar_t
99{
100 ext_toolbar_entry_t type;
101
102 GList * children;
103 unsigned submenu_cnt;
104 unsigned item_cnt;
105
106 char * name;
107 char * defvalue;
108 char * tooltip;
109 void *user_data;
110
111 bool is_required;
112 bool capture_only;
113 ext_toolbar_item_t item_type;
114
115 GList * values;
116 char * regex;
117
118 ext_toolbar_action_cb callback;
119
120} ext_toolbar_t;
121
122 typedef enum
123{
124 EXT_TOOLBAR_UPDATE_VALUE,
125 EXT_TOOLBAR_UPDATE_DATA,
126 EXT_TOOLBAR_UPDATE_DATABYINDEX,
127 EXT_TOOLBAR_UPDATE_DATA_ADD,
128 EXT_TOOLBAR_UPDATE_DATA_REMOVE,
129 EXT_TOOLBAR_SET_ACTIVE
130} ext_toolbar_update_type_t;
131
132 typedef struct _ext_toolbar_update_t
133{
134 ext_toolbar_update_type_t type;
135 bool silent;
136 void *user_data;
137 void *data_index;
138} ext_toolbar_update_t;
139
140/* Registers a new main menu.
141 *
142 * This will register a new main menu entry, underneath all other menu entries will
143 * be sorted
144 *
145 * @param proto_id the proto item for the protocol this menu entry belongs too
146 * @param menulabel the entry label (the displayed name) for the menu item
147 * @param is_plugin must be set to true for plugin registration
148 */
149WS_DLL_PUBLIC ext_menu_t * ext_menubar_register_menu(
150 int proto_id, const char * menulabel, bool is_plugin);
151
152/* Sets a parent menu for the user menu.
153 *
154 * This will set a parent menu, which allows this menu to be filtered underneath
155 * the given menu as a submenu. If the parent menu does not exist, the main menu
156 * will be used
157 *
158 * @param menu the menu for which to add the entry
159 * @param parentmenu a valid menu name for the parent menu
160 */
161WS_DLL_PUBLIC ext_menu_t * ext_menubar_set_parentmenu(
162 ext_menu_t * menu, const char * parentmenu);
163
164/* Registers a new main menu.
165 *
166 * This will register a new sub menu entry, underneath the parent menu
167 *
168 * @param parent the parent menu for this submenu
169 * @param menulabel the entry label (the displayed name) for the menu item
170 */
171WS_DLL_PUBLIC ext_menu_t * ext_menubar_add_submenu(
172 ext_menu_t * parent, const char *menulabel);
173
174/* Registers a new menubar entry.
175 *
176 * This registers a new menubar entry, which will have the given name, and
177 * call the provided callback on activation
178 *
179 * @param parent_menu the parent menu for this entry
180 * @param label the entry label (the displayed name) for the menu item
181 * @param tooltip a tooltip to be displayed on mouse-over
182 * @param callback the action which will be invoked after click on the menu item
183 * @param user_data a user data pointer
184 */
185WS_DLL_PUBLIC void ext_menubar_add_entry(
186 ext_menu_t * parent_menu,
187 const char *label,
188 const char *tooltip,
189 ext_menubar_action_cb callback,
190 void *user_data);
191
192/* Registers a new separator entry.
193 *
194 * @note This will not work using the legacy GTK interface, due to
195 * restrictions on how separators are handled in the menu
196 *
197 * @param parent_menu the parent menu for this entry
198 */
199WS_DLL_PUBLIC void ext_menubar_add_separator(ext_menu_t *parent_menu);
200
201/* Registers a entry for a website call
202 *
203 * This registers a new menubar entry, which will call the given website, using
204 * the predefined webbrowser
205 *
206 * @param parent_menu the parent menu for this entry
207 * @param label the entry label (the displayed name) for the menu item
208 * @param tooltip a tooltip to be displayed on mouse-over
209 * @param url the url for the website
210 */
211WS_DLL_PUBLIC void ext_menubar_add_website(ext_menu_t * parent, const char *label,
212 const char *tooltip, const char *url);
213
214/* Registers a toolbar.
215 *
216 * This will register a new toolbar, which can contain various gui elements
217 *
218 * @param toolbar_label the entry label (the displayed name) for the toolbar item
219 */
220WS_DLL_PUBLIC ext_toolbar_t * ext_toolbar_register_toolbar(const char * toolbar_label);
221
222/* Removes a toolbar from the system.
223 *
224 * This will remove the provided toolbar from the application
225 *
226 * @param toolbar the toolbar to be removed
227 */
228WS_DLL_PUBLIC void ext_toolbar_unregister_toolbar(ext_toolbar_t * toolbar);
229
230/* Removes a toolbar from the system by providing the name of the toolbar.
231 *
232 * This will remove the provided toolbar from the application
233 *
234 * @param toolbar_name the name of the toolbar to be removed
235 */
236WS_DLL_PUBLIC void ext_toolbar_unregister_toolbar_by_name(const char * toolbar_name);
237
238/* Registers a new toolbar entry.
239 *
240 * This registers a new toolbar entry, which will have the given name, and
241 * call the provided callback on activation
242 *
243 * The callback will be fired on different events, depending on the item type
244 * and the implementation of the item type in a GUI element. The following types should
245 * behave as following
246 *
247 * * EXT_TOOLBAR_STRING - Every change of the content fires the callback
248 * * EXT_TOOLBAR_BOOLEAN - Every change of the value fires the callback
249 * * EXT_TOOLBAR_BUTTON - if the button is pressed, the callback fires
250 * * EXT_TOOLBAR_SELECTION - every time the selection changes the callback fires
251 *
252 * @param parent_bar the parent toolbar for this entry
253 * @param type type of the toolbar item
254 * @param label the entry label (the displayed name) for the item
255 * @param defvalue the default value for the toolbar element
256 * @param tooltip a tooltip to be displayed on mouse-over
257 * @param capture_only entry is only active, if capture is active
258 * @param value_list a non-null list of values, if the item type is EXT_TOOLBAR_SELECTOR
259 * @param is_required
260 * @param valid_regex a validation regular expression for EXT_TOOLBAR_STRING
261 * @param callback the action which will be invoked after click on the item
262 * @param user_data a user data pointer
263 * @return a reference to the newly created toolbar entry
264 */
265WS_DLL_PUBLIC ext_toolbar_t * ext_toolbar_add_entry(
266 ext_toolbar_t * parent_bar,
267 ext_toolbar_item_t type,
268 const char *label,
269 const char *defvalue,
270 const char *tooltip,
271 bool capture_only,
272 GList * value_list,
273 bool is_required,
274 const char * valid_regex,
275 ext_toolbar_action_cb callback,
276 void *user_data);
277
278WS_DLL_PUBLIC GList * ext_toolbar_add_val(GList * entries, char * value, char * display, bool is_default);
279
280WS_DLL_PUBLIC void ext_toolbar_register_update_cb(ext_toolbar_t * entry, ext_toolbar_action_cb callback, void *item_data);
281
282/* Updates the entry values
283 *
284 * Update the values for the entry, it is up to the implemented widget, to interpret the
285 * given character values
286 *
287 * @param entry the entry to be updated
288 * @param data the data for the entry
289 * @param silent the update for the entry should not trigger additional actions
290 */
291WS_DLL_PUBLIC void ext_toolbar_update_value(ext_toolbar_t * entry, void *data, bool silent);
292
293/* Updates the entry data
294 *
295 * Update the data for the entry, it is up to the implemented widget, to interpret the given character data
296 *
297 * @param entry the entry to be updated
298 * @param data the data for the entry
299 * @param silent the update for the entry should not trigger additional actions
300 */
301WS_DLL_PUBLIC void ext_toolbar_update_data(ext_toolbar_t * entry, void *data, bool silent);
302
303/* Updates the entry data by index
304 *
305 * This is used to update a single entry of a selector list, by giving it's value and a new display
306 * entry
307 *
308 * @param entry the toolbar item to be updated
309 * @param data the display data for the entry
310 * @param idx the value for the entry to be updated
311 * @param silent the update for the entry should not trigger additional actions
312 */
313WS_DLL_PUBLIC void ext_toolbar_update_data_by_index(ext_toolbar_t * entry, void *data, void *idx, bool silent);
314
315/* Adds the entry data by index
316 *
317 * This is used to add a single entry to a selector list, by giving it's new value and a new display
318 * entry. If the value already exists, the selector may choose to ignore the command
319 *
320 * @param entry the toolbar item to be updated
321 * @param data the display data for the entry to be added
322 * @param idx the value for the entry to be added
323 * @param silent the adding of the entry should not trigger additional actions
324 */
325WS_DLL_PUBLIC void ext_toolbar_update_data_add_entry(ext_toolbar_t * entry, void *data, void *idx, bool silent);
326
327/* Removes an entry data by index
328 *
329 * This is used to remove a single entry to a selector list, by giving it's value and a display
330 * entry. If the value already exists, the selector may choose to ignore the command. Both value
331 * and display must be given, as it is not established, how the entry is found in the selector list
332 *
333 * @param entry the toolbar item to be updated
334 * @param data the display data for the entry to be removed
335 * @param idx the value for the entry to be removed
336 * @param silent the removal of the entry should not trigger additional actions
337 */
338WS_DLL_PUBLIC void ext_toolbar_update_data_remove_entry(ext_toolbar_t * entry, void *data, void *idx, bool silent);
339
340/* Search for and return if found an entry from the toolbar with the given label */
341WS_DLL_PUBLIC ext_toolbar_t * ext_toolbar_entry_by_label(const ext_toolbar_t * toolbar, const char * label);
342
343/* Set the ui element for the given enry to the status */
344WS_DLL_PUBLIC void ext_toolbar_update_data_set_active(ext_toolbar_t * entry, bool status);
345
346/*
347 * Structure definition for the plugin_if_get_ws_info function
348 */
349
350 typedef struct _ws_info_t
351{
352 bool ws_info_supported; /* false if no libpcap */
353 file_state cf_state; /* Current state of capture file */
354 char *cf_filename; /* Name of capture file */
355 uint32_t cf_count; /* Total number of frames */
356 uint32_t cf_framenr;
357 bool frame_passed_dfilter;
358} ws_info_t;
359
360
361/*
362 * Enumeration of possible actions, which are registered in GUI interfaces
363 */
364 typedef enum
365{
366 /* Applies a given string as filter */
367 PLUGIN_IF_FILTER_ACTION_APPLY,
368
369 /* Prepares the given string as filter */
370 PLUGIN_IF_FILTER_ACTION_PREPARE,
371
372 /* Saves a preference entry */
373 PLUGIN_IF_PREFERENCE_SAVE,
374
375 /* Jumps to the provided frame number */
376 PLUGIN_IF_GOTO_FRAME,
377
378 /* Gets status information about the currently loaded capture file */
379 PLUGIN_IF_GET_WS_INFO,
380
381 /* Gets information from frame_data for current packet */
382 PLUGIN_IF_GET_FRAME_DATA,
383
384 /* Gets information from capture_file */
385 PLUGIN_IF_GET_CAPTURE_FILE,
386
387 /* Remove toolbar */
388 PLUGIN_IF_REMOVE_TOOLBAR
389
390} plugin_if_callback_t;
391
392
393 typedef void (*plugin_if_gui_cb)(GHashTable * data_set);
394
395WS_DLL_PUBLIC void plugin_if_register_gui_cb(plugin_if_callback_t actionType, plugin_if_gui_cb callback);
396
397/* Applies the given filter string as display filter */
398WS_DLL_PUBLIC void plugin_if_apply_filter(const char * filter_string, bool force);
399
400/* Saves the given preference to the main preference storage */
401WS_DLL_PUBLIC void plugin_if_save_preference(const char * pref_module, const char * pref_key, const char * pref_value);
402
403/* Jumps to the given frame number */
404WS_DLL_PUBLIC void plugin_if_goto_frame(uint32_t framenr);
405
406/* Takes a snapshot of status information from Wireshark */
407WS_DLL_PUBLIC void plugin_if_get_ws_info(ws_info_t ** ws_info);
408
409 typedef void* (*plugin_if_frame_data_cb)(frame_data*, void*);
410/* Gets frame_data for current packet, data are extracted by extract_cb */
411WS_DLL_PUBLIC void* plugin_if_get_frame_data(plugin_if_frame_data_cb extract_cb, void *user_data);
412
413 typedef void* (*plugin_if_capture_file_cb)(capture_file*, void*);
414/* Gets capture_file, data are extracted by extract_cb */
415WS_DLL_PUBLIC void* plugin_if_get_capture_file(plugin_if_capture_file_cb extract_cb, void* user_data);
416
417/* Private Method for retrieving the menubar entries
418 *
419 * Is only to be used by the UI interfaces to retrieve the menu entries
420 */
421WS_DLL_PUBLIC GList * ext_menubar_get_entries(void);
422
423/* Private Method for retrieving the toolbar entries
424 *
425 * Is only to be used by the UI interfaces to retrieve the toolbar entries
426 */
427WS_DLL_PUBLIC GList * ext_toolbar_get_entries(void);
428
429#ifdef __cplusplus
430}
431#endif /* __cplusplus */
432
433#endif /* EPAN_PLUGIN_IF_H */
434
435/*
436 * Editor modelines
437 *
438 * Local Variables:
439 * c-basic-offset: 4
440 * tab-width: 8
441 * indent-tabs-mode: nil
442 * End:
443 *
444 * ex: set shiftwidth=4 tabstop=8 expandtab:
445 * :indentSize=4:tabSize=8:noTabs=true:
446 */
cfile.h
epan.h
frame_data.h
_capture_file
Definition cfile.h:71
_ext_menubar_t
Definition plugin_if.h:53
_ext_toolbar_t
Definition plugin_if.h:99
_ext_toolbar_update_t
Definition plugin_if.h:133
_ext_toolbar_value_t
Definition plugin_if.h:90
_ws_info_t
Definition plugin_if.h:351
_ws_info_t::frame_passed_dfilter
bool frame_passed_dfilter
Definition plugin_if.h:357
_ws_info_t::cf_framenr
uint32_t cf_framenr
Definition plugin_if.h:356
pref_module
Definition prefs-int.h:27
ws_info
#define ws_info(...)
Log an "info" level entry without source context.
Definition wslog.h:603