forked from osmocom/wireshark
Back out infrastructure change. We missed supporting
stdin and pipes. svn path=/trunk/; revision=39498
This commit is contained in:
parent
3c1f16f904
commit
c219f2eea5
18
capture.c
18
capture.c
|
@ -143,7 +143,6 @@ capture_start(capture_options *capture_opts)
|
|||
/* close the currently loaded capture file */
|
||||
cf_close(capture_opts->cf);
|
||||
|
||||
collect_ifaces(capture_opts);
|
||||
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Start ...");
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -652,9 +651,6 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
|
|||
}
|
||||
|
||||
/* ... and start the capture again */
|
||||
if (capture_opts->ifaces->len == 0) {
|
||||
collect_ifaces(capture_opts);
|
||||
}
|
||||
capture_start(capture_opts);
|
||||
} else {
|
||||
/* We're not doing a capture any more, so we don't have a save file. */
|
||||
|
@ -664,13 +660,13 @@ capture_input_closed(capture_options *capture_opts, gchar *msg)
|
|||
}
|
||||
|
||||
if_stat_cache_t *
|
||||
capture_stat_start(capture_options *capture_opts) {
|
||||
capture_stat_start(GList *if_list) {
|
||||
int stat_fd, fork_child;
|
||||
gchar *msg;
|
||||
if_stat_cache_t *sc = NULL;
|
||||
GList *if_entry;
|
||||
if_info_t *if_info;
|
||||
if_stat_cache_item_t *sc_item;
|
||||
guint i;
|
||||
interface_t device;
|
||||
|
||||
/* Fire up dumpcap. */
|
||||
/*
|
||||
|
@ -698,11 +694,11 @@ capture_stat_start(capture_options *capture_opts) {
|
|||
sc->cache_list = NULL;
|
||||
|
||||
/* Initialize the cache */
|
||||
for (i = 0; i < capture_opts->all_ifaces->len; i++) {
|
||||
device = g_array_index(capture_opts->all_ifaces, interface_t, i);
|
||||
if (&(device.if_info)) {
|
||||
for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
|
||||
if_info = if_entry->data;
|
||||
if (if_info) {
|
||||
sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
|
||||
sc_item->name = g_strdup(device.if_info.name);
|
||||
sc_item->name = g_strdup(if_info->name);
|
||||
sc->cache_list = g_list_append(sc->cache_list, sc_item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ typedef struct if_stat_cache_s if_stat_cache_t;
|
|||
* @param if_list A GList of if_info_t items
|
||||
* @return A pointer to the statistics state data.
|
||||
*/
|
||||
extern if_stat_cache_t * capture_stat_start(capture_options *capture_opts);
|
||||
extern if_stat_cache_t * capture_stat_start(GList *if_list);
|
||||
|
||||
/**
|
||||
* Fetch capture statistics, similar to pcap_stats().
|
||||
|
|
128
capture_opts.c
128
capture_opts.c
|
@ -38,9 +38,6 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/prefs.h>
|
||||
#include "simple_dialog.h"
|
||||
#include "capture_ui_utils.h"
|
||||
|
||||
#include "capture_opts.h"
|
||||
#include "ringbuffer.h"
|
||||
|
@ -60,8 +57,6 @@ capture_opts_init(capture_options *capture_opts, void *cf)
|
|||
{
|
||||
capture_opts->cf = cf;
|
||||
capture_opts->ifaces = g_array_new(FALSE, FALSE, sizeof(interface_options));
|
||||
capture_opts->all_ifaces = g_array_new(FALSE, FALSE, sizeof(interface_t));
|
||||
capture_opts->num_selected = 0;
|
||||
capture_opts->default_options.name = NULL;
|
||||
capture_opts->default_options.descr = NULL;
|
||||
capture_opts->default_options.cfilter = NULL;
|
||||
|
@ -527,83 +522,7 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
|
|||
#endif
|
||||
|
||||
g_array_append_val(capture_opts->ifaces, interface_opts);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
capture_opts_select_iface(capture_options *capture_opts, const char *optarg_str_p)
|
||||
{
|
||||
long adapter_index;
|
||||
char *p;
|
||||
GList *if_list;
|
||||
if_info_t *if_info;
|
||||
int err;
|
||||
guint i;
|
||||
gchar *err_str, *name = NULL;
|
||||
interface_t device;
|
||||
|
||||
/*
|
||||
* If the argument is a number, treat it as an index into the list
|
||||
* of adapters, as printed by "tshark -D".
|
||||
*
|
||||
* This should be OK on UNIX systems, as interfaces shouldn't have
|
||||
* names that begin with digits. It can be useful on Windows, where
|
||||
* more than one interface can have the same name.
|
||||
*/
|
||||
adapter_index = strtol(optarg_str_p, &p, 10);
|
||||
if (p != NULL && *p == '\0') {
|
||||
if (adapter_index < 0) {
|
||||
cmdarg_err("The specified adapter index is a negative number");
|
||||
return 1;
|
||||
}
|
||||
if (adapter_index > INT_MAX) {
|
||||
cmdarg_err("The specified adapter index is too large (greater than %d)",
|
||||
INT_MAX);
|
||||
return 1;
|
||||
}
|
||||
if (adapter_index == 0) {
|
||||
cmdarg_err("There is no interface with that adapter index");
|
||||
return 1;
|
||||
}
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
break;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
if_info = (if_info_t *)g_list_nth_data(if_list, adapter_index - 1);
|
||||
if (if_info == NULL) {
|
||||
cmdarg_err("There is no interface with that adapter index");
|
||||
return 1;
|
||||
}
|
||||
name = g_strdup(if_info->name);
|
||||
/* We don't set iface_descr here because doing so requires
|
||||
* capture_ui_utils.c which requires epan/prefs.c which is
|
||||
* probably a bit too much dependency for here...
|
||||
*/
|
||||
free_interface_list(if_list);
|
||||
} else {
|
||||
name = g_strdup(optarg_str_p);
|
||||
}
|
||||
for(i = 0; i < capture_opts->all_ifaces->len; i++) {
|
||||
device = g_array_index(capture_opts->all_ifaces, interface_t, i);
|
||||
if (strcmp(device.name, name) == 0) {
|
||||
device.selected = TRUE;
|
||||
capture_opts->num_selected++;
|
||||
capture_opts->all_ifaces = g_array_remove_index(capture_opts->all_ifaces, i);
|
||||
g_array_insert_val(capture_opts->all_ifaces, i, device);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -907,7 +826,7 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
|
|||
|
||||
|
||||
/* Did the user specify an interface to use? */
|
||||
if (capture_opts->num_selected == 0 && capture_opts->ifaces->len == 0) {
|
||||
if (capture_opts->ifaces->len == 0) {
|
||||
/* No - is a default specified in the preferences file? */
|
||||
if (capture_device != NULL) {
|
||||
/* Yes - use it. */
|
||||
|
@ -1038,49 +957,4 @@ static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
collect_ifaces(capture_options *capture_opts)
|
||||
{
|
||||
guint i;
|
||||
interface_t device;
|
||||
interface_options interface_opts;
|
||||
for (i = 0; i < capture_opts->all_ifaces->len; i++) {
|
||||
device = g_array_index(capture_opts->all_ifaces, interface_t, i);
|
||||
if (device.selected) {
|
||||
interface_opts.name = g_strdup(device.name);
|
||||
interface_opts.descr = g_strdup(device.display_name);
|
||||
interface_opts.monitor_mode = device.monitor_mode_enabled;
|
||||
interface_opts.linktype = device.active_dlt;
|
||||
interface_opts.cfilter = g_strdup(device.cfilter);
|
||||
interface_opts.snaplen = device.snaplen;
|
||||
interface_opts.has_snaplen = device.has_snaplen;
|
||||
interface_opts.promisc_mode = device.pmode;
|
||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||
interface_opts.buffer_size = device.buffer;
|
||||
#endif
|
||||
if (device.type == IF_REMOTE) {
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
interface_opts.src_type = device.type;
|
||||
interface_opts.remote_host = g_strdup(device.remote_opts.remote_host_opts.remote_host);
|
||||
interface_opts.remote_port = g_strdup(device.remote_opts.remote_host_opts.remote_port);
|
||||
interface_opts.auth_type = device.remote_opts.remote_host_opts.auth_type;
|
||||
interface_opts.auth_username = g_strdup(device.remote_opts.remote_host_opts.auth_username);
|
||||
interface_opts.auth_password = g_strdup(device.remote_opts.remote_host_opts.auth_password);
|
||||
interface_opts.datatx_udp = device.remote_opts.remote_host_opts.datatx_udp;
|
||||
interface_opts.nocap_rpcap = device.remote_opts.remote_host_opts.nocap_rpcap;
|
||||
interface_opts.nocap_local = device.remote_opts.remote_host_opts.nocap_local;
|
||||
#endif
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
interface_opts.sampling_method = device.remote_opts.sampling_method;
|
||||
interface_opts.sampling_param = device.remote_opts.sampling_param;
|
||||
#endif
|
||||
}
|
||||
g_array_append_val(capture_opts->ifaces, interface_opts);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
|
|
@ -73,66 +73,6 @@ typedef enum {
|
|||
} capture_sampling;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
IF_LOCAL,
|
||||
IF_REMOTE,
|
||||
IF_AIRPCAP
|
||||
} interface_type;
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
struct remote_host {
|
||||
gchar *remote_host; /**< Host name or network address for remote capturing */
|
||||
gchar *remote_port; /**< TCP port of remote RPCAP server */
|
||||
gint auth_type; /**< Authentication type */
|
||||
gchar *auth_username; /**< Remote authentication parameters */
|
||||
gchar *auth_password; /**< Remote authentication parameters */
|
||||
gboolean datatx_udp;
|
||||
gboolean nocap_rpcap;
|
||||
gboolean nocap_local;
|
||||
};
|
||||
|
||||
typedef struct remote_options_tag {
|
||||
capture_source src_type;
|
||||
struct remote_host remote_host_opts;
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
capture_sampling sampling_method;
|
||||
int sampling_param;
|
||||
#endif
|
||||
} remote_options;
|
||||
#endif /* HAVE_PCAP_REMOTE */
|
||||
|
||||
typedef struct interface_tag {
|
||||
gchar *name;
|
||||
gchar *display_name;
|
||||
guint type;
|
||||
gchar *addresses;
|
||||
gint no_addresses;
|
||||
gchar *cfilter;
|
||||
GList *links;
|
||||
gint active_dlt;
|
||||
gboolean pmode;
|
||||
gboolean has_snaplen;
|
||||
guint snaplen;
|
||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||
gint buffer;
|
||||
gboolean monitor_mode_enabled;
|
||||
gboolean monitor_mode_supported;
|
||||
#endif
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
remote_options remote_opts;
|
||||
#endif
|
||||
guint32 last_packets;
|
||||
if_info_t if_info;
|
||||
gboolean selected;
|
||||
gboolean hidden;
|
||||
gboolean locked;
|
||||
} interface_t;
|
||||
|
||||
typedef struct link_row_tag {
|
||||
gchar *name;
|
||||
gint dlt;
|
||||
} link_row;
|
||||
|
||||
typedef struct interface_options_tag {
|
||||
gchar *name;
|
||||
gchar *descr;
|
||||
|
@ -168,8 +108,6 @@ typedef struct capture_options_tag {
|
|||
void *cf; /**< handle to cfile (note: untyped handle) */
|
||||
GArray *ifaces; /**< array of interfaces.
|
||||
Currently only used by dumpcap. */
|
||||
GArray *all_ifaces;
|
||||
guint num_selected;
|
||||
interface_options default_options;
|
||||
gboolean saving_to_file; /**< TRUE if capture is writing to a file */
|
||||
gchar *save_file; /**< the capture file name */
|
||||
|
@ -252,25 +190,4 @@ capture_opts_trim_ring_num_files(capture_options *capture_opts);
|
|||
extern gboolean
|
||||
capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
|
||||
|
||||
extern void
|
||||
collect_ifaces(capture_options *capture_opts);
|
||||
|
||||
typedef struct {
|
||||
gboolean monitor_mode;
|
||||
int linktype;
|
||||
} cap_settings_t;
|
||||
|
||||
/** Get capture settings for interface
|
||||
*
|
||||
* @param if_name interface name
|
||||
*/
|
||||
cap_settings_t
|
||||
capture_get_cap_settings (gchar *if_name);
|
||||
|
||||
extern void
|
||||
scan_local_interfaces(capture_options* capture_opts);
|
||||
|
||||
int
|
||||
capture_opts_select_iface(capture_options *capture_opts, const char *optarg_str_p);
|
||||
|
||||
#endif /* capture_opts.h */
|
||||
|
|
|
@ -461,11 +461,9 @@ sync_pipe_start(capture_options *capture_opts) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PCAP_CREATE
|
||||
if (interface_opts.monitor_mode) {
|
||||
argv = sync_pipe_add_arg(argv, &argc, "-I");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
if (interface_opts.datatx_udp)
|
||||
|
|
|
@ -38,9 +38,6 @@
|
|||
#include "epan/ex-opt.h"
|
||||
#include "capture_ifinfo.h"
|
||||
#include "capture_ui_utils.h"
|
||||
#include "simple_dialog.h"
|
||||
#include "wiretap/wtap.h"
|
||||
#include "epan/to_str.h"
|
||||
|
||||
/*
|
||||
* Find user-specified capture device description that matches interface
|
||||
|
|
1061
gtk/capture_dlg.c
1061
gtk/capture_dlg.c
File diff suppressed because it is too large
Load Diff
|
@ -32,12 +32,60 @@
|
|||
* @ingroup dialog_group
|
||||
*/
|
||||
#include "capture_opts.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
struct remote_host {
|
||||
gchar *remote_host; /**< Host name or network address for remote capturing */
|
||||
gchar *remote_port; /**< TCP port of remote RPCAP server */
|
||||
gint auth_type; /**< Authentication type */
|
||||
gchar *auth_username; /**< Remote authentication parameters */
|
||||
gchar *auth_password; /**< Remote authentication parameters */
|
||||
gboolean datatx_udp;
|
||||
gboolean nocap_rpcap;
|
||||
gboolean nocap_local;
|
||||
};
|
||||
|
||||
typedef struct remote_options_tag {
|
||||
capture_source src_type;
|
||||
struct remote_host remote_host_opts;
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
capture_sampling sampling_method;
|
||||
int sampling_param;
|
||||
#endif
|
||||
} remote_options;
|
||||
#endif /* HAVE_PCAP_REMOTE */
|
||||
|
||||
typedef struct row_options_tag {
|
||||
gchar *name;
|
||||
gchar *display_name;
|
||||
gchar *addresses;
|
||||
gint no_addresses;
|
||||
gchar *cfilter;
|
||||
GList *links;
|
||||
gint active_dlt;
|
||||
gboolean pmode;
|
||||
#ifdef HAVE_PCAP_CREATE
|
||||
gboolean monitor_mode_enabled;
|
||||
gboolean monitor_mode_supported;
|
||||
#endif
|
||||
gboolean has_snaplen;
|
||||
guint snaplen;
|
||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||
gint buffer;
|
||||
#endif
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
remote_options remote_opts;
|
||||
#endif
|
||||
} interface_row;
|
||||
|
||||
typedef struct link_row_tag {
|
||||
gchar *name;
|
||||
gint dlt;
|
||||
} link_row;
|
||||
|
||||
enum
|
||||
{
|
||||
CAPTURE = 0,
|
||||
IFACE_HIDDEN_NAME,
|
||||
INTERFACE,
|
||||
LINK,
|
||||
PMODE,
|
||||
|
@ -95,7 +143,6 @@ void capture_start_confirmed(void);
|
|||
void
|
||||
capture_air_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* We remember the capture settings for each interface when a capture
|
||||
* is started on it; the next time we select that interface we start
|
||||
|
@ -116,7 +163,6 @@ typedef struct {
|
|||
*/
|
||||
cap_settings_t
|
||||
capture_get_cap_settings (gchar *if_name);
|
||||
#endif
|
||||
|
||||
GtkTreeModel*
|
||||
create_and_fill_model (GtkTreeView *view);
|
||||
|
@ -156,12 +202,9 @@ gboolean
|
|||
dlg_window_present(void);
|
||||
|
||||
void
|
||||
enable_selected_interface(gchar *name, gboolean selected);
|
||||
enable_selected_interface(gchar *name, gboolean enable);
|
||||
|
||||
void
|
||||
options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata);
|
||||
|
||||
void
|
||||
update_all_rows(void);
|
||||
|
||||
#endif /* capture_dlg.h */
|
||||
|
|
|
@ -110,13 +110,15 @@
|
|||
*/
|
||||
static GtkWidget *cap_if_w;
|
||||
|
||||
static GList *if_data_list = NULL;
|
||||
|
||||
static guint timer_id;
|
||||
|
||||
static GtkWidget *stop_bt, *capture_bt, *options_bt;
|
||||
|
||||
static GList *if_list;
|
||||
|
||||
static GArray *gtk_list;
|
||||
static guint currently_selected = 0;
|
||||
|
||||
static if_stat_cache_t *sc;
|
||||
|
||||
|
@ -128,7 +130,6 @@ static if_stat_cache_t *sc;
|
|||
|
||||
/* the "runtime" data of one interface */
|
||||
typedef struct if_dlg_data_s {
|
||||
gchar *device;
|
||||
GtkWidget *device_lb;
|
||||
GtkWidget *descr_lb;
|
||||
GtkWidget *ip_lb;
|
||||
|
@ -138,65 +139,128 @@ typedef struct if_dlg_data_s {
|
|||
#ifdef _WIN32
|
||||
GtkWidget *details_bt;
|
||||
#endif
|
||||
guint32 last_packets;
|
||||
gchar *device;
|
||||
if_info_t if_info;
|
||||
gboolean selected;
|
||||
} if_dlg_data_t;
|
||||
|
||||
static gboolean gbl_capture_in_progress = FALSE;
|
||||
|
||||
void
|
||||
update_selected_interface(gchar *name)
|
||||
update_selected_interface(gchar *name, gboolean activate)
|
||||
{
|
||||
guint i;
|
||||
interface_t device;
|
||||
if_dlg_data_t data;
|
||||
guint ifs;
|
||||
GList *curr;
|
||||
if_dlg_data_t *temp;
|
||||
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
data = g_array_index(gtk_list, if_dlg_data_t, i);
|
||||
if (strcmp(name, device.name) == 0) {
|
||||
gtk_toggle_button_set_active((GtkToggleButton *)data.choose_bt, device.selected);
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
store_selected(GtkWidget *choose_bt, gpointer name)
|
||||
store_selected(GtkWidget *choose_bt, gpointer if_data)
|
||||
{
|
||||
interface_t device;
|
||||
guint i;
|
||||
if_dlg_data_t *if_dlg_data = if_data, *temp;
|
||||
GList *curr;
|
||||
unsigned int ifs, i;
|
||||
gboolean found;
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
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);
|
||||
found = FALSE;
|
||||
if (strcmp(name, device.if_info.name) == 0) {
|
||||
found = TRUE;
|
||||
if (!device.locked) {
|
||||
device.selected ^= 1;
|
||||
if (device.selected) {
|
||||
global_capture_opts.num_selected++;
|
||||
} else {
|
||||
global_capture_opts.num_selected--;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (gtk_widget_is_focus(choose_bt) && dlg_window_present()) {
|
||||
enable_selected_interface(device.name, device.selected);
|
||||
enable_selected_interface(interface_opts.name, TRUE);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (temp->selected)
|
||||
currently_selected += 1;
|
||||
else
|
||||
currently_selected -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cap_if_w) {
|
||||
#ifdef USE_THREADS
|
||||
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (global_capture_opts.num_selected > 0));
|
||||
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (currently_selected > 0));
|
||||
#else
|
||||
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (global_capture_opts.num_selected == 1));
|
||||
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (currently_selected == 1));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -209,18 +273,19 @@ capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data)
|
|||
capture_do_cb(GtkWidget *capture_bt _U_, gpointer if_data _U_)
|
||||
#endif
|
||||
{
|
||||
if_dlg_data_t data;
|
||||
guint ifs;
|
||||
|
||||
for (ifs = 0; ifs < gtk_list->len; ifs++) {
|
||||
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
||||
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||
g_array_insert_val(gtk_list, ifs, data);
|
||||
if_dlg_data_t *temp;
|
||||
GList *curr;
|
||||
int ifs;
|
||||
#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;
|
||||
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;
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* XXX - remove this? */
|
||||
|
@ -266,14 +331,11 @@ capture_details_cb(GtkWidget *details_bt _U_, gpointer if_data)
|
|||
|
||||
/* update a single interface */
|
||||
static void
|
||||
update_if(gchar *name, if_stat_cache_t *sc)
|
||||
update_if(if_dlg_data_t *if_dlg_data, if_stat_cache_t *sc)
|
||||
{
|
||||
struct pcap_stat stats;
|
||||
gchar *str;
|
||||
guint diff, ifs;
|
||||
interface_t device;
|
||||
if_dlg_data_t data;
|
||||
gboolean found = FALSE;
|
||||
guint diff;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -284,40 +346,23 @@ update_if(gchar *name, if_stat_cache_t *sc)
|
|||
* That's a bug, and should be fixed; "pcap_stats()" is supposed
|
||||
* to work the same way on all platforms.
|
||||
*/
|
||||
device.last_packets = 0;
|
||||
data.curr_lb = NULL;
|
||||
data.last_lb = NULL;
|
||||
if (sc) {
|
||||
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||
if (!device.hidden && strcmp(name, device.name) == 0) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if (capture_stats(sc, name, &stats)) {
|
||||
diff = stats.ps_recv - device.last_packets;
|
||||
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);
|
||||
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||
g_array_insert_val(gtk_list, ifs, data);
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -326,17 +371,16 @@ update_if(gchar *name, if_stat_cache_t *sc)
|
|||
static gboolean
|
||||
update_all(gpointer data)
|
||||
{
|
||||
interface_t device;
|
||||
guint ifs;
|
||||
GList *curr;
|
||||
int ifs;
|
||||
if_stat_cache_t *sc = data;
|
||||
|
||||
if (!cap_if_w) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
update_if(device.name, sc);
|
||||
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
||||
update_if(curr->data, sc);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -350,9 +394,9 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
|
|||
if (cap_if_w) {
|
||||
gtk_widget_set_sensitive(stop_bt, capture_in_progress);
|
||||
#ifdef USE_THREADS
|
||||
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (global_capture_opts.num_selected > 0));
|
||||
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (currently_selected > 0));
|
||||
#else
|
||||
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (global_capture_opts.num_selected == 1));
|
||||
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (currently_selected == 1));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -362,8 +406,17 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
|
|||
static void
|
||||
capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
GList *curr;
|
||||
int ifs;
|
||||
|
||||
g_source_remove(timer_id);
|
||||
|
||||
for (ifs = 0; (curr = g_list_nth(if_data_list, ifs)); ifs++) {
|
||||
g_free(curr->data);
|
||||
}
|
||||
|
||||
if_data_list = NULL;
|
||||
|
||||
free_interface_list(if_list);
|
||||
|
||||
/* Note that we no longer have a "Capture Options" dialog box. */
|
||||
|
@ -648,41 +701,17 @@ static void
|
|||
capture_if_stop_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
guint ifs;
|
||||
if_dlg_data_t data;
|
||||
GList *curr;
|
||||
if_dlg_data_t *if_data;
|
||||
|
||||
for (ifs = 0; ifs < gtk_list->len; ifs++) {
|
||||
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
||||
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||
g_array_insert_val(gtk_list, ifs, data);
|
||||
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);
|
||||
}
|
||||
capture_stop_cb(NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
make_gtk_array(void)
|
||||
{
|
||||
interface_t device;
|
||||
if_dlg_data_t data;
|
||||
guint i;
|
||||
|
||||
gtk_list = g_array_new(FALSE, FALSE, sizeof(if_dlg_data_t));
|
||||
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, 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
|
||||
g_array_append_val(gtk_list, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* start getting capture stats from all interfaces */
|
||||
void
|
||||
|
@ -692,23 +721,30 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
*main_sw,
|
||||
*bbox,
|
||||
*close_bt,
|
||||
*help_bt;
|
||||
*help_bt,
|
||||
*icon;
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
GtkWidget *decryption_cb;
|
||||
#endif
|
||||
|
||||
GtkWidget *if_tb, *icon;
|
||||
GtkWidget *if_tb;
|
||||
GtkWidget *if_lb;
|
||||
GtkWidget *eb;
|
||||
int err;
|
||||
gchar *err_str;
|
||||
GtkRequisition requisition;
|
||||
int row, height;
|
||||
guint ifs;
|
||||
interface_t device;
|
||||
if_dlg_data_t *if_dlg_data = NULL;
|
||||
int ifs;
|
||||
GList *curr;
|
||||
if_info_t *if_info;
|
||||
GString *if_tool_str = g_string_new("");
|
||||
const gchar *addr_str;
|
||||
gchar *user_descr;
|
||||
if_dlg_data_t data;
|
||||
int preselected = 0, i;
|
||||
interface_options interface_opts;
|
||||
gboolean found = FALSE;
|
||||
|
||||
if (cap_if_w != NULL) {
|
||||
/* There's already a "Capture Interfaces" dialog box; reactivate it. */
|
||||
|
@ -727,13 +763,43 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
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:
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
/* LOAD AIRPCAP INTERFACES */
|
||||
airpcap_if_list = get_airpcap_interface_list(&err, &err_str);
|
||||
if (airpcap_if_list == NULL)
|
||||
airpcap_if_active = airpcap_if_selected = NULL;
|
||||
|
||||
decryption_cb = g_object_get_data(G_OBJECT(airpcap_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
||||
update_decryption_mode_list(decryption_cb);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* If no airpcap interface is present, gray everything */
|
||||
if (airpcap_if_active == NULL) {
|
||||
if (airpcap_if_list == NULL) {
|
||||
|
@ -749,7 +815,6 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
||||
#endif
|
||||
|
||||
make_gtk_array();
|
||||
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);
|
||||
|
||||
|
@ -797,109 +862,142 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
|
||||
height += 30;
|
||||
/* Start gathering statistics (using dumpcap) */
|
||||
sc = capture_stat_start(&global_capture_opts);
|
||||
sc = capture_stat_start(if_list);
|
||||
|
||||
/* List the interfaces */
|
||||
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
data = g_array_index(gtk_list, if_dlg_data_t, ifs);
|
||||
currently_selected = 0;
|
||||
for (ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
|
||||
g_string_assign(if_tool_str, "");
|
||||
if_info = curr->data;
|
||||
|
||||
/* Continue if capture device is hidden */
|
||||
if (device.hidden) {
|
||||
if (prefs_is_capture_device_hidden(if_info->name)) {
|
||||
continue;
|
||||
}
|
||||
data.choose_bt = gtk_check_button_new();
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.choose_bt, 0, 1, row, row+1);
|
||||
if (gbl_capture_in_progress) {
|
||||
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
||||
|
||||
if_dlg_data = g_malloc0(sizeof(if_dlg_data_t));
|
||||
|
||||
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 {
|
||||
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
||||
if_dlg_data->selected = FALSE;
|
||||
}
|
||||
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.if_info));
|
||||
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);
|
||||
if (gbl_capture_in_progress) {
|
||||
gtk_widget_set_sensitive(if_dlg_data->choose_bt, FALSE);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(if_dlg_data->choose_bt, TRUE);
|
||||
}
|
||||
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
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 1, 2, row, row+1);
|
||||
|
||||
/* device name */
|
||||
data.device_lb = gtk_label_new(device.name);
|
||||
if_dlg_data->device_lb = gtk_label_new(if_info->name);
|
||||
if_dlg_data->device = if_info->name;
|
||||
#ifndef _WIN32
|
||||
gtk_misc_set_alignment(GTK_MISC(data.device_lb), 0.0f, 0.5f);
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.device_lb, 2, 4, row, row+1);
|
||||
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);
|
||||
#endif
|
||||
g_string_append(if_tool_str, "Device: ");
|
||||
g_string_append(if_tool_str, device.name);
|
||||
g_string_append(if_tool_str, if_info->name);
|
||||
g_string_append(if_tool_str, "\n");
|
||||
|
||||
/* description */
|
||||
user_descr = capture_dev_user_descr_find(device.name);
|
||||
user_descr = capture_dev_user_descr_find(if_info->name);
|
||||
if (user_descr) {
|
||||
data.descr_lb = gtk_label_new(user_descr);
|
||||
if_dlg_data->descr_lb = gtk_label_new(user_descr);
|
||||
g_free (user_descr);
|
||||
} else {
|
||||
if (device.if_info.description)
|
||||
data.descr_lb = gtk_label_new(device.if_info.description);
|
||||
if (if_info->description)
|
||||
if_dlg_data->descr_lb = gtk_label_new(if_info->description);
|
||||
else
|
||||
data.descr_lb = gtk_label_new("");
|
||||
if_dlg_data->descr_lb = gtk_label_new("");
|
||||
}
|
||||
gtk_misc_set_alignment(GTK_MISC(data.descr_lb), 0.0f, 0.5f);
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.descr_lb, 4, 5, row, row+1);
|
||||
if (device.if_info.description) {
|
||||
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) {
|
||||
g_string_append(if_tool_str, "Description: ");
|
||||
g_string_append(if_tool_str, device.if_info.description);
|
||||
g_string_append(if_tool_str, if_info->description);
|
||||
g_string_append(if_tool_str, "\n");
|
||||
}
|
||||
|
||||
/* IP address */
|
||||
/* Only one IP address will be shown, start with the first */
|
||||
g_string_append(if_tool_str, "IP: ");
|
||||
data.ip_lb = gtk_label_new("");
|
||||
addr_str = set_ip_addr_label (device.if_info.addrs, data.ip_lb, 0);
|
||||
if_dlg_data->ip_lb = gtk_label_new("");
|
||||
addr_str = set_ip_addr_label (if_info->addrs, if_dlg_data->ip_lb, 0);
|
||||
if (addr_str) {
|
||||
gtk_widget_set_sensitive(data.ip_lb, TRUE);
|
||||
gtk_widget_set_sensitive(if_dlg_data->ip_lb, TRUE);
|
||||
g_string_append(if_tool_str, addr_str);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(data.ip_lb, FALSE);
|
||||
gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
|
||||
g_string_append(if_tool_str, "none");
|
||||
}
|
||||
eb = gtk_event_box_new ();
|
||||
gtk_container_add(GTK_CONTAINER(eb), data.ip_lb);
|
||||
gtk_container_add(GTK_CONTAINER(eb), if_dlg_data->ip_lb);
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), eb, 5, 6, row, row+1);
|
||||
if (get_ip_addr_count(device.if_info.addrs) > 1) {
|
||||
if (get_ip_addr_count(if_info->addrs) > 1) {
|
||||
/* More than one IP address, make it possible to toggle */
|
||||
g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, data.ip_lb);
|
||||
g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, if_dlg_data->ip_lb);
|
||||
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);
|
||||
g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), device.if_info.addrs);
|
||||
g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), if_info->addrs);
|
||||
}
|
||||
g_string_append(if_tool_str, "\n");
|
||||
|
||||
/* packets */
|
||||
data.curr_lb = gtk_label_new("-");
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.curr_lb, 6, 7, row, row+1);
|
||||
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);
|
||||
|
||||
/* packets/s */
|
||||
data.last_lb = gtk_label_new("-");
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.last_lb, 7, 8, row, row+1);
|
||||
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);
|
||||
|
||||
/* details button */
|
||||
#ifdef _WIN32
|
||||
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.");
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), data.details_bt, 8, 9, row, row+1);
|
||||
if (capture_if_has_details(device.name)) {
|
||||
g_signal_connect(data.details_bt, "clicked", G_CALLBACK(capture_details_cb), device.name);
|
||||
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);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(data.details_bt, FALSE);
|
||||
gtk_widget_set_sensitive(if_dlg_data->details_bt, FALSE);
|
||||
}
|
||||
#endif
|
||||
gtk_list = g_array_remove_index(gtk_list, ifs);
|
||||
g_array_insert_val(gtk_list, ifs, data);
|
||||
|
||||
if_data_list = g_list_append(if_data_list, if_dlg_data);
|
||||
|
||||
row++;
|
||||
if (row <= 10) {
|
||||
/* Lets add up 10 rows of interfaces, otherwise the window may become too high */
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(data.choose_bt), &requisition, NULL);
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(if_dlg_data->choose_bt), &requisition, NULL);
|
||||
height += requisition.height;
|
||||
}
|
||||
}
|
||||
|
@ -919,9 +1017,9 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
|
||||
gtk_widget_set_tooltip_text(close_bt, "Close this window.");
|
||||
options_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_OPTIONS);
|
||||
g_signal_connect(options_bt, "clicked", G_CALLBACK(capture_prepare_cb), device.name);
|
||||
g_signal_connect(options_bt, "clicked", G_CALLBACK(capture_prepare_cb), if_dlg_data);
|
||||
capture_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
|
||||
g_signal_connect(capture_bt, "clicked", G_CALLBACK(capture_do_cb), device.name);
|
||||
g_signal_connect(capture_bt, "clicked", G_CALLBACK(capture_do_cb), if_dlg_data);
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(close_bt), &requisition, NULL);
|
||||
/* height + static offset + what the GTK MS Windows Engine needs in addition per interface */
|
||||
height += requisition.height + 40 + ifs;
|
||||
|
@ -952,14 +1050,16 @@ void refresh_if_window(void)
|
|||
capture_if_cb(NULL, NULL);
|
||||
}
|
||||
|
||||
void select_all_interfaces(gboolean enable _U_)
|
||||
void select_all_interfaces(gboolean enable)
|
||||
{
|
||||
if_dlg_data_t *temp;
|
||||
guint ifs;
|
||||
interface_t device;
|
||||
GList *curr;
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ GtkWidget *
|
|||
capture_get_if_icon(const if_info_t* if_info);
|
||||
|
||||
void
|
||||
update_selected_interface(gchar *name);
|
||||
update_selected_interface(gchar *name, gboolean activate);
|
||||
|
||||
gboolean
|
||||
interfaces_dialog_window_present(void);
|
||||
|
@ -65,9 +65,6 @@ select_all_interfaces(gboolean enable);
|
|||
void
|
||||
destroy_if_window(void);
|
||||
|
||||
gint
|
||||
if_list_comparator_alph (const void *first_arg, const void *second_arg);
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
#endif /* capture_if_dlg.h */
|
||||
|
|
489
gtk/main.c
489
gtk/main.c
|
@ -114,7 +114,6 @@
|
|||
#include "../capture_ifinfo.h"
|
||||
#include "../capture.h"
|
||||
#include "../capture_sync.h"
|
||||
extern gint if_list_comparator_alph (const void *first_arg, const void *second_arg);
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -513,16 +512,16 @@ selected_ptree_ref_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
static gboolean
|
||||
is_address_column (gint column)
|
||||
{
|
||||
if (((cfile.cinfo.col_fmt[column] == COL_DEF_SRC) ||
|
||||
(cfile.cinfo.col_fmt[column] == COL_RES_SRC) ||
|
||||
(cfile.cinfo.col_fmt[column] == COL_DEF_DST) ||
|
||||
(cfile.cinfo.col_fmt[column] == COL_RES_DST)) &&
|
||||
strlen(cfile.cinfo.col_expr.col_expr_val[column]))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
if (((cfile.cinfo.col_fmt[column] == COL_DEF_SRC) ||
|
||||
(cfile.cinfo.col_fmt[column] == COL_RES_SRC) ||
|
||||
(cfile.cinfo.col_fmt[column] == COL_DEF_DST) ||
|
||||
(cfile.cinfo.col_fmt[column] == COL_RES_DST)) &&
|
||||
strlen(cfile.cinfo.col_expr.col_expr_val[column]))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GList *
|
||||
|
@ -548,17 +547,17 @@ get_ip_address_list_from_packet_list_row(gpointer data)
|
|||
epan_dissect_run(&edt, &cfile.pseudo_header, cfile.pd, fdata, &cfile.cinfo);
|
||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||
|
||||
/* First check selected column */
|
||||
if (is_address_column (column)) {
|
||||
addr_list = g_list_append (addr_list, se_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[column]));
|
||||
/* First check selected column */
|
||||
if (is_address_column (column)) {
|
||||
addr_list = g_list_append (addr_list, se_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[column]));
|
||||
}
|
||||
|
||||
for (col = 0; col < cfile.cinfo.num_cols; col++) {
|
||||
/* Then check all columns except the selected */
|
||||
if ((col != column) && (is_address_column (col))) {
|
||||
addr_list = g_list_append (addr_list, se_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[col]));
|
||||
}
|
||||
}
|
||||
for (col = 0; col < cfile.cinfo.num_cols; col++) {
|
||||
/* Then check all columns except the selected */
|
||||
if ((col != column) && (is_address_column (col))) {
|
||||
addr_list = g_list_append (addr_list, se_strdup_printf("%s", cfile.cinfo.col_expr.col_expr_val[col]));
|
||||
}
|
||||
}
|
||||
|
||||
epan_dissect_cleanup(&edt);
|
||||
}
|
||||
|
@ -695,7 +694,7 @@ set_frame_reftime(gboolean set, frame_data *frame, gint row) {
|
|||
return;
|
||||
if (set) {
|
||||
frame->flags.ref_time=1;
|
||||
cfile.ref_time_count++;
|
||||
cfile.ref_time_count++;
|
||||
} else {
|
||||
frame->flags.ref_time=0;
|
||||
cfile.ref_time_count--;
|
||||
|
@ -717,8 +716,8 @@ static void reftime_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_
|
|||
case(ESD_BTN_YES):
|
||||
timestamp_set_type(TS_RELATIVE);
|
||||
recent.gui_time_format = TS_RELATIVE;
|
||||
cf_timestamp_auto_precision(&cfile);
|
||||
new_packet_list_queue_draw();
|
||||
cf_timestamp_auto_precision(&cfile);
|
||||
new_packet_list_queue_draw();
|
||||
break;
|
||||
case(ESD_BTN_NO):
|
||||
break;
|
||||
|
@ -728,7 +727,7 @@ static void reftime_answered_cb(gpointer dialog _U_, gint btn, gpointer data _U_
|
|||
|
||||
if (cfile.current_frame) {
|
||||
set_frame_reftime(!cfile.current_frame->flags.ref_time,
|
||||
cfile.current_frame, cfile.current_row);
|
||||
cfile.current_frame, cfile.current_row);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1400,9 +1399,6 @@ npf_warning_dialog_cb(gpointer dialog, gint btn _U_, gpointer data _U_)
|
|||
static void
|
||||
main_cf_cb_file_closing(capture_file *cf)
|
||||
{
|
||||
#ifdef HAVE_LIBPCAP
|
||||
int i;
|
||||
#endif
|
||||
|
||||
/* if we have more than 10000 packets, show a splash screen while closing */
|
||||
/* XXX - don't know a better way to decide whether to show or not,
|
||||
|
@ -1421,14 +1417,6 @@ main_cf_cb_file_closing(capture_file *cf)
|
|||
destroy_packet_wins();
|
||||
file_save_as_destroy();
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if (global_capture_opts.ifaces && global_capture_opts.ifaces->len > 0) {
|
||||
for (i = (int)global_capture_opts.ifaces->len-1; i >= 0; i--) {
|
||||
global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Restore the standard title bar message. */
|
||||
set_main_window_name("The Wireshark Network Analyzer");
|
||||
|
||||
|
@ -2186,8 +2174,8 @@ main(int argc, char *argv[])
|
|||
recent_read_static(&rf_path, &rf_open_errno);
|
||||
if (rf_path != NULL && rf_open_errno != 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
||||
"Could not open common recent file\n\"%s\": %s.",
|
||||
rf_path, g_strerror(rf_open_errno));
|
||||
"Could not open common recent file\n\"%s\": %s.",
|
||||
rf_path, g_strerror(rf_open_errno));
|
||||
}
|
||||
|
||||
/* "pre-scan" the command line parameters, if we have "console only"
|
||||
|
@ -2206,13 +2194,13 @@ main(int argc, char *argv[])
|
|||
while ((opt = getopt(argc, argv, optstring)) != -1) {
|
||||
switch (opt) {
|
||||
case 'C': /* Configuration Profile */
|
||||
if (profile_exists (optarg, FALSE)) {
|
||||
set_profile_name (optarg);
|
||||
} else {
|
||||
cmdarg_err("Configuration Profile \"%s\" does not exist", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
if (profile_exists (optarg, FALSE)) {
|
||||
set_profile_name (optarg);
|
||||
} else {
|
||||
cmdarg_err("Configuration Profile \"%s\" does not exist", optarg);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'D': /* Print a list of capture devices and exit */
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
|
@ -2281,8 +2269,8 @@ main(int argc, char *argv[])
|
|||
recent_read_profile_static(&rf_path, &rf_open_errno);
|
||||
if (rf_path != NULL && rf_open_errno != 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
||||
"Could not open recent file\n\"%s\": %s.",
|
||||
rf_path, g_strerror(rf_open_errno));
|
||||
"Could not open recent file\n\"%s\": %s.",
|
||||
rf_path, g_strerror(rf_open_errno));
|
||||
}
|
||||
|
||||
if (recent.gui_fileopen_remembered_dir &&
|
||||
|
@ -2455,11 +2443,6 @@ main(int argc, char *argv[])
|
|||
/* Fill in capture options with values from the preferences */
|
||||
prefs_to_capture_opts();
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if (global_capture_opts.all_ifaces->len == 0) {
|
||||
scan_local_interfaces(&global_capture_opts);
|
||||
}
|
||||
#endif
|
||||
/* Now get our args */
|
||||
while ((opt = getopt(argc, argv, optstring)) != -1) {
|
||||
switch (opt) {
|
||||
|
@ -2470,6 +2453,7 @@ main(int argc, char *argv[])
|
|||
case 'f': /* capture filter */
|
||||
case 'k': /* Start capture immediately */
|
||||
case 'H': /* Hide capture info dialog box */
|
||||
case 'i': /* Use interface xxx */
|
||||
case 'p': /* Don't capture in promiscuous mode */
|
||||
#ifdef HAVE_PCAP_CREATE
|
||||
case 'I': /* Capture in monitor mode, if available */
|
||||
|
@ -2499,25 +2483,13 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
case 'i': /* Use interface xxx */
|
||||
status = capture_opts_select_iface(&global_capture_opts, optarg);
|
||||
if (status != 0) {
|
||||
exit(status);
|
||||
}
|
||||
#else
|
||||
capture_option_specified = TRUE;
|
||||
arg_error = TRUE;
|
||||
#endif
|
||||
break;
|
||||
|
||||
/*** all non capture option specific ***/
|
||||
case 'C':
|
||||
/* Configuration profile settings were already processed just ignore them this time*/
|
||||
break;
|
||||
break;
|
||||
case 'd':
|
||||
dfilter = optarg;
|
||||
break;
|
||||
dfilter = optarg;
|
||||
break;
|
||||
case 'j': /* Search backwards for a matching packet from filter in option J */
|
||||
jump_backwards = TRUE;
|
||||
break;
|
||||
|
@ -2556,7 +2528,7 @@ main(int argc, char *argv[])
|
|||
badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
|
||||
if (badopt != '\0') {
|
||||
cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
|
||||
badopt);
|
||||
badopt);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
|
@ -2581,7 +2553,7 @@ main(int argc, char *argv[])
|
|||
case PREFS_SET_NO_SUCH_PREF:
|
||||
case PREFS_SET_OBSOLETE:
|
||||
cmdarg_err("-o flag \"%s\" specifies unknown preference/recent value",
|
||||
optarg);
|
||||
optarg);
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
|
@ -2590,7 +2562,7 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
case PREFS_SET_OBSOLETE:
|
||||
cmdarg_err("-o flag \"%s\" specifies obsolete preference",
|
||||
optarg);
|
||||
optarg);
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
|
@ -2601,9 +2573,9 @@ main(int argc, char *argv[])
|
|||
/* Path settings were already processed just ignore them this time*/
|
||||
break;
|
||||
case 'r': /* Read capture file xxx */
|
||||
/* We may set "last_open_dir" to "cf_name", and if we change
|
||||
"last_open_dir" later, we free the old value, so we have to
|
||||
set "cf_name" to something that's been allocated. */
|
||||
/* We may set "last_open_dir" to "cf_name", and if we change
|
||||
"last_open_dir" later, we free the old value, so we have to
|
||||
set "cf_name" to something that's been allocated. */
|
||||
cf_name = g_strdup(optarg);
|
||||
break;
|
||||
case 'R': /* Read file filter */
|
||||
|
@ -2654,11 +2626,11 @@ main(int argc, char *argv[])
|
|||
part of a tap filter. Instead, we just add the argument
|
||||
to a list of stat arguments. */
|
||||
if (!process_stat_cmd_arg(optarg)) {
|
||||
cmdarg_err("Invalid -z argument.");
|
||||
cmdarg_err_cont(" -z argument must be one of :");
|
||||
list_stat_cmd_args();
|
||||
exit(1);
|
||||
}
|
||||
cmdarg_err("Invalid -z argument.");
|
||||
cmdarg_err_cont(" -z argument must be one of :");
|
||||
list_stat_cmd_args();
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case '?': /* Bad flag - print usage message */
|
||||
|
@ -2745,18 +2717,23 @@ main(int argc, char *argv[])
|
|||
sense? */
|
||||
if (global_capture_opts.multi_files_on) {
|
||||
/* Ring buffer works only under certain conditions:
|
||||
a) ring buffer does not work with temporary files;
|
||||
b) real_time_mode and multi_files_on are mutually exclusive -
|
||||
real_time_mode takes precedence;
|
||||
c) it makes no sense to enable the ring buffer if the maximum
|
||||
file size is set to "infinite". */
|
||||
a) ring buffer does not work with temporary files;
|
||||
b) real_time_mode and multi_files_on are mutually exclusive -
|
||||
real_time_mode takes precedence;
|
||||
c) it makes no sense to enable the ring buffer if the maximum
|
||||
file size is set to "infinite". */
|
||||
if (global_capture_opts.save_file == NULL) {
|
||||
cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
|
||||
global_capture_opts.multi_files_on = FALSE;
|
||||
cmdarg_err("Ring buffer requested, but capture isn't being saved to a permanent file.");
|
||||
global_capture_opts.multi_files_on = FALSE;
|
||||
}
|
||||
/* if (global_capture_opts.real_time_mode) {
|
||||
cmdarg_err("Ring buffer requested, but an \"Update list of packets in real time\" capture is being done.");
|
||||
global_capture_opts.multi_files_on = FALSE;
|
||||
}*/
|
||||
if (!global_capture_opts.has_autostop_filesize && !global_capture_opts.has_file_duration) {
|
||||
cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
|
||||
/* XXX - this must be redesigned as the conditions changed */
|
||||
cmdarg_err("Ring buffer requested, but no maximum capture file size or duration were specified.");
|
||||
/* XXX - this must be redesigned as the conditions changed */
|
||||
/* global_capture_opts.multi_files_on = FALSE;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2773,32 +2750,23 @@ main(int argc, char *argv[])
|
|||
/* Get the list of link-layer types for the capture devices. */
|
||||
if_capabilities_t *caps;
|
||||
guint i;
|
||||
interface_t device;
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
interface_options interface_opts;
|
||||
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
if (device.selected) {
|
||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||
caps = capture_get_if_capabilities(device.name, device.monitor_mode_supported, &err_str);
|
||||
#else
|
||||
caps = capture_get_if_capabilities(device.name, FALSE, &err_str);
|
||||
#endif
|
||||
if (caps == NULL) {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
exit(2);
|
||||
}
|
||||
if (caps->data_link_types == NULL) {
|
||||
cmdarg_err("The capture device \"%s\" has no data link types.", device.name);
|
||||
exit(2);
|
||||
}
|
||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||
capture_opts_print_if_capabilities(caps, device.name, device.monitor_mode_supported);
|
||||
#else
|
||||
capture_opts_print_if_capabilities(caps, device.name, FALSE);
|
||||
#endif
|
||||
free_if_capabilities(caps);
|
||||
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
|
||||
|
||||
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
|
||||
caps = capture_get_if_capabilities(interface_opts.name, interface_opts.monitor_mode, &err_str);
|
||||
if (caps == NULL) {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
exit(2);
|
||||
}
|
||||
if (caps->data_link_types == NULL) {
|
||||
cmdarg_err("The capture device \"%s\" has no data link types.", interface_opts.name);
|
||||
exit(2);
|
||||
}
|
||||
capture_opts_print_if_capabilities(caps, interface_opts.name, interface_opts.monitor_mode);
|
||||
free_if_capabilities(caps);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
@ -2819,20 +2787,53 @@ main(int argc, char *argv[])
|
|||
exit(2);
|
||||
}
|
||||
#endif
|
||||
if ((global_capture_opts.num_selected == 0) &&
|
||||
if ((global_capture_opts.ifaces->len == 0) &&
|
||||
(prefs.capture_device != NULL)) {
|
||||
guint i;
|
||||
interface_t device;
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
if (!device.hidden && strcmp(device.display_name, prefs.capture_device) == 0) {
|
||||
device.selected = TRUE;
|
||||
global_capture_opts.num_selected++;
|
||||
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);
|
||||
break;
|
||||
GList *curr, *combo_list;
|
||||
gboolean found = FALSE;
|
||||
|
||||
if_list = capture_interface_list(&err, NULL);
|
||||
if (g_list_length(if_list) > 0) {
|
||||
combo_list = build_capture_combo_list(if_list, FALSE);
|
||||
free_interface_list(if_list);
|
||||
for (curr = combo_list; curr; curr = g_list_next(curr)) {
|
||||
if (strcmp(curr->data, prefs.capture_device) == 0) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
interface_options interface_opts;
|
||||
|
||||
interface_opts.name = g_strdup(get_if_name(prefs.capture_device));
|
||||
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
|
||||
interface_opts.monitor_mode = prefs_capture_device_monitor_mode(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.snaplen = global_capture_opts.default_options.snaplen;
|
||||
interface_opts.has_snaplen = global_capture_opts.default_options.has_snaplen;
|
||||
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
|
||||
#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_insert_val(global_capture_opts.ifaces, 0, interface_opts);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2874,8 +2875,8 @@ main(int argc, char *argv[])
|
|||
recent_read_dynamic(&rf_path, &rf_open_errno);
|
||||
if (rf_path != NULL && rf_open_errno != 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK,
|
||||
"Could not open recent file\n\"%s\": %s.",
|
||||
rf_path, g_strerror(rf_open_errno));
|
||||
"Could not open recent file\n\"%s\": %s.",
|
||||
rf_path, g_strerror(rf_open_errno));
|
||||
}
|
||||
|
||||
color_filters_enable(recent.packet_list_colorize);
|
||||
|
@ -2997,15 +2998,15 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
/* If the filename is not the absolute path, prepend the current dir. This happens
|
||||
when wireshark is invoked from a cmd shell (e.g.,'wireshark -r file.pcap'). */
|
||||
if (!g_path_is_absolute(cf_name)) {
|
||||
char *old_cf_name = cf_name;
|
||||
char *pwd = g_get_current_dir();
|
||||
cf_name = g_strdup_printf("%s%s%s", pwd, G_DIR_SEPARATOR_S, cf_name);
|
||||
g_free(old_cf_name);
|
||||
g_free(pwd);
|
||||
}
|
||||
/* If the filename is not the absolute path, prepend the current dir. This happens
|
||||
when wireshark is invoked from a cmd shell (e.g.,'wireshark -r file.pcap'). */
|
||||
if (!g_path_is_absolute(cf_name)) {
|
||||
char *old_cf_name = cf_name;
|
||||
char *pwd = g_get_current_dir();
|
||||
cf_name = g_strdup_printf("%s%s%s", pwd, G_DIR_SEPARATOR_S, cf_name);
|
||||
g_free(old_cf_name);
|
||||
g_free(pwd);
|
||||
}
|
||||
|
||||
/* Save the name of the containing directory specified in the
|
||||
path name, if any; we can write over cf_name, which is a
|
||||
|
@ -3020,7 +3021,7 @@ main(int argc, char *argv[])
|
|||
dfilter_free(rfcode);
|
||||
cfile.rfcode = NULL;
|
||||
show_main_window(FALSE);
|
||||
/* Don't call check_and_warn_user_startup(): we did it above */
|
||||
/* Don't call check_and_warn_user_startup(): we did it above */
|
||||
set_menus_for_capture_in_progress(FALSE);
|
||||
set_capture_if_dialog_for_capture_in_progress(FALSE);
|
||||
}
|
||||
|
@ -3040,10 +3041,10 @@ main(int argc, char *argv[])
|
|||
check_and_warn_user_startup(cf_name);
|
||||
if (capture_start(&global_capture_opts)) {
|
||||
/* The capture started. Open stat windows; we do so after creating
|
||||
the main window, to avoid GTK warnings, and after successfully
|
||||
opening the capture file, so we know we have something to compute
|
||||
stats on, and after registering all dissectors, so that MATE will
|
||||
have registered its field array and we can have a tap filter with
|
||||
the main window, to avoid GTK warnings, and after successfully
|
||||
opening the capture file, so we know we have something to compute
|
||||
stats on, and after registering all dissectors, so that MATE will
|
||||
have registered its field array and we can have a tap filter with
|
||||
one of MATE's late-registered fields as part of the filter. */
|
||||
start_requested_stats();
|
||||
}
|
||||
|
@ -3549,6 +3550,7 @@ main_widgets_show_or_hide(void)
|
|||
if (!have_capture_file) {
|
||||
if(welcome_pane) {
|
||||
gtk_widget_show(welcome_pane);
|
||||
select_ifaces();
|
||||
}
|
||||
} else {
|
||||
gtk_widget_hide(welcome_pane);
|
||||
|
@ -3856,218 +3858,3 @@ void redissect_packets(void)
|
|||
cf_redissect_packets(&cfile);
|
||||
status_expert_update();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
void
|
||||
scan_local_interfaces(capture_options* capture_opts)
|
||||
{
|
||||
GList *if_entry, *lt_entry, *if_list;
|
||||
if_info_t *if_info, *temp;
|
||||
char *if_string="";
|
||||
gchar *descr, *str, *err_str = NULL;
|
||||
if_capabilities_t *caps=NULL;
|
||||
gint linktype_count;
|
||||
cap_settings_t cap_settings;
|
||||
GSList *curr_addr;
|
||||
int ips = 0, err, i;
|
||||
guint count = 0;
|
||||
if_addr_t *addr, *temp_addr;
|
||||
link_row *link = NULL;
|
||||
data_link_info_t *data_link_info;
|
||||
interface_t device;
|
||||
GString *ip_str;
|
||||
|
||||
if (capture_opts->all_ifaces->len > 0) {
|
||||
for (i = (int)capture_opts->all_ifaces->len-1; i >= 0; i--) {
|
||||
device = g_array_index(capture_opts->all_ifaces, interface_t, i);
|
||||
if (device.type == IF_LOCAL) {
|
||||
capture_opts->all_ifaces = g_array_remove_index(capture_opts->all_ifaces, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Scan through the list and build a list of strings to display. */
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
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;
|
||||
}
|
||||
count = 0;
|
||||
for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
|
||||
if_info = if_entry->data;
|
||||
ip_str = g_string_new("");
|
||||
str = "";
|
||||
ips = 0;
|
||||
device.name = g_strdup(if_info->name);
|
||||
device.hidden = FALSE;
|
||||
device.locked = FALSE;
|
||||
temp = g_malloc0(sizeof(if_info_t));
|
||||
temp->name = g_strdup(if_info->name);
|
||||
temp->description = g_strdup(if_info->description);
|
||||
temp->loopback = if_info->loopback;
|
||||
/* Is this interface hidden and, if so, should we include it anyway? */
|
||||
|
||||
/* Do we have a user-supplied description? */
|
||||
descr = capture_dev_user_descr_find(if_info->name);
|
||||
if (descr != NULL) {
|
||||
/* Yes, we have a user-supplied description; use it. */
|
||||
if_string = g_strdup_printf("%s: %s", descr, if_info->name);
|
||||
g_free(descr);
|
||||
} else {
|
||||
/* No, we don't have a user-supplied description; did we get
|
||||
one from the OS or libpcap? */
|
||||
if (if_info->description != NULL) {
|
||||
/* Yes - use it. */
|
||||
if_string = g_strdup_printf("%s: %s", if_info->description, if_info->name);
|
||||
} else {
|
||||
/* No. */
|
||||
if_string = g_strdup(if_info->name);
|
||||
}
|
||||
}
|
||||
if (if_info->loopback) {
|
||||
device.display_name = g_strdup_printf("%s (loopback)", if_string);
|
||||
} else {
|
||||
device.display_name = g_strdup(if_string);
|
||||
}
|
||||
device.selected = FALSE;
|
||||
if (prefs_is_capture_device_hidden(if_info->name)) {
|
||||
device.hidden = TRUE;
|
||||
}
|
||||
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
|
||||
device.buffer = capture_opts->default_options.buffer_size;
|
||||
#endif
|
||||
device.pmode = capture_opts->default_options.promisc_mode;
|
||||
device.has_snaplen = capture_opts->default_options.has_snaplen;
|
||||
device.snaplen = capture_opts->default_options.snaplen;
|
||||
device.cfilter = g_strdup(capture_opts->default_options.cfilter);
|
||||
cap_settings = capture_get_cap_settings(if_info->name);
|
||||
caps = capture_get_if_capabilities(if_info->name, cap_settings.monitor_mode, NULL);
|
||||
for (; (curr_addr = g_slist_nth(if_info->addrs, ips)) != NULL; ips++) {
|
||||
temp_addr = g_malloc0(sizeof(if_addr_t));
|
||||
if (ips != 0) {
|
||||
g_string_append(ip_str, "\n");
|
||||
}
|
||||
addr = (if_addr_t *)curr_addr->data;
|
||||
if (addr) {
|
||||
temp_addr->ifat_type = addr->ifat_type;
|
||||
switch (addr->ifat_type) {
|
||||
case IF_AT_IPv4:
|
||||
temp_addr->addr.ip4_addr = addr->addr.ip4_addr;
|
||||
g_string_append(ip_str, ip_to_str((guint8 *)&addr->addr.ip4_addr));
|
||||
break;
|
||||
case IF_AT_IPv6:
|
||||
memcpy(temp_addr->addr.ip6_addr, addr->addr.ip6_addr, sizeof(addr->addr));
|
||||
g_string_append(ip_str, ip6_to_str((struct e_in6_addr *)&addr->addr.ip6_addr));
|
||||
break;
|
||||
default:
|
||||
/* In case we add non-IP addresses */
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
g_free(temp_addr);
|
||||
temp_addr = NULL;
|
||||
}
|
||||
if (temp_addr) {
|
||||
temp->addrs = g_slist_append(temp->addrs, temp_addr);
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
device.remote_opts.src_type = CAPTURE_IFLOCAL;
|
||||
#endif
|
||||
linktype_count = 0;
|
||||
device.links = NULL;
|
||||
if (caps != NULL) {
|
||||
#ifdef HAVE_PCAP_CREATE
|
||||
device.monitor_mode_enabled = cap_settings.monitor_mode;
|
||||
device.monitor_mode_supported = caps->can_set_rfmon;
|
||||
#endif
|
||||
for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
|
||||
data_link_info = lt_entry->data;
|
||||
if (data_link_info->description != NULL) {
|
||||
str = g_strdup_printf("%s", data_link_info->description);
|
||||
} else {
|
||||
str = g_strdup_printf("%s (not supported)", data_link_info->name);
|
||||
}
|
||||
if (linktype_count == 0) {
|
||||
device.active_dlt = data_link_info->dlt;
|
||||
}
|
||||
link = (link_row *)g_malloc(sizeof(link_row));
|
||||
link->dlt = data_link_info->dlt;
|
||||
link->name = g_strdup(str);
|
||||
device.links = g_list_append(device.links, link);
|
||||
linktype_count++;
|
||||
}
|
||||
} else {
|
||||
cap_settings.monitor_mode = FALSE;
|
||||
#ifdef HAVE_PCAP_CREATE
|
||||
device.monitor_mode_enabled = FALSE;
|
||||
device.monitor_mode_supported = FALSE;
|
||||
#endif
|
||||
device.active_dlt = -1;
|
||||
}
|
||||
device.addresses = g_strdup(ip_str->str);
|
||||
device.no_addresses = ips;
|
||||
device.type = IF_LOCAL;
|
||||
device.if_info = *temp;
|
||||
device.last_packets = 0;
|
||||
|
||||
if (capture_opts->all_ifaces->len <= count) {
|
||||
g_array_append_val(capture_opts->all_ifaces, device);
|
||||
count = capture_opts->all_ifaces->len;
|
||||
} else {
|
||||
g_array_insert_val(capture_opts->all_ifaces, count, device);
|
||||
}
|
||||
if (caps != NULL) {
|
||||
free_if_capabilities(caps);
|
||||
}
|
||||
|
||||
g_string_free(ip_str, TRUE);
|
||||
count++;
|
||||
}
|
||||
free_interface_list(if_list);
|
||||
}
|
||||
|
||||
void hide_interface(gchar* new_hide)
|
||||
{
|
||||
gchar *tok;
|
||||
guint i;
|
||||
interface_t device;
|
||||
gboolean found = FALSE;
|
||||
GList *hidden_devices = NULL, *entry;
|
||||
if (new_hide != NULL) {
|
||||
for (tok = strtok (new_hide, ","); tok; tok = strtok(NULL, ",")) {
|
||||
hidden_devices = g_list_append(hidden_devices, tok);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
found = FALSE;
|
||||
for (entry = hidden_devices; entry != NULL; entry = g_list_next(entry)) {
|
||||
if (strcmp(entry->data, device.name)==0) {
|
||||
device.hidden = TRUE;
|
||||
if (device.selected) {
|
||||
device.selected = FALSE;
|
||||
global_capture_opts.num_selected--;
|
||||
}
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
device.hidden = 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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#define __MAIN_H__
|
||||
|
||||
#include "globals.h"
|
||||
#include "capture_opts.h"
|
||||
|
||||
/** @defgroup main_window_group Main window
|
||||
* The main window has the following submodules:
|
||||
|
@ -366,6 +365,4 @@ extern GList *get_ip_address_list_from_packet_list_row(gpointer data);
|
|||
|
||||
extern GtkWidget *pkt_scrollw;
|
||||
|
||||
void hide_interface(gchar* new_hide);
|
||||
|
||||
#endif /* __MAIN_H__ */
|
||||
|
|
|
@ -81,6 +81,8 @@
|
|||
#endif
|
||||
|
||||
/* XXX */
|
||||
extern gint if_list_comparator_alph (const void *first_arg, const void *second_arg);
|
||||
|
||||
static GtkWidget *welcome_hb = NULL;
|
||||
static GtkWidget *header_lb = NULL;
|
||||
/* Foreground colors are set using Pango markup */
|
||||
|
@ -101,8 +103,10 @@ static GdkColor topic_item_entered_bg = { 0, 0xd3d3, 0xd8d8, 0xdada };
|
|||
#endif
|
||||
static GtkWidget *welcome_file_panel_vb = NULL;
|
||||
#ifdef HAVE_LIBPCAP
|
||||
static GtkWidget *welcome_if_panel_vb = NULL;
|
||||
static GtkWidget *if_view = NULL;
|
||||
static GtkWidget *swindow;
|
||||
static GArray *interfaces = NULL;
|
||||
#endif
|
||||
|
||||
static GSList *status_messages = NULL;
|
||||
|
@ -207,9 +211,9 @@ static gboolean
|
|||
welcome_item_enter_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_entered_bg);
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_entered_bg);
|
||||
#else
|
||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_entered_bg);
|
||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_entered_bg);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -220,7 +224,7 @@ static gboolean
|
|||
welcome_item_leave_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
||||
#else
|
||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
|
||||
#endif
|
||||
|
@ -247,12 +251,12 @@ welcome_button(const gchar *stock_item,
|
|||
eb = gtk_event_box_new();
|
||||
gtk_container_add(GTK_CONTAINER(eb), item_hb);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_item_idle_bg);
|
||||
#else
|
||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_item_idle_bg);
|
||||
#endif
|
||||
if(tooltip != NULL) {
|
||||
gtk_widget_set_tooltip_text(eb, tooltip);
|
||||
gtk_widget_set_tooltip_text(eb, tooltip);
|
||||
}
|
||||
|
||||
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(welcome_item_enter_cb), NULL);
|
||||
|
@ -353,7 +357,7 @@ welcome_header_new(void)
|
|||
gtk_box_pack_start(GTK_BOX(item_vb), item_hb, FALSE, FALSE, 10);
|
||||
|
||||
/*icon = xpm_to_widget_from_parent(top_level, wssplash_xpm);*/
|
||||
icon = xpm_to_widget(wssplash_xpm);
|
||||
icon = xpm_to_widget(wssplash_xpm);
|
||||
gtk_box_pack_start(GTK_BOX(item_hb), icon, FALSE, FALSE, 10);
|
||||
|
||||
header_lb = gtk_label_new(NULL);
|
||||
|
@ -419,7 +423,7 @@ welcome_topic_header_new(const char *header)
|
|||
eb = gtk_event_box_new();
|
||||
gtk_container_add(GTK_CONTAINER(eb), w);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_header_bg);
|
||||
gtk_widget_override_background_color(eb, GTK_STATE_NORMAL, &rgba_topic_header_bg);
|
||||
#else
|
||||
gtk_widget_modify_bg(eb, GTK_STATE_NORMAL, &topic_header_bg);
|
||||
#endif
|
||||
|
@ -450,7 +454,7 @@ welcome_topic_new(const char *header, GtkWidget **to_fill)
|
|||
topic_eb = gtk_event_box_new();
|
||||
gtk_container_add(GTK_CONTAINER(topic_eb), topic_vb);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_background_color(topic_eb, GTK_STATE_NORMAL, &rgba_topic_content_bg);
|
||||
gtk_widget_override_background_color(topic_eb, GTK_STATE_NORMAL, &rgba_topic_content_bg);
|
||||
#else
|
||||
gtk_widget_modify_bg(topic_eb, GTK_STATE_NORMAL, &topic_content_bg);
|
||||
#endif
|
||||
|
@ -575,16 +579,16 @@ static void welcome_filename_destroy_cb(GtkWidget *w _U_, gpointer data) {
|
|||
g_mutex_lock(recent_mtx);
|
||||
#endif
|
||||
if (ri_stat->timer) {
|
||||
g_source_remove(ri_stat->timer);
|
||||
ri_stat->timer = 0;
|
||||
g_source_remove(ri_stat->timer);
|
||||
ri_stat->timer = 0;
|
||||
}
|
||||
|
||||
g_object_unref(ri_stat->menu_item);
|
||||
|
||||
if (ri_stat->stat_done) {
|
||||
g_free(ri_stat->filename);
|
||||
g_string_free(ri_stat->str, TRUE);
|
||||
g_free(ri_stat);
|
||||
g_free(ri_stat->filename);
|
||||
g_string_free(ri_stat->str, TRUE);
|
||||
g_free(ri_stat);
|
||||
} else {
|
||||
ri_stat->label = NULL;
|
||||
}
|
||||
|
@ -714,22 +718,22 @@ static gboolean select_current_ifaces(GtkTreeModel *model,
|
|||
{
|
||||
guint i;
|
||||
gchar *if_name;
|
||||
interface_t device;
|
||||
gboolean found = FALSE;
|
||||
|
||||
GtkTreeSelection *selection = (GtkTreeSelection *)userdata;
|
||||
device.name = NULL;
|
||||
GtkTreeSelection *selection = (GtkTreeSelection *)userdata;
|
||||
gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
if (strcmp(device.name, if_name) == 0) {
|
||||
if (device.selected && !gtk_tree_selection_path_is_selected(selection, path)) {
|
||||
gtk_tree_selection_select_iter(selection, iter);
|
||||
} else {
|
||||
gtk_tree_selection_unselect_iter(selection, iter);
|
||||
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
|
||||
if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, if_name) == 0) {
|
||||
if (!gtk_tree_selection_path_is_selected(selection, path)) {
|
||||
gtk_tree_selection_select_iter(selection, iter);
|
||||
}
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
gtk_tree_selection_unselect_iter(selection, iter);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -741,42 +745,100 @@ gboolean on_selection_changed(GtkTreeSelection *selection _U_,
|
|||
{
|
||||
GtkTreeIter iter;
|
||||
gchar *if_name;
|
||||
guint i;
|
||||
interface_t device;
|
||||
|
||||
interface_options interface_opts;
|
||||
guint i, j;
|
||||
cap_settings_t cap_settings;
|
||||
gboolean found = FALSE;
|
||||
displayed_interface d_interface;
|
||||
|
||||
d_interface.name = NULL;
|
||||
d_interface.descr = NULL;
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
gtk_tree_model_get (model, &iter, IFACE_NAME, &if_name, -1);
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
if (strcmp(device.name, if_name) == 0) {
|
||||
if (!device.locked) {
|
||||
if (global_capture_opts.ifaces->len > 0) {
|
||||
for (i = 0; i < global_capture_opts.ifaces->len; i++) {
|
||||
if (strcmp(g_array_index(global_capture_opts.ifaces, interface_options, i).name, if_name) == 0) {
|
||||
found = TRUE;
|
||||
if (path_currently_selected) {
|
||||
if (device.selected) {
|
||||
device.selected = FALSE;
|
||||
device.locked = TRUE;
|
||||
global_capture_opts.num_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(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && interfaces_dialog_window_present()) {
|
||||
update_selected_interface(g_strdup(interface_opts.name), FALSE);
|
||||
}
|
||||
} else {
|
||||
if (!device.selected) {
|
||||
device.selected = TRUE;
|
||||
device.locked = TRUE;
|
||||
global_capture_opts.num_selected++;
|
||||
if (gtk_widget_is_focus(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && 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;
|
||||
}
|
||||
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 (dlg_window_present()) {
|
||||
enable_selected_interface(g_strdup(if_name), device.selected);
|
||||
}
|
||||
if (interfaces_dialog_window_present()) {
|
||||
update_selected_interface(g_strdup(if_name));
|
||||
}
|
||||
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);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found && !path_currently_selected) {
|
||||
for (j = 0; j < interfaces->len; j++) {
|
||||
d_interface = g_array_index(interfaces, displayed_interface, j);
|
||||
if (strcmp(d_interface.name, if_name) == 0) {
|
||||
interface_opts.name = g_strdup(d_interface.name);
|
||||
interface_opts.descr = g_strdup(d_interface.descr);
|
||||
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
|
||||
if (d_interface.remote_opts.src_type == CAPTURE_IFREMOTE) {
|
||||
interface_opts.src_type = d_interface.remote_opts.src_type;
|
||||
interface_opts.remote_host = g_strdup(d_interface.remote_opts.remote_host_opts.remote_host);
|
||||
interface_opts.remote_port = g_strdup(d_interface.remote_opts.remote_host_opts.remote_port);
|
||||
interface_opts.auth_type = d_interface.remote_opts.remote_host_opts.auth_type;
|
||||
interface_opts.auth_username = g_strdup(d_interface.remote_opts.remote_host_opts.auth_username);
|
||||
interface_opts.auth_password = g_strdup(d_interface.remote_opts.remote_host_opts.auth_password);
|
||||
interface_opts.datatx_udp = d_interface.remote_opts.remote_host_opts.datatx_udp;
|
||||
interface_opts.nocap_rpcap = d_interface.remote_opts.remote_host_opts.nocap_rpcap;
|
||||
interface_opts.nocap_local = d_interface.remote_opts.remote_host_opts.nocap_local;
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
interface_opts.sampling_method = d_interface.remote_opts.sampling_method;
|
||||
interface_opts.sampling_param = d_interface.remote_opts.sampling_param;
|
||||
#endif
|
||||
} else {
|
||||
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;
|
||||
#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
|
||||
}
|
||||
#endif
|
||||
|
||||
g_array_append_val(global_capture_opts.ifaces, interface_opts);
|
||||
if (gtk_widget_is_focus(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && interfaces_dialog_window_present()) {
|
||||
update_selected_interface(g_strdup(interface_opts.name), TRUE);
|
||||
}
|
||||
if (gtk_widget_is_focus(g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES)) && dlg_window_present()) {
|
||||
enable_selected_interface(interface_opts.name, TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -823,8 +885,10 @@ void change_selection_for_all(gboolean enable)
|
|||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
change_interface_selection(g_array_index(global_capture_opts.all_ifaces, interface_t, i).name, enable);
|
||||
if (interfaces) {
|
||||
for (i = 0; i < interfaces->len; i++) {
|
||||
change_interface_selection(g_array_index(interfaces, displayed_interface, i).name, enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -837,7 +901,7 @@ select_ifaces(void)
|
|||
GtkTreeModel *model;
|
||||
GtkTreeSelection *entry;
|
||||
|
||||
if (global_capture_opts.num_selected > 0 && swindow) {
|
||||
if (global_capture_opts.ifaces->len > 0 && swindow) {
|
||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
|
||||
entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||
|
@ -849,24 +913,40 @@ select_ifaces(void)
|
|||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
void
|
||||
add_interface_to_list(guint index)
|
||||
add_interface_to_list(gchar *name, gchar *descr, remote_options *remote_opts)
|
||||
{
|
||||
GtkWidget *view, *icon;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gint size;
|
||||
gchar *lines;
|
||||
interface_t device;
|
||||
displayed_interface d_interface;
|
||||
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, index);
|
||||
d_interface.name = g_strdup(name);
|
||||
d_interface.descr = g_strdup(descr);
|
||||
d_interface.remote_opts.src_type = remote_opts->src_type;
|
||||
d_interface.remote_opts.remote_host_opts.remote_host = g_strdup(remote_opts->remote_host_opts.remote_host);
|
||||
d_interface.remote_opts.remote_host_opts.remote_port = g_strdup(remote_opts->remote_host_opts.remote_port);
|
||||
d_interface.remote_opts.remote_host_opts.auth_type = remote_opts->remote_host_opts.auth_type;
|
||||
d_interface.remote_opts.remote_host_opts.auth_username = g_strdup(remote_opts->remote_host_opts.auth_username);
|
||||
d_interface.remote_opts.remote_host_opts.auth_password = g_strdup(remote_opts->remote_host_opts.auth_password);
|
||||
d_interface.remote_opts.remote_host_opts.datatx_udp = remote_opts->remote_host_opts.datatx_udp;
|
||||
d_interface.remote_opts.remote_host_opts.nocap_rpcap = remote_opts->remote_host_opts.nocap_rpcap;
|
||||
d_interface.remote_opts.remote_host_opts.nocap_local = remote_opts->remote_host_opts.nocap_local;
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
d_interface.remote_opts.sampling_method = remote_opts->sampling_method;
|
||||
d_interface.remote_opts.sampling_param = remote_opts->sampling_param;
|
||||
#endif
|
||||
icon = pixbuf_to_widget(remote_sat_pb_data);
|
||||
d_interface.icon = icon;
|
||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
|
||||
size = gtk_tree_model_iter_n_children(model, NULL);
|
||||
lines = g_strdup_printf("%d", size-1);
|
||||
g_array_append_val(interfaces, d_interface);
|
||||
if (gtk_tree_model_get_iter_from_string(model, &iter, lines)) {
|
||||
gtk_list_store_append (GTK_LIST_STORE(model), &iter);
|
||||
gtk_list_store_set(GTK_LIST_STORE(model), &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, device.display_name, IFACE_NAME, device.name, -1);
|
||||
gtk_list_store_set(GTK_LIST_STORE(model), &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, descr, IFACE_NAME, name, -1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -876,40 +956,91 @@ void
|
|||
welcome_if_tree_load(void)
|
||||
{
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if_info_t *if_info;
|
||||
GList *if_list;
|
||||
int err;
|
||||
guint i;
|
||||
gchar *err_str = NULL;
|
||||
GList *curr;
|
||||
gchar *user_descr;
|
||||
GtkListStore *store = NULL;
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *view;
|
||||
GtkWidget *icon, *view;
|
||||
GtkTreeSelection *entry;
|
||||
interface_t device;
|
||||
gboolean changed = FALSE;
|
||||
displayed_interface d_interface;
|
||||
|
||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||
entry = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||
gtk_tree_selection_unselect_all(entry);
|
||||
store = gtk_list_store_new(NUMCOLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
|
||||
|
||||
gtk_list_store_clear(store);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(if_view), GTK_TREE_MODEL (store));
|
||||
/* LOAD THE INTERFACES */
|
||||
if (global_capture_opts.all_ifaces->len == 0) {
|
||||
scan_local_interfaces(&global_capture_opts);
|
||||
if (interfaces && interfaces->len > 0) {
|
||||
for (i = 0; i < interfaces->len; i++) {
|
||||
d_interface = g_array_index(interfaces, displayed_interface, i);
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, ICON, d_interface.icon, IFACE_DESCR, d_interface.descr, IFACE_NAME, d_interface.name, -1);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
if (!device.hidden) {
|
||||
interfaces = g_array_new(TRUE, TRUE, sizeof(displayed_interface));
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
if_list = g_list_sort (if_list, if_list_comparator_alph);
|
||||
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||
g_free(err_str);
|
||||
return;
|
||||
} else if (err_str) {
|
||||
g_free(err_str);
|
||||
}
|
||||
if (g_list_length(if_list) > 0) {
|
||||
/* List the interfaces */
|
||||
for (curr = g_list_first(if_list); curr; curr = g_list_next(curr)) {
|
||||
if_info = curr->data;
|
||||
/* Continue if capture device is hidden */
|
||||
if (prefs_is_capture_device_hidden(if_info->name)) {
|
||||
continue;
|
||||
}
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(capture_get_if_icon(&(device.if_info)))), IFACE_DESCR, device.display_name, IFACE_NAME, device.name, -1);
|
||||
}
|
||||
if (device.selected) {
|
||||
gtk_tree_selection_select_iter(entry, &iter);
|
||||
d_interface.name = g_strdup(if_info->name);
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
d_interface.remote_opts.src_type = CAPTURE_IFLOCAL;
|
||||
#endif
|
||||
#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
|
||||
d_interface.icon = icon;
|
||||
user_descr = capture_dev_user_descr_find(if_info->name);
|
||||
if (user_descr) {
|
||||
#ifndef _WIN32
|
||||
gchar *comment = user_descr;
|
||||
user_descr = g_strdup_printf("%s (%s)", comment, if_info->name);
|
||||
g_free (comment);
|
||||
#endif
|
||||
gtk_list_store_set(store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, user_descr, IFACE_NAME, if_info->name, -1);
|
||||
d_interface.descr = g_strdup(user_descr);
|
||||
g_free (user_descr);
|
||||
} else if (if_info->description) {
|
||||
gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, if_info->description, IFACE_NAME, if_info->name, -1);
|
||||
d_interface.descr = g_strdup(if_info->description);
|
||||
} else {
|
||||
gtk_list_store_set (store, &iter, ICON, gtk_image_get_pixbuf(GTK_IMAGE(icon)), IFACE_DESCR, if_info->name, IFACE_NAME, if_info->name, -1);
|
||||
d_interface.descr = g_strdup(if_info->name);
|
||||
}
|
||||
g_array_append_val(interfaces, d_interface);
|
||||
}
|
||||
}
|
||||
changed = TRUE;
|
||||
}
|
||||
gtk_tree_selection_set_select_function(entry, on_selection_changed, (gpointer)&changed, NULL);
|
||||
if (gtk_widget_is_focus(view) && dlg_window_present()) {
|
||||
update_all_rows();
|
||||
free_interface_list(if_list);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(if_view), GTK_TREE_MODEL (store));
|
||||
if (global_capture_opts.ifaces->len > 0) {
|
||||
gtk_tree_model_foreach(GTK_TREE_MODEL(store), select_current_ifaces, (gpointer) entry);
|
||||
gtk_widget_grab_focus(view);
|
||||
}
|
||||
gtk_tree_selection_set_select_function(entry, on_selection_changed, NULL, NULL);
|
||||
}
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
}
|
||||
|
@ -920,9 +1051,23 @@ void
|
|||
welcome_if_panel_reload(void)
|
||||
{
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if (welcome_hb) {
|
||||
GtkWidget *child_box;
|
||||
GList* child_list;
|
||||
GList* child_list_item;
|
||||
|
||||
if(welcome_if_panel_vb) {
|
||||
child_box = scroll_box_dynamic_reset(welcome_if_panel_vb);
|
||||
child_list = gtk_container_get_children(GTK_CONTAINER(child_box));
|
||||
child_list_item = child_list;
|
||||
|
||||
while(child_list_item) {
|
||||
gtk_container_remove(GTK_CONTAINER(child_box), child_list_item->data);
|
||||
child_list_item = g_list_next(child_list_item);
|
||||
}
|
||||
|
||||
g_list_free(child_list);
|
||||
welcome_if_tree_load();
|
||||
gtk_widget_show_all(welcome_hb);
|
||||
gtk_widget_show_all(welcome_if_panel_vb);
|
||||
}
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
}
|
||||
|
@ -931,16 +1076,16 @@ welcome_if_panel_reload(void)
|
|||
static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
|
||||
{
|
||||
#ifdef HAVE_AIRPCAP
|
||||
interface_t device;
|
||||
guint i;
|
||||
interface_options interface_opts;
|
||||
#endif
|
||||
if (global_capture_opts.num_selected == 0) {
|
||||
|
||||
if (global_capture_opts.ifaces->len == 0) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"You didn't specify an interface on which to capture packets.");
|
||||
return;
|
||||
}
|
||||
#ifndef USE_THREADS
|
||||
if (global_capture_opts.num_selected > 1) {
|
||||
if (global_capture_opts.ifaces->len > 1) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"You specified multiple interfaces for capturing which this version of Wireshark doesn't support.");
|
||||
return;
|
||||
|
@ -952,15 +1097,10 @@ static void capture_if_start(GtkWidget *w _U_, gpointer data _U_)
|
|||
g_free(global_capture_opts.save_file);
|
||||
global_capture_opts.save_file = NULL;
|
||||
}
|
||||
#ifdef HAVE_AIRPCAP /* TODO: don't let it depend on interface_opts */
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, device.name);
|
||||
airpcap_if_selected = airpcap_if_active;
|
||||
if (airpcap_if_selected) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_AIRPCAP
|
||||
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
|
||||
airpcap_if_active = get_airpcap_if_from_name(airpcap_if_list, interface_opts.name);
|
||||
airpcap_if_selected = airpcap_if_active;
|
||||
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
||||
#endif
|
||||
capture_start_cb(NULL, NULL);
|
||||
|
@ -991,11 +1131,14 @@ welcome_new(void)
|
|||
GtkTreeSelection *selection;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GList *if_list;
|
||||
int err;
|
||||
gchar *err_str = NULL;
|
||||
#endif
|
||||
|
||||
/* prepare colors */
|
||||
#if 0
|
||||
/* Allocating color isn't necessary? */
|
||||
/* Allocating collor isn't necessary? */
|
||||
|
||||
/* "page" background */
|
||||
get_color(&welcome_bg);
|
||||
|
@ -1015,7 +1158,7 @@ welcome_new(void)
|
|||
topic_item_idle_bg = topic_content_bg;
|
||||
#endif
|
||||
#if 0
|
||||
/* Allocating color isn't necessary? */
|
||||
/* Allocating collor isn't necessary? */
|
||||
/* topic item entered color */
|
||||
get_color(&topic_item_entered_bg);
|
||||
#endif
|
||||
|
@ -1026,9 +1169,9 @@ welcome_new(void)
|
|||
welcome_eb = gtk_event_box_new();
|
||||
gtk_container_add(GTK_CONTAINER(welcome_eb), welcome_vb);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_background_color(welcome_eb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
||||
gtk_widget_override_background_color(welcome_eb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
||||
#else
|
||||
gtk_widget_modify_bg(welcome_eb, GTK_STATE_NORMAL, &welcome_bg);
|
||||
gtk_widget_modify_bg(welcome_eb, GTK_STATE_NORMAL, &welcome_bg);
|
||||
#endif
|
||||
/* header */
|
||||
header = welcome_header_new();
|
||||
|
@ -1043,7 +1186,7 @@ welcome_new(void)
|
|||
/* column capture */
|
||||
column_vb = gtk_vbox_new(FALSE, 10);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_background_color(column_vb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
||||
gtk_widget_override_background_color(column_vb, GTK_STATE_NORMAL, &rgba_welcome_bg);
|
||||
#else
|
||||
gtk_widget_modify_bg(column_vb, GTK_STATE_NORMAL, &welcome_bg);
|
||||
#endif
|
||||
|
@ -1054,10 +1197,8 @@ welcome_new(void)
|
|||
gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if (global_capture_opts.all_ifaces->len == 0) {
|
||||
scan_local_interfaces(&global_capture_opts);
|
||||
}
|
||||
if (global_capture_opts.all_ifaces->len > 0) {
|
||||
if_list = capture_interface_list(&err, &err_str);
|
||||
if (g_list_length(if_list) > 0) {
|
||||
item_hb = welcome_button(WIRESHARK_STOCK_CAPTURE_INTERFACES,
|
||||
"Interface List",
|
||||
"Live list of the capture interfaces\n(counts incoming packets)",
|
||||
|
@ -1074,13 +1215,17 @@ welcome_new(void)
|
|||
g_object_set(G_OBJECT(if_view), "headers-visible", FALSE, NULL);
|
||||
g_signal_connect(if_view, "row-activated", G_CALLBACK(options_interface_cb), (gpointer)welcome_hb);
|
||||
g_object_set_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES, if_view);
|
||||
column = gtk_tree_view_column_new();
|
||||
renderer = gtk_cell_renderer_pixbuf_new();
|
||||
gtk_tree_view_column_pack_start(column, renderer, FALSE);
|
||||
gtk_tree_view_column_set_attributes(column, renderer, "pixbuf", ICON, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes ("",
|
||||
GTK_CELL_RENDERER(renderer),
|
||||
"pixbuf", ICON,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_column_pack_start(column, renderer, TRUE);
|
||||
gtk_tree_view_column_set_attributes(column, renderer, "text", IFACE_DESCR, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes ("",
|
||||
GTK_CELL_RENDERER(renderer),
|
||||
"text", IFACE_DESCR,
|
||||
NULL);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(if_view), column);
|
||||
gtk_tree_view_column_set_resizable(gtk_tree_view_get_column(GTK_TREE_VIEW(if_view), 0), TRUE);
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
|
@ -1141,6 +1286,8 @@ welcome_new(void)
|
|||
gtk_box_pack_start(GTK_BOX(topic_to_fill), w, FALSE, FALSE, 5);
|
||||
}
|
||||
|
||||
free_interface_list(if_list);
|
||||
|
||||
/* capture help topic */
|
||||
topic_vb = welcome_topic_new("Capture Help", &topic_to_fill);
|
||||
gtk_box_pack_start(GTK_BOX(column_vb), topic_vb, TRUE, TRUE, 0);
|
||||
|
@ -1281,3 +1428,9 @@ GtkWidget* get_welcome_window(void)
|
|||
return welcome_hb;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
displayed_interface get_interface_data(gint index)
|
||||
{
|
||||
return g_array_index(interfaces, displayed_interface, index);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -40,6 +40,15 @@ typedef struct selected_name_s {
|
|||
gboolean activate;
|
||||
} selected_name_t;
|
||||
|
||||
typedef struct displayed_interface_s {
|
||||
gchar *name;
|
||||
gchar *descr;
|
||||
GtkWidget *icon;
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
remote_options remote_opts;
|
||||
#endif
|
||||
} displayed_interface;
|
||||
|
||||
GtkWidget *welcome_new(void);
|
||||
|
||||
/* reset the list of recently used files */
|
||||
|
@ -51,8 +60,6 @@ void main_welcome_add_recent_capture_file(const char *widget_cf_name, GObject *m
|
|||
/* reload the list of interfaces */
|
||||
void welcome_if_panel_reload(void);
|
||||
|
||||
void welcome_if_tree_load(void);
|
||||
|
||||
/** Push a status message into the welcome screen header similar to
|
||||
* statusbar_push_*_msg(). This hides everything under the header.
|
||||
* If msg is dynamically allocated, it is up to the caller to free
|
||||
|
@ -78,10 +85,10 @@ void change_interface_selection(gchar* name, gboolean activate);
|
|||
|
||||
void change_selection_for_all(gboolean enable);
|
||||
|
||||
void update_welcome_list(void);
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
void add_interface_to_list(guint index);
|
||||
void add_interface_to_list(gchar *name, gchar *descr, remote_options *remote_opts);
|
||||
#endif
|
||||
|
||||
displayed_interface get_interface_data(gint index);
|
||||
|
||||
#endif /* __MAIN_WELCOME_H__ */
|
||||
|
|
|
@ -1434,7 +1434,6 @@ ifopts_write_new_hide(void)
|
|||
g_free(new_hide);
|
||||
prefs.capture_devices_hide = NULL;
|
||||
}
|
||||
hide_interface(g_strdup(new_hide));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue