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