diff options
author | Roland Knall <roland.knall@br-automation.com> | 2014-02-25 14:05:11 +0100 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-08-21 03:34:02 +0000 |
commit | bed29af46db06f4bce00d8a4dab26317d4563dd3 (patch) | |
tree | 3502e7ee703097a9c7c3e067ac9e6c7b5ad9ed8a /ui/gtk/capture_dlg.c | |
parent | 401469880b8b98a4d42011bdf9af7fbb67c6f057 (diff) | |
download | wireshark-bed29af46db06f4bce00d8a4dab26317d4563dd3.tar.gz |
Extcap Capture Interface
Extcap is a plugin interface, which allows for the usage
of external capture interfaces via pipes using a predefined
configuration language which results in a graphical gui.
This implementation seeks for a generic implementation,
which results in a seamless integration with the current
system, and does add all external interfaces as simple
interfaces.
Windows Note: Due to limitations with GTK and Windows,
a gspawn-winXX-helper.exe, respective gspawn-winXX-helper-console.exe
is needed, which is part of any GTK windows installation.
The default installation directory from the build is an extcap
subdirectory underneath the run directory. The folder used by
extcap may be viewed in the folders tab of the about dialog.
The default installation directory for extcap plugins with
a pre-build or installer version of wireshark is the extcap
subdirectory underneath the main wireshark directory.
For more information see:
http://youtu.be/Nn84T506SwU
bug #9009
Also take a look in doc/extcap_example.py for a Python-example
and in extcap.pod for the arguments grammer.
Todo:
- Integrate with Qt - currently no GUI is generated, but
the interfaces are still usable
Change-Id: I4f1239b2f1ebd8b2969f73af137915f5be1ce50f
Signed-off-by: Mike Ryan <mikeryan+wireshark@lacklustre.net>
Signed-off-by: Mike Kershaw <dragorn@kismetwireless.net>
Signed-off-by: Roland Knall <rknall@gmail.com>
Reviewed-on: https://code.wireshark.org/review/359
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/gtk/capture_dlg.c')
-rw-r--r-- | ui/gtk/capture_dlg.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c index 4a628c022b..7a299d047c 100644 --- a/ui/gtk/capture_dlg.c +++ b/ui/gtk/capture_dlg.c @@ -80,6 +80,11 @@ #include "airpcap_dlg.h" #endif +#ifdef HAVE_EXTCAP +#include "extcap.h" +#include "ui/gtk/extcap_gtk.h" +#endif + /* * Symbolic names for column indices. */ @@ -165,6 +170,10 @@ enum #define E_CAP_T_RESOLVE_KEY "cap_t_resolve" #define E_CAP_E_RESOLVE_KEY "cap_e_resolve" +#ifdef HAVE_EXTCAP +#define E_CAP_EXTCAP_KEY "cap_extcap_vbox" +#endif + #define E_CAP_IFTYPE_CBX_KEY "cap_iftype_cbx" #ifdef HAVE_PCAP_REMOTE #define E_CAP_IF_LIST_KEY "cap_if_list" @@ -2382,6 +2391,9 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_) #if defined(_WIN32) || defined(HAVE_PCAP_CREATE) GtkWidget *buffer_size_sb; #endif +#ifdef HAVE_EXTCAP + GtkWidget *extcap_vbox; +#endif interface_t device; gpointer ptr = NULL; @@ -2403,6 +2415,10 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_) linktype_combo_box = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_LT_CBX_KEY); +#ifdef HAVE_EXTCAP + extcap_vbox = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_EXTCAP_KEY); +#endif + if (device.links != NULL) { if (ws_combo_box_get_active_pointer(GTK_COMBO_BOX(linktype_combo_box), &ptr)) { /* Even though device.links != NULL, we might not have an active pointer @@ -2436,6 +2452,19 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_) g_free(device.cfilter); g_assert(filter_text != NULL); device.cfilter = filter_text; + +#ifdef HAVE_EXTCAP + if (device.external_cap_args_settings != NULL) + g_hash_table_unref(device.external_cap_args_settings); + + device.external_cap_args_settings = extcap_gtk_get_state(extcap_vbox); + + /* Destroy the args data linked in the gtk widget */ +#if 0 + extcap_gtk_free_args(extcap_vbox); +#endif +#endif + #ifdef HAVE_PCAP_CREATE /* if dumpcap reported that the interface does not support monitor mode, we disable monitor mode even if the user explicitly selected it */ @@ -2472,6 +2501,36 @@ adjust_snap_sensitivity(GtkWidget *tb _U_, gpointer parent_w _U_) g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device); } +#ifdef HAVE_EXTCAP +void +extcap_free_arglist(gpointer data, gpointer user_data _U_) +{ + extcap_free_arg ( (extcap_arg *) data ); +} + +static GtkWidget *build_extcap_options(const gchar *name, GHashTable *hash) { + GtkWidget *ret_box = NULL; + GList *arglist = NULL; + GList *elem = NULL; + + arglist = extcap_get_if_configuration( name ); + for ( elem = g_list_first(arglist); elem; elem = elem->next ) + { + GSList *widget_list; + +#if GTK_CHECK_VERSION(3, 0, 0) + ret_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 3); +#else + ret_box = gtk_vbox_new(FALSE, 3); +#endif + widget_list = extcap_populate_gtk_vbox((GList *) elem->data, ret_box, hash); + g_object_set_data(G_OBJECT(ret_box), EXTCAP_GTK_DATA_KEY_WIDGETLIST, widget_list); + } + + return ret_box; +} +#endif + void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata) { GtkWidget *caller, *window, *swindow = NULL, *if_view, @@ -2494,7 +2553,11 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum *compile_bt, #endif *bbox, *ok_but, *cancel_bt, +#ifdef HAVE_EXTCAP + *extcap_vbox, +#endif *help_bt; + GList *cf_entry, *list, *cfilter_list; GtkAdjustment *snap_adj; #if defined(_WIN32) || defined(HAVE_PCAP_CREATE) @@ -2518,6 +2581,9 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum GtkCellRenderer *renderer; GtkListStore *store; const gchar *new_cfilter; +#ifdef HAVE_EXTCAP + GHashTable *extcap_hash; +#endif window = (GtkWidget *)userdata; caller = gtk_widget_get_toplevel(GTK_WIDGET(window)); @@ -2544,6 +2610,9 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum #if defined(_WIN32) || defined(HAVE_PCAP_CREATE) device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE; #endif +#ifdef HAVE_EXTCAP + device.external_cap_args_settings = NULL; +#endif model = gtk_tree_view_get_model(view); gtk_tree_model_get_iter (model, &iter, path); @@ -2913,6 +2982,14 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum } #endif +#ifdef HAVE_EXTCAP + extcap_hash = device.external_cap_args_settings; + extcap_vbox = build_extcap_options(device.name, extcap_hash); + gtk_box_pack_start(GTK_BOX(capture_vb), extcap_vbox, FALSE, FALSE, 5); + gtk_widget_show(extcap_vbox); + g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_EXTCAP_KEY, extcap_vbox); +#endif + /* Button row: "Start", "Cancel" and "Help" buttons */ bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL); gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5); |