1 /* plugin_if.c
2 * An API for Wireshark plugins
3 *
4 * This enables wireshark dissectors, especially those implemented by plugins
5 * to register menubar entries, which then will call a pre-defined callback
6 * function for the dissector or plugin.
7 *
8 * Also it implements additional methods, which allow plugins to interoperate
9 * with the main GUI.
10 *
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
14 *
15 * SPDX-License-Identifier: GPL-2.0-or-later
16 */
17
18 #include "config.h"
19
20 #include <glib.h>
21 #include <epan/epan.h>
22 #include <epan/proto.h>
23 #include <wsutil/ws_assert.h>
24
25 #include "plugin_if.h"
26
27 static GList * menubar_entries = NULL;
28 static GList * menubar_menunames = NULL;
29
30 static GHashTable * plugin_if_callback_functions;
31
32 static void
plugin_if_init_hashtable(void)33 plugin_if_init_hashtable(void)
34 {
35 if ( plugin_if_callback_functions == 0 )
36 plugin_if_callback_functions = g_hash_table_new(g_direct_hash, g_direct_equal);
37 }
38
plugin_if_call_gui_cb(plugin_if_callback_t actionType,GHashTable * dataSet)39 static void plugin_if_call_gui_cb(plugin_if_callback_t actionType, GHashTable * dataSet)
40 {
41 plugin_if_gui_cb action;
42
43 plugin_if_init_hashtable();
44
45 if ( g_hash_table_lookup_extended(plugin_if_callback_functions, GINT_TO_POINTER(actionType), NULL, (gpointer*)&action) )
46 {
47 if ( action != NULL )
48 action(dataSet);
49 }
50 }
51
52
ext_menubar_get_entries(void)53 extern GList * ext_menubar_get_entries(void)
54 {
55 return menubar_entries;
56 }
57
ext_menubar_register_menu(int proto_id,const gchar * menulabel,gboolean is_plugin)58 extern ext_menu_t * ext_menubar_register_menu(int proto_id, const gchar * menulabel,
59 gboolean is_plugin)
60 {
61 ext_menubar_t * entry = NULL;
62 gchar * name = NULL;
63
64 /* A name for the entry must be provided */
65 ws_assert(menulabel != NULL && strlen ( menulabel ) > 0 );
66
67 /* A protocol must exist for the given id */
68 ws_assert(find_protocol_by_id(proto_id) != NULL);
69
70 /* Create unique name, which is used by GTK to provide the menu */
71 name = g_strconcat(proto_get_protocol_filter_name(proto_id), "Menu", NULL);
72
73 /* For now, a protocol may only register one main menu */
74 ws_assert(g_list_find(menubar_menunames, name) == NULL);
75
76 entry = g_new0(ext_menubar_t, 1);
77 entry->type = EXT_MENUBAR_MENU;
78 entry->proto = proto_id;
79 entry->is_plugin = is_plugin;
80
81 entry->parent_menu = 0;
82
83 /* Create a name for this submenu */
84 entry->name = name;
85 entry->label = g_strdup(menulabel);
86 entry->tooltip = g_strdup(menulabel);
87
88 entry->submenu_cnt = 0;
89 entry->item_cnt = 0;
90
91 menubar_entries = g_list_append(menubar_entries, entry);
92 menubar_menunames = g_list_append(menubar_menunames, name);
93
94 return entry;
95 }
96
ext_menubar_set_parentmenu(ext_menu_t * menu,const gchar * parentmenu)97 extern ext_menu_t * ext_menubar_set_parentmenu(ext_menu_t * menu, const gchar * parentmenu)
98 {
99 ws_assert(menu != NULL && menu->parent == NULL);
100
101 ws_assert(parentmenu != 0);
102
103 menu->parent_menu = g_strdup(parentmenu);
104
105 return menu;
106 }
107
ext_menubar_add_submenu(ext_menu_t * parent,const gchar * menulabel)108 extern ext_menu_t * ext_menubar_add_submenu(ext_menu_t * parent, const gchar *menulabel)
109 {
110 ext_menubar_t * entry = NULL;
111
112 /* A name for the entry must be provided */
113 ws_assert(menulabel != NULL && strlen ( menulabel ) > 0 );
114
115 /* Parent must be a valid parent */
116 ws_assert(parent != NULL && parent->type == EXT_MENUBAR_MENU);
117
118 parent->submenu_cnt++;
119
120 /* Create submenu entry */
121 entry = g_new0(ext_menubar_t, 1);
122 entry->type = EXT_MENUBAR_MENU;
123 entry->parent = parent;
124 /* Just a convenience */
125 entry->proto = parent->proto;
126 entry->is_plugin = parent->is_plugin;
127 /* Create unique name, which is used by GTK to provide the menu */
128 entry->name = g_strdup_printf("%sS%02d", parent->name, parent->submenu_cnt);
129 entry->label = g_strdup(menulabel);
130 entry->tooltip = g_strdup(menulabel);
131
132 parent->children = g_list_append(parent->children, entry);
133
134 return entry;
135 }
136
ext_menubar_add_generic_entry(ext_menubar_entry_t type,ext_menu_t * parent,const gchar * label,const gchar * tooltip,ext_menubar_action_cb callback,gpointer user_data)137 static void ext_menubar_add_generic_entry (
138 ext_menubar_entry_t type, ext_menu_t * parent, const gchar * label,
139 const gchar * tooltip, ext_menubar_action_cb callback, gpointer user_data )
140 {
141 ext_menubar_t * entry = NULL;
142
143 /* A valid parent must exist */
144 ws_assert(parent != NULL && parent->type == EXT_MENUBAR_MENU);
145 /* A label for the entry must be provided */
146 ws_assert(label != NULL && strlen ( label ) > 0 );
147
148 parent->item_cnt++;
149
150 /* Create menu entry */
151 entry = g_new0(ext_menubar_t, 1);
152 entry->type = type;
153 /* Create unique name, which is used by GTK to provide the menu */
154 entry->name = g_strdup_printf("%sI%02d", parent->name, parent->item_cnt);
155 entry->label = g_strdup(label);
156
157 if ( tooltip != NULL && strlen(tooltip) > 0 )
158 entry->tooltip = g_strdup(tooltip);
159
160 entry->callback = callback;
161 entry->user_data = user_data;
162
163 parent->children = g_list_append(parent->children, entry);
164 }
165
ext_menubar_add_entry(ext_menu_t * parent,const gchar * label,const gchar * tooltip,ext_menubar_action_cb callback,gpointer user_data)166 extern void ext_menubar_add_entry(ext_menu_t * parent, const gchar *label,
167 const gchar *tooltip, ext_menubar_action_cb callback, gpointer user_data)
168 {
169 /* A callback must be provided */
170 ws_assert(callback != NULL);
171
172 ext_menubar_add_generic_entry ( EXT_MENUBAR_ITEM, parent, label, tooltip, callback, user_data );
173 }
174
ext_menubar_add_website(ext_menu_t * parent,const gchar * label,const gchar * tooltip,const gchar * url)175 extern void ext_menubar_add_website(ext_menu_t * parent, const gchar *label,
176 const gchar *tooltip, const gchar *url)
177 {
178 /* An url for the entry must be provided */
179 ws_assert(url != NULL && strlen ( url ) > 0 );
180
181 ext_menubar_add_generic_entry ( EXT_MENUBAR_URL, parent, label, tooltip, NULL, (gpointer) g_strdup(url) );
182 }
183
ext_menubar_add_separator(ext_menu_t * parent)184 extern void ext_menubar_add_separator(ext_menu_t *parent)
185 {
186 ext_menubar_add_generic_entry ( EXT_MENUBAR_SEPARATOR, parent, "-", NULL, NULL, NULL );
187 }
188
189 /* Implementation of external toolbar handlers */
190
191 static GList * toolbar_entries = NULL;
192
ext_toolbar_get_entries(void)193 extern GList * ext_toolbar_get_entries(void)
194 {
195 return toolbar_entries;
196 }
197
ext_toolbar_register_toolbar(const gchar * toolbarlabel)198 ext_toolbar_t * ext_toolbar_register_toolbar(const gchar * toolbarlabel)
199 {
200 ext_toolbar_t * entry = NULL;
201
202 /* A name for the entry must be provided */
203 ws_assert(toolbarlabel != NULL && strlen ( toolbarlabel ) > 0 );
204
205 entry = g_new0(ext_toolbar_t, 1);
206 entry->type = EXT_TOOLBAR_BAR;
207
208 /* Create a name for this toolbar */
209 entry->name = g_strdup(toolbarlabel);
210 entry->tooltip = g_strdup(toolbarlabel);
211
212 entry->submenu_cnt = 0;
213 entry->item_cnt = 0;
214
215 toolbar_entries = g_list_append(toolbar_entries, entry);
216
217 return entry;
218 }
219
220 static gint
ext_toolbar_compare(gconstpointer a,gconstpointer b)221 ext_toolbar_compare(gconstpointer a, gconstpointer b)
222 {
223 if ( !a || !b )
224 return -1;
225
226 const ext_toolbar_t * ta = (const ext_toolbar_t *)a;
227 const ext_toolbar_t * tb = (const ext_toolbar_t *)b;
228
229 return strcmp(ta->name, tb->name);
230 }
231
ext_toolbar_unregister_toolbar_by_name(const gchar * toolbar_name)232 void ext_toolbar_unregister_toolbar_by_name(const gchar * toolbar_name)
233 {
234 GList * walker = 0;
235
236 if ( ! toolbar_name )
237 return;
238
239 walker = toolbar_entries;
240 while ( walker && walker->data )
241 {
242 ext_toolbar_t * entry = (ext_toolbar_t *)walker->data;
243 if ( g_strcmp0(entry->name, toolbar_name) == 0)
244 {
245 ext_toolbar_unregister_toolbar(entry);
246 break;
247 }
248
249 walker = g_list_next(walker);
250 }
251 }
252
ext_toolbar_unregister_toolbar(ext_toolbar_t * toolbar)253 void ext_toolbar_unregister_toolbar(ext_toolbar_t * toolbar)
254 {
255 if ( ! toolbar )
256 return;
257
258 GList * entry = g_list_find_custom(toolbar_entries, toolbar, (GCompareFunc) ext_toolbar_compare);
259 if ( entry && entry->data )
260 {
261 ext_toolbar_t * et = (ext_toolbar_t *)entry->data;
262 toolbar_entries = g_list_remove(toolbar_entries, et);
263
264 if ( ! g_list_find_custom(toolbar_entries, toolbar, (GCompareFunc) ext_toolbar_compare) )
265 {
266 GHashTable * dataSet = g_hash_table_new(g_str_hash, g_str_equal);
267 g_hash_table_insert( dataSet, g_strdup("toolbar_name"), g_strdup(et->name) );
268 plugin_if_call_gui_cb(PLUGIN_IF_REMOVE_TOOLBAR, dataSet);
269
270 g_free(et->name);
271 g_free(et->tooltip);
272 g_free(et->defvalue);
273 g_free(et->regex);
274
275 g_free(et);
276 }
277 }
278 }
279
280 static gint
ext_toolbar_insert_sort(gconstpointer a,gconstpointer b)281 ext_toolbar_insert_sort(gconstpointer a, gconstpointer b)
282 {
283 const ext_toolbar_t * ca = (const ext_toolbar_t *)a;
284 const ext_toolbar_t * cb = (const ext_toolbar_t *)b;
285
286 if ( ca == 0 || cb == 0 )
287 return 0;
288
289 /* Sort buttons after rest of objects */
290 if ( ca->item_type == EXT_TOOLBAR_BUTTON && cb->item_type != EXT_TOOLBAR_BUTTON )
291 return 1;
292 else if ( ca->item_type != EXT_TOOLBAR_BUTTON && cb->item_type == EXT_TOOLBAR_BUTTON )
293 return -1;
294 else
295 {
296 if ( ca->item_cnt > cb->item_cnt )
297 return 2;
298 else if ( ca->item_cnt < cb->item_cnt )
299 return -2;
300 else
301 return 0;
302 }
303 }
304
305 ext_toolbar_t *
ext_toolbar_add_entry(ext_toolbar_t * parent,ext_toolbar_item_t type,const gchar * label,const gchar * defvalue,const gchar * tooltip,gboolean capture_only,GList * value_list,gboolean is_required,const gchar * regex,ext_toolbar_action_cb callback,gpointer user_data)306 ext_toolbar_add_entry( ext_toolbar_t * parent, ext_toolbar_item_t type, const gchar *label,
307 const gchar *defvalue, const gchar *tooltip, gboolean capture_only, GList * value_list,
308 gboolean is_required, const gchar * regex, ext_toolbar_action_cb callback, gpointer user_data)
309 {
310 ext_toolbar_t * entry = NULL;
311
312 /* A valid parent must exist */
313 ws_assert(parent != NULL && parent->type == EXT_TOOLBAR_BAR);
314 /* A label for the entry must be provided */
315 ws_assert(label != NULL && strlen ( label ) > 0 );
316 /* A callback must be provided */
317 ws_assert(callback != NULL);
318
319 parent->item_cnt++;
320
321 /* Create menu entry */
322 entry = g_new0(ext_toolbar_t, 1);
323 entry->type = EXT_TOOLBAR_ITEM;
324 entry->item_type = type;
325 entry->item_cnt = g_list_length(parent->children) + 1;
326
327 entry->name = g_strdup(label);
328
329 if ( tooltip != NULL && strlen(tooltip) > 0 )
330 entry->tooltip = g_strdup(tooltip);
331
332 if ( defvalue != NULL && strlen(defvalue) > 0 )
333 entry->defvalue = g_strdup(defvalue);
334
335 if ( value_list != NULL && g_list_length(value_list) > 0 )
336 entry->values = g_list_copy(value_list);
337
338 entry->regex = g_strdup(regex);
339
340 entry->is_required = is_required;
341 entry->capture_only = capture_only;
342 entry->callback = callback;
343 entry->user_data = user_data;
344
345 parent->children = g_list_insert_sorted(parent->children, entry, ext_toolbar_insert_sort);
346
347 return entry;
348 }
349
350 static gint
ext_toolbar_search_label(gconstpointer tb,gconstpointer lbl)351 ext_toolbar_search_label(gconstpointer tb, gconstpointer lbl)
352 {
353 if ( ! tb || ! lbl )
354 return -1;
355
356 const ext_toolbar_t * toolbar = (const ext_toolbar_t *) tb;
357 if ( toolbar->type != EXT_TOOLBAR_ITEM )
358 return -2;
359
360 const gchar * label = (const gchar * )lbl;
361
362 return g_strcmp0(toolbar->name, label);
363 }
364
ext_toolbar_entry_by_label(const ext_toolbar_t * toolbar,const gchar * label)365 ext_toolbar_t * ext_toolbar_entry_by_label(const ext_toolbar_t * toolbar, const gchar * label)
366 {
367 ext_toolbar_t * result = 0;
368 GList * entry = g_list_find_custom(toolbar->children, label, ext_toolbar_search_label);
369 if ( entry )
370 result = (ext_toolbar_t *)entry->data;
371 return result;
372 }
373
ext_toolbar_add_val(GList * entries,gchar * value,gchar * display,gboolean is_default)374 GList * ext_toolbar_add_val(GList * entries, gchar * value, gchar * display, gboolean is_default)
375 {
376 ext_toolbar_value_t * newval = g_new0(ext_toolbar_value_t, 1);
377 newval->value = g_strdup(value);
378 newval->display = g_strdup(display);
379 newval->is_default = is_default;
380
381 return g_list_append(entries, newval);
382 }
383
384 typedef struct _ext_toolbar_update_entry_t
385 {
386 ext_toolbar_action_cb callback;
387 gpointer item_data;
388 } ext_toolbar_update_entry_t;
389
390 typedef struct _ext_toolbar_update_list_t
391 {
392 ext_toolbar_t * item;
393 GList * entries;
394 } ext_toolbar_update_list_t;
395
396 static gint
ext_toolbar_find_item(gconstpointer a,gconstpointer b)397 ext_toolbar_find_item(gconstpointer a, gconstpointer b)
398 {
399 if ( a == 0 || b == 0 )
400 return -1;
401
402 const ext_toolbar_update_list_t * item = (const ext_toolbar_update_list_t *)a;
403 const ext_toolbar_t * entry = (const ext_toolbar_t *)b;
404
405 if ( item->item && g_strcmp0 ( item->item->name, entry->name ) == 0 )
406 return 0;
407
408 return -1;
409 }
410
411 static GList * toolbar_updates = NULL;
412
ext_toolbar_register_update_cb(ext_toolbar_t * entry,ext_toolbar_action_cb callback,gpointer item_data)413 void ext_toolbar_register_update_cb(ext_toolbar_t * entry, ext_toolbar_action_cb callback, gpointer item_data)
414 {
415 if ( entry == 0 || item_data == 0 || callback == 0 )
416 return;
417
418 ext_toolbar_update_list_t * update = NULL;
419 GList * update_list = g_list_find_custom(toolbar_updates, entry, ext_toolbar_find_item);
420 if ( ! update_list )
421 {
422 update = g_new0(ext_toolbar_update_list_t, 1);
423 update->item = entry;
424 toolbar_updates = g_list_append(toolbar_updates, update);
425 }
426 else
427 {
428 update = (ext_toolbar_update_list_t*)update_list->data;
429 }
430
431 ext_toolbar_update_entry_t * update_entry = g_new0(ext_toolbar_update_entry_t, 1);
432 update_entry->callback = callback;
433 update_entry->item_data = item_data;
434 update->entries = g_list_append(update->entries, update_entry);
435 }
436
437 static void
ext_toolbar_update_entry(ext_toolbar_update_type_t update_type,ext_toolbar_t * entry,gpointer data,gpointer idx,gboolean silent)438 ext_toolbar_update_entry(ext_toolbar_update_type_t update_type, ext_toolbar_t * entry, gpointer data, gpointer idx, gboolean silent)
439 {
440 GList * update = g_list_find_custom(toolbar_updates, entry, ext_toolbar_find_item);
441 GList * walker = NULL;
442
443 if ( ! update || ! update->data )
444 return;
445
446 ext_toolbar_update_t * update_data = g_new0(ext_toolbar_update_t, 1);
447 update_data->user_data = data;
448 update_data->data_index = idx;
449 update_data->silent = silent;
450 update_data->type = update_type;
451
452 walker = ((ext_toolbar_update_list_t *)(update->data))->entries;
453
454 while ( walker && walker->data )
455 {
456 ext_toolbar_update_entry_t * update_entry = (ext_toolbar_update_entry_t *)walker->data;
457 /* Call Callback */
458 if ( update_entry->callback && update_entry->item_data )
459 update_entry->callback(entry, update_entry->item_data, update_data);
460 walker = g_list_next(walker);
461 }
462
463 g_free(update_data);
464 }
465
ext_toolbar_update_value(ext_toolbar_t * entry,gpointer data,gboolean silent)466 void ext_toolbar_update_value(ext_toolbar_t * entry, gpointer data, gboolean silent)
467 {
468 ext_toolbar_update_entry( EXT_TOOLBAR_UPDATE_VALUE, entry, data, NULL, silent );
469 }
470
ext_toolbar_update_data(ext_toolbar_t * entry,gpointer data,gboolean silent)471 void ext_toolbar_update_data(ext_toolbar_t * entry, gpointer data, gboolean silent)
472 {
473 if ( entry->item_type == EXT_TOOLBAR_SELECTOR )
474 ext_toolbar_update_entry( EXT_TOOLBAR_UPDATE_DATA, entry, data, NULL, silent );
475 }
476
ext_toolbar_update_data_by_index(ext_toolbar_t * entry,gpointer data,gpointer idx,gboolean silent)477 void ext_toolbar_update_data_by_index(ext_toolbar_t * entry, gpointer data, gpointer idx, gboolean silent)
478 {
479 if ( entry->item_type == EXT_TOOLBAR_SELECTOR )
480 ext_toolbar_update_entry( EXT_TOOLBAR_UPDATE_DATABYINDEX, entry, data, idx, silent );
481 }
482
ext_toolbar_update_data_add_entry(ext_toolbar_t * entry,gpointer data,gpointer idx,gboolean silent)483 void ext_toolbar_update_data_add_entry(ext_toolbar_t * entry, gpointer data, gpointer idx, gboolean silent)
484 {
485 if ( entry->item_type == EXT_TOOLBAR_SELECTOR )
486 ext_toolbar_update_entry( EXT_TOOLBAR_UPDATE_DATA_ADD, entry, data, idx, silent );
487 }
488
ext_toolbar_update_data_remove_entry(ext_toolbar_t * entry,gpointer data,gpointer idx,gboolean silent)489 void ext_toolbar_update_data_remove_entry(ext_toolbar_t * entry, gpointer data, gpointer idx, gboolean silent)
490 {
491 if ( entry->item_type == EXT_TOOLBAR_SELECTOR )
492 ext_toolbar_update_entry( EXT_TOOLBAR_UPDATE_DATA_REMOVE, entry, data, idx, silent );
493 }
494
ext_toolbar_update_data_set_active(ext_toolbar_t * entry,gboolean status)495 void ext_toolbar_update_data_set_active(ext_toolbar_t * entry, gboolean status)
496 {
497 ext_toolbar_update_entry(EXT_TOOLBAR_SET_ACTIVE, entry, GINT_TO_POINTER(status ? 1 : 0), 0, TRUE );
498 }
499
500 /* Implementation of GUI callback methods follows.
501 * This is a necessity, as using modern UI systems, gui interfaces often operate
502 * in different threads then the calling application. Even more so, if the calling
503 * application is implemented using a separate plugin. Therefore the external menubars
504 * cannot call gui functionality directly, the gui has to perform the function within
505 * it' own scope. */
506
plugin_if_apply_filter(const char * filter_string,gboolean force)507 extern void plugin_if_apply_filter(const char * filter_string, gboolean force)
508 {
509 plugin_if_callback_t actionType;
510 GHashTable * dataSet = NULL;
511
512 actionType = ( force == TRUE ) ? PLUGIN_IF_FILTER_ACTION_APPLY : PLUGIN_IF_FILTER_ACTION_PREPARE;
513 dataSet = g_hash_table_new(g_str_hash, g_str_equal);
514
515 g_hash_table_insert( dataSet, g_strdup("action_type"), (gpointer) &actionType );
516 g_hash_table_insert( dataSet, g_strdup("filter_string"), g_strdup(filter_string) );
517 g_hash_table_insert( dataSet, g_strdup("force"), (gpointer) &force );
518
519 plugin_if_call_gui_cb(actionType, dataSet);
520 }
521
plugin_if_goto_frame(guint32 framenr)522 extern void plugin_if_goto_frame(guint32 framenr)
523 {
524 GHashTable * dataSet = NULL;
525
526 dataSet = g_hash_table_new(g_str_hash, g_str_equal);
527
528 g_hash_table_insert( dataSet, g_strdup("frame_nr"), GUINT_TO_POINTER(framenr) );
529
530 plugin_if_call_gui_cb(PLUGIN_IF_GOTO_FRAME, dataSet);
531 }
532
plugin_if_save_preference(const char * pref_module,const char * pref_key,const char * pref_value)533 extern void plugin_if_save_preference(const char * pref_module, const char * pref_key, const char * pref_value)
534 {
535 GHashTable * dataSet = NULL;
536
537 dataSet = g_hash_table_new(g_str_hash, g_str_equal);
538
539 g_hash_table_insert( dataSet, g_strdup("pref_module"), g_strdup(pref_module) );
540 g_hash_table_insert( dataSet, g_strdup("pref_key"), g_strdup(pref_key) );
541 g_hash_table_insert( dataSet, g_strdup("pref_value"), g_strdup(pref_value) );
542
543 plugin_if_call_gui_cb(PLUGIN_IF_PREFERENCE_SAVE, dataSet);
544 }
545
plugin_if_get_ws_info(ws_info_t ** ws_info_ptr)546 extern void plugin_if_get_ws_info(ws_info_t **ws_info_ptr)
547 {
548 static ws_info_t ws_info = { FALSE, FILE_CLOSED, NULL, 0, 0, FALSE };
549 #ifdef HAVE_LIBPCAP
550
551 GHashTable * dataSet;
552 gchar * pluginKey = g_strdup("ws_info");
553
554 dataSet = g_hash_table_new(g_str_hash, g_str_equal);
555
556 g_hash_table_insert(dataSet, pluginKey, &ws_info);
557
558 plugin_if_call_gui_cb(PLUGIN_IF_GET_WS_INFO, dataSet);
559
560 g_hash_table_destroy(dataSet);
561 g_free(pluginKey);
562
563 #else
564
565 /* Initialise the ws_info structure */
566
567 ws_info.ws_info_supported = FALSE;
568 ws_info.cf_count = 0;
569 ws_info.cf_filename = NULL;
570 ws_info.cf_framenr = 0;
571 ws_info.frame_passed_dfilter = FALSE;
572 ws_info.cf_state = FILE_CLOSED;
573
574 #endif /* HAVE_LIBPCAP */
575
576 *ws_info_ptr = &ws_info;
577 }
578
plugin_if_get_frame_data(plugin_if_frame_data_cb extract_cb,void * user_data)579 extern void* plugin_if_get_frame_data(plugin_if_frame_data_cb extract_cb, void* user_data) {
580 GHashTable* dataSet = NULL;
581 void* ret_value = NULL;
582
583 dataSet = g_hash_table_new(g_str_hash, g_str_equal);
584
585 g_hash_table_insert(dataSet, g_strdup("extract_cb"), extract_cb);
586 g_hash_table_insert(dataSet, g_strdup("user_data"), user_data);
587 g_hash_table_insert(dataSet, g_strdup("ret_value_ptr"), &ret_value);
588
589 plugin_if_call_gui_cb(PLUGIN_IF_GET_FRAME_DATA, dataSet);
590
591 g_hash_table_destroy(dataSet);
592
593 return ret_value;
594 }
595
plugin_if_get_capture_file(plugin_if_capture_file_cb extract_cb,void * user_data)596 extern void* plugin_if_get_capture_file(plugin_if_capture_file_cb extract_cb, void* user_data) {
597 GHashTable* dataSet = NULL;
598 void* ret_value = NULL;
599
600 dataSet = g_hash_table_new(g_str_hash, g_str_equal);
601
602 g_hash_table_insert(dataSet, g_strdup("extract_cb"), extract_cb);
603 g_hash_table_insert(dataSet, g_strdup("user_data"), user_data);
604 g_hash_table_insert(dataSet, g_strdup("ret_value_ptr"), &ret_value);
605
606 plugin_if_call_gui_cb(PLUGIN_IF_GET_CAPTURE_FILE, dataSet);
607
608 g_hash_table_destroy(dataSet);
609
610 return ret_value;
611 }
612
plugin_if_register_gui_cb(plugin_if_callback_t actionType,plugin_if_gui_cb callback)613 extern void plugin_if_register_gui_cb(plugin_if_callback_t actionType, plugin_if_gui_cb callback)
614 {
615 plugin_if_init_hashtable();
616
617 if ( ! g_hash_table_lookup_extended(plugin_if_callback_functions, GINT_TO_POINTER(actionType), NULL, NULL ) )
618 g_hash_table_insert(plugin_if_callback_functions, GINT_TO_POINTER(actionType), (gpointer)callback);
619 }
620
621 /*
622 * Editor modelines
623 *
624 * Local Variables:
625 * c-basic-offset: 4
626 * tab-width: 8
627 * indent-tabs-mode: nil
628 * End:
629 *
630 * ex: set shiftwidth=4 tabstop=8 expandtab:
631 * :indentSize=4:tabSize=8:noTabs=true:
632 */
633