2004-07-18 00:24:25 +00:00
|
|
|
/* capture_if_dlg.c
|
|
|
|
* Routines for the capture interface dialog
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-07-18 00:24:25 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2008-04-12 23:34:44 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
|
2009-02-01 22:20:42 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2009-02-02 04:15:17 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
#include <epan/prefs.h>
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
#include "../capture_ifinfo.h"
|
2008-04-13 00:55:59 +00:00
|
|
|
#include "../capture.h"
|
2010-03-04 01:12:04 +00:00
|
|
|
#include "../capture-pcap-util.h"
|
2008-04-13 00:55:59 +00:00
|
|
|
#include "../capture_ui_utils.h"
|
2009-03-09 15:10:11 +00:00
|
|
|
#include "wsutil/file_util.h"
|
2008-04-13 00:55:59 +00:00
|
|
|
#include <wiretap/wtap.h>
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-01-16 01:07:52 +00:00
|
|
|
#include "ui/simple_dialog.h"
|
|
|
|
|
2008-04-13 00:55:59 +00:00
|
|
|
#ifdef _WIN32
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/capture_if_details_dlg_win32.h"
|
2008-04-13 00:55:59 +00:00
|
|
|
#endif
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/stock_icons.h"
|
|
|
|
#include "ui/gtk/capture_dlg.h"
|
|
|
|
#include "ui/gtk/capture_if_dlg.h"
|
|
|
|
#include "ui/gtk/recent.h"
|
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/main.h"
|
|
|
|
#include "ui/gtk/main_toolbar.h"
|
|
|
|
#include "ui/gtk/help_dlg.h"
|
|
|
|
#include "ui/gtk/keys.h"
|
|
|
|
#include "ui/gtk/webbrowser.h"
|
|
|
|
#include "ui/gtk/capture_globals.h"
|
|
|
|
#include "ui/gtk/network_icons.h"
|
|
|
|
#include "ui/gtk/main_welcome.h"
|
|
|
|
#include "ui/gtk/menus.h"
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/old-gtk-compat.h"
|
2011-07-24 07:59:34 +00:00
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2012-01-15 22:40:03 +00:00
|
|
|
#include "../../image/toolbar/capture_airpcap_16.xpm"
|
2006-08-16 18:01:25 +00:00
|
|
|
#endif
|
2009-11-11 00:43:23 +00:00
|
|
|
|
2011-09-24 14:16:37 +00:00
|
|
|
#if defined(HAVE_PCAP_REMOTE)
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/remote_icons.h"
|
2011-09-24 14:16:37 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-11 18:29:23 +00:00
|
|
|
#ifdef _WIN32
|
2012-01-15 22:40:03 +00:00
|
|
|
#include "../../image/toolbar/capture_ethernet_16.xpm"
|
|
|
|
#include "../../image/toolbar/modem_16.xpm"
|
2009-01-31 07:00:05 +00:00
|
|
|
#endif
|
2009-11-11 00:43:23 +00:00
|
|
|
|
2012-01-15 22:40:03 +00:00
|
|
|
#include "../../image/toolbar/network_virtual_16.xpm"
|
2009-01-31 07:00:05 +00:00
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
/* new buttons to be used instead of labels for 'Capture','Prepare',' */
|
2012-01-15 22:40:03 +00:00
|
|
|
/*#include "../../image/toolbar/capture_capture_16.xpm"*/
|
|
|
|
/*#include "../../image/toolbar/capture_prepare_16.xpm"*/
|
|
|
|
/*#include "../../image/toolbar/capture_details_16.xpm"*/
|
2006-08-16 18:01:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_AIRPCAP
|
2008-10-15 22:51:17 +00:00
|
|
|
#include "airpcap.h"
|
2006-08-16 18:01:25 +00:00
|
|
|
#include "airpcap_loader.h"
|
|
|
|
#include "airpcap_gui_utils.h"
|
|
|
|
#include "airpcap_dlg.h"
|
|
|
|
#endif
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2009-05-26 21:13:16 +00:00
|
|
|
#define CAPTURE_IF_IP_ADDR_LABEL "capture_if_ip_addr_label"
|
|
|
|
#define CAPTURE_IF_SELECTED_IP_ADDR "capture_if_selected_ip_addr"
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
/*
|
|
|
|
* Keep a static pointer to the current "Capture Interfaces" window, if
|
|
|
|
* any, so that if somebody tries to do "Capture:Start" while there's
|
|
|
|
* already a "Capture Interfaces" window up, we just pop up the existing
|
|
|
|
* one, rather than creating a new one.
|
|
|
|
*/
|
2006-08-26 00:12:12 +00:00
|
|
|
static GtkWidget *cap_if_w;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
static GList *if_data_list = NULL;
|
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
static guint timer_id;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-07-05 20:29:33 +00:00
|
|
|
static GtkWidget *stop_bt, *capture_bt, *options_bt;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2010-01-29 16:13:26 +00:00
|
|
|
static GList *if_list;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
static guint currently_selected = 0;
|
2011-08-05 07:19:17 +00:00
|
|
|
|
|
|
|
static if_stat_cache_t *sc;
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
/*
|
|
|
|
* Timeout, in milliseconds, for reads from the stream of captured packets.
|
|
|
|
*/
|
|
|
|
#define CAP_READ_TIMEOUT 250
|
|
|
|
|
|
|
|
|
|
|
|
/* the "runtime" data of one interface */
|
|
|
|
typedef struct if_dlg_data_s {
|
|
|
|
GtkWidget *device_lb;
|
|
|
|
GtkWidget *descr_lb;
|
|
|
|
GtkWidget *ip_lb;
|
|
|
|
GtkWidget *curr_lb;
|
|
|
|
GtkWidget *last_lb;
|
2011-07-05 20:29:33 +00:00
|
|
|
GtkWidget *choose_bt;
|
2005-05-20 22:23:00 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
GtkWidget *details_bt;
|
|
|
|
#endif
|
2011-10-20 19:44:40 +00:00
|
|
|
guint32 last_packets;
|
|
|
|
gchar *device;
|
|
|
|
if_info_t if_info;
|
|
|
|
gboolean selected;
|
2004-07-18 00:24:25 +00:00
|
|
|
} if_dlg_data_t;
|
|
|
|
|
2011-07-05 20:29:33 +00:00
|
|
|
static gboolean gbl_capture_in_progress = FALSE;
|
|
|
|
|
2011-07-20 12:51:57 +00:00
|
|
|
void
|
2011-10-20 19:44:40 +00:00
|
|
|
update_selected_interface(gchar *name, gboolean activate)
|
2011-07-20 12:51:57 +00:00
|
|
|
{
|
2011-10-20 19:44:40 +00:00
|
|
|
guint ifs;
|
|
|
|
GList *curr;
|
|
|
|
if_dlg_data_t *temp;
|
|
|
|
|
|
|
|
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
|
|
|
curr = g_list_nth(if_data_list, ifs);
|
|
|
|
temp = (if_dlg_data_t *)(curr->data);
|
|
|
|
if (strcmp(name, temp->if_info.name) == 0) {
|
|
|
|
if (activate) {
|
|
|
|
gtk_toggle_button_set_active((GtkToggleButton *)temp->choose_bt, TRUE);
|
|
|
|
} else {
|
|
|
|
gtk_toggle_button_set_active((GtkToggleButton *)temp->choose_bt, FALSE);
|
|
|
|
}
|
2011-07-20 12:51:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-05 20:29:33 +00:00
|
|
|
static void
|
2011-10-20 19:44:40 +00:00
|
|
|
store_selected(GtkWidget *choose_bt, gpointer if_data)
|
2011-07-05 20:29:33 +00:00
|
|
|
{
|
2011-12-01 06:33:14 +00:00
|
|
|
if_dlg_data_t *if_dlg_data = (if_dlg_data_t *)if_data, *temp;
|
2011-10-20 19:44:40 +00:00
|
|
|
GList *curr;
|
|
|
|
unsigned int ifs, i;
|
2011-07-19 12:42:18 +00:00
|
|
|
gboolean found;
|
2011-10-20 19:44:40 +00:00
|
|
|
cap_settings_t cap_settings;
|
|
|
|
interface_options interface_opts;
|
|
|
|
|
|
|
|
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
|
|
|
curr = g_list_nth(if_data_list, ifs);
|
|
|
|
temp = (if_dlg_data_t *)(curr->data);
|
2011-07-19 12:42:18 +00:00
|
|
|
found = FALSE;
|
2011-10-20 19:44:40 +00:00
|
|
|
if (strcmp(if_dlg_data->if_info.name, temp->if_info.name) == 0) {
|
|
|
|
temp->selected ^=1;
|
|
|
|
if_data_list = g_list_remove(if_data_list, curr->data);
|
|
|
|
if_data_list = g_list_insert(if_data_list, temp, ifs);
|
2011-11-07 23:42:53 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
|
|
|
|
if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, temp->if_info.name) == 0) {
|
|
|
|
found = TRUE;
|
|
|
|
if (!temp->selected) {
|
|
|
|
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
|
|
|
|
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
|
|
|
|
if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) {
|
|
|
|
change_interface_selection(interface_opts.name, FALSE);
|
|
|
|
}
|
|
|
|
if (gtk_widget_is_focus(choose_bt) && dlg_window_present()) {
|
|
|
|
enable_selected_interface(interface_opts.name, FALSE);
|
|
|
|
}
|
|
|
|
g_free(interface_opts.name);
|
|
|
|
g_free(interface_opts.descr);
|
|
|
|
g_free(interface_opts.cfilter);
|
|
|
|
#ifdef HAVE_PCAP_REMOTE
|
|
|
|
g_free(interface_opts.remote_host);
|
|
|
|
g_free(interface_opts.remote_port);
|
|
|
|
g_free(interface_opts.auth_username);
|
|
|
|
g_free(interface_opts.auth_password);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2011-11-07 23:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-20 19:44:40 +00:00
|
|
|
if (!found && temp->selected) {
|
|
|
|
interface_opts.name = g_strdup(temp->if_info.name);
|
|
|
|
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
|
|
|
|
interface_opts.linktype = capture_dev_user_linktype_find(interface_opts.name);
|
|
|
|
interface_opts.cfilter = g_strdup(global_capture_opts.default_options.cfilter);
|
|
|
|
interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
|
|
|
|
interface_opts.snaplen = global_capture_opts.default_options.snaplen;
|
|
|
|
cap_settings = capture_get_cap_settings (interface_opts.name);;
|
|
|
|
interface_opts.promisc_mode = global_capture_opts.default_options.promisc_mode;
|
|
|
|
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
|
|
|
interface_opts.buffer_size = global_capture_opts.default_options.buffer_size;
|
|
|
|
#endif
|
|
|
|
interface_opts.monitor_mode = cap_settings.monitor_mode;
|
|
|
|
#ifdef HAVE_PCAP_REMOTE
|
|
|
|
interface_opts.src_type = global_capture_opts.default_options.src_type;
|
|
|
|
interface_opts.remote_host = g_strdup(global_capture_opts.default_options.remote_host);
|
|
|
|
interface_opts.remote_port = g_strdup(global_capture_opts.default_options.remote_port);
|
|
|
|
interface_opts.auth_type = global_capture_opts.default_options.auth_type;
|
|
|
|
interface_opts.auth_username = g_strdup(global_capture_opts.default_options.auth_username);
|
|
|
|
interface_opts.auth_password = g_strdup(global_capture_opts.default_options.auth_password);
|
|
|
|
interface_opts.datatx_udp = global_capture_opts.default_options.datatx_udp;
|
|
|
|
interface_opts.nocap_rpcap = global_capture_opts.default_options.nocap_rpcap;
|
|
|
|
interface_opts.nocap_local = global_capture_opts.default_options.nocap_local;
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_PCAP_SETSAMPLING
|
|
|
|
interface_opts.sampling_method = global_capture_opts.default_options.sampling_method;
|
|
|
|
interface_opts.sampling_param = global_capture_opts.default_options.sampling_param;
|
|
|
|
#endif
|
|
|
|
g_array_append_val(global_capture_opts.ifaces, interface_opts);
|
|
|
|
if (gtk_widget_is_focus(choose_bt) && get_welcome_window() != NULL) {
|
|
|
|
change_interface_selection(g_strdup(temp->if_info.name), TRUE);
|
2011-07-20 12:51:57 +00:00
|
|
|
}
|
2011-08-05 07:19:17 +00:00
|
|
|
if (gtk_widget_is_focus(choose_bt) && dlg_window_present()) {
|
2011-10-20 19:44:40 +00:00
|
|
|
enable_selected_interface(interface_opts.name, TRUE);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2011-07-19 12:42:18 +00:00
|
|
|
}
|
2011-11-07 23:42:53 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
if (temp->selected)
|
|
|
|
currently_selected += 1;
|
|
|
|
else
|
|
|
|
currently_selected -= 1;
|
2011-07-05 20:29:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cap_if_w) {
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (currently_selected > 0));
|
2011-07-05 20:29:33 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
/* start capture button was pressed */
|
|
|
|
static void
|
2011-07-05 20:29:33 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2004-07-18 00:24:25 +00:00
|
|
|
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
|
2011-07-05 20:29:33 +00:00
|
|
|
#else
|
|
|
|
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data _U_)
|
|
|
|
#endif
|
2004-07-18 00:24:25 +00:00
|
|
|
{
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data_t *temp;
|
|
|
|
GList *curr;
|
|
|
|
int ifs;
|
2011-10-20 18:17:54 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data_t *if_dlg_data = if_data;
|
|
|
|
|
|
|
|
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, if_dlg_data->if_info.name);
|
|
|
|
airpcap_if_selected = airpcap_if_active;
|
2006-08-16 18:01:25 +00:00
|
|
|
#endif
|
2011-10-20 19:44:40 +00:00
|
|
|
|
|
|
|
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
|
|
|
temp = (if_dlg_data_t *)(curr->data);
|
|
|
|
gtk_widget_set_sensitive(temp->choose_bt, FALSE);
|
2011-07-05 20:29:33 +00:00
|
|
|
}
|
2011-05-22 11:11:00 +00:00
|
|
|
|
2005-04-19 21:02:01 +00:00
|
|
|
/* XXX - remove this? */
|
2008-06-24 02:22:36 +00:00
|
|
|
if (global_capture_opts.save_file) {
|
|
|
|
g_free(global_capture_opts.save_file);
|
|
|
|
global_capture_opts.save_file = NULL;
|
2005-04-16 19:24:10 +00:00
|
|
|
}
|
2005-02-06 21:20:35 +00:00
|
|
|
|
2011-07-16 11:07:32 +00:00
|
|
|
if (global_capture_opts.ifaces->len > 1) {
|
2011-07-05 20:29:33 +00:00
|
|
|
global_capture_opts.use_pcapng = TRUE;
|
|
|
|
}
|
2005-09-07 22:00:25 +00:00
|
|
|
/* stop capturing from all interfaces, we are going to do real work now ... */
|
|
|
|
window_destroy(cap_if_w);
|
|
|
|
|
2005-04-19 21:02:01 +00:00
|
|
|
capture_start_cb(NULL, NULL);
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* prepare capture button was pressed */
|
|
|
|
static void
|
2011-07-05 20:29:33 +00:00
|
|
|
capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data _U_)
|
2004-07-18 00:24:25 +00:00
|
|
|
{
|
2005-09-07 22:00:25 +00:00
|
|
|
/* stop capturing from all interfaces, we are going to do real work now ... */
|
|
|
|
window_destroy(cap_if_w);
|
2011-07-16 11:07:32 +00:00
|
|
|
if (global_capture_opts.ifaces->len > 1) {
|
2011-07-05 20:29:33 +00:00
|
|
|
global_capture_opts.use_pcapng = TRUE;
|
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
capture_prep_cb(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-20 22:23:00 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
/* capture details button was pressed */
|
|
|
|
static void
|
|
|
|
capture_details_cb(GtkWidget *details_bt _U_, gpointer if_data)
|
|
|
|
{
|
|
|
|
if_dlg_data_t *if_dlg_data = if_data;
|
|
|
|
|
|
|
|
|
|
|
|
capture_if_details_open(if_dlg_data->device);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
/* update a single interface */
|
2009-02-01 23:14:07 +00:00
|
|
|
static void
|
2011-10-20 19:44:40 +00:00
|
|
|
update_if(if_dlg_data_t *if_dlg_data, if_stat_cache_t *sc)
|
2004-07-18 00:24:25 +00:00
|
|
|
{
|
|
|
|
struct pcap_stat stats;
|
|
|
|
gchar *str;
|
2011-10-20 19:44:40 +00:00
|
|
|
guint diff;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
|
2007-08-30 17:36:38 +00:00
|
|
|
/*
|
|
|
|
* Note that some versions of libpcap, on some versions of UN*X,
|
2008-06-26 16:42:07 +00:00
|
|
|
* pcap_stats() returns the number of packets since the last
|
2007-08-30 17:36:38 +00:00
|
|
|
* pcap_stats call.
|
|
|
|
*
|
2008-06-26 16:42:07 +00:00
|
|
|
* That's a bug, and should be fixed; "pcap_stats()" is supposed
|
2007-08-30 17:36:38 +00:00
|
|
|
* to work the same way on all platforms.
|
2004-07-18 00:24:25 +00:00
|
|
|
*/
|
2007-08-02 21:45:27 +00:00
|
|
|
if (sc) {
|
2011-10-20 19:44:40 +00:00
|
|
|
if (capture_stats(sc, if_dlg_data->device, &stats)) {
|
|
|
|
diff = stats.ps_recv - if_dlg_data->last_packets;
|
|
|
|
if_dlg_data->last_packets = stats.ps_recv;
|
|
|
|
|
|
|
|
str = g_strdup_printf("%u", if_dlg_data->last_packets);
|
|
|
|
gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), str);
|
|
|
|
g_free(str);
|
|
|
|
str = g_strdup_printf("%u", diff);
|
|
|
|
gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), str);
|
|
|
|
g_free(str);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(if_dlg_data->curr_lb, diff);
|
|
|
|
gtk_widget_set_sensitive(if_dlg_data->last_lb, diff);
|
|
|
|
} else {
|
|
|
|
gtk_label_set_text(GTK_LABEL(if_dlg_data->curr_lb), "error");
|
|
|
|
gtk_label_set_text(GTK_LABEL(if_dlg_data->last_lb), "error");
|
2004-07-18 02:56:29 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update all interfaces */
|
2005-08-02 04:47:15 +00:00
|
|
|
static gboolean
|
2004-07-18 00:24:25 +00:00
|
|
|
update_all(gpointer data)
|
|
|
|
{
|
2011-10-20 19:44:40 +00:00
|
|
|
GList *curr;
|
|
|
|
int ifs;
|
2011-12-01 06:33:14 +00:00
|
|
|
if_stat_cache_t *sc = (if_stat_cache_t *)data;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-07-05 20:29:33 +00:00
|
|
|
if (!cap_if_w) {
|
2004-07-18 00:24:25 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
2011-12-01 06:33:14 +00:00
|
|
|
update_if((if_dlg_data_t *)curr->data, sc);
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* a live capture has started or stopped */
|
|
|
|
void
|
|
|
|
set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
|
|
|
|
{
|
2011-07-05 20:29:33 +00:00
|
|
|
gbl_capture_in_progress = capture_in_progress;
|
|
|
|
if (cap_if_w) {
|
|
|
|
gtk_widget_set_sensitive(stop_bt, capture_in_progress);
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (currently_selected > 0));
|
2011-07-05 20:29:33 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* the window was closed, cleanup things */
|
|
|
|
static void
|
2011-08-05 07:19:17 +00:00
|
|
|
capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
2004-07-18 00:24:25 +00:00
|
|
|
{
|
2011-10-20 19:44:40 +00:00
|
|
|
GList *curr;
|
|
|
|
int ifs;
|
|
|
|
|
2008-07-08 02:25:30 +00:00
|
|
|
g_source_remove(timer_id);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
|
|
|
g_free(curr->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if_data_list = NULL;
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
free_interface_list(if_list);
|
|
|
|
|
|
|
|
/* Note that we no longer have a "Capture Options" dialog box. */
|
|
|
|
cap_if_w = NULL;
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2007-08-02 21:45:27 +00:00
|
|
|
capture_stat_stop(sc);
|
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2007-08-02 21:45:27 +00:00
|
|
|
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
2006-08-16 18:01:25 +00:00
|
|
|
#endif
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-18 21:06:20 +00:00
|
|
|
/*
|
|
|
|
* Sorts the Interface List in alphabetical order
|
|
|
|
*/
|
2007-05-19 22:00:09 +00:00
|
|
|
gint if_list_comparator_alph (const void *first_arg, const void *second_arg){
|
|
|
|
const if_info_t *first = first_arg, *second = second_arg;
|
|
|
|
|
2007-06-11 03:58:58 +00:00
|
|
|
if (first != NULL && first->description != NULL &&
|
2007-05-19 22:00:09 +00:00
|
|
|
second != NULL && second->description != NULL) {
|
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
|
|
|
return g_ascii_strcasecmp(first->description, second->description);
|
2007-05-18 21:06:20 +00:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-30 22:55:52 +00:00
|
|
|
|
|
|
|
/*
|
2009-02-01 22:20:42 +00:00
|
|
|
* Used to retrieve the interface icon.
|
|
|
|
* This is hideously platform-dependent.
|
2009-01-30 22:55:52 +00:00
|
|
|
*/
|
2011-07-07 21:16:03 +00:00
|
|
|
GtkWidget * capture_get_if_icon(const if_info_t* if_info)
|
2009-01-30 22:55:52 +00:00
|
|
|
{
|
2011-09-25 19:56:42 +00:00
|
|
|
#if defined(__linux__)
|
|
|
|
ws_statb64 statb;
|
|
|
|
char *wireless_path;
|
|
|
|
#endif
|
|
|
|
|
2011-09-24 14:16:37 +00:00
|
|
|
#ifdef HAVE_PCAP_REMOTE
|
|
|
|
if (if_info->description && strstr(if_info->description, "on remote node") != NULL ) {
|
|
|
|
return pixbuf_to_widget(remote_sat_pb_data);
|
|
|
|
}
|
|
|
|
#endif
|
2009-02-01 22:20:42 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
/*
|
|
|
|
* Much digging failed to reveal any obvious way to get something such
|
|
|
|
* as the SNMP MIB-II ifType value for an interface:
|
|
|
|
*
|
|
|
|
* http://www.iana.org/assignments/ianaiftype-mib
|
|
|
|
*
|
|
|
|
* by making some NDIS request.
|
|
|
|
*/
|
2009-11-06 18:08:59 +00:00
|
|
|
if ( if_info->description && ( strstr(if_info->description,"generic dialup") != NULL ||
|
|
|
|
strstr(if_info->description,"PPP/SLIP") != NULL ) ) {
|
2009-01-30 22:55:52 +00:00
|
|
|
return xpm_to_widget(modem_16_xpm);
|
|
|
|
}
|
2009-02-14 03:03:28 +00:00
|
|
|
|
2009-11-06 18:08:59 +00:00
|
|
|
if ( if_info->description && ( strstr(if_info->description,"Wireless") != NULL ||
|
|
|
|
strstr(if_info->description,"802.11") != NULL || strstr(if_info->description,"AirPcap") != NULL ) ) {
|
2009-11-10 18:02:05 +00:00
|
|
|
return pixbuf_to_widget(network_wireless_pb_data);
|
2009-11-06 18:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( strstr(if_info->name,"airpcap") != NULL ) {
|
2009-11-10 18:02:05 +00:00
|
|
|
return pixbuf_to_widget(network_wireless_pb_data);
|
2009-02-01 22:20:42 +00:00
|
|
|
}
|
2009-02-14 03:03:28 +00:00
|
|
|
|
2009-11-11 00:43:23 +00:00
|
|
|
if ( if_info->description && strstr(if_info->description, "Bluetooth") != NULL ) {
|
2009-11-10 18:02:05 +00:00
|
|
|
return pixbuf_to_widget(network_bluetooth_pb_data);
|
2009-02-13 21:35:41 +00:00
|
|
|
}
|
2009-02-01 22:20:42 +00:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
/*
|
|
|
|
* XXX - yes, fetching all the network addresses for an interface
|
|
|
|
* gets you an AF_LINK address, of type "struct sockaddr_dl", and,
|
|
|
|
* yes, that includes an SNMP MIB-II ifType value.
|
|
|
|
*
|
|
|
|
* However, it's IFT_ETHER, i.e. Ethernet, for AirPort interfaces,
|
|
|
|
* not IFT_IEEE80211 (which isn't defined in OS X in any case).
|
|
|
|
*
|
2009-02-01 22:57:17 +00:00
|
|
|
* Perhaps some other BSD-flavored OSes won't make this mistake;
|
|
|
|
* however, FreeBSD 7.0 and OpenBSD 4.2, at least, appear to have
|
|
|
|
* made the same mistake, at least for my Belkin ZyDAS stick.
|
2009-02-01 22:20:42 +00:00
|
|
|
*
|
2009-02-01 22:57:17 +00:00
|
|
|
* On Mac OS X, one might be able to get the information one wants from
|
|
|
|
* IOKit.
|
2009-02-01 22:20:42 +00:00
|
|
|
*/
|
|
|
|
if ( strcmp(if_info->name, "en1") == 0) {
|
2009-11-10 18:02:05 +00:00
|
|
|
return pixbuf_to_widget(network_wireless_pb_data);
|
2009-01-30 22:55:52 +00:00
|
|
|
}
|
2009-02-14 03:03:28 +00:00
|
|
|
|
2009-02-01 22:20:42 +00:00
|
|
|
/*
|
|
|
|
* XXX - PPP devices have names beginning with "ppp" and an IFT_ of
|
|
|
|
* IFT_PPP, but they could be dial-up, or PPPoE, or mobile phone modem,
|
|
|
|
* or VPN, or... devices. One might have to dive into the bowels of
|
|
|
|
* IOKit to find out.
|
|
|
|
*/
|
2009-02-14 03:03:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX - there's currently no support for raw Bluetooth capture,
|
|
|
|
* and IP-over-Bluetooth devices just look like fake Ethernet
|
|
|
|
* devices. There's also Bluetooth modem support, but that'll
|
|
|
|
* probably just give you a device that looks like a PPP device.
|
|
|
|
*/
|
2009-02-02 04:15:17 +00:00
|
|
|
#elif defined(__linux__)
|
|
|
|
/*
|
|
|
|
* Look for /sys/class/net/{device}/wireless.
|
|
|
|
*/
|
|
|
|
wireless_path = g_strdup_printf("/sys/class/net/%s/wireless", if_info->name);
|
|
|
|
if (wireless_path != NULL) {
|
2011-04-10 20:59:10 +00:00
|
|
|
if (ws_stat64(wireless_path, &statb) == 0) {
|
2009-03-09 15:10:11 +00:00
|
|
|
g_free(wireless_path);
|
2009-11-10 18:02:05 +00:00
|
|
|
return pixbuf_to_widget(network_wireless_pb_data);
|
2009-02-02 04:15:17 +00:00
|
|
|
}
|
2009-03-09 15:10:11 +00:00
|
|
|
g_free(wireless_path);
|
2009-02-02 04:15:17 +00:00
|
|
|
}
|
2009-02-12 01:48:47 +00:00
|
|
|
|
2009-02-14 03:03:28 +00:00
|
|
|
/*
|
|
|
|
* Bluetooth devices.
|
|
|
|
*
|
|
|
|
* XXX - this is for raw Bluetooth capture; what about IP-over-Bluetooth
|
|
|
|
* devices?
|
|
|
|
*/
|
|
|
|
if ( strstr(if_info->name,"bluetooth") != NULL) {
|
2009-11-10 18:02:05 +00:00
|
|
|
return pixbuf_to_widget(network_bluetooth_pb_data);
|
2009-02-14 03:03:28 +00:00
|
|
|
}
|
2009-11-14 00:43:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* USB devices.
|
|
|
|
*/
|
|
|
|
if ( strstr(if_info->name,"usbmon") != NULL ) {
|
|
|
|
return pixbuf_to_widget(network_usb_pb_data);
|
|
|
|
}
|
2009-02-01 22:20:42 +00:00
|
|
|
#endif
|
2009-01-30 22:55:52 +00:00
|
|
|
|
2009-11-11 00:43:23 +00:00
|
|
|
/*
|
|
|
|
* TODO: find a better icon!
|
|
|
|
* Bridge, NAT, or host-only interfaces on VMWare hosts have the name
|
|
|
|
* vmnet[0-9]+ or VMnet[0-9+ on Windows. Guests might use a native
|
|
|
|
* (LANCE or E1000) driver or the vmxnet driver. These devices have an
|
|
|
|
* IFT_ of IFT_ETHER, so we have to check the name.
|
|
|
|
*/
|
|
|
|
if ( g_ascii_strncasecmp(if_info->name, "vmnet", 5) == 0) {
|
|
|
|
return xpm_to_widget(network_virtual_16_xpm);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( g_ascii_strncasecmp(if_info->name, "vmxnet", 6) == 0) {
|
|
|
|
return xpm_to_widget(network_virtual_16_xpm);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( if_info->description && strstr(if_info->description, "VMware") != NULL ) {
|
|
|
|
return xpm_to_widget(network_virtual_16_xpm);
|
|
|
|
}
|
|
|
|
|
2009-11-10 18:02:05 +00:00
|
|
|
return pixbuf_to_widget(network_wired_pb_data);
|
2009-01-30 22:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
static int
|
|
|
|
get_ip_addr_count(GSList *addr_list)
|
|
|
|
{
|
|
|
|
GSList *curr_addr;
|
|
|
|
if_addr_t *addr;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
for (curr_addr = addr_list; curr_addr != NULL;
|
|
|
|
curr_addr = g_slist_next(curr_addr)) {
|
|
|
|
addr = (if_addr_t *)curr_addr->data;
|
|
|
|
switch (addr->ifat_type) {
|
|
|
|
|
|
|
|
case IF_AT_IPv4:
|
|
|
|
case IF_AT_IPv6:
|
|
|
|
count++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* In case we add non-IP addresses */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2009-05-26 21:13:16 +00:00
|
|
|
static const gchar *
|
2010-03-04 01:12:04 +00:00
|
|
|
set_ip_addr_label(GSList *addr_list, GtkWidget *ip_lb, guint selected_ip_addr)
|
2009-05-26 21:13:16 +00:00
|
|
|
{
|
2010-03-04 01:12:04 +00:00
|
|
|
GSList *curr_addr;
|
|
|
|
if_addr_t *addr;
|
2009-05-26 21:13:16 +00:00
|
|
|
const gchar *addr_str = NULL;
|
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
curr_addr = g_slist_nth(addr_list, selected_ip_addr);
|
|
|
|
if (curr_addr) {
|
|
|
|
addr = (if_addr_t *)curr_addr->data;
|
|
|
|
switch (addr->ifat_type) {
|
2009-05-26 21:13:16 +00:00
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
case IF_AT_IPv4:
|
|
|
|
addr_str = ip_to_str((guint8 *)&addr->addr.ip4_addr);
|
2009-05-26 21:13:16 +00:00
|
|
|
break;
|
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
case IF_AT_IPv6:
|
|
|
|
addr_str = ip6_to_str((struct e_in6_addr *)&addr->addr.ip6_addr);
|
2009-05-26 21:13:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-03-04 01:12:04 +00:00
|
|
|
/* Ignore non-IP addresses, in case we ever support them */
|
|
|
|
break;
|
2009-05-26 21:13:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (addr_str) {
|
|
|
|
gtk_label_set_text(GTK_LABEL(ip_lb), addr_str);
|
|
|
|
} else {
|
2011-08-13 19:21:02 +00:00
|
|
|
gtk_label_set_text(GTK_LABEL(ip_lb), "none");
|
2009-05-26 21:13:16 +00:00
|
|
|
}
|
|
|
|
g_object_set_data(G_OBJECT(ip_lb), CAPTURE_IF_SELECTED_IP_ADDR, GINT_TO_POINTER(selected_ip_addr));
|
|
|
|
|
|
|
|
return addr_str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
ip_label_enter_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
|
|
|
{
|
|
|
|
gtk_widget_set_state(eb, GTK_STATE_PRELIGHT);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
ip_label_leave_cb(GtkWidget *eb, GdkEvent *event _U_, gpointer user_data _U_)
|
|
|
|
{
|
|
|
|
gtk_widget_set_state(eb, GTK_STATE_NORMAL);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
ip_label_press_cb(GtkWidget *widget, GdkEvent *event _U_, gpointer data)
|
|
|
|
{
|
2011-12-01 06:33:14 +00:00
|
|
|
GtkWidget *ip_lb = (GtkWidget *)g_object_get_data(G_OBJECT(widget), CAPTURE_IF_IP_ADDR_LABEL);
|
|
|
|
GSList *addr_list = (GSList *)data;
|
2010-03-04 01:12:04 +00:00
|
|
|
GSList *curr_addr, *start_addr;
|
|
|
|
if_addr_t *addr;
|
2011-12-01 06:33:14 +00:00
|
|
|
guint selected_ip_addr = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(ip_lb), CAPTURE_IF_SELECTED_IP_ADDR));
|
2009-05-26 21:13:16 +00:00
|
|
|
|
|
|
|
/* Select next IP address */
|
2010-03-04 01:12:04 +00:00
|
|
|
start_addr = g_slist_nth(addr_list, selected_ip_addr);
|
|
|
|
for (;;) {
|
|
|
|
selected_ip_addr++;
|
|
|
|
if (g_slist_length(addr_list) <= selected_ip_addr) {
|
|
|
|
/* Wrap around */
|
|
|
|
selected_ip_addr = 0;
|
|
|
|
}
|
|
|
|
curr_addr = g_slist_nth(addr_list, selected_ip_addr);
|
|
|
|
if (curr_addr == start_addr) {
|
|
|
|
/* We wrapped all the way around */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = (if_addr_t *)curr_addr->data;
|
|
|
|
switch (addr->ifat_type) {
|
|
|
|
|
|
|
|
case IF_AT_IPv4:
|
|
|
|
case IF_AT_IPv6:
|
|
|
|
goto found;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* In case we add non-IP addresses */
|
|
|
|
break;
|
|
|
|
}
|
2009-05-26 21:13:16 +00:00
|
|
|
}
|
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
found:
|
|
|
|
set_ip_addr_label(addr_list, ip_lb, selected_ip_addr);
|
2009-05-26 21:13:16 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-07-08 13:40:00 +00:00
|
|
|
static void
|
|
|
|
capture_if_stop_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
2011-08-05 07:19:17 +00:00
|
|
|
guint ifs;
|
2011-10-20 19:44:40 +00:00
|
|
|
GList *curr;
|
|
|
|
if_dlg_data_t *if_data;
|
2011-07-11 19:10:57 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
|
|
|
curr = g_list_nth(if_data_list, ifs);
|
|
|
|
if_data = (if_dlg_data_t *)(curr->data);
|
|
|
|
gtk_widget_set_sensitive(if_data->choose_bt, TRUE);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
|
|
|
capture_stop_cb(NULL, NULL);
|
2011-07-08 13:40:00 +00:00
|
|
|
}
|
2009-05-26 21:13:16 +00:00
|
|
|
|
2009-01-30 22:55:52 +00:00
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
/* start getting capture stats from all interfaces */
|
|
|
|
void
|
|
|
|
capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
2011-07-05 20:29:33 +00:00
|
|
|
GtkWidget *main_vb,
|
|
|
|
*main_sw,
|
|
|
|
*bbox,
|
|
|
|
*close_bt,
|
2011-10-20 19:44:40 +00:00
|
|
|
*help_bt,
|
|
|
|
*icon;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2006-12-11 19:43:19 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2011-07-05 20:29:33 +00:00
|
|
|
GtkWidget *decryption_cb;
|
2006-12-11 19:43:19 +00:00
|
|
|
#endif
|
2006-12-05 19:24:25 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
GtkWidget *if_tb;
|
2011-07-05 20:29:33 +00:00
|
|
|
GtkWidget *if_lb;
|
|
|
|
GtkWidget *eb;
|
2011-10-20 19:44:40 +00:00
|
|
|
int err;
|
|
|
|
gchar *err_str;
|
2011-07-05 20:29:33 +00:00
|
|
|
GtkRequisition requisition;
|
|
|
|
int row, height;
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data_t *if_dlg_data = NULL;
|
|
|
|
int ifs;
|
|
|
|
GList *curr;
|
|
|
|
if_info_t *if_info;
|
2011-07-05 20:29:33 +00:00
|
|
|
GString *if_tool_str = g_string_new("");
|
|
|
|
const gchar *addr_str;
|
|
|
|
gchar *user_descr;
|
2011-10-20 19:44:40 +00:00
|
|
|
int preselected = 0, i;
|
|
|
|
interface_options interface_opts;
|
|
|
|
gboolean found = FALSE;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
if (cap_if_w != NULL) {
|
|
|
|
/* There's already a "Capture Interfaces" dialog box; reactivate it. */
|
|
|
|
reactivate_window(cap_if_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
preselected = global_capture_opts.ifaces->len;
|
|
|
|
/* LOAD THE INTERFACES */
|
|
|
|
if_list = capture_interface_list(&err, &err_str);
|
|
|
|
if_list = g_list_sort (if_list, if_list_comparator_alph);
|
|
|
|
if (if_list == NULL) {
|
|
|
|
switch (err) {
|
|
|
|
|
|
|
|
case CANT_GET_INTERFACE_LIST:
|
2011-12-29 22:49:49 +00:00
|
|
|
case DONT_HAVE_PCAP:
|
2011-10-20 19:44:40 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
|
|
|
g_free(err_str);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NO_INTERFACES_FOUND:
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
|
|
|
"There are no interfaces on which a capture can be done.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
|
|
|
/* LOAD AIRPCAP INTERFACES */
|
2011-10-20 19:44:40 +00:00
|
|
|
airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
|
|
|
|
if (airpcap_if_list == NULL)
|
|
|
|
airpcap_if_active = airpcap_if_selected = NULL;
|
2007-01-21 23:45:36 +00:00
|
|
|
|
2009-05-13 16:14:28 +00:00
|
|
|
decryption_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
|
|
|
update_decryption_mode_list(decryption_cb);
|
2007-01-21 23:45:36 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
if (airpcap_if_list == NULL && err == CANT_GET_AIRPCAP_INTERFACE_LIST) {
|
|
|
|
#if 0
|
|
|
|
/* XXX - Do we need to show an error here? */
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
|
|
|
#endif
|
|
|
|
g_free(err_str);
|
|
|
|
}
|
|
|
|
|
2007-01-21 23:45:36 +00:00
|
|
|
/* If no airpcap interface is present, gray everything */
|
|
|
|
if (airpcap_if_active == NULL) {
|
|
|
|
if (airpcap_if_list == NULL) {
|
|
|
|
/*No airpcap device found */
|
|
|
|
airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
|
|
|
|
} else {
|
|
|
|
/* default adapter is not airpcap... or is airpcap but is not found*/
|
|
|
|
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
|
|
|
airpcap_enable_toolbar_widgets(airpcap_tb,FALSE);
|
|
|
|
}
|
|
|
|
}
|
2006-08-16 18:01:25 +00:00
|
|
|
|
|
|
|
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
|
|
|
#endif
|
|
|
|
|
2009-06-21 20:42:07 +00:00
|
|
|
cap_if_w = dlg_window_new("Wireshark: Capture Interfaces"); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(cap_if_w), TRUE);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2006-04-08 20:19:40 +00:00
|
|
|
main_sw = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(main_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_container_add(GTK_CONTAINER(cap_if_w), main_sw);
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
main_vb = gtk_vbox_new(FALSE, 0);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
2006-04-08 20:19:40 +00:00
|
|
|
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(main_sw), main_vb);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
if_tb = gtk_table_new(1,9, FALSE);
|
2004-07-18 00:24:25 +00:00
|
|
|
gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3);
|
2006-04-08 20:19:40 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), if_tb, FALSE, FALSE, 0);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
row = 0;
|
2006-04-08 20:19:40 +00:00
|
|
|
height = 0;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
/* This is the icon column, used to display which kind of interface we have */
|
|
|
|
if_lb = gtk_label_new("");
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 0, 1, row, row+1);
|
|
|
|
|
2004-09-11 23:03:36 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
/*
|
|
|
|
* On Windows, device names are generally not meaningful - NT 5
|
|
|
|
* uses long blobs with GUIDs in them, for example - so we don't
|
|
|
|
* bother showing them.
|
|
|
|
*/
|
2004-07-18 00:24:25 +00:00
|
|
|
if_lb = gtk_label_new("Device");
|
2011-07-05 20:29:33 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 1, 4, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
#endif
|
|
|
|
if_lb = gtk_label_new("Description");
|
2011-07-05 20:29:33 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 4, 5, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
if_lb = gtk_label_new(" IP ");
|
2011-07-05 20:29:33 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 5, 6, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
if_lb = gtk_label_new("Packets");
|
2011-07-05 20:29:33 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 6, 7, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
if_lb = gtk_label_new(" Packets/s ");
|
2011-07-05 20:29:33 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_lb, 7, 8, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
row++;
|
|
|
|
|
2011-07-05 20:29:33 +00:00
|
|
|
height += 30;
|
2007-08-02 21:45:27 +00:00
|
|
|
/* Start gathering statistics (using dumpcap) */
|
2011-10-20 19:44:40 +00:00
|
|
|
sc = capture_stat_start(if_list);
|
2007-08-02 21:45:27 +00:00
|
|
|
|
|
|
|
/* List the interfaces */
|
2011-10-20 19:44:40 +00:00
|
|
|
currently_selected = 0;
|
|
|
|
for (ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
|
2011-08-05 07:19:17 +00:00
|
|
|
g_string_assign(if_tool_str, "");
|
2011-12-01 06:33:14 +00:00
|
|
|
if_info = (if_info_t *)curr->data;
|
2011-10-20 19:44:40 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* Continue if capture device is hidden */
|
2011-10-20 19:44:40 +00:00
|
|
|
if (prefs_is_capture_device_hidden(if_info->name)) {
|
2011-08-05 07:19:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-10-20 19:44:40 +00:00
|
|
|
|
2011-12-01 06:33:14 +00:00
|
|
|
if_dlg_data = g_new0(if_dlg_data_t,1);
|
2011-10-20 19:44:40 +00:00
|
|
|
|
|
|
|
if (preselected > 0) {
|
|
|
|
found = FALSE;
|
|
|
|
for (i = 0; i < (gint)global_capture_opts.ifaces->len; i++) {
|
|
|
|
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
|
|
|
|
if ((interface_opts.name == NULL) ||
|
|
|
|
(strcmp(interface_opts.name, (char*)if_info->name) != 0)) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
found = TRUE;
|
|
|
|
currently_selected++;
|
|
|
|
preselected--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if_dlg_data->selected = found;
|
|
|
|
} else {
|
|
|
|
if_dlg_data->selected = FALSE;
|
|
|
|
}
|
|
|
|
if_dlg_data->if_info = *if_info;
|
|
|
|
|
|
|
|
if_dlg_data->choose_bt = gtk_check_button_new();
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->choose_bt, 0, 1, row, row+1);
|
2011-08-05 07:19:17 +00:00
|
|
|
if (gbl_capture_in_progress) {
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_set_sensitive(if_dlg_data->choose_bt, FALSE);
|
2011-08-05 07:19:17 +00:00
|
|
|
} else {
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_set_sensitive(if_dlg_data->choose_bt, TRUE);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_toggle_button_set_active((GtkToggleButton *)if_dlg_data->choose_bt, if_dlg_data->selected);
|
|
|
|
g_signal_connect(if_dlg_data->choose_bt, "toggled", G_CALLBACK(store_selected), if_dlg_data);
|
|
|
|
/* Kind of adaptor (icon) */
|
|
|
|
#ifdef HAVE_AIRPCAP
|
|
|
|
if (get_airpcap_if_from_name(airpcap_if_list,if_info->name) != NULL)
|
|
|
|
icon = xpm_to_widget(capture_airpcap_16_xpm);
|
|
|
|
else
|
|
|
|
icon = capture_get_if_icon(if_info);
|
|
|
|
#else
|
|
|
|
icon = capture_get_if_icon(if_info);
|
|
|
|
#endif
|
2011-08-05 07:19:17 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 1, 2, row, row+1);
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
/* device name */
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data->device_lb = gtk_label_new(if_info->name);
|
|
|
|
if_dlg_data->device = if_info->name;
|
2004-09-11 23:03:36 +00:00
|
|
|
#ifndef _WIN32
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->device_lb), 0.0f, 0.5f);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->device_lb, 2, 4, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
#endif
|
2011-08-05 07:19:17 +00:00
|
|
|
g_string_append(if_tool_str, "Device: ");
|
2011-10-20 19:44:40 +00:00
|
|
|
g_string_append(if_tool_str, if_info->name);
|
2011-08-05 07:19:17 +00:00
|
|
|
g_string_append(if_tool_str, "\n");
|
|
|
|
|
|
|
|
/* description */
|
2011-10-20 19:44:40 +00:00
|
|
|
user_descr = capture_dev_user_descr_find(if_info->name);
|
2011-08-05 07:19:17 +00:00
|
|
|
if (user_descr) {
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data->descr_lb = gtk_label_new(user_descr);
|
2011-08-05 07:19:17 +00:00
|
|
|
g_free (user_descr);
|
|
|
|
} else {
|
2011-10-20 19:44:40 +00:00
|
|
|
if (if_info->description)
|
|
|
|
if_dlg_data->descr_lb = gtk_label_new(if_info->description);
|
2011-08-05 07:19:17 +00:00
|
|
|
else
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data->descr_lb = gtk_label_new("");
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(if_dlg_data->descr_lb), 0.0f, 0.5f);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->descr_lb, 4, 5, row, row+1);
|
|
|
|
|
|
|
|
if (if_info->description) {
|
2011-08-05 07:19:17 +00:00
|
|
|
g_string_append(if_tool_str, "Description: ");
|
2011-10-20 19:44:40 +00:00
|
|
|
g_string_append(if_tool_str, if_info->description);
|
2004-07-18 00:24:25 +00:00
|
|
|
g_string_append(if_tool_str, "\n");
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IP address */
|
|
|
|
/* Only one IP address will be shown, start with the first */
|
|
|
|
g_string_append(if_tool_str, "IP: ");
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data->ip_lb = gtk_label_new("");
|
|
|
|
addr_str = set_ip_addr_label (if_info->addrs, if_dlg_data->ip_lb, 0);
|
2011-08-05 07:19:17 +00:00
|
|
|
if (addr_str) {
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_set_sensitive(if_dlg_data->ip_lb, TRUE);
|
2011-08-05 07:19:17 +00:00
|
|
|
g_string_append(if_tool_str, addr_str);
|
|
|
|
} else {
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
|
2011-08-13 19:21:02 +00:00
|
|
|
g_string_append(if_tool_str, "none");
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
|
|
|
eb = gtk_event_box_new ();
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(eb), if_dlg_data->ip_lb);
|
2011-08-05 07:19:17 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), eb, 5, 6, row, row+1);
|
2011-10-20 19:44:40 +00:00
|
|
|
if (get_ip_addr_count(if_info->addrs) > 1) {
|
2011-08-05 07:19:17 +00:00
|
|
|
/* More than one IP address, make it possible to toggle */
|
2011-10-20 19:44:40 +00:00
|
|
|
g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, if_dlg_data->ip_lb);
|
2011-08-05 07:19:17 +00:00
|
|
|
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(ip_label_enter_cb), NULL);
|
|
|
|
g_signal_connect(eb, "leave-notify-event", G_CALLBACK(ip_label_leave_cb), NULL);
|
2011-10-20 19:44:40 +00:00
|
|
|
g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), if_info->addrs);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
|
|
|
g_string_append(if_tool_str, "\n");
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* packets */
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data->curr_lb = gtk_label_new("-");
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->curr_lb, 6, 7, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* packets/s */
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data->last_lb = gtk_label_new("-");
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->last_lb, 7, 8, row, row+1);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* details button */
|
2005-05-20 22:23:00 +00:00
|
|
|
#ifdef _WIN32
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data->details_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_DETAILS);
|
|
|
|
gtk_widget_set_tooltip_text(if_dlg_data->details_bt, "Open the capture details dialog of this interface.");
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(if_tb), if_dlg_data->details_bt, 8, 9, row, row+1);
|
|
|
|
if (capture_if_has_details(if_dlg_data->device)) {
|
|
|
|
g_signal_connect(if_dlg_data->details_bt, "clicked", G_CALLBACK(capture_details_cb), if_dlg_data);
|
2011-08-05 07:19:17 +00:00
|
|
|
} else {
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_set_sensitive(if_dlg_data->details_bt, FALSE);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2005-05-20 22:23:00 +00:00
|
|
|
#endif
|
2011-10-20 19:44:40 +00:00
|
|
|
|
|
|
|
if_data_list = g_list_append(if_data_list, if_dlg_data);
|
2011-11-07 23:42:53 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
row++;
|
|
|
|
if (row <= 10) {
|
2011-07-05 20:29:33 +00:00
|
|
|
/* Lets add up 10 rows of interfaces, otherwise the window may become too high */
|
2011-10-20 19:44:40 +00:00
|
|
|
gtk_widget_get_preferred_size(GTK_WIDGET(if_dlg_data->choose_bt), &requisition, NULL);
|
2011-08-05 07:19:17 +00:00
|
|
|
height += requisition.height;
|
2011-11-07 23:42:53 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_string_free(if_tool_str, TRUE);
|
|
|
|
|
2011-07-05 20:29:33 +00:00
|
|
|
/* Button row: close, help, stop, start, and options button */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_HELP, WIRESHARK_STOCK_CAPTURE_START, WIRESHARK_STOCK_CAPTURE_OPTIONS, WIRESHARK_STOCK_CAPTURE_STOP, GTK_STOCK_CLOSE, NULL);
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
|
2011-12-01 06:33:14 +00:00
|
|
|
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
2011-07-05 20:29:33 +00:00
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)(HELP_CAPTURE_INTERFACES_DIALOG));
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-12-01 06:33:14 +00:00
|
|
|
stop_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_STOP);
|
2011-07-08 13:40:00 +00:00
|
|
|
g_signal_connect(stop_bt, "clicked", G_CALLBACK(capture_if_stop_cb), NULL);
|
2011-12-01 06:33:14 +00:00
|
|
|
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2004-07-18 00:24:25 +00:00
|
|
|
window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
|
2011-02-16 18:27:00 +00:00
|
|
|
gtk_widget_set_tooltip_text(close_bt, "Close this window.");
|
2011-12-01 06:33:14 +00:00
|
|
|
options_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_OPTIONS);
|
2011-10-20 19:44:40 +00:00
|
|
|
g_signal_connect(options_bt, "clicked", G_CALLBACK(capture_prepare_cb), if_dlg_data);
|
2011-12-01 06:33:14 +00:00
|
|
|
capture_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
|
2011-10-20 19:44:40 +00:00
|
|
|
g_signal_connect(capture_bt, "clicked", G_CALLBACK(capture_do_cb), if_dlg_data);
|
2011-07-24 07:59:34 +00:00
|
|
|
gtk_widget_get_preferred_size(GTK_WIDGET(close_bt), &requisition, NULL);
|
2008-06-26 16:42:07 +00:00
|
|
|
/* height + static offset + what the GTK MS Windows Engine needs in addition per interface */
|
2011-08-05 07:19:17 +00:00
|
|
|
height += requisition.height + 40 + ifs;
|
2006-04-08 20:19:40 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
gtk_widget_grab_default(close_bt);
|
|
|
|
|
2008-04-11 21:20:51 +00:00
|
|
|
g_signal_connect(cap_if_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(cap_if_w, "destroy", G_CALLBACK(capture_if_destroy_cb), sc);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
gtk_widget_show_all(cap_if_w);
|
|
|
|
window_present(cap_if_w);
|
|
|
|
|
2010-10-12 17:39:44 +00:00
|
|
|
set_capture_if_dialog_for_capture_in_progress(gbl_capture_in_progress);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* update the interface list every 1000ms */
|
2008-07-08 02:25:30 +00:00
|
|
|
timer_id = g_timeout_add(1000, update_all, sc);
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
gboolean interfaces_dialog_window_present(void)
|
2011-07-19 12:42:18 +00:00
|
|
|
{
|
2011-08-05 07:19:17 +00:00
|
|
|
return (cap_if_w?TRUE:FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void refresh_if_window(void)
|
|
|
|
{
|
|
|
|
capture_if_destroy_cb(NULL, NULL);
|
|
|
|
capture_if_cb(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
void select_all_interfaces(gboolean enable)
|
2011-08-05 07:19:17 +00:00
|
|
|
{
|
2011-10-20 19:44:40 +00:00
|
|
|
if_dlg_data_t *temp;
|
2011-08-05 07:19:17 +00:00
|
|
|
guint ifs;
|
2011-10-20 19:44:40 +00:00
|
|
|
GList *curr;
|
2011-08-05 07:19:17 +00:00
|
|
|
|
2011-10-20 19:44:40 +00:00
|
|
|
for (ifs = 0; ifs < g_list_length(if_data_list); ifs++) {
|
|
|
|
curr = g_list_nth(if_data_list, ifs);
|
|
|
|
temp = (if_dlg_data_t *)(curr->data);
|
|
|
|
update_selected_interface(temp->if_info.name, enable);
|
2011-11-07 23:42:53 +00:00
|
|
|
}
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void destroy_if_window(void)
|
|
|
|
{
|
|
|
|
if (cap_if_w) {
|
|
|
|
window_destroy(cap_if_w);
|
|
|
|
}
|
2011-07-19 12:42:18 +00:00
|
|
|
}
|
2008-04-12 21:30:38 +00:00
|
|
|
#else /* HAVE_LIBPCAP */
|
|
|
|
|
|
|
|
void
|
|
|
|
set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress _U_)
|
|
|
|
{
|
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
#endif /* HAVE_LIBPCAP */
|