* Routines for the "Capture Options" dialog and dialog windows popped
* up from it
*
- * $Id$
- *
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
#ifdef HAVE_LIBPCAP
-#include <string.h>
-
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <gtk/gtk.h>
#include <epan/prefs.h>
#include <wsutil/filesystem.h>
-#include "../capture.h"
-#include "../capture_ifinfo.h"
-#include "../capture-pcap-util.h"
-#include "../capture_ui_utils.h"
+#include "ui/capture.h"
+#include "caputils/capture_ifinfo.h"
+#include "caputils/capture-pcap-util.h"
#include "../ringbuffer.h"
+#include "ui/capture_ui_utils.h"
#include "ui/capture_globals.h"
#include "ui/iface_lists.h"
#include "ui/preference_utils.h"
#include "ui/recent.h"
#include "ui/recent_utils.h"
-#include "ui/simple_dialog.h"
#include "ui/util.h"
#include "ui/gtk/main.h"
#include "ui/gtk/filter_dlg.h"
#include "ui/gtk/dlg_utils.h"
#include "ui/gtk/file_dlg.h"
-#include "ui/gtk/stock_icons.h"
#include "ui/gtk/capture_file_dlg.h"
#include "ui/gtk/help_dlg.h"
#include "ui/gtk/gtkglobals.h"
#include "ui/gtk/cfilter_combo_utils.h"
#include "ui/gtk/capture_if_dlg.h"
#include "ui/gtk/main_welcome.h"
-#include "ui/gtk/network_icons.h"
#include "ui/gtk/menus.h"
#include "ui/gtk/prefs_dlg.h"
#include "ui/gtk/main_80211_toolbar.h"
+#include "ui/gtk/stock_icons.h"
+#ifndef HAVE_GRESOURCE
+#include "ui/gtk/pixbuf-csource.h"
+#endif
+#include "simple_dialog.h"
#include "ui/gtk/keys.h"
#include "ui/gtk/old-gtk-compat.h"
-#include "ui/gtk/expert_indicators.h"
#ifdef HAVE_AIRPCAP
-#include <airpcap.h>
-#include "airpcap_loader.h"
+#include <caputils/airpcap.h>
+#include <caputils/airpcap_loader.h>
#include "airpcap_gui_utils.h"
#include "airpcap_dlg.h"
#endif
+#ifdef HAVE_EXTCAP
+#include "extcap.h"
+#include "ui/gtk/extcap_gtk.h"
+#endif
+
/*
* Symbolic names for column indices.
*/
LINK,
PMODE,
SNAPLEN,
-#if defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
BUFFER,
+#endif
+#ifdef HAVE_PCAP_CREATE
MONITOR,
-#elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
- BUFFER,
#endif
FILTER,
NUM_COLUMNS
#define E_CAP_SNAP_CB_KEY "cap_snap_cb"
#define E_CAP_LT_CBX_KEY "cap_lt_cbx"
#define E_CAP_LT_CBX_LABEL_KEY "cap_lt_cbx_label"
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
#define E_CAP_BUFFER_SIZE_SB_KEY "cap_buffer_size_sb"
#endif
#define E_CAP_SNAP_SB_KEY "cap_snap_sb"
#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"
static GtkWidget *compile_bpf_w = NULL;
#endif
static gboolean cap_open_complete; /* valid only if cap_open_w != NULL */
-static const gchar *pipe_name;
+static const gchar *pipe_name = NULL;
static const gchar *selected_name;
static GtkWidget *columns_menu_object;
static GtkUIManager *ui_manager_columns = NULL;
static gint marked_row;
#ifdef HAVE_PCAP_REMOTE
-static GHashTable *remote_host_list=NULL;
static remote_options global_remote_opts;
static guint num_selected = 0;
#endif
+static gulong capture_all_handler_id;
+static gulong promisc_all_handler_id;
+
static void
capture_prep_file_cb(GtkWidget *file_bt, GtkWidget *file_te);
break;
case SNAPLEN: col_name = g_strdup("SNAPLEN");
break;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case BUFFER: col_name = g_strdup("BUFFER");
break;
#endif
-#if defined (HAVE_PCAP_CREATE)
+#ifdef HAVE_PCAP_CREATE
case MONITOR: col_name = g_strdup("MONITOR");
break;
#endif
if (strcmp(name, "Link-layer header") == 0) return LINK;
if (strcmp(name, "Prom. Mode") == 0) return PMODE;
if (strcmp(name, "Snaplen [B]") == 0) return SNAPLEN;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
- if (strcmp(name, "Buffer [MB]") == 0) return BUFFER;
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
+ if (strcmp(name, "Buffer [MiB]") == 0) return BUFFER;
#endif
-#if defined (HAVE_PCAP_CREATE)
+#ifdef HAVE_PCAP_CREATE
if (strcmp(name, "Mon. Mode") == 0) return MONITOR;
#endif
if (strcmp(name, "Capture Filter") == 0) return FILTER;
colorize_filter_te_as_empty(filter_te);
if (strlen(device.cfilter) > 0) {
g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_free(device.cfilter);
device.cfilter = g_strdup(filter_text);
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
update_filter_string(device.name, filter_text);
}
g_assert(filter_text != NULL);
g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_free(device.cfilter);
device.cfilter = g_strdup(filter_text);
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
g_mutex_lock(cfc_data_mtx);
#define SIZE_UNIT_GIGABYTES 2
#define MAX_SIZE_UNITS 3
static const char *size_unit_name[MAX_SIZE_UNITS] = {
- "kibibyte(s)",
- "mebibyte(s)",
- "gibibyte(s)"
+ "kilobyte(s)",
+ "megabyte(s)",
+ "gigabyte(s)"
};
/* create one of the size options */
/* the selected combo_box item can't be changed, once the combo_box
is created, so set the matching combo_box item now */
/* gigabytes */
- if (value >= 1024 * 1024) {
+ if (value >= 1000 * 1000) {
gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), SIZE_UNIT_GIGABYTES);
} else {
/* megabytes */
- if (value >= 1024) {
+ if (value >= 1000) {
gtk_combo_box_set_active(GTK_COMBO_BOX(unit_combo_box), SIZE_UNIT_MEGABYTES);
} else {
/* kilobytes */
return unit_combo_box;
}
-/* convert size value from raw to displayed (e.g. 1024 Bytes -> 1 KB) */
+/* convert size value from raw to displayed (e.g. 1000 Bytes -> 1 kB) */
static guint32 size_unit_combo_box_set_value(
guint32 value)
{
/* gigabytes */
- if (value >= 1024 * 1024) {
- return value / (1024 * 1024);
+ if (value >= 1000 * 1000) {
+ return value / (1000 * 1000);
}
/* megabytes */
- if (value >= 1024) {
- return value / (1024);
+ if (value >= 1000) {
+ return value / (1000);
}
/* kilobytes */
switch(unit) {
case(SIZE_UNIT_KILOBYTES):
- if (value > (((guint32)G_MAXINT + 1) / 1024)) {
+ if (value > (((guint32)G_MAXINT + 1) / 1000)) {
return 0;
} else {
return value;
}
case(SIZE_UNIT_MEGABYTES):
- if (value > (((guint32)G_MAXINT + 1) / (1024 * 1024))) {
+ if (value > (((guint32)G_MAXINT + 1) / (1000 * 1000))) {
return 0;
} else {
- return value * 1024;
+ return value * 1000;
}
case(SIZE_UNIT_GIGABYTES):
- if (value > (((guint32)G_MAXINT + 1) / (1024 * 1024 * 1024))) {
+ if (value > (((guint32)G_MAXINT + 1) / (1000 * 1000 * 1000))) {
return 0;
} else {
- return value * 1024 * 1024;
+ return value * 1000 * 1000;
}
default:
g_assert_not_reached();
GtkTreeIter iter;
gboolean create_new = FALSE;
gchar *string;
- guint i, pos = REMOTE_HOST_START;
- struct remote_host_info *rh;
+ guint pos = REMOTE_HOST_START;
+ struct remote_host *rh;
- rh = g_hash_table_lookup (remote_host_list, device->remote_opts.remote_host_opts.remote_host);
+ rh = recent_get_remote_host(device->remote_opts.remote_host_opts.remote_host);
if (!rh) {
rh = g_malloc0 (sizeof (*rh));
- if (g_hash_table_size (remote_host_list) == 0) {
+ if (recent_get_remote_host_list_size() == 0) {
iftype_combo_box_add_remote_separators (iftype_cbx);
}
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(iftype_cbx), pos, device->remote_opts.remote_host_opts.remote_host);
- rh->remote_host = g_strdup (device->remote_opts.remote_host_opts.remote_host);
+ rh->r_host = g_strdup (device->remote_opts.remote_host_opts.remote_host);
create_new = TRUE;
} else {
- model = gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cbx));
- if (gtk_tree_model_get_iter_first(model, &iter)) {
- /* Skip the first entries */
- for (i = 0; i < REMOTE_HOST_START; i++)
- gtk_tree_model_iter_next(model, &iter);
- do {
+ model = (GtkTreeModel *)gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cbx));
+ if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) {
+ while (gtk_tree_model_iter_next(model, &iter)) {
gtk_tree_model_get(model, &iter, 0, &string, -1);
if (string) {
if (strcmp (device->remote_opts.remote_host_opts.remote_host, string) == 0) {
g_free (string);
}
pos++;
- } while (gtk_tree_model_iter_next(model, &iter));
+ }
}
g_free (rh->remote_port);
rh->auth_password = g_strdup (device->remote_opts.remote_host_opts.auth_password);
if (create_new) {
- g_hash_table_insert (remote_host_list, g_strdup (device->remote_opts.remote_host_opts.remote_host), rh);
+ recent_add_remote_host(g_strdup (device->remote_opts.remote_host_opts.remote_host), rh);
}
g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(1));
iftype_combo_box_add_remote_host (gpointer key, gpointer value _U_, gpointer user_data)
{
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(user_data), REMOTE_HOST_START, key);
-
-/* if (g_array_index(global_capture_opts.ifaces, interface_options, 0).src_type == CAPTURE_IFREMOTE) {*/
- /* Ensure we select the correct entry */
- /* if (strcmp ((char *)key, g_array_index(global_capture_opts.ifaces, interface_options, 0).remote_host) == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(user_data), REMOTE_HOST_START);
- }
- }*/
}
/* Fill the menu of available types of interfaces */
iftype_combo_box_new(void)
{
GtkWidget *iftype_cbx;
+ GHashTable *ht;
iftype_cbx = gtk_combo_box_text_new_with_entry();
- /* for (i = 0; i < sizeof(iftype) / sizeof(iftype[0]); i++) {
- gtk_combo_box_text_append_text(GTK_COMBO_BOX(iftype_cbx), iftype[i].name);
- }*/
-
- if (g_hash_table_size (remote_host_list) > 0) {
+ ht = get_remote_host_list();
+ if (g_hash_table_size (ht) > 0) {
/* Add remote hosts */
- g_hash_table_foreach (remote_host_list, iftype_combo_box_add_remote_host, iftype_cbx);
+ g_hash_table_foreach (ht, iftype_combo_box_add_remote_host, iftype_cbx);
iftype_combo_box_add_remote_separators (iftype_cbx);
}
GtkTreeView *if_cb;
GtkTreeModel *model;
link_row *linkr = NULL;
+ address addr_str;
+ char* temp_addr_str = NULL;
if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
model = gtk_tree_view_get_model(if_cb);
/* Scan through the list and build a list of strings to display. */
for (if_entry = g_list_first(list); if_entry != NULL; if_entry = g_list_next(if_entry)) {
+ gchar *auth_str = NULL;
if_info = (if_info_t *)if_entry->data;
#ifdef HAVE_PCAP_REMOTE
add_interface_to_remote_list(if_info);
ip_str = g_string_new("");
str = "";
ips = 0;
+ memset(&device, 0, sizeof(device));
device.name = g_strdup(if_info->name);
/* Is this interface hidden and, if so, should we include it
anyway? */
} else {
device.display_name = g_strdup(if_string);
}
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if ((device.buffer = capture_dev_user_buffersize_find(if_string)) == -1) {
device.buffer = global_capture_opts.default_options.buffer_size;
}
#endif
- if ((device.pmode = capture_dev_user_pmode_find(if_string)) == -1) {
+ if (!capture_dev_user_pmode_find(if_string, &device.pmode)) {
device.pmode = global_capture_opts.default_options.promisc_mode;
}
- device.has_snaplen = global_capture_opts.default_options.has_snaplen;
- if ((device.snaplen = capture_dev_user_snaplen_find(if_string)) == -1) {
+ if (!capture_dev_user_snaplen_find(if_string, &device.has_snaplen,
+ &device.snaplen)) {
+ device.has_snaplen = global_capture_opts.default_options.has_snaplen;
device.snaplen = global_capture_opts.default_options.snaplen;
}
device.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
monitor_mode = prefs_capture_device_monitor_mode(if_string);
- caps = capture_get_if_capabilities(if_string, monitor_mode, NULL, main_window_update);
+#ifdef HAVE_PCAP_REMOTE
+ if (global_remote_opts.remote_host_opts.auth_type == CAPTURE_AUTH_PWD) {
+ auth_str = g_strdup_printf("%s:%s", global_remote_opts.remote_host_opts.auth_username,
+ global_remote_opts.remote_host_opts.auth_password);
+ }
+#endif
+ caps = capture_get_if_capabilities(if_string, monitor_mode, auth_str, NULL, main_window_update);
+ g_free(auth_str);
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
for (; (curr_addr = g_slist_nth(if_info->addrs, ips)) != NULL; ips++) {
if (ips != 0) {
switch (addr->ifat_type) {
case IF_AT_IPv4:
- g_string_append(ip_str, ip_to_str((guint8 *)&addr->addr.ip4_addr));
+ set_address(&addr_str, AT_IPv4, 4, &addr->addr.ip4_addr);
+ temp_addr_str = (char*)address_to_str(NULL, &addr_str);
+ g_string_append(ip_str, temp_addr_str);
break;
case IF_AT_IPv6:
- g_string_append(ip_str, ip6_to_str((struct e_in6_addr *)&addr->addr.ip6_addr));
+ set_address(&addr_str, AT_IPv6, 16, addr->addr.ip6_addr);
+ temp_addr_str = (char*)address_to_str(NULL, &addr_str);
+ g_string_append(ip_str, temp_addr_str);
break;
default:
/* In case we add non-IP addresses */
+ temp_addr_str = NULL;
break;
}
+
+ wmem_free(NULL, temp_addr_str);
} /* for curr_addr */
linktype_count = 0;
device.links = NULL;
device.selected = TRUE;
global_capture_opts.num_selected++;
g_array_append_val(global_capture_opts.all_ifaces, device);
- if (device.has_snaplen) {
- snaplen_string = g_strdup_printf("%d", device.snaplen);
- } else {
- snaplen_string = g_strdup("default");
- }
+ snaplen_string = g_strdup_printf("%d", device.snaplen);
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, BUFFER, device.buffer, MONITOR, "no",FILTER, "",-1);
-#elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
+#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, BUFFER, device.buffer, FILTER, "",-1);
#else
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, FALSE, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, link_type_name, PMODE, (device.pmode?"enabled":"disabled"), SNAPLEN, snaplen_string, -1);
#endif
#ifdef HAVE_PCAP_REMOTE
-/* Retrieve the list of local or remote interfaces according to selected
+/* Retrieve the list of remote interfaces according to selected
* options and re-fill interface name combobox */
static void
-update_interface_list(void)
+update_remote_interface_list(void)
{
GtkWidget *iftype_cbx;
- GList *if_list, *if_r_list;
- int iftype_id, err;
+ GList *if_list;
+ int err;
gchar *err_str;
if (cap_open_w == NULL)
return;
iftype_cbx = (GtkWidget *)g_object_get_data(G_OBJECT(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY)), E_REMOTE_HOST_TE_KEY);
- iftype_id = CAPTURE_IFREMOTE;
- if (iftype_id >= CAPTURE_IFREMOTE) {
- if_r_list = get_remote_interface_list(global_remote_opts.remote_host_opts.remote_host,
- global_remote_opts.remote_host_opts.remote_port,
- global_remote_opts.remote_host_opts.auth_type,
- global_remote_opts.remote_host_opts.auth_username,
- global_remote_opts.remote_host_opts.auth_password,
- &err, &err_str);
-
- if_list = if_r_list;
- } else {
- if_list = capture_interface_list(&err, &err_str, main_window_update); /* Warning: see capture_prep_cb() */
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IF_LIST_KEY, NULL);
- }
-
+ if_list = get_remote_interface_list(global_remote_opts.remote_host_opts.remote_host,
+ global_remote_opts.remote_host_opts.remote_port,
+ global_remote_opts.remote_host_opts.auth_type,
+ global_remote_opts.remote_host_opts.auth_username,
+ global_remote_opts.remote_host_opts.auth_password,
+ &err, &err_str);
if (if_list == NULL &&
(err == CANT_GET_INTERFACE_LIST || err == DONT_HAVE_PCAP)) {
gpointer dialog = simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
g_free(err_str);
- if (iftype_id >= CAPTURE_IFREMOTE) {
- /* Fall back to previous interface list */
- simple_dialog_set_cb(dialog, error_list_remote_interface_cb, iftype_cbx);
- return;
- }
- } else if (iftype_id == CAPTURE_IFREMOTE) {
+ /* Fall back to previous interface list */
+ simple_dialog_set_cb(dialog, error_list_remote_interface_cb, iftype_cbx);
+ return;
+ } else {
/* New remote interface */
insert_new_rows(if_list);
refresh_non_local_interface_lists();
gtk_widget_set_sensitive(GTK_WIDGET(passwd_te), state);
}
-/* user requested to destroy the dialog */
-static void
-capture_remote_destroy_cb(GtkWidget *win, gpointer user_data _U_)
-{
- g_object_set_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY, NULL);
-}
/* user requested to accept remote interface options */
static void
{
GtkWidget *host_te, *port_te, *username_te, *passwd_te, *auth_passwd_rb;
gchar *hostname;
+ struct remote_host *rh;
if (remote_w == NULL) {
return;
global_remote_opts.remote_host_opts.auth_password =
g_strdup(gtk_entry_get_text(GTK_ENTRY(passwd_te)));
- window_destroy(GTK_WIDGET(remote_w));
- update_interface_list();
+ rh = g_malloc (sizeof (*rh));
+ rh->r_host = g_strdup(global_remote_opts.remote_host_opts.remote_host);
+ rh->remote_port = g_strdup(global_remote_opts.remote_host_opts.remote_port);
+ rh->auth_type = global_remote_opts.remote_host_opts.auth_type;
+ rh->auth_password = g_strdup("");
+ rh->auth_username = g_strdup("");
+
+ recent_add_remote_host(hostname, rh);
+
+ update_remote_interface_list();
fill_remote_list();
+ window_destroy(GTK_WIDGET(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY)));
}
static void
window_cancel_button_cb (win, data);
}
-static gboolean
-free_remote_host (gpointer key _U_, gpointer value, gpointer user _U_)
-{
- struct remote_host *rh = value;
-
- g_free (rh->remote_host);
- g_free (rh->remote_port);
- g_free (rh->auth_username);
- g_free (rh->auth_password);
-
- return TRUE;
-}
-
static void
select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data _U_)
{
struct remote_host *rh;
int new_iftype = gtk_combo_box_get_active(GTK_COMBO_BOX(iftype_cbx));
- gint num_remote = g_hash_table_size (remote_host_list);
+ gint num_remote = recent_get_remote_host_list_size();
if (new_iftype != -1 && new_iftype == num_remote+1) {
- g_hash_table_foreach_remove (remote_host_list, free_remote_host, NULL);
+ free_remote_host_list();
num_remote += 2;
while (num_remote--) { /* Remove separator lines and "Clear" item */
gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT(iftype_cbx), num_remote);
capture_remote_cb(GTK_WIDGET(iftype_cbx), FALSE);
} else {
string = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(iftype_cbx));
- rh = g_hash_table_lookup (remote_host_list, string);
+ rh = recent_get_remote_host(string);
g_free (string);
if (rh) {
remote_w = g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
gtk_entry_set_visibility(GTK_ENTRY(passwd_te), FALSE);
ws_gtk_grid_attach_defaults(GTK_GRID (auth_passwd_grid), passwd_te, 1, 1, 1, 1);
- /* Button row: "Start" and "Cancel" buttons */
+ /* Button row: "OK" and "Cancel" buttons */
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
entries, so that if the user types Return there, we act as if the
"OK" button had been selected, as happens if Return is typed if some
widget that *doesn't* handle the Return key has the input focus. */
- dlg_set_activate(host_te, ok_but);
dlg_set_activate(port_te, ok_but);
dlg_set_activate(user_te, ok_but);
dlg_set_activate(passwd_te, ok_but);
g_signal_connect(remote_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
- g_signal_connect(remote_w, "destroy", G_CALLBACK(capture_remote_destroy_cb), NULL);
g_object_set_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY, host_te);
g_object_set_data(G_OBJECT(remote_w), E_REMOTE_PORT_TE_KEY, port_te);
window_present(opt_remote_w);
}
-static void
-recent_print_remote_host (gpointer key _U_, gpointer value, gpointer user)
-{
- FILE *rf = user;
- struct remote_host_info *ri = value;
-
- fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", ri->remote_host, ri->remote_port, ri->auth_type);
-}
-
-void
-capture_remote_combo_recent_write_all(FILE *rf)
-{
- if (remote_host_list && g_hash_table_size (remote_host_list) > 0) {
- /* Write all remote interfaces to the recent file */
- g_hash_table_foreach (remote_host_list, recent_print_remote_host, rf);
- }
-}
-
-gboolean
-capture_remote_combo_add_recent(const gchar *s)
-{
- GList *vals = prefs_get_string_list (s);
- GList *valp = vals;
- gint auth_type;
- char *p;
- struct remote_host_info *rh;
-
- if (valp == NULL)
- return FALSE;
-
- if (remote_host_list == NULL) {
- remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- rh = g_malloc (sizeof (*rh));
-
- /* First value is the host */
- rh->remote_host = g_strdup (valp->data);
- if (strlen(rh->remote_host) == 0) {
- /* Empty remote host */
- g_free(rh->remote_host);
- g_free(rh);
- return FALSE;
- }
- rh->auth_type = CAPTURE_AUTH_NULL;
- valp = valp->next;
-
- if (valp) {
- /* Found value 2, this is the port number */
- rh->remote_port = g_strdup (valp->data);
- valp = valp->next;
- } else {
- /* Did not find a port number */
- rh->remote_port = g_strdup ("");
- }
-
- if (valp) {
- /* Found value 3, this is the authentication type */
- auth_type = strtol(valp->data, &p, 0);
- if (p != valp->data && *p == '\0') {
- rh->auth_type = auth_type;
- }
- }
-
- /* Do not store username and password */
- rh->auth_username = g_strdup ("");
- rh->auth_password = g_strdup ("");
-
- prefs_clear_string_list(vals);
-
- g_hash_table_insert (remote_host_list, g_strdup(rh->remote_host), rh);
-
- return TRUE;
-}
-
#endif /* HAVE_PCAP_REMOTE */
#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
if (error) {
+#ifdef HAVE_GRESOURCE
+ icon = pixbuf_to_widget("/org/wireshark/image/toolbar/14x14/x-expert-error.png");
+#else
icon = pixbuf_to_widget(expert_error_pb_data);
+#endif
gtk_list_store_set(GTK_LIST_STORE(model), &iter, COMPILE_ERROR, 1, SIGN, gtk_image_get_pixbuf(GTK_IMAGE(icon)), INAME, name, -1);
} else {
+#ifdef HAVE_GRESOURCE
+ icon = pixbuf_to_widget("/org/wireshark/image/expert_ok.png");
+#else
icon = pixbuf_to_widget(expert_ok_pb_data);
+#endif
gtk_list_store_set(GTK_LIST_STORE(model), &iter, COMPILE_ERROR, 0, SIGN, gtk_image_get_pixbuf(GTK_IMAGE(icon)), INAME, name, -1);
}
g_hash_table_insert(compile_results, name, text);
}
if (!linkname)
linkname = g_strdup("unknown");
- if (device.has_snaplen) {
- snaplen_string = g_strdup_printf("%d", device.snaplen);
- } else {
- snaplen_string = g_strdup("default");
- }
+ snaplen_string = g_strdup_printf("%d", device.snaplen);
if (cap_open_w) {
if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
path_str = g_strdup_printf("%d", indx);
}
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
- #elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
+ #elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
*monitor_cb,
#endif
*filter_cm, *linktype_combo_box;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
GtkWidget *buffer_size_sb;
#endif
+#ifdef HAVE_EXTCAP
+ GtkWidget *extcap_vbox = NULL;
+#endif
interface_t device;
gpointer ptr = NULL;
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
snap_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_CB_KEY);
snap_sb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_SNAP_SB_KEY);
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
buffer_size_sb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_BUFFER_SIZE_SB_KEY);
#endif
promisc_cb = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_PROMISC_KEY);
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
}
}
device.active_dlt = dlt;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
device.buffer = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_sb));
#endif
device.pmode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(promisc_cb));
device.has_snaplen = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
if (device.has_snaplen) {
- if (device.snaplen != (guint)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb))) {
- }
device.snaplen = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(snap_sb));
- if (device.snaplen < 1)
- device.snaplen = WTAP_MAX_PACKET_SIZE;
- else if (device.snaplen < MIN_PACKET_SIZE)
+ if (device.snaplen < MIN_PACKET_SIZE)
device.snaplen = MIN_PACKET_SIZE;
} else {
device.snaplen = WTAP_MAX_PACKET_SIZE;
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);
+
+ if (extcap_vbox != NULL)
+ 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 */
g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
}
+#ifdef HAVE_EXTCAP
+
+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
+
+/*
+ * If we have an AirPcap "Wireless Settings" checkbox, have two columns
+ * (vboxes) of settings, and put the buffer size in the right column.
+ *
+ * If we have remote capture support, and if this is a remote interface,
+ * have two columns of settings, have a "Remote Sttings" button, and
+ * put it in the right column.
+ *
+ * If we can set the buffer size, then have two columns of settings
+ * and, if we don't have a "Remote Settings" button, put it in the
+ * right column.
+ *
+ * We avoid having the right column if we don't need it, because it
+ * steals 3 pixels.
+ */
+#if defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(CAN_SET_CAPTURE_BUFFER_SIZE)
+#define HAVE_TWO_SETTING_COLUMNS
+# if !defined(HAVE_PCAP_REMOTE)
+# define BUFFER_SIZE_IN_RIGHT_COLUMN
+# endif /* !defined(HAVE_PCAP_REMOTE) */
+#endif /* defined(HAVE_AIRPCAP) || defined(HAVE_PCAP_REMOTE) || defined(CAN_SET_CAPTURE_BUFFER_SIZE) */
+
void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata)
{
GtkWidget *caller, *window, *swindow = NULL, *if_view,
*main_vb, *if_hb, *if_lb, *if_lb_name,
*main_hb, *left_vb,
-#if defined (HAVE_AIRPCAP) || defined (HAVE_PCAP_REMOTE) || defined (HAVE_PCAP_CREATE)
+#ifdef HAVE_TWO_SETTING_COLUMNS
*right_vb,
#endif
*capture_fr, *capture_vb,
*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)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
GtkAdjustment *buffer_size_adj;
GtkWidget *buffer_size_lb, *buffer_size_sb, *buffer_size_hb;
#endif
#ifdef HAVE_PCAP_REMOTE
GtkWidget *remote_bt;
#endif
- #ifdef HAVE_AIRPCAP
+#ifdef HAVE_AIRPCAP
GtkWidget *advanced_bt;
#endif
interface_t device;
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));
device.has_snaplen = FALSE;
device.snaplen = 65535;
device.cfilter = NULL;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
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);
gtk_container_set_border_width(GTK_CONTAINER(left_vb), 0);
gtk_box_pack_start(GTK_BOX(main_hb), left_vb, TRUE, TRUE, 0);
-#if defined (HAVE_AIRPCAP) || defined (HAVE_PCAP_REMOTE) || defined (HAVE_PCAP_CREATE)
- /* Avoid adding the right vbox if not needed, because it steals 3 pixels */
+#ifdef HAVE_TWO_SETTING_COLUMNS
right_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(right_vb), 0);
gtk_box_pack_start(GTK_BOX(main_hb), right_vb, FALSE, FALSE, 3);
filter_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
gtk_box_pack_start(GTK_BOX(capture_vb), filter_hb, FALSE, FALSE, 0);
- filter_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
+ filter_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
g_signal_connect(filter_bt, "clicked", G_CALLBACK(capture_filter_construct_cb), NULL);
g_signal_connect(filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
gtk_widget_set_tooltip_text(filter_bt,
gtk_box_pack_start(GTK_BOX(filter_hb), compile_bt, FALSE, FALSE, 3);
#endif
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
buffer_size_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
buffer_size_lb = gtk_label_new("Buffer size:");
gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 0);
"The memory buffer size used while capturing. If you notice packet drops, you can try to increase this size.");
gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_sb, FALSE, FALSE, 0);
g_object_set_data(G_OBJECT(opt_edit_w), E_CAP_BUFFER_SIZE_SB_KEY, buffer_size_sb);
- buffer_size_lb = gtk_label_new("megabyte(s)");
+ buffer_size_lb = gtk_label_new("mebibyte(s)");
gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 3);
gtk_misc_set_alignment(GTK_MISC(buffer_size_lb), 1, 0);
-#ifdef HAVE_PCAP_REMOTE
- gtk_box_pack_start (GTK_BOX(left_vb), buffer_size_hb, FALSE, FALSE, 0);
-#else
+#ifdef BUFFER_SIZE_IN_RIGHT_COLUMN
gtk_box_pack_start (GTK_BOX(right_vb), buffer_size_hb, FALSE, FALSE, 0);
-#endif
-#endif
+#else /* BUFFER_SIZE_IN_RIGHT_COLUMN */
+ gtk_box_pack_start (GTK_BOX(left_vb), buffer_size_hb, FALSE, FALSE, 0);
+#endif /* BUFFER_SIZE_IN_RIGHT_COLUMN */
+#endif /* CAN_SET_CAPTURE_BUFFER_SIZE */
#ifdef HAVE_PCAP_REMOTE
/*
* confuse users, so that they ask why this is grayed out on
* their non-Windows machine and ask how to enable it.
*/
- airpcap_if_selected = get_airpcap_if_from_name(airpcap_if_list, device.name);
+ airpcap_if_selected = get_airpcap_if_from_name(g_airpcap_if_list, device.name);
if (airpcap_if_selected != NULL) {
advanced_bt = gtk_button_new_with_label("Wireless Settings");
}
#endif
+#ifdef HAVE_EXTCAP
+ extcap_hash = device.external_cap_args_settings;
+ extcap_vbox = build_extcap_options(device.name, extcap_hash);
+ if (extcap_vbox != NULL) {
+ 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);
gint indx = -1;
guint i;
+ /* Initialise device */
+ device.locked = FALSE;
+ device.cfilter = NULL;
+
if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
model = gtk_tree_view_get_model(if_cb);
gtk_tree_model_get_iter (model, &iter, path);
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
if (strcmp(device.name, interface) == 0) {
g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_free(device.cfilter);
device.cfilter = g_strdup(filter_text);
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
update_filter_string(device.name, filter_text);
GtkTreeIter iter;
GtkTreeView *if_cb;
GtkTreeModel *model;
- gboolean enabled = FALSE, set;
+ gboolean enabled = FALSE;
interface_t device;
interface_options interface_opts;
guint i;
- set = gtk_toggle_button_get_active(button);
- gtk_toggle_button_set_active(button, (set?FALSE:TRUE));
if (gtk_toggle_button_get_active(button))
enabled = TRUE;
case(ESD_BTN_OK):
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp((gchar *)data, device.name) == 0) {
- simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
- "%sA pipe with this name already exists.%s",
- simple_dialog_primary_start(), simple_dialog_primary_end());
- if_cb = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
- pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, 0, &optname, -1);
- if (strcmp(optname, (gchar *) data) == 0) {
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, pipe_name, -1);
- gtk_entry_set_text(GTK_ENTRY(pipe_te), pipe_name);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
- g_free(optname);
- }
- return;
+ if (strcmp((gchar *)data, device.name) == 0) {
+ simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
+ "%sA pipe with this name already exists.%s",
+ simple_dialog_primary_start(), simple_dialog_primary_end());
+ if_cb = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
+ pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
+ model = gtk_tree_view_get_model(if_cb);
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ gtk_tree_model_get(model, &iter, 0, &optname, -1);
+ if (strcmp(optname, (gchar *) data) == 0) {
+ gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, pipe_name, -1);
+ gtk_entry_set_text(GTK_ENTRY(pipe_te), pipe_name);
+ break;
+ }
+ } while (gtk_tree_model_iter_next(model, &iter));
+ g_free(optname);
}
+ return;
}
- for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
- device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
- if (strcmp(pipe_name, device.name) == 0) {
- device.name = g_strdup((gchar *)data);
- device.display_name = g_strdup_printf("%s", device.name);
- g_array_remove_index(global_capture_opts.all_ifaces, i);
- g_array_insert_val(global_capture_opts.all_ifaces, i, device);
- temp = g_strdup_printf("<b>%s</b>", device.display_name);
- if (device.has_snaplen) {
- snaplen_string = g_strdup_printf("%d", device.snaplen);
- } else {
- snaplen_string = g_strdup("default");
- }
- if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
- model = gtk_tree_view_get_model(if_cb);
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, IFACE_HIDDEN_NAME, &optname, -1);
- if (strcmp(optname, pipe_name) == 0) {
+ }
+ for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
+ device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
+ if (strcmp(pipe_name, device.name) == 0) {
+ g_free(device.name);
+ g_free(device.display_name);
+ device.name = g_strdup((gchar *)data);
+ device.display_name = g_strdup_printf("%s", device.name);
+ g_array_remove_index(global_capture_opts.all_ifaces, i);
+ g_array_insert_val(global_capture_opts.all_ifaces, i, device);
+ temp = g_strdup_printf("<b>%s</b>", device.display_name);
+ snaplen_string = g_strdup_printf("%d", device.snaplen);
+ if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
+ model = gtk_tree_view_get_model(if_cb);
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ gtk_tree_model_get(model, &iter, IFACE_HIDDEN_NAME, &optname, -1);
+ if (strcmp(optname, pipe_name) == 0) {
#if defined(HAVE_PCAP_CREATE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
-#elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
+ gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
+#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
+ gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
+ gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
#endif
#if 0
- oldname = g_strdup(pipe_name);
+ oldname = g_strdup(pipe_name);
#endif
- pipe_name = g_strdup(device.name);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
+ pipe_name = g_strdup(device.name);
+ break;
+ }
+ } while (gtk_tree_model_iter_next(model, &iter));
- g_free(optname);
- }
- if (global_capture_opts.num_selected > 0) {
- gtk_widget_set_sensitive(ok_bt, TRUE);
+ g_free(optname);
+ }
+ if (global_capture_opts.num_selected > 0) {
+ gtk_widget_set_sensitive(ok_bt, TRUE);
#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, TRUE);
+ gtk_widget_set_sensitive(all_compile_bt, TRUE);
#endif
- } else {
- gtk_widget_set_sensitive(ok_bt, FALSE);
+ } else {
+ gtk_widget_set_sensitive(ok_bt, FALSE);
#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
- gtk_widget_set_sensitive(all_compile_bt, FALSE);
+ gtk_widget_set_sensitive(all_compile_bt, FALSE);
#endif
- }
- refresh_non_local_interface_lists();
- break;
}
+ refresh_non_local_interface_lists();
+ break;
}
- break;
- case(ESD_BTN_CANCEL): {
- if_cb = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
- pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
- model = gtk_tree_view_get_model(if_cb);
+ }
+ break;
+ case(ESD_BTN_CANCEL): {
+ if_cb = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_L_KEY));
+ pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
+ model = gtk_tree_view_get_model(if_cb);
- if (gtk_tree_model_get_iter_first (model, &iter)) {
- do {
- gtk_tree_model_get(model, &iter, 0, &optname, -1);
- if (strcmp(optname, (gchar *) data) == 0) {
- gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, pipe_name, -1);
- gtk_entry_set_text(GTK_ENTRY(pipe_te), pipe_name);
- break;
- }
- } while (gtk_tree_model_iter_next(model, &iter));
- g_free(optname);
- }
- break;
+ if (gtk_tree_model_get_iter_first (model, &iter)) {
+ do {
+ gtk_tree_model_get(model, &iter, 0, &optname, -1);
+ if (strcmp(optname, (gchar *) data) == 0) {
+ gtk_list_store_set (GTK_LIST_STORE(model), &iter, 0, pipe_name, -1);
+ gtk_entry_set_text(GTK_ENTRY(pipe_te), pipe_name);
+ break;
+ }
+ } while (gtk_tree_model_iter_next(model, &iter));
+ g_free(optname);
}
- default:
- g_assert_not_reached();
+ break;
+ }
+ default:
+ g_assert_not_reached();
}
}
guint i;
gpointer dialog;
+ if (!pipe_name)
+ return;
+
pipe_te = (GtkWidget *) g_object_get_data(G_OBJECT(interface_management_w), E_CAP_PIPE_TE_KEY);
g_save_file = gtk_entry_get_text(GTK_ENTRY(pipe_te));
name = g_strdup(g_save_file);
}
}
pipe_name = g_strdup(g_save_file);
+ memset(&device, 0, sizeof(device));
device.name = g_strdup(g_save_file);
device.display_name = g_strdup_printf("%s", device.name);
device.hidden = FALSE;
device.no_addresses = 0;
device.last_packets = 0;
device.links = NULL;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
device.active_dlt = -1;
device.if_info.vendor_description = NULL;
device.if_info.addrs = NULL;
device.if_info.loopback = FALSE;
+ device.if_info.type = IF_PIPE;
+#ifdef HAVE_EXTCAP
+ device.if_info.extcap = NULL;
+ device.external_cap_args_settings = NULL;
+#endif
#if defined(HAVE_PCAP_CREATE)
device.monitor_mode_enabled = FALSE;
device.monitor_mode_supported = FALSE;
indx = global_capture_opts.all_ifaces->len;
temp = g_strdup_printf("<b>%s</b>", device.display_name);
- if (device.has_snaplen) {
- snaplen_string = g_strdup_printf("%d", device.snaplen);
- } else {
- snaplen_string = g_strdup("default");
- }
+ snaplen_string = g_strdup_printf("%d", device.snaplen);
if_cb = (GtkTreeView *) g_object_get_data(G_OBJECT(cap_open_w), E_CAP_IFACE_KEY);
path_str = g_strdup_printf("%d", indx);
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
-#elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
+#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
gtk_list_store_set (GTK_LIST_STORE(model), &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp,LINK, "", PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
static void
cancel_pipe_cb (gpointer w _U_)
{
+#ifdef HAVE_PCAP_REMOTE
+ if (interface_management_w && G_IS_OBJECT(interface_management_w)) {
+ GtkWidget *remote_w;
+ remote_w = g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
+ if (remote_w != NULL && G_IS_OBJECT(remote_w))
+ window_destroy(remote_w);
+ }
+#endif
window_destroy(GTK_WIDGET(interface_management_w));
+ pipe_name = NULL;
}
static void
gchar *host = "";
GtkTreeView *remote_l;
GtkTreeStore *store;
- GtkWidget *host_te, *remote_w;
num_selected = 0;
- gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(interface_management_w), E_REMOTE_DEL_BT_KEY), FALSE);
remote_l = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_L_KEY));
store = gtk_tree_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
} else {
/* fill the store */
if (strcmp(host, device.remote_opts.remote_host_opts.remote_host) != 0) {
- remote_w = g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
- host_te = (GtkWidget *)g_object_get_data(G_OBJECT(remote_w), E_REMOTE_HOST_TE_KEY);
- iftype_combo_box_add (host_te, &device);
host = g_strdup(device.remote_opts.remote_host_opts.remote_host);
gtk_tree_store_append(store, &iter, NULL);
gtk_tree_store_set(store, &iter, 0, host, 3, "FALSE", -1);
} while (gtk_tree_model_iter_next(model, &iter));
g_free(name);
}
- hide_interface(g_strdup(new_hide));
+ hide_interface(new_hide);
/* Refresh all places that are displaying an interface list
that includes interfaces other than local interfaces
} else {
if (strcmp(host, device.remote_opts.remote_host_opts.remote_host) == 0) {
g_array_remove_index(global_capture_opts.all_ifaces, i);
+ capture_opts_free_interface_t(&device);
}
}
}
GtkTreeSelection *selection;
#endif
+ if (interface_management_w != NULL && G_IS_OBJECT(interface_management_w)) {
+ /* There's already a "Manage Interfaces" dialog box; reactivate it. */
+ reactivate_window(interface_management_w);
+ return;
+ }
+
interface_management_w = window_new(GTK_WINDOW_TOPLEVEL, "Interface Management");
gtk_window_set_transient_for(GTK_WINDOW(interface_management_w), GTK_WINDOW(parent_win));
gtk_window_set_destroy_with_parent(GTK_WINDOW(interface_management_w), TRUE);
gtk_container_add(GTK_CONTAINER(edit_fr), list_bb);
gtk_widget_show(list_bb);
- new_bt = gtk_button_new_from_stock(GTK_STOCK_NEW);
+ new_bt = ws_gtk_button_new_from_stock(GTK_STOCK_NEW);
g_signal_connect(new_bt, "clicked", G_CALLBACK(pipe_new_bt_clicked_cb), NULL);
gtk_widget_show(new_bt);
gtk_box_pack_start (GTK_BOX (list_bb), new_bt, FALSE, FALSE, 0);
gtk_widget_set_tooltip_text (new_bt, "Add a new pipe (with default properties)");
- del_bt = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+ del_bt = ws_gtk_button_new_from_stock(GTK_STOCK_DELETE);
g_signal_connect(del_bt, "clicked", G_CALLBACK(pipe_del_bt_clicked_cb), NULL);
gtk_widget_show(del_bt);
gtk_widget_set_sensitive(del_bt, FALSE);
);
gtk_box_pack_start(GTK_BOX(middle_hb), pipe_te, TRUE, TRUE, 3);
gtk_widget_set_sensitive(pipe_te, FALSE);
- pipe_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
+ pipe_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
gtk_widget_set_tooltip_text(GTK_WIDGET(pipe_bt),
"Select a pipe from which data should be captured, "
"instead of entering the pipe name directly. "
gtk_widget_show(help_hbox);
gtk_box_set_spacing(GTK_BOX(help_hbox), DLG_BUTTON_SPACING);
- add_but = gtk_button_new_from_stock(GTK_STOCK_ADD);
+ add_but = ws_gtk_button_new_from_stock(GTK_STOCK_ADD);
g_object_set_data(G_OBJECT(bbox), GTK_STOCK_ADD, add_but);
gtk_box_pack_start(GTK_BOX(help_hbox), add_but, FALSE, FALSE, 0);
g_signal_connect(add_but, "clicked", G_CALLBACK(show_remote_dialog), NULL);
gtk_widget_set_tooltip_text(GTK_WIDGET(add_but), "Add a remote host to the list");
gtk_widget_show(add_but);
- delete_bt = gtk_button_new_from_stock(GTK_STOCK_DELETE);
+ delete_bt = ws_gtk_button_new_from_stock(GTK_STOCK_DELETE);
g_object_set_data(G_OBJECT(bbox), GTK_STOCK_DELETE, delete_bt);
gtk_box_pack_start(GTK_BOX(help_hbox), delete_bt, FALSE, FALSE, 0);
g_signal_connect(delete_bt, "clicked", G_CALLBACK(remove_remote_host), NULL);
g_object_set_data(G_OBJECT(interface_management_w), E_REMOTE_DEL_BT_KEY, delete_bt);
gtk_widget_show(delete_bt);
- ok_but = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+ ok_but = ws_gtk_button_new_from_stock(GTK_STOCK_APPLY);
gtk_box_pack_end(GTK_BOX(button_hbox), ok_but, FALSE, FALSE, 0);
g_signal_connect(GTK_WIDGET(ok_but), "clicked", G_CALLBACK(ok_remote_cb), NULL);
gtk_widget_set_tooltip_text(GTK_WIDGET(ok_but), "Apply the changes to the general list of local interfaces");
gtk_widget_show(ok_but);
- cancel_bt = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
+ cancel_bt = ws_gtk_button_new_from_stock(GTK_STOCK_CLOSE);
gtk_box_pack_end(GTK_BOX(button_hbox), cancel_bt, FALSE, FALSE, 0);
g_signal_connect(GTK_WIDGET(cancel_bt), "clicked", G_CALLBACK(cancel_pipe_cb), interface_management_w);
gtk_widget_set_tooltip_text(GTK_WIDGET(cancel_bt), "Cancel and exit dialog.");
/* If we don't have a Capture Options dialog open, there's nothing
for us to do. */
- if (cap_open_w == NULL)
+ if (!cap_open_w)
return;
/* Determine whether all interfaces:
/* If all interfaces are selected, check the "capture on all interfaces"
checkbox, otherwise un-check it. */
- if (capture_all) {
- capture_b = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_KEY_ALL);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(capture_b), TRUE);
- }
+ capture_b = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_KEY_ALL);
+ g_signal_handler_block(capture_b, capture_all_handler_id);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(capture_b), capture_all);
+ g_signal_handler_unblock(capture_b, capture_all_handler_id);
/* If all selected interfaces are in promiscuous mode, check the global
"promiscuous mode" checkbox, otherwise un-check it. */
promisc_b = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_CAP_PROMISC_KEY_ALL);
+ g_signal_handler_block(promisc_b, promisc_all_handler_id);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_b), promisc_all);
+ g_signal_handler_unblock(promisc_b, promisc_all_handler_id);
/* If all selected interfaces have the same filter string, set the
global filter string to it. */
if (interfaces_dialog_window_present()) {
destroy_if_window();
}
- if (cap_open_w != NULL) {
+ if (cap_open_w != NULL && G_IS_OBJECT(cap_open_w)) {
/* There's already a "Capture Options" dialog box; reactivate it. */
reactivate_window(cap_open_w);
return;
/* update airpcap interface list */
/* load the airpcap interfaces */
- airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
+ g_airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
/* If we don't get a list don't do any thing.
- * If the error is AIRPCAP_NOT_LOADED it avoids a unneccessay rescan of the packet list
+ * If the error is AIRPCAP_NOT_LOADED it avoids an unnecessary rescan of the packet list
* ( see airpcap_loader.h for error codes).
*/
- if (airpcap_if_list == NULL) {
+ if (g_airpcap_if_list == NULL) {
if (err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
g_free(err_str);
}
}else{
decryption_cb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
- /* XXXX update_decryption_mode_list() trigers a rescan, should only be done if the mode is changed */
+ /* XXXX update_decryption_mode_list() triggers a rescan, should only be done if the mode is changed */
update_decryption_mode_list(decryption_cb);
/* select the first as default (THIS SHOULD BE CHANGED) */
- airpcap_if_active = airpcap_get_default_if(airpcap_if_list);
+ airpcap_if_active = airpcap_get_default_if(g_airpcap_if_list);
}
#endif
gtk_container_set_border_width(GTK_CONTAINER(capture_vb), DLG_OUTER_MARGIN);
gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
-#if defined (HAVE_PCAP_REMOTE)
- if (remote_host_list == NULL) {
- remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
- }
-#endif
-
swindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_set_size_request(swindow, 676, 180);
+ gtk_widget_set_size_request(swindow, 676, 100);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swindow), GTK_SHADOW_IN);
view = gtk_tree_view_new ();
gtk_tree_view_column_set_visible(column, FALSE);
g_object_set(renderer, "xalign", 0.5f, NULL);
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("Buffer [MB]", renderer, "text", BUFFER, NULL);
+ column = gtk_tree_view_column_new_with_attributes("Buffer [MiB]", renderer, "text", BUFFER, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
gtk_tree_view_column_set_reorderable(column, TRUE);
g_object_set_data(G_OBJECT(column), E_MCAPTURE_COLUMNS_COL_KEY, GINT_TO_POINTER(BUFFER));
all_cb = gtk_check_button_new_with_mnemonic( "Capture on all interfaces");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(all_cb), FALSE);
- g_signal_connect(all_cb, "toggled", G_CALLBACK(capture_all_cb), NULL);
+ capture_all_handler_id = g_signal_connect(all_cb, "toggled", G_CALLBACK(capture_all_cb), NULL);
gtk_widget_set_tooltip_text(all_cb, "Activate the box to capture on all interfaces. "
"Deactivate it to capture on none and set the interfaces individually.");
gtk_box_pack_start(GTK_BOX(left_vb), all_cb, TRUE, TRUE, 0);
} else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(promisc_cb), get_all_prom_mode());
}
- g_signal_connect(promisc_cb, "button-press-event", G_CALLBACK(promisc_mode_callback), NULL);
+ promisc_all_handler_id = g_signal_connect(promisc_cb, "toggled", G_CALLBACK(promisc_mode_callback), NULL);
gtk_widget_set_tooltip_text(promisc_cb,
"Usually a network adapter will only capture the traffic sent to its own network address. "
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_IFTYPE_CBX_KEY, iftype_cbx);
gtk_box_pack_start(GTK_BOX(right_vb), iftype_cbx, FALSE, FALSE, 0);
- g_signal_connect(iftype_cbx, "clicked", G_CALLBACK(show_add_interfaces_dialog), cap_open_w);
+ g_signal_connect(iftype_cbx, "clicked", G_CALLBACK(show_add_interfaces_dialog), NULL);
gtk_widget_show(iftype_cbx);
main_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DLG_UNRELATED_SPACING, FALSE);
all_filter_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
gtk_box_pack_start(GTK_BOX(all_vb), all_filter_hb, FALSE, FALSE, DLG_LABEL_SPACING);
- all_filter_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
+ all_filter_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_FILTER_ENTRY);
g_signal_connect(all_filter_bt, "clicked", G_CALLBACK(capture_filter_construct_cb), NULL);
g_signal_connect(all_filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
gtk_widget_set_tooltip_text(all_filter_bt,
}
}
if (global_capture_opts.default_options.cfilter && (strlen(global_capture_opts.default_options.cfilter) > 0)) {
-fprintf(stderr, "Adding the default filter \"%s\"???\n", global_capture_opts.default_options.cfilter);
gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(all_filter_cm), global_capture_opts.default_options.cfilter);
gtk_combo_box_set_active(GTK_COMBO_BOX(all_filter_cm), 0);
}
);
gtk_box_pack_start(GTK_BOX(file_hb), file_te, TRUE, TRUE, 3);
- file_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
+ file_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_BROWSE);
gtk_widget_set_tooltip_text(file_bt,
"Select a file to which captured data will be written, "
"instead of entering the file name directly. "
row++;
- /* Files row */
- stop_files_cb = gtk_check_button_new_with_label("Stop capture after");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_files_cb),
- global_capture_opts.has_autostop_files);
- g_signal_connect(stop_files_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
- gtk_widget_set_tooltip_text(stop_files_cb, "Stop capturing after the given number of \"file switches\" have been done.");
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), stop_files_cb, 0, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_files,
- 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
- stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
- gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
- gtk_widget_set_size_request(stop_files_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), stop_files_sb, 1, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- stop_files_lb = gtk_label_new("file(s)");
- gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5f);
- ws_gtk_grid_attach_extended(GTK_GRID (multi_grid), stop_files_lb, 2, row, 1, 1,
- (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
-
- row++;
-
/* Capture limits frame */
limit_fr = frame_new("Stop Capture Automatically After...");
gtk_box_pack_start(GTK_BOX (left_vb), limit_fr, TRUE, TRUE, 0);
ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_packets_lb, 2, row, 1, 1,
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
- row++;
-
/* Filesize row */
stop_filesize_cb = gtk_check_button_new();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_filesize_cb),
global_capture_opts.has_autostop_filesize);
g_signal_connect(stop_filesize_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
gtk_widget_set_tooltip_text(stop_filesize_cb, "Stop capturing after the specified amount of data has been captured.");
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_cb, 0, row, 1, 1,
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_cb, 3, row, 1, 1,
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
stop_filesize_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
stop_filesize_sb = gtk_spin_button_new (stop_filesize_adj, 0, 0);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_filesize_sb), TRUE);
gtk_widget_set_size_request(stop_filesize_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_sb, 1, row, 1, 1,
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_sb, 4, row, 1, 1,
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
stop_filesize_cbx = size_unit_combo_box_new(global_capture_opts.autostop_filesize);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_cbx, 2, row, 1, 1,
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_filesize_cbx, 5, row, 1, 1,
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
value = size_unit_combo_box_set_value(global_capture_opts.autostop_filesize);
row++;
+ /* Files row */
+ stop_files_cb = gtk_check_button_new();
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_files_cb),
+ global_capture_opts.has_autostop_files);
+ g_signal_connect(stop_files_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
+ gtk_widget_set_tooltip_text(stop_files_cb, "Stop capturing after the given number of \"file switches\" have been done.");
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_files_cb, 0, row, 1, 1,
+ (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
+
+ stop_files_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat)global_capture_opts.autostop_files,
+ 1, (gfloat)INT_MAX, 1.0, 10.0, 0.0);
+ stop_files_sb = gtk_spin_button_new (stop_files_adj, 0, 0);
+ gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_files_sb), TRUE);
+ gtk_widget_set_size_request(stop_files_sb, 80, -1);
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_files_sb, 1, row, 1, 1,
+ (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
+
+ stop_files_lb = gtk_label_new("file(s)");
+ gtk_misc_set_alignment(GTK_MISC(stop_files_lb), 0, 0.5f);
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_files_lb, 2, row, 1, 1,
+ (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
+
/* Duration row */
stop_duration_cb = gtk_check_button_new();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(stop_duration_cb),
global_capture_opts.has_autostop_duration);
g_signal_connect(stop_duration_cb, "toggled", G_CALLBACK(capture_prep_adjust_sensitivity), cap_open_w);
gtk_widget_set_tooltip_text(stop_duration_cb, "Stop capturing after the specified amount of time has passed.");
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_cb, 0, row, 1, 1,
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_cb, 3, row, 1, 1,
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
stop_duration_adj = (GtkAdjustment *) gtk_adjustment_new(0.0,
stop_duration_sb = gtk_spin_button_new (stop_duration_adj, 0, 0);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (stop_duration_sb), TRUE);
gtk_widget_set_size_request(stop_duration_sb, 80, -1);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_sb, 1, row, 1, 1,
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_sb, 4, row, 1, 1,
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
stop_duration_cbx = time_unit_combo_box_new(global_capture_opts.autostop_duration);
- ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_cbx, 2, row, 1, 1,
+ ws_gtk_grid_attach_extended(GTK_GRID (limit_grid), stop_duration_cbx, 5, row, 1, 1,
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0);
value = time_unit_combo_box_convert_value(global_capture_opts.autostop_duration);
display_fr = frame_new("Display Options");
gtk_box_pack_start(GTK_BOX (right_vb), display_fr, TRUE, TRUE, 0);
- display_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
+ display_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_LABEL_SPACING, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(display_vb), DLG_OUTER_MARGIN);
gtk_container_add(GTK_CONTAINER(display_fr), display_vb);
gtk_widget_set_tooltip_text(sync_cb,
"Using this option will show the captured packets immediately on the main screen. "
"Please note: this will slow down capturing, so increased packet drops might appear.");
- gtk_box_pack_start(GTK_BOX (display_vb), sync_cb, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (display_vb), sync_cb, FALSE, TRUE, 0);
/* "Auto-scroll live update" row */
auto_scroll_cb = gtk_check_button_new_with_mnemonic("_Automatically scroll during live capture");
gtk_widget_set_tooltip_text(auto_scroll_cb,
"This will scroll the \"Packet List\" automatically to the latest captured packet, "
"when the \"Update List of packets in real time\" option is used.");
- gtk_box_pack_start(GTK_BOX (display_vb), auto_scroll_cb, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (display_vb), auto_scroll_cb, FALSE, TRUE, 0);
/* "Hide capture info" row */
hide_info_cb = gtk_check_button_new_with_mnemonic("_Hide capture info dialog");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hide_info_cb), !global_capture_opts.show_info);
gtk_widget_set_tooltip_text(hide_info_cb, "Hide the capture info dialog while capturing.");
- gtk_box_pack_start(GTK_BOX (display_vb), hide_info_cb, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (display_vb), hide_info_cb, FALSE, TRUE, 0);
/* Name Resolution frame */
resolv_fr = frame_new("Name Resolution");
gtk_box_pack_start(GTK_BOX (right_vb), resolv_fr, TRUE, TRUE, 0);
- resolv_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
+ resolv_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_LABEL_SPACING, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(resolv_vb), DLG_OUTER_MARGIN);
gtk_container_add(GTK_CONTAINER(resolv_fr), resolv_vb);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_resolv_cb),
gbl_resolv_flags.mac_name);
gtk_widget_set_tooltip_text(m_resolv_cb, "Perform MAC layer name resolution while capturing.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), m_resolv_cb, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (resolv_vb), m_resolv_cb, FALSE, TRUE, 0);
n_resolv_cb = gtk_check_button_new_with_mnemonic(
"Resolve _network-layer names");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(n_resolv_cb),
gbl_resolv_flags.network_name);
gtk_widget_set_tooltip_text(n_resolv_cb, "Perform network layer name resolution while capturing.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), n_resolv_cb, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (resolv_vb), n_resolv_cb, FALSE, TRUE, 0);
t_resolv_cb = gtk_check_button_new_with_mnemonic(
"Resolve _transport-layer name");
gbl_resolv_flags.transport_name);
gtk_widget_set_tooltip_text(t_resolv_cb,
"Perform transport layer name resolution while capturing.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), t_resolv_cb, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (resolv_vb), t_resolv_cb, FALSE, TRUE, 0);
e_resolv_cb = gtk_check_button_new_with_mnemonic(
"Use _external network name resolver");
gbl_resolv_flags.use_external_net_name_resolver);
gtk_widget_set_tooltip_text(e_resolv_cb,
"Use the (system's) configured name resolver (e.g., DNS) to resolve network names.");
- gtk_box_pack_start(GTK_BOX (resolv_vb), e_resolv_cb, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (resolv_vb), e_resolv_cb, FALSE, TRUE, 0);
/* Button row: "Start", "Cancel" and "Help" buttons */
bbox = dlg_button_row_new(WIRESHARK_STOCK_CAPTURE_START, GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
gtk_widget_grab_default(ok_bt);
/* Attach pointers to needed widgets to the capture prefs window/object */
-#if defined(HAVE_PCAP_REMOTE)
- g_object_set_data(G_OBJECT(cap_open_w), E_CAP_REMOTE_DIALOG_PTR_KEY, NULL);
-#endif
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_KEY_ALL, all_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_PROMISC_KEY_ALL, promisc_cb);
g_object_set_data(G_OBJECT(cap_open_w), E_CAP_PCAP_NG_KEY, pcap_ng_cb);
this capture. */
collect_ifaces(&global_capture_opts);
- if (capture_start(&global_capture_opts, &global_capture_session, main_window_update)) {
+ if (capture_start(&global_capture_opts, &global_capture_session, &global_info_data, main_window_update)) {
/* The capture succeeded, which means the capture filters specified are
valid; add them to the recent capture filter lists for the interfaces.
guint i;
link_row *linkr = NULL;
interface_t device;
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
gint buffer;
#endif
gint snaplen;
#if defined(HAVE_PCAP_CREATE)
store = gtk_list_store_new (9, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
-#elif defined(_WIN32) && !defined (HAVE_PCAP_CREATE)
+#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
store = gtk_list_store_new (8, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
#else
store = gtk_list_store_new (7, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
} else {
temp = g_strdup_printf("<b>%s</b>\n<span size='small'>%s</span>", device.display_name, device.addresses);
}
+ set_active_dlt(&device, global_capture_opts.default_options.linktype);
linkname = NULL;
- if(capture_dev_user_linktype_find(device.name) != -1) {
- device.active_dlt = capture_dev_user_linktype_find(device.name);
- }
for (list = device.links; list != NULL; list = g_list_next(list)) {
linkr = (link_row*)(list->data);
if (linkr->dlt == device.active_dlt) {
}
if (!linkname)
linkname = g_strdup("unknown");
- pmode = capture_dev_user_pmode_find(device.name);
- if (pmode != -1) {
+ if (capture_dev_user_pmode_find(device.name, &pmode)) {
device.pmode = pmode;
}
- hassnap = capture_dev_user_hassnap_find(device.name);
- snaplen = capture_dev_user_snaplen_find(device.name);
- if(snaplen != -1 && hassnap != -1) {
- /* Default snap lenght set in preferences */
+ if (capture_dev_user_snaplen_find(device.name, &hassnap, &snaplen)) {
+ /* Default snap length set in preferences */
device.snaplen = snaplen;
device.has_snaplen = hassnap;
} else {
device.has_snaplen = FALSE;
}
- if (device.has_snaplen) {
- snaplen_string = g_strdup_printf("%d", device.snaplen);
- } else {
- snaplen_string = g_strdup("default");
- }
+ snaplen_string = g_strdup_printf("%d", device.snaplen);
-#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
if (capture_dev_user_buffersize_find(device.name) != -1) {
buffer = capture_dev_user_buffersize_find(device.name);
device.buffer = buffer;
gtk_list_store_append (store, &iter);
#if defined(HAVE_PCAP_CREATE)
gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, MONITOR, device.monitor_mode_supported?(device.monitor_mode_enabled?"enabled":"disabled"):"n/a", FILTER, device.cfilter, -1);
-#elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
+#elif defined(CAN_SET_CAPTURE_BUFFER_SIZE)
gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, BUFFER, (guint) device.buffer, FILTER, device.cfilter, -1);
#else
gtk_list_store_set (store, &iter, CAPTURE, device.selected, IFACE_HIDDEN_NAME, device.name, INTERFACE, temp, LINK, linkname, PMODE, device.pmode?"enabled":"disabled", SNAPLEN, snaplen_string, FILTER, device.cfilter, -1);
case SNAPLEN: g_snprintf(buffer, sizeof(buffer), "Limit the maximum number of bytes to be captured from each packet. This size includes the "
"link-layer header and all subsequent headers.");
break;
-#if defined(HAVE_PCAP_CREATE)
+#ifdef CAN_SET_CAPTURE_BUFFER_SIZE
case BUFFER: g_snprintf (buffer, sizeof(buffer), "The memory buffer size used while capturing. "
"If you notice packet drops, you can try increasing this size.");
break;
+#endif
+#if defined(HAVE_PCAP_CREATE)
case MONITOR: g_snprintf (buffer, sizeof(buffer), "Usually a Wi-Fi adapter will, even in promiscuous mode, only capture "
"the traffic on the BSS to which it's associated. "
"If you want to capture all traffic that the Wi-Fi adapter can \"receive\", select this option. "
"it might be necessary to turn this option on.\n\n"
"Note that, in monitor mode, the adapter might disassociate from the network to which it's associated.");
break;
-#elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
- case BUFFER: g_snprintf (buffer, sizeof(buffer), "The memory buffer size used while capturing. "
- "If you notice packet drops, you can try increasing this size.");
- break;
#endif
case FILTER: g_snprintf(buffer, sizeof(buffer), "Selected capture filter to reduce the amount of packets to be captured.");
break;
GtkWidget *fs;
#ifdef HAVE_PCAP_REMOTE
GList *if_list;
- GtkWidget *remote_w;
#endif
+ if (!cap_open_w || !G_IS_OBJECT(cap_open_w))
+ return;
/* Is there a file selection dialog associated with this
Capture Options dialog? */
fs = (GtkWidget *)g_object_get_data(G_OBJECT(cap_open_w), E_FILE_SEL_DIALOG_PTR_KEY);
}
#endif
- if (fs != NULL) {
+ if (fs != NULL && G_IS_OBJECT(fs)) {
/* Yes. Destroy it. */
window_destroy(fs);
}
if (airpcap_if_active)
airpcap_set_toolbar_stop_capture(airpcap_if_active);
#endif
-
-#ifdef HAVE_PCAP_REMOTE
- remote_w = g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
- if (remote_w != NULL)
- window_destroy(remote_w);
-#endif
}
link_row *linkr;
GtkWidget *linktype_combo_box = (GtkWidget *) g_object_get_data(G_OBJECT(opt_edit_w), E_CAP_LT_CBX_KEY);
GtkWidget *linktype_lb = (GtkWidget *)g_object_get_data(G_OBJECT(linktype_combo_box), E_CAP_LT_CBX_LABEL_KEY);
+ gchar *auth_str = NULL;
device = g_array_index(global_capture_opts.all_ifaces, interface_t, marked_interface);
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, marked_interface);
if_string = g_strdup(device.name);
monitor_mode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(monitor));
- caps = capture_get_if_capabilities(if_string, monitor_mode, NULL, main_window_update);
+#ifdef HAVE_PCAP_REMOTE
+ if (device.remote_opts.remote_host_opts.auth_type == CAPTURE_AUTH_PWD) {
+ auth_str = g_strdup_printf("%s:%s", device.remote_opts.remote_host_opts.auth_username,
+ device.remote_opts.remote_host_opts.auth_password);
+ }
+#endif
+ caps = capture_get_if_capabilities(if_string, monitor_mode, auth_str, NULL, main_window_update);
+ g_free(auth_str);
if (caps != NULL) {
g_signal_handlers_disconnect_by_func(linktype_combo_box, G_CALLBACK(select_link_type_cb), NULL );