2004-07-18 00:24:25 +00:00
|
|
|
/* capture_if_dlg.c
|
|
|
|
* Routines for the capture interface dialog
|
|
|
|
*
|
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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-07-18 00:24:25 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:48:30 +00:00
|
|
|
#include "config.h"
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
#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>
|
|
|
|
|
2006-08-16 18:01:25 +00:00
|
|
|
#include <epan/prefs.h>
|
2013-12-21 17:23:17 +00:00
|
|
|
#include <epan/to_str.h>
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2013-05-22 07:44:28 +00:00
|
|
|
#include "../capture_opts.h"
|
|
|
|
#include "../capture_session.h"
|
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-08-03 23:30:47 +00:00
|
|
|
#include "ui/capture_globals.h"
|
2012-01-18 19:38:34 +00:00
|
|
|
#include "ui/recent.h"
|
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"
|
2012-01-25 13:04:32 +00:00
|
|
|
#include "../../capture-wpcap.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/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/network_icons.h"
|
2012-01-25 13:04:32 +00:00
|
|
|
#include "ui/gtk/pipe_icon.h"
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/main_welcome.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
|
|
|
|
|
2012-01-15 22:40:03 +00:00
|
|
|
#include "../../image/toolbar/modem_16.xpm"
|
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"
|
2013-03-21 23:25:58 +00:00
|
|
|
#define SOFT_LABEL_LEN 50
|
2009-05-26 21:13:16 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
2012-11-25 21:07:07 +00:00
|
|
|
static GtkWidget *cap_if_w;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-11-25 21:07:07 +00:00
|
|
|
static guint timer_id;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-11-25 21:07:07 +00:00
|
|
|
static GtkWidget *close_bt, *stop_bt, *capture_bt, *options_bt;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-11-25 21:07:07 +00:00
|
|
|
static GArray *if_array;
|
2011-08-05 07:19:17 +00:00
|
|
|
|
2012-11-25 21:07:07 +00:00
|
|
|
static if_stat_cache_t *sc;
|
|
|
|
static GtkWidget *cap_if_top_vb, *cap_if_sw;
|
2011-08-05 07:19:17 +00:00
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
/*
|
|
|
|
* Timeout, in milliseconds, for reads from the stream of captured packets.
|
|
|
|
*/
|
2012-11-25 21:07:07 +00:00
|
|
|
#define CAP_READ_TIMEOUT 250
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* the "runtime" data of one interface */
|
|
|
|
typedef struct if_dlg_data_s {
|
2012-11-25 21:07:07 +00:00
|
|
|
gchar *device;
|
|
|
|
GtkWidget *device_lb;
|
|
|
|
GtkWidget *descr_lb;
|
|
|
|
GtkWidget *ip_lb;
|
|
|
|
GtkWidget *curr_lb;
|
|
|
|
GtkWidget *last_lb;
|
|
|
|
GtkWidget *choose_bt;
|
2005-05-20 22:23:00 +00:00
|
|
|
#ifdef _WIN32
|
2012-11-25 21:07:07 +00:00
|
|
|
GtkWidget *details_bt;
|
2005-05-20 22:23:00 +00:00
|
|
|
#endif
|
2012-11-25 21:07:07 +00:00
|
|
|
gboolean hidden;
|
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;
|
|
|
|
|
Detangle the code that manages the interface list on the welcome screen:
fill_capture_box():
if there are interfaces on which to capture, constructs the
interface list, otherwise destroys the interface list and puts
up a message.
update_capture_box():
updates the interface list to reflect current reality.
welcome_if_panel_reload():
if there is an interface list, and if there are interfaces on
which to capture (so that we still want that list), updates the
list by calling update_capture_box(), otherwise creates or
destroys it by calling fill_capture_box() (as either it doesn't
exist but now needs to or does exist but needs to go away).
Have refresh_local_interface_lists(), which re-fetches the list of local
interfaces and updates every interface list that includes local
interfaces, and refresh_non_local_interface_lists(), which only updates
interface lists that (also) include interfaces other than local
interfaces (such as pipes and remote interfaces). Call them in the
apprpriate places (if we know the list of local interfaces has been
updated, call refresh_local_interface_lists(), otherwise, if we know
interfaces other than local interfaces have been added or removed, call
refresh_non_local_interface_lists()).
Don't have any routine that updates the interface list for one widget
update the interface list for any other widget; leave the global
updating of interface lists up to refresh_local_interface_lists() and
refresh_non_local_interface_lists() - only call one of them if any
interface lists are to be updated.
svn path=/trunk/; revision=43517
2012-06-28 08:13:21 +00:00
|
|
|
#if 0
|
2012-02-21 11:59:41 +00:00
|
|
|
void
|
|
|
|
add_interface(void)
|
|
|
|
{
|
|
|
|
if_dlg_data_t data;
|
2012-06-27 23:15:28 +00:00
|
|
|
|
2012-11-25 21:07:07 +00:00
|
|
|
data.device_lb = NULL;
|
2012-02-21 11:59:41 +00:00
|
|
|
data.descr_lb = NULL;
|
|
|
|
data.ip_lb = NULL;
|
|
|
|
data.curr_lb = NULL;
|
|
|
|
data.last_lb = NULL;
|
|
|
|
data.choose_bt = NULL;
|
|
|
|
#ifdef _WIN32
|
|
|
|
data.details_bt = NULL;
|
|
|
|
#endif
|
2012-04-23 11:06:21 +00:00
|
|
|
data.hidden = FALSE;
|
2012-06-27 23:15:28 +00:00
|
|
|
g_array_append_val(if_array, data);
|
2012-02-21 11:59:41 +00:00
|
|
|
refresh_if_window();
|
|
|
|
}
|
Detangle the code that manages the interface list on the welcome screen:
fill_capture_box():
if there are interfaces on which to capture, constructs the
interface list, otherwise destroys the interface list and puts
up a message.
update_capture_box():
updates the interface list to reflect current reality.
welcome_if_panel_reload():
if there is an interface list, and if there are interfaces on
which to capture (so that we still want that list), updates the
list by calling update_capture_box(), otherwise creates or
destroys it by calling fill_capture_box() (as either it doesn't
exist but now needs to or does exist but needs to go away).
Have refresh_local_interface_lists(), which re-fetches the list of local
interfaces and updates every interface list that includes local
interfaces, and refresh_non_local_interface_lists(), which only updates
interface lists that (also) include interfaces other than local
interfaces (such as pipes and remote interfaces). Call them in the
apprpriate places (if we know the list of local interfaces has been
updated, call refresh_local_interface_lists(), otherwise, if we know
interfaces other than local interfaces have been added or removed, call
refresh_non_local_interface_lists()).
Don't have any routine that updates the interface list for one widget
update the interface list for any other widget; leave the global
updating of interface lists up to refresh_local_interface_lists() and
refresh_non_local_interface_lists() - only call one of them if any
interface lists are to be updated.
svn path=/trunk/; revision=43517
2012-06-28 08:13:21 +00:00
|
|
|
#endif
|
2012-02-21 11:59:41 +00:00
|
|
|
|
2011-07-20 12:51:57 +00:00
|
|
|
void
|
2012-01-25 13:04:32 +00:00
|
|
|
update_selected_interface(gchar *name)
|
2011-07-20 12:51:57 +00:00
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
guint i;
|
|
|
|
interface_t device;
|
2012-01-25 13:04:32 +00:00
|
|
|
if_dlg_data_t data;
|
|
|
|
|
|
|
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
2012-06-27 23:15:28 +00:00
|
|
|
data = g_array_index(if_array, if_dlg_data_t, i);
|
2012-01-25 13:04:32 +00:00
|
|
|
if (strcmp(name, device.name) == 0) {
|
|
|
|
gtk_toggle_button_set_active((GtkToggleButton *)data.choose_bt, device.selected);
|
2011-07-20 12:51:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-05 20:29:33 +00:00
|
|
|
static void
|
2012-01-25 13:04:32 +00:00
|
|
|
store_selected(GtkWidget *choose_bt, gpointer name)
|
2011-07-05 20:29:33 +00:00
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
interface_t device;
|
2012-11-25 21:07:07 +00:00
|
|
|
guint i;
|
2012-01-25 16:32:51 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
2013-03-21 02:29:09 +00:00
|
|
|
if (strcmp((char *)name, device.if_info.name) == 0) {
|
2012-01-25 13:04:32 +00:00
|
|
|
if (!device.locked) {
|
|
|
|
device.selected ^= 1;
|
|
|
|
if (device.selected) {
|
|
|
|
global_capture_opts.num_selected++;
|
|
|
|
} else {
|
|
|
|
global_capture_opts.num_selected--;
|
2011-11-07 23:42:53 +00:00
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
|
|
|
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
|
|
|
if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) {
|
|
|
|
change_interface_selection(device.name, device.selected);
|
2011-07-20 12:51:57 +00:00
|
|
|
}
|
2012-06-28 01:54:42 +00:00
|
|
|
if (gtk_widget_is_focus(choose_bt) && capture_dlg_window_present()) {
|
2012-01-25 13:04:32 +00:00
|
|
|
enable_selected_interface(device.name, device.selected);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
device.locked = FALSE;
|
|
|
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
|
|
|
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
2011-07-19 12:42:18 +00:00
|
|
|
}
|
2011-07-05 20:29:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cap_if_w) {
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (global_capture_opts.num_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
|
2012-11-25 21:07:07 +00:00
|
|
|
capture_do_cb(GtkWidget *capture_bt_arg _U_, gpointer if_data _U_)
|
2004-07-18 00:24:25 +00:00
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
if_dlg_data_t data;
|
2012-11-25 21:07:07 +00:00
|
|
|
guint ifs;
|
2012-01-24 17:12:56 +00:00
|
|
|
|
2012-06-27 23:15:28 +00:00
|
|
|
for (ifs = 0; ifs < if_array->len; ifs++) {
|
|
|
|
data = g_array_index(if_array, if_dlg_data_t, ifs);
|
2012-04-23 11:06:21 +00:00
|
|
|
if (data.hidden) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
2012-06-27 23:15:28 +00:00
|
|
|
if_array = g_array_remove_index(if_array, ifs);
|
|
|
|
g_array_insert_val(if_array, ifs, data);
|
2012-01-25 13:04:32 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
|
|
|
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, gtk_label_get_text(GTK_LABEL(data.device_lb)));
|
|
|
|
airpcap_if_selected = airpcap_if_active;
|
2006-08-16 18:01:25 +00:00
|
|
|
#endif
|
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
|
2012-02-16 20:22:34 +00:00
|
|
|
capture_details_cb(GtkWidget *details_bt _U_, gpointer name)
|
2005-05-20 22:23:00 +00:00
|
|
|
{
|
2012-02-16 20:22:34 +00:00
|
|
|
capture_if_details_open(name);
|
2005-05-20 22:23:00 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
/* update a single interface */
|
2009-02-01 23:14:07 +00:00
|
|
|
static void
|
2012-11-25 21:07:07 +00:00
|
|
|
update_if(gchar *name, if_stat_cache_t *sc_p)
|
2004-07-18 00:24:25 +00:00
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
struct pcap_stat stats;
|
|
|
|
gchar *str;
|
|
|
|
guint diff, ifs, data_ifs;
|
|
|
|
interface_t device;
|
|
|
|
if_dlg_data_t data;
|
|
|
|
gboolean found = FALSE;
|
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
|
|
|
*/
|
2012-01-25 13:04:32 +00:00
|
|
|
device.last_packets = 0;
|
|
|
|
data.curr_lb = NULL;
|
|
|
|
data.last_lb = NULL;
|
2012-11-25 21:07:07 +00:00
|
|
|
if (sc_p) {
|
2012-02-21 11:59:41 +00:00
|
|
|
for (ifs = 0, data_ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
|
|
|
if (device.type != IF_PIPE) {
|
2012-06-27 23:15:28 +00:00
|
|
|
data = g_array_index(if_array, if_dlg_data_t, data_ifs++);
|
2012-01-25 13:04:32 +00:00
|
|
|
if (!device.hidden && strcmp(name, device.name) == 0) {
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2012-02-21 11:59:41 +00:00
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
|
|
|
if (found) {
|
2012-11-25 21:07:07 +00:00
|
|
|
if (capture_stats(sc_p, name, &stats)) {
|
2012-02-21 11:59:41 +00:00
|
|
|
if ((int)(stats.ps_recv - device.last_packets) < 0) {
|
|
|
|
diff = 0;
|
|
|
|
} else {
|
|
|
|
diff = stats.ps_recv - device.last_packets;
|
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
device.last_packets = stats.ps_recv;
|
|
|
|
|
|
|
|
str = g_strdup_printf("%u", device.last_packets);
|
|
|
|
gtk_label_set_text(GTK_LABEL(data.curr_lb), str);
|
|
|
|
g_free(str);
|
|
|
|
str = g_strdup_printf("%u", diff);
|
|
|
|
gtk_label_set_text(GTK_LABEL(data.last_lb), str);
|
|
|
|
g_free(str);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(data.curr_lb, diff);
|
|
|
|
gtk_widget_set_sensitive(data.last_lb, diff);
|
|
|
|
} else {
|
|
|
|
gtk_label_set_text(GTK_LABEL(data.curr_lb), "error");
|
|
|
|
gtk_label_set_text(GTK_LABEL(data.last_lb), "error");
|
|
|
|
}
|
|
|
|
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, ifs);
|
|
|
|
g_array_insert_val(global_capture_opts.all_ifaces, ifs, device);
|
2012-06-27 23:15:28 +00:00
|
|
|
if_array = g_array_remove_index(if_array, ifs);
|
|
|
|
g_array_insert_val(if_array, ifs, data);
|
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)
|
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
interface_t device;
|
|
|
|
guint ifs;
|
2013-03-07 22:57:36 +00:00
|
|
|
if_stat_cache_t *sc_p = (if_stat_cache_t *)data;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
if (!cap_if_w) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
2012-11-25 21:07:07 +00:00
|
|
|
update_if(device.name, sc_p);
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
return TRUE;
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (global_capture_opts.num_selected > 0));
|
2011-07-05 20:29:33 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
2012-06-14 02:19:46 +00:00
|
|
|
/* a live capture is being stopped */
|
|
|
|
void
|
|
|
|
set_capture_if_dialog_for_capture_stopping(void)
|
|
|
|
{
|
|
|
|
if (cap_if_w) {
|
|
|
|
gtk_widget_set_sensitive(stop_bt, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-01-25 13:04:32 +00:00
|
|
|
g_source_remove(timer_id);
|
2011-10-20 19:44:40 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
if (sc) {
|
2012-02-21 11:59:41 +00:00
|
|
|
capture_stat_stop(sc);
|
2012-06-28 01:54:42 +00:00
|
|
|
sc = NULL;
|
|
|
|
}
|
2012-02-21 11:59:41 +00:00
|
|
|
window_destroy(GTK_WIDGET(cap_if_w));
|
2012-01-25 13:04:32 +00:00
|
|
|
/* Note that we no longer have a "Capture Options" dialog box. */
|
2013-01-10 16:29:30 +00:00
|
|
|
cap_if_w = NULL;
|
2012-06-28 01:54:42 +00:00
|
|
|
cap_if_top_vb = NULL;
|
2013-01-10 16:29:30 +00:00
|
|
|
cap_if_sw = NULL;
|
2006-08-16 18:01:25 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2012-04-02 17:15:58 +00:00
|
|
|
if (airpcap_if_active)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-30 22:55:52 +00:00
|
|
|
/*
|
2009-02-01 22:20:42 +00:00
|
|
|
* Used to retrieve the interface icon.
|
2009-01-30 22:55:52 +00:00
|
|
|
*/
|
2012-01-25 13:04:32 +00:00
|
|
|
GtkWidget * capture_get_if_icon(interface_t *device)
|
2009-01-30 22:55:52 +00:00
|
|
|
{
|
2011-09-24 14:16:37 +00:00
|
|
|
#ifdef HAVE_PCAP_REMOTE
|
2012-01-25 13:04:32 +00:00
|
|
|
if (!device->local) {
|
2011-09-24 14:16:37 +00:00
|
|
|
return pixbuf_to_widget(remote_sat_pb_data);
|
|
|
|
}
|
|
|
|
#endif
|
2012-12-19 09:51:20 +00:00
|
|
|
if (device->display_name && strstr(device->display_name,"Wi-Fi") != NULL) {
|
|
|
|
return pixbuf_to_widget(network_wireless_pb_data);
|
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
switch (device->type) {
|
|
|
|
case IF_DIALUP:
|
2009-01-30 22:55:52 +00:00
|
|
|
return xpm_to_widget(modem_16_xpm);
|
2012-03-27 02:30:51 +00:00
|
|
|
case IF_WIRELESS:
|
2012-01-24 17:12:56 +00:00
|
|
|
return pixbuf_to_widget(network_wireless_pb_data);
|
2012-06-28 20:40:44 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2012-01-25 13:04:32 +00:00
|
|
|
case IF_AIRPCAP:
|
|
|
|
return xpm_to_widget(capture_airpcap_16_xpm);
|
2012-06-28 20:40:44 +00:00
|
|
|
#endif
|
2012-01-25 13:04:32 +00:00
|
|
|
case IF_BLUETOOTH:
|
2012-01-24 17:12:56 +00:00
|
|
|
return pixbuf_to_widget(network_bluetooth_pb_data);
|
2012-01-25 13:04:32 +00:00
|
|
|
case IF_USB:
|
2009-11-14 00:43:22 +00:00
|
|
|
return pixbuf_to_widget(network_usb_pb_data);
|
2012-01-25 13:04:32 +00:00
|
|
|
case IF_VIRTUAL:
|
2009-11-11 00:43:23 +00:00
|
|
|
return xpm_to_widget(network_virtual_16_xpm);
|
2012-01-25 13:04:32 +00:00
|
|
|
case IF_WIRED:
|
|
|
|
return pixbuf_to_widget(network_wired_pb_data);
|
|
|
|
case IF_PIPE:
|
|
|
|
case IF_STDIN:
|
|
|
|
return pixbuf_to_widget(pipe_pb_data);
|
|
|
|
default:
|
|
|
|
printf("unknown device type\n");
|
2009-11-11 00:43:23 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
GSList *curr_addr;
|
2010-03-04 01:12:04 +00:00
|
|
|
if_addr_t *addr;
|
2012-11-25 21:07:07 +00:00
|
|
|
int count;
|
2010-03-04 01:12:04 +00:00
|
|
|
|
|
|
|
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
|
|
|
{
|
2012-11-25 21:07:07 +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)
|
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
GtkWidget *ip_lb = (GtkWidget *)g_object_get_data(G_OBJECT(widget), CAPTURE_IF_IP_ADDR_LABEL);
|
|
|
|
GSList *addr_list = (GSList *)data;
|
|
|
|
GSList *curr_addr, *start_addr;
|
2010-03-04 01:12:04 +00:00
|
|
|
if_addr_t *addr;
|
2012-11-25 21:07:07 +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_)
|
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
guint ifs;
|
2012-01-25 13:04:32 +00:00
|
|
|
if_dlg_data_t data;
|
2011-07-11 19:10:57 +00:00
|
|
|
|
2012-06-27 23:15:28 +00:00
|
|
|
for (ifs = 0; ifs < if_array->len; ifs++) {
|
|
|
|
data = g_array_index(if_array, if_dlg_data_t, ifs);
|
2012-04-23 11:06:21 +00:00
|
|
|
if (data.hidden) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
2012-06-27 23:15:28 +00:00
|
|
|
if_array = g_array_remove_index(if_array, ifs);
|
|
|
|
g_array_insert_val(if_array, ifs, data);
|
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
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
static void
|
2012-06-27 23:15:28 +00:00
|
|
|
make_if_array(void)
|
2012-01-25 13:04:32 +00:00
|
|
|
{
|
|
|
|
if_dlg_data_t data;
|
|
|
|
guint i;
|
|
|
|
|
2012-06-27 23:15:28 +00:00
|
|
|
if_array = g_array_new(FALSE, FALSE, sizeof(if_dlg_data_t));
|
2012-01-25 13:04:32 +00:00
|
|
|
|
|
|
|
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
|
|
|
data.device_lb = NULL;
|
|
|
|
data.descr_lb = NULL;
|
|
|
|
data.ip_lb = NULL;
|
|
|
|
data.curr_lb = NULL;
|
|
|
|
data.last_lb = NULL;
|
|
|
|
data.choose_bt = NULL;
|
|
|
|
#ifdef _WIN32
|
|
|
|
data.details_bt = NULL;
|
|
|
|
#endif
|
2012-04-23 11:06:21 +00:00
|
|
|
data.hidden = FALSE;
|
2012-06-27 23:15:28 +00:00
|
|
|
g_array_append_val(if_array, data);
|
2012-01-25 13:04:32 +00:00
|
|
|
}
|
|
|
|
}
|
2009-01-30 22:55:52 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
/*
|
|
|
|
* If this is Windows, is WinPcap loaded? If not, pop up a dialog noting
|
|
|
|
* that fact and return FALSE, as we can't capture traffic.
|
|
|
|
*
|
|
|
|
* Otherwise (not Windows or WinPcap loaded), are there any interfaces?
|
|
|
|
* If not, pop up a dialog noting that fact and return FALSE, as there
|
|
|
|
* are no interfaces on which to capture traffic.
|
|
|
|
*
|
|
|
|
* Otherwise, return TRUE, as we can capture.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
can_capture(void)
|
2004-07-18 00:24:25 +00:00
|
|
|
{
|
2012-06-28 01:54:42 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
/* Is WPcap loaded? */
|
|
|
|
if (!has_wpcap) {
|
|
|
|
char *detailed_err;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
detailed_err = cant_load_winpcap_err("Wireshark");
|
|
|
|
simple_error_message_box("%s", detailed_err);
|
|
|
|
g_free(detailed_err);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-12-11 19:43:19 +00:00
|
|
|
#endif
|
2006-12-05 19:24:25 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
if (global_capture_opts.all_ifaces->len == 0) {
|
|
|
|
simple_error_message_box("There are no interfaces on which a capture can be done.");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
capture_if_refresh_if_list(void)
|
|
|
|
{
|
2013-01-10 16:29:30 +00:00
|
|
|
GtkWidget *if_vb, *if_grid, *icon, *if_lb, *eb;
|
2012-11-25 21:07:07 +00:00
|
|
|
GtkRequisition requisition;
|
2013-03-16 18:57:35 +00:00
|
|
|
int row = 0, height = 0;
|
2012-11-25 21:07:07 +00:00
|
|
|
guint ifs;
|
|
|
|
interface_t device;
|
|
|
|
const gchar *addr_str;
|
|
|
|
gchar *user_descr;
|
|
|
|
if_dlg_data_t data;
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
if (!can_capture()) {
|
|
|
|
/* No interfaces or, on Windows, no WinPcap; we've already popped
|
|
|
|
up a message, so just get rid of the interface dialog. */
|
|
|
|
destroy_if_window();
|
2004-07-18 00:24:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-03-27 02:30:51 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
if (cap_if_sw) {
|
|
|
|
/* First, get rid of the old interface list, and stop updating
|
|
|
|
the statistics on it. */
|
|
|
|
gtk_container_remove(GTK_CONTAINER(cap_if_top_vb), cap_if_sw);
|
|
|
|
capture_stat_stop(sc);
|
|
|
|
g_source_remove(timer_id);
|
2011-10-20 19:44:40 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
/* Now construct the new interface list, and start updating the
|
|
|
|
statistics on it. */
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2012-06-27 23:15:28 +00:00
|
|
|
make_if_array();
|
2006-04-08 20:19:40 +00:00
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
cap_if_sw = gtk_scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cap_if_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_box_pack_start(GTK_BOX(cap_if_top_vb), cap_if_sw, TRUE, TRUE, 0);
|
2012-06-19 06:08:58 +00:00
|
|
|
|
2013-03-06 04:43:12 +00:00
|
|
|
if_vb = gtk_alignment_new(0.0F, 0.0F, 1.0F, 0.0F);
|
2012-06-19 06:08:58 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(if_vb), 5);
|
2013-03-04 19:20:39 +00:00
|
|
|
#if ! GTK_CHECK_VERSION(3,8,0)
|
2012-06-28 01:54:42 +00:00
|
|
|
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(cap_if_sw), if_vb);
|
2013-03-04 19:20:39 +00:00
|
|
|
#else
|
|
|
|
gtk_container_add(GTK_CONTAINER(cap_if_sw), if_vb);
|
|
|
|
#endif
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2013-01-10 16:29:30 +00:00
|
|
|
if_grid = ws_gtk_grid_new();
|
|
|
|
ws_gtk_grid_set_row_spacing(GTK_GRID(if_grid), 3);
|
|
|
|
ws_gtk_grid_set_column_spacing(GTK_GRID(if_grid), 3);
|
2013-03-06 00:33:58 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(if_vb), if_grid);
|
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("");
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 0, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
2006-08-16 18:01:25 +00:00
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
if_lb = gtk_label_new("Device");
|
2013-01-10 16:29:30 +00:00
|
|
|
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), if_lb, 1, row, 3, 1);
|
From Mike Garratt:
Friendly Names for interfaces on Windows
Notes on the changes the patch covers:
* if_info_t struct: addition of friendly_name
* Dumpcap Interface list format changes:
+ Win32: "dumpcap -D" shows friendly_name in place of descript if known
+ All: machine interface "dumpcap -D -Z none" includes friendly_name in the
list in addition to the existing parameters
* interface_options struct: addition of console_display_name
+ When an interface name is displayed in a console, it will typically be the
console_display_name (instead of name).
+ console_display_name is used as the basis of the autogenerated temp
filenames
+ console_display_name is typically set to the friendly_name if known,
otherwise it is set to the interface name
* Enhancements to capture_opts_add_iface_opt() (the function which process -i
options).
+ Can now specify the interface using its name and friendly_name
+ Interface name matching is case insenstive
+ Name matching first attempts exact matching, then falls back to prefix
matching
(e.g. dumpcap -i local)
+ Validates interface names, instead of blindly sending them off to
winpcap/libpcap
+ Interface specification by number is still supported.
* capture_opts_trim_iface() has been refactored:
+ Instead of repeating a decent chunk of the cost in
capture_opts_add_iface_opt(), it calls capture_opts_trim_iface() to specify the
interface.
* introduction of capture_win_ifnames.[ch] (windows only code)
+ Implements static function GetInterfaceFriendlyNameFromDeviceGuid() - a
windows version independant function to convert an interface guid into its
friendly name. Uses published api functions on windows vista and higher, but
falls back to unpublished API functions on older windows releases.
+ void get_windows_interface_friendlyname(/* IN */ char
*interface_devicename, /* OUT */char **interface_friendlyname); - extracts the
GUID from the interface_devicename, then uses
GetInterfaceFriendlyNameFromDeviceGuid() to do the resolution
* Auto temp filename generation:
+ Now uses wireshark_pcapng_* or wireshark_pcap_* depending on file format
+ Basis temp filename format on console_display_name
+ Win32: if console_display_name is a windows interface guid, extracts
numbers from GUID here (instead of in interface option processing)
GUI CHANGES:
* Dialog that displays when you click the "Manage Interfaces" button (within
Capture Options dialog) has been renamed from "Add new interfaces" to
"Interface Management"
* ui/gtk/capture_dlg.c: new_interfaces_w variable renamed to
interface_management_w
* Win32: Local Interfaces tab on Interface Management dialog, shows includes
friendly name as far left column
* Interface Management dialog defaults to larger size on win32 - so it fits
without resizing local interfaces tab
* Interface Management dialog now saves preferences when you click the apply
button (local hidden interfaces was not persisting across restarts)
* Tweaks: "Interface Details" dialog (Interface list->Capture Interfaces ->
Details):
+ "Friendly Name" renamed to "NDIS Friendly Name"
+ Added "OS Friendly Name" to the top of the list
* Win32: The "Capture Interfaces" dialog now shows the friendly name instead of
device guid
* Welcome screen:
+ The height of the interface list scrollbox dynamically adjusts & updates to
the number visible interfaces.
Up to 10 interfaces can be listed without a scroll bar, the minimum height
is for 2 interfaces.
+ Win32: now shows just the Friendly Name if known - in place of
"Interfacename_Guid:(Description)"
svn path=/trunk/; revision=46083
2012-11-19 20:07:27 +00:00
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
if_lb = gtk_label_new("Description");
|
2013-01-10 16:29:30 +00:00
|
|
|
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), if_lb, 4, row, 1, 1);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
if_lb = gtk_label_new(" IP ");
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 5, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
if_lb = gtk_label_new("Packets");
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 6, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
if_lb = gtk_label_new(" Packets/s ");
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 7, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
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) */
|
2012-01-25 13:04:32 +00:00
|
|
|
sc = capture_stat_start(&global_capture_opts);
|
2007-08-02 21:45:27 +00:00
|
|
|
|
|
|
|
/* List the interfaces */
|
2012-01-25 13:04:32 +00:00
|
|
|
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
2012-06-27 23:15:28 +00:00
|
|
|
data = g_array_index(if_array, if_dlg_data_t, ifs);
|
2011-08-05 07:19:17 +00:00
|
|
|
/* Continue if capture device is hidden */
|
2012-01-25 13:04:32 +00:00
|
|
|
if (device.hidden) {
|
2012-04-23 11:06:21 +00:00
|
|
|
data.hidden = TRUE;
|
2012-06-27 23:15:28 +00:00
|
|
|
if_array = g_array_remove_index(if_array, ifs);
|
|
|
|
g_array_insert_val(if_array, ifs, data);
|
2011-08-05 07:19:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
data.choose_bt = gtk_check_button_new();
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.choose_bt, 0, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
2011-08-05 07:19:17 +00:00
|
|
|
if (gbl_capture_in_progress) {
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
2011-08-05 07:19:17 +00:00
|
|
|
} else {
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_toggle_button_set_active((GtkToggleButton *)data.choose_bt, device.selected);
|
|
|
|
g_signal_connect(data.choose_bt, "toggled", G_CALLBACK(store_selected), device.name);
|
|
|
|
/* Kind of adaptor (icon) */
|
|
|
|
icon = capture_get_if_icon(&(device));
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), icon, 1, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
2006-08-16 18:01:25 +00:00
|
|
|
|
From Mike Garratt:
Friendly Names for interfaces on Windows
Notes on the changes the patch covers:
* if_info_t struct: addition of friendly_name
* Dumpcap Interface list format changes:
+ Win32: "dumpcap -D" shows friendly_name in place of descript if known
+ All: machine interface "dumpcap -D -Z none" includes friendly_name in the
list in addition to the existing parameters
* interface_options struct: addition of console_display_name
+ When an interface name is displayed in a console, it will typically be the
console_display_name (instead of name).
+ console_display_name is used as the basis of the autogenerated temp
filenames
+ console_display_name is typically set to the friendly_name if known,
otherwise it is set to the interface name
* Enhancements to capture_opts_add_iface_opt() (the function which process -i
options).
+ Can now specify the interface using its name and friendly_name
+ Interface name matching is case insenstive
+ Name matching first attempts exact matching, then falls back to prefix
matching
(e.g. dumpcap -i local)
+ Validates interface names, instead of blindly sending them off to
winpcap/libpcap
+ Interface specification by number is still supported.
* capture_opts_trim_iface() has been refactored:
+ Instead of repeating a decent chunk of the cost in
capture_opts_add_iface_opt(), it calls capture_opts_trim_iface() to specify the
interface.
* introduction of capture_win_ifnames.[ch] (windows only code)
+ Implements static function GetInterfaceFriendlyNameFromDeviceGuid() - a
windows version independant function to convert an interface guid into its
friendly name. Uses published api functions on windows vista and higher, but
falls back to unpublished API functions on older windows releases.
+ void get_windows_interface_friendlyname(/* IN */ char
*interface_devicename, /* OUT */char **interface_friendlyname); - extracts the
GUID from the interface_devicename, then uses
GetInterfaceFriendlyNameFromDeviceGuid() to do the resolution
* Auto temp filename generation:
+ Now uses wireshark_pcapng_* or wireshark_pcap_* depending on file format
+ Basis temp filename format on console_display_name
+ Win32: if console_display_name is a windows interface guid, extracts
numbers from GUID here (instead of in interface option processing)
GUI CHANGES:
* Dialog that displays when you click the "Manage Interfaces" button (within
Capture Options dialog) has been renamed from "Add new interfaces" to
"Interface Management"
* ui/gtk/capture_dlg.c: new_interfaces_w variable renamed to
interface_management_w
* Win32: Local Interfaces tab on Interface Management dialog, shows includes
friendly name as far left column
* Interface Management dialog defaults to larger size on win32 - so it fits
without resizing local interfaces tab
* Interface Management dialog now saves preferences when you click the apply
button (local hidden interfaces was not persisting across restarts)
* Tweaks: "Interface Details" dialog (Interface list->Capture Interfaces ->
Details):
+ "Friendly Name" renamed to "NDIS Friendly Name"
+ Added "OS Friendly Name" to the top of the list
* Win32: The "Capture Interfaces" dialog now shows the friendly name instead of
device guid
* Welcome screen:
+ The height of the interface list scrollbox dynamically adjusts & updates to
the number visible interfaces.
Up to 10 interfaces can be listed without a scroll bar, the minimum height
is for 2 interfaces.
+ Win32: now shows just the Friendly Name if known - in place of
"Interfacename_Guid:(Description)"
svn path=/trunk/; revision=46083
2012-11-19 20:07:27 +00:00
|
|
|
/* device name */
|
|
|
|
#ifdef _WIN32
|
|
|
|
/*
|
|
|
|
* On Windows, device names are generally not meaningful - NT 5
|
|
|
|
* uses long blobs with GUIDs in them, for example - so instead we use
|
|
|
|
* the display name which should match that shown in ncpa.cpl
|
|
|
|
*/
|
|
|
|
data.device_lb = gtk_label_new(device.display_name);
|
|
|
|
#else
|
2012-01-25 13:04:32 +00:00
|
|
|
data.device_lb = gtk_label_new(device.name);
|
From Mike Garratt:
Friendly Names for interfaces on Windows
Notes on the changes the patch covers:
* if_info_t struct: addition of friendly_name
* Dumpcap Interface list format changes:
+ Win32: "dumpcap -D" shows friendly_name in place of descript if known
+ All: machine interface "dumpcap -D -Z none" includes friendly_name in the
list in addition to the existing parameters
* interface_options struct: addition of console_display_name
+ When an interface name is displayed in a console, it will typically be the
console_display_name (instead of name).
+ console_display_name is used as the basis of the autogenerated temp
filenames
+ console_display_name is typically set to the friendly_name if known,
otherwise it is set to the interface name
* Enhancements to capture_opts_add_iface_opt() (the function which process -i
options).
+ Can now specify the interface using its name and friendly_name
+ Interface name matching is case insenstive
+ Name matching first attempts exact matching, then falls back to prefix
matching
(e.g. dumpcap -i local)
+ Validates interface names, instead of blindly sending them off to
winpcap/libpcap
+ Interface specification by number is still supported.
* capture_opts_trim_iface() has been refactored:
+ Instead of repeating a decent chunk of the cost in
capture_opts_add_iface_opt(), it calls capture_opts_trim_iface() to specify the
interface.
* introduction of capture_win_ifnames.[ch] (windows only code)
+ Implements static function GetInterfaceFriendlyNameFromDeviceGuid() - a
windows version independant function to convert an interface guid into its
friendly name. Uses published api functions on windows vista and higher, but
falls back to unpublished API functions on older windows releases.
+ void get_windows_interface_friendlyname(/* IN */ char
*interface_devicename, /* OUT */char **interface_friendlyname); - extracts the
GUID from the interface_devicename, then uses
GetInterfaceFriendlyNameFromDeviceGuid() to do the resolution
* Auto temp filename generation:
+ Now uses wireshark_pcapng_* or wireshark_pcap_* depending on file format
+ Basis temp filename format on console_display_name
+ Win32: if console_display_name is a windows interface guid, extracts
numbers from GUID here (instead of in interface option processing)
GUI CHANGES:
* Dialog that displays when you click the "Manage Interfaces" button (within
Capture Options dialog) has been renamed from "Add new interfaces" to
"Interface Management"
* ui/gtk/capture_dlg.c: new_interfaces_w variable renamed to
interface_management_w
* Win32: Local Interfaces tab on Interface Management dialog, shows includes
friendly name as far left column
* Interface Management dialog defaults to larger size on win32 - so it fits
without resizing local interfaces tab
* Interface Management dialog now saves preferences when you click the apply
button (local hidden interfaces was not persisting across restarts)
* Tweaks: "Interface Details" dialog (Interface list->Capture Interfaces ->
Details):
+ "Friendly Name" renamed to "NDIS Friendly Name"
+ Added "OS Friendly Name" to the top of the list
* Win32: The "Capture Interfaces" dialog now shows the friendly name instead of
device guid
* Welcome screen:
+ The height of the interface list scrollbox dynamically adjusts & updates to
the number visible interfaces.
Up to 10 interfaces can be listed without a scroll bar, the minimum height
is for 2 interfaces.
+ Win32: now shows just the Friendly Name if known - in place of
"Interfacename_Guid:(Description)"
svn path=/trunk/; revision=46083
2012-11-19 20:07:27 +00:00
|
|
|
#endif
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(data.device_lb), 0.0f, 0.5f);
|
2013-03-21 23:25:58 +00:00
|
|
|
if (strlen(gtk_label_get_text(GTK_LABEL(data.device_lb))) > SOFT_LABEL_LEN) {
|
|
|
|
gtk_label_set_ellipsize(GTK_LABEL(data.device_lb), PANGO_ELLIPSIZE_MIDDLE);
|
2013-03-21 23:31:16 +00:00
|
|
|
gtk_label_set_width_chars(GTK_LABEL(data.device_lb), SOFT_LABEL_LEN);
|
2013-03-21 23:25:58 +00:00
|
|
|
}
|
2013-01-10 16:29:30 +00:00
|
|
|
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), data.device_lb, 2, row, 2, 1);
|
From Mike Garratt:
Friendly Names for interfaces on Windows
Notes on the changes the patch covers:
* if_info_t struct: addition of friendly_name
* Dumpcap Interface list format changes:
+ Win32: "dumpcap -D" shows friendly_name in place of descript if known
+ All: machine interface "dumpcap -D -Z none" includes friendly_name in the
list in addition to the existing parameters
* interface_options struct: addition of console_display_name
+ When an interface name is displayed in a console, it will typically be the
console_display_name (instead of name).
+ console_display_name is used as the basis of the autogenerated temp
filenames
+ console_display_name is typically set to the friendly_name if known,
otherwise it is set to the interface name
* Enhancements to capture_opts_add_iface_opt() (the function which process -i
options).
+ Can now specify the interface using its name and friendly_name
+ Interface name matching is case insenstive
+ Name matching first attempts exact matching, then falls back to prefix
matching
(e.g. dumpcap -i local)
+ Validates interface names, instead of blindly sending them off to
winpcap/libpcap
+ Interface specification by number is still supported.
* capture_opts_trim_iface() has been refactored:
+ Instead of repeating a decent chunk of the cost in
capture_opts_add_iface_opt(), it calls capture_opts_trim_iface() to specify the
interface.
* introduction of capture_win_ifnames.[ch] (windows only code)
+ Implements static function GetInterfaceFriendlyNameFromDeviceGuid() - a
windows version independant function to convert an interface guid into its
friendly name. Uses published api functions on windows vista and higher, but
falls back to unpublished API functions on older windows releases.
+ void get_windows_interface_friendlyname(/* IN */ char
*interface_devicename, /* OUT */char **interface_friendlyname); - extracts the
GUID from the interface_devicename, then uses
GetInterfaceFriendlyNameFromDeviceGuid() to do the resolution
* Auto temp filename generation:
+ Now uses wireshark_pcapng_* or wireshark_pcap_* depending on file format
+ Basis temp filename format on console_display_name
+ Win32: if console_display_name is a windows interface guid, extracts
numbers from GUID here (instead of in interface option processing)
GUI CHANGES:
* Dialog that displays when you click the "Manage Interfaces" button (within
Capture Options dialog) has been renamed from "Add new interfaces" to
"Interface Management"
* ui/gtk/capture_dlg.c: new_interfaces_w variable renamed to
interface_management_w
* Win32: Local Interfaces tab on Interface Management dialog, shows includes
friendly name as far left column
* Interface Management dialog defaults to larger size on win32 - so it fits
without resizing local interfaces tab
* Interface Management dialog now saves preferences when you click the apply
button (local hidden interfaces was not persisting across restarts)
* Tweaks: "Interface Details" dialog (Interface list->Capture Interfaces ->
Details):
+ "Friendly Name" renamed to "NDIS Friendly Name"
+ Added "OS Friendly Name" to the top of the list
* Win32: The "Capture Interfaces" dialog now shows the friendly name instead of
device guid
* Welcome screen:
+ The height of the interface list scrollbox dynamically adjusts & updates to
the number visible interfaces.
Up to 10 interfaces can be listed without a scroll bar, the minimum height
is for 2 interfaces.
+ Win32: now shows just the Friendly Name if known - in place of
"Interfacename_Guid:(Description)"
svn path=/trunk/; revision=46083
2012-11-19 20:07:27 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* description */
|
2012-01-25 13:04:32 +00:00
|
|
|
user_descr = capture_dev_user_descr_find(device.name);
|
2011-08-05 07:19:17 +00:00
|
|
|
if (user_descr) {
|
2012-01-25 13:04:32 +00:00
|
|
|
data.descr_lb = gtk_label_new(user_descr);
|
2011-08-05 07:19:17 +00:00
|
|
|
g_free (user_descr);
|
|
|
|
} else {
|
2012-11-22 06:02:49 +00:00
|
|
|
if (device.if_info.vendor_description)
|
|
|
|
data.descr_lb = gtk_label_new(device.if_info.vendor_description);
|
2011-08-05 07:19:17 +00:00
|
|
|
else
|
2012-01-25 13:04:32 +00:00
|
|
|
data.descr_lb = gtk_label_new("");
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_misc_set_alignment(GTK_MISC(data.descr_lb), 0.0f, 0.5f);
|
2013-03-21 23:25:58 +00:00
|
|
|
if (strlen(gtk_label_get_text(GTK_LABEL(data.descr_lb))) > SOFT_LABEL_LEN) {
|
|
|
|
gtk_label_set_ellipsize(GTK_LABEL(data.descr_lb), PANGO_ELLIPSIZE_MIDDLE);
|
2013-03-21 23:31:16 +00:00
|
|
|
gtk_label_set_width_chars(GTK_LABEL(data.descr_lb), SOFT_LABEL_LEN);
|
2013-03-21 23:25:58 +00:00
|
|
|
}
|
2013-01-10 16:29:30 +00:00
|
|
|
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), data.descr_lb, 4, row, 1, 1);
|
2011-08-05 07:19:17 +00:00
|
|
|
|
|
|
|
/* IP address */
|
|
|
|
/* Only one IP address will be shown, start with the first */
|
2012-01-25 13:04:32 +00:00
|
|
|
data.ip_lb = gtk_label_new("");
|
|
|
|
addr_str = set_ip_addr_label (device.if_info.addrs, data.ip_lb, 0);
|
2011-08-05 07:19:17 +00:00
|
|
|
if (addr_str) {
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(data.ip_lb, TRUE);
|
2011-08-05 07:19:17 +00:00
|
|
|
} else {
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(data.ip_lb, FALSE);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
|
|
|
eb = gtk_event_box_new ();
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(eb), data.ip_lb);
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), eb, 5, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
2012-01-25 13:04:32 +00:00
|
|
|
if (get_ip_addr_count(device.if_info.addrs) > 1) {
|
2011-08-05 07:19:17 +00:00
|
|
|
/* More than one IP address, make it possible to toggle */
|
2012-01-25 13:04:32 +00:00
|
|
|
g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, data.ip_lb);
|
2013-10-23 14:41:30 +00:00
|
|
|
gtk_widget_set_tooltip_text(eb, "Click to see additional IP addresses");
|
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);
|
2012-01-25 13:04:32 +00:00
|
|
|
g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), device.if_info.addrs);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* packets */
|
2012-01-25 13:04:32 +00:00
|
|
|
data.curr_lb = gtk_label_new("-");
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.curr_lb, 6, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
/* packets/s */
|
2012-01-25 13:04:32 +00:00
|
|
|
data.last_lb = gtk_label_new("-");
|
2013-03-24 23:04:13 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.last_lb, 7, row, 1, 1,
|
|
|
|
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
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
|
2012-01-25 13:04:32 +00:00
|
|
|
data.details_bt = gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_DETAILS);
|
|
|
|
gtk_widget_set_tooltip_text(data.details_bt, "Open the capture details dialog of this interface.");
|
2013-03-21 23:00:21 +00:00
|
|
|
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.details_bt, 8, row, 1, 1, 0, 0, 0, 0);
|
2012-01-25 13:04:32 +00:00
|
|
|
if (capture_if_has_details(device.name)) {
|
|
|
|
g_signal_connect(data.details_bt, "clicked", G_CALLBACK(capture_details_cb), device.name);
|
2011-08-05 07:19:17 +00:00
|
|
|
} else {
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_set_sensitive(data.details_bt, FALSE);
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
2005-05-20 22:23:00 +00:00
|
|
|
#endif
|
2012-06-27 23:15:28 +00:00
|
|
|
if_array = g_array_remove_index(if_array, ifs);
|
|
|
|
g_array_insert_val(if_array, ifs, data);
|
2012-03-27 02:30:51 +00:00
|
|
|
|
2011-08-05 07:19:17 +00:00
|
|
|
row++;
|
2012-06-19 06:08:58 +00:00
|
|
|
if (row <= 20) {
|
2013-03-16 18:57:35 +00:00
|
|
|
/* Add up to 20 rows of interfaces, otherwise the window may become too high */
|
2012-11-25 21:07:07 +00:00
|
|
|
#ifdef _WIN32
|
From Mike Garratt:
Friendly Names for interfaces on Windows
Notes on the changes the patch covers:
* if_info_t struct: addition of friendly_name
* Dumpcap Interface list format changes:
+ Win32: "dumpcap -D" shows friendly_name in place of descript if known
+ All: machine interface "dumpcap -D -Z none" includes friendly_name in the
list in addition to the existing parameters
* interface_options struct: addition of console_display_name
+ When an interface name is displayed in a console, it will typically be the
console_display_name (instead of name).
+ console_display_name is used as the basis of the autogenerated temp
filenames
+ console_display_name is typically set to the friendly_name if known,
otherwise it is set to the interface name
* Enhancements to capture_opts_add_iface_opt() (the function which process -i
options).
+ Can now specify the interface using its name and friendly_name
+ Interface name matching is case insenstive
+ Name matching first attempts exact matching, then falls back to prefix
matching
(e.g. dumpcap -i local)
+ Validates interface names, instead of blindly sending them off to
winpcap/libpcap
+ Interface specification by number is still supported.
* capture_opts_trim_iface() has been refactored:
+ Instead of repeating a decent chunk of the cost in
capture_opts_add_iface_opt(), it calls capture_opts_trim_iface() to specify the
interface.
* introduction of capture_win_ifnames.[ch] (windows only code)
+ Implements static function GetInterfaceFriendlyNameFromDeviceGuid() - a
windows version independant function to convert an interface guid into its
friendly name. Uses published api functions on windows vista and higher, but
falls back to unpublished API functions on older windows releases.
+ void get_windows_interface_friendlyname(/* IN */ char
*interface_devicename, /* OUT */char **interface_friendlyname); - extracts the
GUID from the interface_devicename, then uses
GetInterfaceFriendlyNameFromDeviceGuid() to do the resolution
* Auto temp filename generation:
+ Now uses wireshark_pcapng_* or wireshark_pcap_* depending on file format
+ Basis temp filename format on console_display_name
+ Win32: if console_display_name is a windows interface guid, extracts
numbers from GUID here (instead of in interface option processing)
GUI CHANGES:
* Dialog that displays when you click the "Manage Interfaces" button (within
Capture Options dialog) has been renamed from "Add new interfaces" to
"Interface Management"
* ui/gtk/capture_dlg.c: new_interfaces_w variable renamed to
interface_management_w
* Win32: Local Interfaces tab on Interface Management dialog, shows includes
friendly name as far left column
* Interface Management dialog defaults to larger size on win32 - so it fits
without resizing local interfaces tab
* Interface Management dialog now saves preferences when you click the apply
button (local hidden interfaces was not persisting across restarts)
* Tweaks: "Interface Details" dialog (Interface list->Capture Interfaces ->
Details):
+ "Friendly Name" renamed to "NDIS Friendly Name"
+ Added "OS Friendly Name" to the top of the list
* Win32: The "Capture Interfaces" dialog now shows the friendly name instead of
device guid
* Welcome screen:
+ The height of the interface list scrollbox dynamically adjusts & updates to
the number visible interfaces.
Up to 10 interfaces can be listed without a scroll bar, the minimum height
is for 2 interfaces.
+ Win32: now shows just the Friendly Name if known - in place of
"Interfacename_Guid:(Description)"
svn path=/trunk/; revision=46083
2012-11-19 20:07:27 +00:00
|
|
|
gtk_widget_get_preferred_size(GTK_WIDGET(data.details_bt), &requisition, NULL);
|
|
|
|
#else
|
2012-01-25 13:04:32 +00:00
|
|
|
gtk_widget_get_preferred_size(GTK_WIDGET(data.choose_bt), &requisition, NULL);
|
2012-11-25 21:07:07 +00:00
|
|
|
#endif
|
|
|
|
height += requisition.height;
|
2012-03-27 02:30:51 +00:00
|
|
|
}
|
2004-07-18 00:24:25 +00:00
|
|
|
}
|
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
gtk_widget_get_preferred_size(GTK_WIDGET(close_bt), &requisition, NULL);
|
2013-03-24 17:19:15 +00:00
|
|
|
/* height + static offset + grid spacing */
|
|
|
|
height += requisition.height + 40 + (row * 3);
|
2012-06-28 01:54:42 +00:00
|
|
|
|
2013-03-16 18:57:35 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
|
2012-06-28 01:54:42 +00:00
|
|
|
|
|
|
|
gtk_widget_show_all(cap_if_w);
|
|
|
|
|
|
|
|
/* update the interface list every 1000ms */
|
|
|
|
timer_id = g_timeout_add(1000, update_all, sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start getting capture stats from all interfaces */
|
|
|
|
void
|
|
|
|
capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
GtkWidget *bbox,
|
|
|
|
*help_bt;
|
2012-06-28 01:54:42 +00:00
|
|
|
#ifdef HAVE_AIRPCAP
|
2012-11-25 21:07:07 +00:00
|
|
|
GtkWidget *decryption_cb;
|
2012-06-28 01:54:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (cap_if_w != NULL) {
|
|
|
|
/* There's already a "Capture Interfaces" dialog box; reactivate it. */
|
|
|
|
reactivate_window(cap_if_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!can_capture()) {
|
|
|
|
/* No interfaces or, on Windows, no WinPcap; just give up. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_AIRPCAP
|
|
|
|
/* LOAD AIRPCAP INTERFACES */
|
|
|
|
|
|
|
|
/* 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(wireless_tb,FALSE);
|
|
|
|
} else {
|
|
|
|
/* default adapter is not airpcap... or is airpcap but is not found*/
|
2013-02-28 17:55:07 +00:00
|
|
|
if (airpcap_if_active){
|
|
|
|
/* XXX can never happen? */
|
2012-06-28 01:54:42 +00:00
|
|
|
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
2013-03-16 18:57:35 +00:00
|
|
|
}
|
2012-06-28 01:54:42 +00:00
|
|
|
airpcap_enable_toolbar_widgets(wireless_tb,FALSE);
|
|
|
|
}
|
|
|
|
}
|
2013-02-28 17:55:07 +00:00
|
|
|
if (airpcap_if_active){
|
2013-03-07 22:57:36 +00:00
|
|
|
decryption_cb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
2013-02-28 17:55:07 +00:00
|
|
|
/* XXXX update_decryption_mode_list() trigers a rescan, should only be done if the mode is changed */
|
|
|
|
update_decryption_mode_list(decryption_cb);
|
2012-06-28 01:54:42 +00:00
|
|
|
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
2013-02-28 17:55:07 +00:00
|
|
|
}
|
2012-06-28 01:54:42 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-06 00:33:58 +00:00
|
|
|
cap_if_w = dlg_window_new("Wireshark: Capture Interfaces"); /* transient_for top_level */
|
|
|
|
/* XXX: Note that on Windows the following is effectively a no-op; See dlg_window_new(). */
|
|
|
|
/* This means, on Windows, if the top_level Wireshark window is destroyed when */
|
|
|
|
/* the capture_interfaces dialog window is open, that the dumpcap process will not */
|
|
|
|
/* be stopped since the destroy callback for the capture_interfaces dialog window */
|
|
|
|
/* will not be called. */
|
|
|
|
/* ToDo: Fix this ! */
|
2012-06-28 01:54:42 +00:00
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(cap_if_w), TRUE);
|
|
|
|
|
2013-03-21 23:00:21 +00:00
|
|
|
cap_if_top_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
|
2012-06-28 01:54:42 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(cap_if_w), cap_if_top_vb);
|
2013-03-21 23:00:21 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(cap_if_top_vb), DLG_OUTER_MARGIN);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
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);
|
|
|
|
|
2013-03-21 23:00:21 +00:00
|
|
|
gtk_box_pack_end(GTK_BOX(cap_if_top_vb), bbox, FALSE, FALSE, 0);
|
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);
|
2012-03-27 06:57:21 +00:00
|
|
|
g_signal_connect(options_bt, "clicked", G_CALLBACK(capture_prepare_cb), NULL);
|
2011-12-01 06:33:14 +00:00
|
|
|
capture_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
|
2012-03-27 06:57:21 +00:00
|
|
|
g_signal_connect(capture_bt, "clicked", G_CALLBACK(capture_do_cb), NULL);
|
2006-04-08 20:19:40 +00:00
|
|
|
|
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
|
|
|
|
2012-06-28 01:54:42 +00:00
|
|
|
capture_if_refresh_if_list();
|
|
|
|
|
2004-07-18 00:24:25 +00:00
|
|
|
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
|
|
|
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)
|
|
|
|
{
|
2012-06-28 01:54:42 +00:00
|
|
|
if (cap_if_w) {
|
|
|
|
capture_if_refresh_if_list();
|
|
|
|
}
|
2011-08-05 07:19:17 +00:00
|
|
|
}
|
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
void select_all_interfaces(gboolean enable _U_)
|
2011-08-05 07:19:17 +00:00
|
|
|
{
|
2012-11-25 21:07:07 +00:00
|
|
|
guint ifs;
|
2012-01-25 13:04:32 +00:00
|
|
|
interface_t device;
|
2011-08-05 07:19:17 +00:00
|
|
|
|
2012-01-25 13:04:32 +00:00
|
|
|
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
|
|
|
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
|
|
|
update_selected_interface(device.if_info.name);
|
|
|
|
}
|
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 */
|
2012-11-25 21:07:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|