forked from osmocom/wireshark
Add support for multiple interfaces to the capture options dialog.
Obtained from Irene Ruengeler. svn path=/trunk/; revision=38350
This commit is contained in:
parent
7f895c681b
commit
eaffdfeaaa
|
@ -696,9 +696,11 @@ capture_stat_start(GList *if_list) {
|
|||
/* Initialize the cache */
|
||||
for (if_entry = if_list; if_entry != NULL; if_entry = g_list_next(if_entry)) {
|
||||
if_info = if_entry->data;
|
||||
sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
|
||||
sc_item->name = g_strdup(if_info->name);
|
||||
sc->cache_list = g_list_append(sc->cache_list, sc_item);
|
||||
if (if_info) {
|
||||
sc_item = g_malloc0(sizeof(if_stat_cache_item_t));
|
||||
sc_item->name = g_strdup(if_info->name);
|
||||
sc->cache_list = g_list_append(sc->cache_list, sc_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sc;
|
||||
|
|
|
@ -55,6 +55,45 @@
|
|||
|
||||
#include "capture_ifinfo.h"
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
static GList *remote_interface_list = NULL;
|
||||
|
||||
static void append_remote_list(GList *iflist)
|
||||
{
|
||||
GSList *list;
|
||||
GList *rlist;
|
||||
if_addr_t *if_addr, *temp_addr;
|
||||
if_info_t *if_info, *temp;
|
||||
|
||||
for (rlist = g_list_nth(remote_interface_list, 0); rlist != NULL; rlist = g_list_next(rlist)) {
|
||||
if_info = (if_info_t *)rlist->data;
|
||||
temp = g_malloc0(sizeof(if_info_t));
|
||||
temp->name = g_strdup(if_info->name);
|
||||
temp->description = g_strdup(if_info->description);
|
||||
for (list = g_slist_nth(if_info->addrs, 0); list != NULL; list = g_slist_next(list)) {
|
||||
temp_addr = g_malloc0(sizeof(if_addr_t));
|
||||
if_addr = (if_addr_t *)list->data;
|
||||
if (if_addr) {
|
||||
temp_addr->ifat_type = if_addr->ifat_type;
|
||||
if (temp_addr->ifat_type == IF_AT_IPv4) {
|
||||
temp_addr->addr.ip4_addr = if_addr->addr.ip4_addr;
|
||||
} else {
|
||||
memcpy(temp_addr->addr.ip6_addr, if_addr->addr.ip6_addr, sizeof(if_addr->addr));
|
||||
}
|
||||
} else {
|
||||
g_free(temp_addr);
|
||||
temp_addr = NULL;
|
||||
}
|
||||
if (temp_addr) {
|
||||
temp->addrs = g_slist_append(temp->addrs, temp_addr);
|
||||
}
|
||||
}
|
||||
temp->loopback = if_info->loopback;
|
||||
iflist = g_list_append(iflist, temp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Fetch the interface list from a child process (dumpcap).
|
||||
*
|
||||
|
@ -151,6 +190,11 @@ capture_interface_list(int *err, char **err_str)
|
|||
if (err_str)
|
||||
*err_str = g_strdup("No interfaces found");
|
||||
}
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
if (remote_interface_list && g_list_length(remote_interface_list) > 0) {
|
||||
append_remote_list(if_list);
|
||||
}
|
||||
#endif
|
||||
return if_list;
|
||||
}
|
||||
|
||||
|
@ -261,4 +305,35 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode,
|
|||
return caps;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
void add_interface_to_remote_list(if_info_t *if_info)
|
||||
{
|
||||
GSList *list;
|
||||
if_addr_t *if_addr, *temp_addr;
|
||||
|
||||
if_info_t *temp = g_malloc0(sizeof(if_info_t));
|
||||
temp->name = g_strdup(if_info->name);
|
||||
temp->description = g_strdup(if_info->description);
|
||||
for (list = g_slist_nth(if_info->addrs, 0); list != NULL; list = g_slist_next(list)) {
|
||||
temp_addr = g_malloc0(sizeof(if_addr_t));
|
||||
if_addr = (if_addr_t *)list->data;
|
||||
if (if_addr) {
|
||||
temp_addr->ifat_type = if_addr->ifat_type;
|
||||
if (temp_addr->ifat_type == IF_AT_IPv4) {
|
||||
temp_addr->addr.ip4_addr = if_addr->addr.ip4_addr;
|
||||
} else {
|
||||
memcpy(temp_addr->addr.ip6_addr, if_addr->addr.ip6_addr, sizeof(if_addr->addr));
|
||||
}
|
||||
} else {
|
||||
g_free(temp_addr);
|
||||
temp_addr = NULL;
|
||||
}
|
||||
if (temp_addr) {
|
||||
temp->addrs = g_slist_append(temp->addrs, temp_addr);
|
||||
}
|
||||
}
|
||||
temp->loopback = if_info->loopback;
|
||||
remote_interface_list = g_list_append(remote_interface_list, temp);
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
|
|
@ -91,4 +91,6 @@ capture_get_if_capabilities(const char *devname, gboolean monitor_mode,
|
|||
|
||||
void free_if_capabilities(if_capabilities_t *caps);
|
||||
|
||||
void add_interface_to_remote_list(if_info_t *if_info);
|
||||
|
||||
#endif /* __CAPTURE_IFINFO_H__ */
|
||||
|
|
2753
gtk/capture_dlg.c
2753
gtk/capture_dlg.c
File diff suppressed because it is too large
Load Diff
|
@ -31,6 +31,68 @@
|
|||
* "Capture Options" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
#include "capture_opts.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;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct remote_options_tag {
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
capture_source src_type;
|
||||
struct remote_host remote_host_opts;
|
||||
#endif
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
capture_sampling sampling_method;
|
||||
int sampling_param;
|
||||
#endif
|
||||
} remote_options;
|
||||
|
||||
typedef struct row_options_tag {
|
||||
gchar *name;
|
||||
gchar *display_name;
|
||||
gchar *addresses;
|
||||
gchar *cfilter;
|
||||
GList *links;
|
||||
gint active_dlt;
|
||||
gboolean pmode;
|
||||
gboolean monitor_mode;
|
||||
gboolean has_snaplen;
|
||||
guint snaplen;
|
||||
gint buffer;
|
||||
remote_options remote_opts;
|
||||
} interface_row;
|
||||
|
||||
typedef struct link_row_tag {
|
||||
gchar *link_type;
|
||||
gint pointer;
|
||||
} link_row;
|
||||
|
||||
enum
|
||||
{
|
||||
CAPTURE = 0,
|
||||
INTERFACE,
|
||||
LINK,
|
||||
PMODE,
|
||||
SNAPLEN,
|
||||
#if defined(HAVE_PCAP_CREATE)
|
||||
BUFFER,
|
||||
MONITOR,
|
||||
#elif defined(_WIN32) && !defined(HAVE_PCAP_CREATE)
|
||||
BUFFER,
|
||||
#endif
|
||||
FILTER,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
|
||||
/** User requested the "Capture Options" dialog box by menu or toolbar.
|
||||
*
|
||||
|
@ -92,16 +154,22 @@ typedef struct {
|
|||
cap_settings_t
|
||||
capture_get_cap_settings (gchar *if_name);
|
||||
|
||||
GtkTreeModel*
|
||||
create_and_fill_model (GList *if_list, gboolean do_hide, GtkTreeView *view);
|
||||
|
||||
gboolean
|
||||
query_tooltip_tree_view_cb (GtkWidget *widget,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean keyboard_tip,
|
||||
GtkTooltip *tooltip,
|
||||
gpointer data);
|
||||
|
||||
void
|
||||
activate_monitor (GtkTreeViewColumn *tree_column, GtkCellRenderer *renderer,
|
||||
GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
|
||||
|
||||
#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 */
|
||||
};
|
||||
|
||||
#define RECENT_KEY_REMOTE_HOST "recent.remote_host"
|
||||
|
||||
/** Write all remote hosts to the recent file
|
||||
|
@ -120,4 +188,10 @@ gboolean
|
|||
capture_remote_combo_add_recent(gchar *s);
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
dlg_window_present(void);
|
||||
|
||||
void
|
||||
enable_selected_interface(gchar *name, gboolean enable);
|
||||
|
||||
#endif /* capture_dlg.h */
|
||||
|
|
|
@ -108,13 +108,16 @@ static GtkWidget *cap_if_w;
|
|||
|
||||
static GList *if_data_list = NULL;
|
||||
|
||||
static guint timer_id;
|
||||
static guint timer_id;
|
||||
|
||||
static GtkWidget *stop_bt, *capture_bt, *options_bt;
|
||||
|
||||
static GList *if_list;
|
||||
|
||||
static guint currently_selected = 0;
|
||||
static guint currently_selected = 0;
|
||||
|
||||
static if_stat_cache_t *sc;
|
||||
|
||||
/*
|
||||
* Timeout, in milliseconds, for reads from the stream of captured packets.
|
||||
*/
|
||||
|
@ -182,13 +185,16 @@ store_selected(GtkWidget *choose_bt, gpointer if_data)
|
|||
|
||||
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;
|
||||
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);
|
||||
|
@ -234,6 +240,9 @@ store_selected(GtkWidget *choose_bt, gpointer if_data)
|
|||
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(interface_opts.name, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (temp->selected)
|
||||
|
@ -249,9 +258,7 @@ store_selected(GtkWidget *choose_bt, gpointer if_data)
|
|||
#else
|
||||
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (currently_selected == 1));
|
||||
#endif
|
||||
gtk_widget_set_sensitive(options_bt, !gbl_capture_in_progress && (currently_selected <= 1));
|
||||
}
|
||||
set_menus_for_number_of_ifaces();
|
||||
}
|
||||
|
||||
/* start capture button was pressed */
|
||||
|
@ -387,18 +394,16 @@ set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
|
|||
#else
|
||||
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (currently_selected == 1));
|
||||
#endif
|
||||
gtk_widget_set_sensitive(options_bt, !capture_in_progress && (currently_selected <= 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* the window was closed, cleanup things */
|
||||
static void
|
||||
capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data)
|
||||
capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
GList *curr;
|
||||
int ifs;
|
||||
if_stat_cache_t *sc = user_data;
|
||||
|
||||
g_source_remove(timer_id);
|
||||
|
||||
|
@ -684,16 +689,16 @@ found:
|
|||
static void
|
||||
capture_if_stop_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
guint ifs;
|
||||
GList *curr;
|
||||
if_dlg_data_t *if_data;
|
||||
guint ifs;
|
||||
GList *curr;
|
||||
if_dlg_data_t *if_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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -726,7 +731,6 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
GString *if_tool_str = g_string_new("");
|
||||
const gchar *addr_str;
|
||||
gchar *user_descr;
|
||||
if_stat_cache_t *sc;
|
||||
int preselected = 0, i;
|
||||
interface_options interface_opts;
|
||||
gboolean found = FALSE;
|
||||
|
@ -811,7 +815,6 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(main_sw), main_vb);
|
||||
|
||||
|
||||
if_tb = gtk_table_new(1,9, FALSE);
|
||||
gtk_table_set_row_spacings(GTK_TABLE(if_tb), 3);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(if_tb), 3);
|
||||
|
@ -853,141 +856,139 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
/* List the interfaces */
|
||||
currently_selected = 0;
|
||||
for (ifs = 0; (curr = g_list_nth(if_list, ifs)); ifs++) {
|
||||
g_string_assign(if_tool_str, "");
|
||||
if_info = curr->data;
|
||||
g_string_assign(if_tool_str, "");
|
||||
if_info = curr->data;
|
||||
|
||||
/* Continue if capture device is hidden */
|
||||
if (prefs_is_capture_device_hidden(if_info->name)) {
|
||||
/* Continue if capture device is hidden */
|
||||
if (prefs_is_capture_device_hidden(if_info->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
found = TRUE;
|
||||
currently_selected++;
|
||||
preselected--;
|
||||
break;
|
||||
}
|
||||
if_dlg_data->selected = found;
|
||||
}
|
||||
else
|
||||
if_dlg_data->selected = FALSE;
|
||||
if_dlg_data->selected = found;
|
||||
} else {
|
||||
if_dlg_data->selected = FALSE;
|
||||
}
|
||||
if_dlg_data->if_info = *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);
|
||||
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
|
||||
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);
|
||||
gtk_table_attach_defaults(GTK_TABLE(if_tb), icon, 1, 2, row, row+1);
|
||||
|
||||
/* device name */
|
||||
if_dlg_data->device_lb = gtk_label_new(if_info->name);
|
||||
if_dlg_data->device = if_info->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(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);
|
||||
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, if_info->name);
|
||||
g_string_append(if_tool_str, "Device: ");
|
||||
g_string_append(if_tool_str, if_info->name);
|
||||
g_string_append(if_tool_str, "\n");
|
||||
|
||||
/* description */
|
||||
user_descr = capture_dev_user_descr_find(if_info->name);
|
||||
if (user_descr) {
|
||||
if_dlg_data->descr_lb = gtk_label_new(user_descr);
|
||||
g_free (user_descr);
|
||||
} else {
|
||||
if (if_info->description)
|
||||
if_dlg_data->descr_lb = gtk_label_new(if_info->description);
|
||||
else
|
||||
if_dlg_data->descr_lb = gtk_label_new("");
|
||||
}
|
||||
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, if_info->description);
|
||||
g_string_append(if_tool_str, "\n");
|
||||
}
|
||||
|
||||
/* description */
|
||||
user_descr = capture_dev_user_descr_find(if_info->name);
|
||||
if (user_descr) {
|
||||
if_dlg_data->descr_lb = gtk_label_new(user_descr);
|
||||
g_free (user_descr);
|
||||
} else {
|
||||
if (if_info->description)
|
||||
if_dlg_data->descr_lb = gtk_label_new(if_info->description);
|
||||
else
|
||||
if_dlg_data->descr_lb = gtk_label_new("");
|
||||
}
|
||||
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);
|
||||
/* IP address */
|
||||
/* Only one IP address will be shown, start with the first */
|
||||
g_string_append(if_tool_str, "IP: ");
|
||||
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(if_dlg_data->ip_lb, TRUE);
|
||||
g_string_append(if_tool_str, addr_str);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
|
||||
g_string_append(if_tool_str, "unknown");
|
||||
}
|
||||
eb = gtk_event_box_new ();
|
||||
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(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, 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), if_info->addrs);
|
||||
}
|
||||
g_string_append(if_tool_str, "\n");
|
||||
|
||||
if (if_info->description) {
|
||||
g_string_append(if_tool_str, "Description: ");
|
||||
g_string_append(if_tool_str, if_info->description);
|
||||
g_string_append(if_tool_str, "\n");
|
||||
}
|
||||
/* packets */
|
||||
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);
|
||||
|
||||
/* IP address */
|
||||
/* Only one IP address will be shown, start with the first */
|
||||
g_string_append(if_tool_str, "IP: ");
|
||||
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(if_dlg_data->ip_lb, TRUE);
|
||||
g_string_append(if_tool_str, addr_str);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(if_dlg_data->ip_lb, FALSE);
|
||||
g_string_append(if_tool_str, "unknown");
|
||||
}
|
||||
eb = gtk_event_box_new ();
|
||||
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(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, 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), if_info->addrs);
|
||||
}
|
||||
g_string_append(if_tool_str, "\n");
|
||||
/* packets/s */
|
||||
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);
|
||||
|
||||
/* packets */
|
||||
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 */
|
||||
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 */
|
||||
/* details button */
|
||||
#ifdef _WIN32
|
||||
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(if_dlg_data->details_bt, FALSE);
|
||||
}
|
||||
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(if_dlg_data->details_bt, FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if_data_list = g_list_append(if_data_list, if_dlg_data);
|
||||
|
||||
row++;
|
||||
if (row <= 10) {
|
||||
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(if_dlg_data->choose_bt), &requisition, NULL);
|
||||
height += requisition.height;
|
||||
}
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(if_dlg_data->choose_bt), &requisition, NULL);
|
||||
height += requisition.height;
|
||||
}
|
||||
}
|
||||
|
||||
g_string_free(if_tool_str, TRUE);
|
||||
|
@ -1010,7 +1011,7 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
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 + 20 + ifs;
|
||||
height += requisition.height + 40 + ifs;
|
||||
gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
|
||||
|
||||
gtk_widget_grab_default(close_bt);
|
||||
|
@ -1023,13 +1024,39 @@ capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
|
||||
set_capture_if_dialog_for_capture_in_progress(gbl_capture_in_progress);
|
||||
|
||||
/* update the interface list every 1000ms */
|
||||
/* update the interface list every 1000ms */
|
||||
timer_id = g_timeout_add(1000, update_all, sc);
|
||||
}
|
||||
|
||||
GtkWidget* get_interfaces_dialog_window(void)
|
||||
gboolean interfaces_dialog_window_present(void)
|
||||
{
|
||||
return cap_if_w;
|
||||
return (cap_if_w?TRUE:FALSE);
|
||||
}
|
||||
|
||||
void refresh_if_window(void)
|
||||
{
|
||||
capture_if_destroy_cb(NULL, NULL);
|
||||
capture_if_cb(NULL, NULL);
|
||||
}
|
||||
|
||||
void select_all_interfaces(gboolean enable)
|
||||
{
|
||||
if_dlg_data_t *temp;
|
||||
guint ifs;
|
||||
GList *curr;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void destroy_if_window(void)
|
||||
{
|
||||
if (cap_if_w) {
|
||||
window_destroy(cap_if_w);
|
||||
}
|
||||
}
|
||||
#else /* HAVE_LIBPCAP */
|
||||
|
||||
|
|
|
@ -53,8 +53,17 @@ capture_get_if_icon(const if_info_t* if_info);
|
|||
void
|
||||
update_selected_interface(gchar *name, gboolean activate);
|
||||
|
||||
GtkWidget *
|
||||
get_interfaces_dialog_window(void);
|
||||
gboolean
|
||||
interfaces_dialog_window_present(void);
|
||||
|
||||
void
|
||||
refresh_if_window(void);
|
||||
|
||||
void
|
||||
select_all_interfaces(gboolean enable);
|
||||
|
||||
void
|
||||
destroy_if_window(void);
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ static GtkWidget *welcome_file_panel_vb = NULL;
|
|||
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;
|
||||
|
@ -490,9 +491,9 @@ static void *get_recent_item_status(void *data)
|
|||
}
|
||||
|
||||
if (!ri_stat->label) { /* The widget went away while we were busy. */
|
||||
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->stat_done = TRUE;
|
||||
}
|
||||
|
@ -520,14 +521,14 @@ update_recent_items(gpointer data)
|
|||
if (ri_stat->stat_done) {
|
||||
again = FALSE;
|
||||
gtk_label_set_markup(GTK_LABEL(ri_stat->label), ri_stat->str->str);
|
||||
if (ri_stat->err == 0) {
|
||||
gtk_widget_set_sensitive(ri_stat->label, TRUE);
|
||||
if (ri_stat->err == 0) {
|
||||
gtk_widget_set_sensitive(ri_stat->label, TRUE);
|
||||
#ifdef MAIN_MENU_USE_UIMANAGER
|
||||
gtk_action_set_sensitive((GtkAction *) ri_stat->menu_item, TRUE);
|
||||
gtk_action_set_sensitive((GtkAction *) ri_stat->menu_item, TRUE);
|
||||
#else
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(ri_stat->menu_item), TRUE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(ri_stat->menu_item), TRUE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ri_stat->timer = 0;
|
||||
}
|
||||
/* Else append some sort of Unicode or ASCII animation to the label? */
|
||||
|
@ -541,7 +542,7 @@ static void welcome_filename_destroy_cb(GtkWidget *w _U_, gpointer data) {
|
|||
recent_item_status *ri_stat = (recent_item_status *) data;
|
||||
|
||||
if (!ri_stat) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_THREADS
|
||||
|
@ -711,37 +712,51 @@ gboolean on_selection_changed(GtkTreeSelection *selection _U_,
|
|||
GtkTreeIter iter;
|
||||
gchar *if_name;
|
||||
interface_options interface_opts;
|
||||
guint i;
|
||||
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.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) {
|
||||
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)) && get_interfaces_dialog_window()) {
|
||||
update_selected_interface(g_strdup(interface_opts.name), FALSE);
|
||||
}
|
||||
g_free(interface_opts.name);
|
||||
g_free(interface_opts.descr);
|
||||
g_free(interface_opts.cfilter);
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found && !path_currently_selected) {
|
||||
interface_opts.name = g_strdup(if_name);
|
||||
interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
|
||||
for (j = 0; j < interfaces->len; j++) {
|
||||
d_interface = g_array_index(interfaces, displayed_interface, j);
|
||||
if (strcmp(d_interface.name, if_name) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
@ -753,26 +768,45 @@ gboolean on_selection_changed(GtkTreeSelection *selection _U_,
|
|||
#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
|
||||
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 = global_capture_opts.default_options.sampling_method;
|
||||
interface_opts.sampling_param = global_capture_opts.default_options.sampling_param;
|
||||
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)) && get_interfaces_dialog_window()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
set_menus_for_number_of_ifaces();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -785,7 +819,7 @@ static gboolean activate_ifaces(GtkTreeModel *model,
|
|||
GtkWidget *view;
|
||||
GtkTreeSelection *selection;
|
||||
selected_name_t *entry = (selected_name_t *)userdata;
|
||||
|
||||
|
||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||
gtk_tree_model_get (model, iter, IFACE_NAME, &if_name, -1);
|
||||
|
@ -805,13 +839,22 @@ void change_interface_selection(gchar* name, gboolean activate)
|
|||
GtkWidget *view;
|
||||
GtkTreeModel *model;
|
||||
selected_name_t entry;
|
||||
|
||||
|
||||
view = g_object_get_data(G_OBJECT(welcome_hb), TREE_VIEW_INTERFACES);
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(view));
|
||||
entry.name = g_strdup(name);
|
||||
entry.activate = activate;
|
||||
gtk_tree_model_foreach(GTK_TREE_MODEL(model), (GtkTreeModelForeachFunc)(activate_ifaces), (gpointer) &entry);
|
||||
}
|
||||
|
||||
void change_selection_for_all(gboolean enable)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < interfaces->len; i++) {
|
||||
change_interface_selection(g_array_index(interfaces, displayed_interface, i).name, enable);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -832,69 +875,130 @@ select_ifaces(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
void
|
||||
add_interface_to_list(gchar *name, gchar *descr, remote_options *remote_opts)
|
||||
{
|
||||
GtkWidget *view, *icon;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gint size;
|
||||
gchar *lines;
|
||||
displayed_interface d_interface;
|
||||
|
||||
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 = xpm_to_widget(capture_airpcap_16_xpm);
|
||||
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, descr, IFACE_NAME, name, -1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* list the interfaces */
|
||||
void
|
||||
welcome_if_tree_load(void)
|
||||
{
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if_info_t *if_info;
|
||||
GList *if_list;
|
||||
int err;
|
||||
gchar *err_str = NULL;
|
||||
GList *curr;
|
||||
gchar *user_descr;
|
||||
GtkListStore *store = NULL;
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *icon, *view;
|
||||
GtkTreeSelection *entry;
|
||||
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 *icon, *view;
|
||||
GtkTreeSelection *entry;
|
||||
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);
|
||||
|
||||
/* 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 && 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) {
|
||||
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);
|
||||
/* 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;
|
||||
}
|
||||
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 {
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
icon = capture_get_if_icon(if_info);
|
||||
#endif
|
||||
user_descr = capture_dev_user_descr_find(if_info->name);
|
||||
if (user_descr) {
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
} 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
@ -902,7 +1006,6 @@ welcome_if_tree_load(void)
|
|||
}
|
||||
gtk_tree_selection_set_select_function(entry, on_selection_changed, NULL, NULL);
|
||||
}
|
||||
free_interface_list(if_list);
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#ifndef __MAIN_WELCOME_H__
|
||||
#define __MAIN_WELCOME_H__
|
||||
|
||||
#include "gtk/capture_dlg.h"
|
||||
|
||||
enum
|
||||
{
|
||||
ICON = 0,
|
||||
|
@ -37,6 +39,14 @@ typedef struct selected_name_s {
|
|||
gchar *name;
|
||||
gboolean activate;
|
||||
} selected_name_t;
|
||||
|
||||
typedef struct displayed_interface_s {
|
||||
gchar *name;
|
||||
gchar *descr;
|
||||
GtkWidget *icon;
|
||||
remote_options remote_opts;
|
||||
} displayed_interface;
|
||||
|
||||
GtkWidget *welcome_new(void);
|
||||
|
||||
/* reset the list of recently used files */
|
||||
|
@ -71,4 +81,8 @@ GtkWidget* get_welcome_window(void);
|
|||
|
||||
void change_interface_selection(gchar* name, gboolean activate);
|
||||
|
||||
void change_selection_for_all(gboolean enable);
|
||||
|
||||
void add_interface_to_list(gchar *name, gchar *descr, remote_options *remote_opts);
|
||||
|
||||
#endif /* __MAIN_WELCOME_H__ */
|
||||
|
|
17
gtk/menus.c
17
gtk/menus.c
|
@ -5909,7 +5909,7 @@ set_menus_for_capture_in_progress(gboolean capture_in_progress)
|
|||
#ifdef HAVE_LIBPCAP
|
||||
#ifdef MAIN_MENU_USE_UIMANAGER
|
||||
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Options",
|
||||
!capture_in_progress && global_capture_opts.ifaces->len <= 1);
|
||||
!capture_in_progress);
|
||||
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Start",
|
||||
!capture_in_progress);
|
||||
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Stop",
|
||||
|
@ -5918,7 +5918,7 @@ set_menus_for_capture_in_progress(gboolean capture_in_progress)
|
|||
capture_in_progress);
|
||||
#else /* MAIN_MENU_USE_UIMANAGER */
|
||||
set_menu_sensitivity_old("/Capture/Options...",
|
||||
(!capture_in_progress && global_capture_opts.ifaces->len <= 1));
|
||||
!capture_in_progress);
|
||||
set_menu_sensitivity_old("/Capture/Start",
|
||||
!capture_in_progress);
|
||||
set_menu_sensitivity_old("/Capture/Stop",
|
||||
|
@ -5932,19 +5932,6 @@ set_menus_for_capture_in_progress(gboolean capture_in_progress)
|
|||
#endif /* HAVE_LIBPCAP */
|
||||
}
|
||||
|
||||
void set_menus_for_number_of_ifaces(void)
|
||||
{
|
||||
#ifdef HAVE_LIBPCAP
|
||||
#ifdef MAIN_MENU_USE_UIMANAGER
|
||||
set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/CaptureMenu/Options",
|
||||
global_capture_opts.ifaces->len <= 1);
|
||||
#else /* MAIN_MENU_USE_UIMANAGER */
|
||||
set_menu_sensitivity_old("/Capture/Options...",
|
||||
global_capture_opts.ifaces->len <= 1);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Enable or disable menu items based on whether you have some captured
|
||||
packets. */
|
||||
static gboolean
|
||||
|
|
|
@ -161,8 +161,6 @@ void set_menus_for_selected_packet(capture_file *cf);
|
|||
/* Enable or disable menu items based on configuration profile */
|
||||
void set_menus_for_profiles(gboolean default_profile);
|
||||
|
||||
void set_menus_for_number_of_ifaces(void);
|
||||
|
||||
#ifdef MAIN_MENU_USE_UIMANAGER
|
||||
#define MENU_BAR_PATH_FILE_OPEN "/Menubar/FileMenu/Open"
|
||||
#define MENU_BAR_PATH_EDIT_COPY_AS_FLT "/Menubar/EditMenu/Copy/AsFilter"
|
||||
|
|
Loading…
Reference in New Issue