Populate Remote Interfaces with data from recent file
Remote Interfaces have been saved in the recent_common file however they were never populated by the GUI. Bug: 8557 Change-Id: Ib68a75ce02f5b5e2c115b72d58c3e781a5122f9f Reviewed-on: https://code.wireshark.org/review/25039 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
c693522e33
commit
ead32b5628
|
@ -271,6 +271,9 @@ static void
|
|||
select_link_type_cb(GtkWidget *w, gpointer data);
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
static void
|
||||
populate_existing_remotes(gpointer key, gpointer value, gpointer user_data);
|
||||
|
||||
static void
|
||||
capture_remote_cb(GtkWidget *w, gboolean focus_username);
|
||||
|
||||
|
@ -1428,6 +1431,47 @@ insert_new_rows(GList *rlist)
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
static void
|
||||
populate_existing_remotes(gpointer key, gpointer value, gpointer user_data _U_)
|
||||
{
|
||||
const gchar *host = (const gchar *)key;
|
||||
struct remote_host *remote_host = (struct remote_host *)value;
|
||||
GList *if_list;
|
||||
int err;
|
||||
gchar *err_str;
|
||||
|
||||
g_free(global_remote_opts.remote_host_opts.remote_host);
|
||||
g_free(global_remote_opts.remote_host_opts.remote_port);
|
||||
g_free(global_remote_opts.remote_host_opts.auth_username);
|
||||
g_free(global_remote_opts.remote_host_opts.auth_password);
|
||||
global_remote_opts.src_type = CAPTURE_IFREMOTE;
|
||||
global_remote_opts.remote_host_opts.remote_host = g_strdup(host);
|
||||
global_remote_opts.remote_host_opts.remote_port = g_strdup(remote_host->remote_port);
|
||||
global_remote_opts.remote_host_opts.auth_type = remote_host->auth_type;
|
||||
global_remote_opts.remote_host_opts.auth_username = g_strdup(remote_host->auth_username);
|
||||
global_remote_opts.remote_host_opts.auth_password = g_strdup(remote_host->auth_password);
|
||||
global_remote_opts.remote_host_opts.datatx_udp = FALSE;
|
||||
global_remote_opts.remote_host_opts.nocap_rpcap = TRUE;
|
||||
global_remote_opts.remote_host_opts.nocap_local = FALSE;
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
global_remote_opts.sampling_method = CAPTURE_SAMP_NONE;
|
||||
global_remote_opts.sampling_param = 0;
|
||||
#endif
|
||||
|
||||
if_list = get_remote_interface_list(global_remote_opts.remote_host_opts.remote_host,
|
||||
global_remote_opts.remote_host_opts.remote_port,
|
||||
global_remote_opts.remote_host_opts.auth_type,
|
||||
global_remote_opts.remote_host_opts.auth_username,
|
||||
global_remote_opts.remote_host_opts.auth_password,
|
||||
&err, &err_str);
|
||||
if (if_list != NULL) {
|
||||
/* New remote interface */
|
||||
insert_new_rows(if_list);
|
||||
refresh_non_local_interface_lists();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the list of remote interfaces according to selected
|
||||
* options and re-fill interface name combobox */
|
||||
static void
|
||||
|
@ -4358,6 +4402,7 @@ show_add_interfaces_dialog(GtkWidget *bt _U_, GtkWidget *parent_win)
|
|||
gtk_container_add(GTK_CONTAINER(remote_sc), remote_l);
|
||||
gtk_widget_show(remote_l);
|
||||
|
||||
recent_remote_host_list_foreach(populate_existing_remotes, NULL);
|
||||
fill_remote_list();
|
||||
|
||||
bbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#ifdef HAVE_PCAP_REMOTE
|
||||
#include "ui/qt/remote_capture_dialog.h"
|
||||
#include "ui/qt/remote_settings_dialog.h"
|
||||
#include "caputils/capture-pcap-util.h"
|
||||
#include "ui/recent.h"
|
||||
#endif
|
||||
#include "ui/iface_lists.h"
|
||||
#include "ui/preference_utils.h"
|
||||
|
@ -55,6 +57,7 @@
|
|||
#include <QLineEdit>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTreeWidgetItemIterator>
|
||||
#include <QMessageBox>
|
||||
|
||||
// To do:
|
||||
// - Check the validity of pipes and remote interfaces and provide feedback
|
||||
|
@ -81,6 +84,57 @@ enum {
|
|||
tab_remote_
|
||||
};
|
||||
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
static void populateExistingRemotes(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
ManageInterfacesDialog *dialog = (ManageInterfacesDialog*)user_data;
|
||||
const gchar *host = (const gchar *)key;
|
||||
struct remote_host *remote_host = (struct remote_host *)value;
|
||||
remote_options global_remote_opts;
|
||||
int err;
|
||||
gchar *err_str;
|
||||
|
||||
global_remote_opts.src_type = CAPTURE_IFREMOTE;
|
||||
global_remote_opts.remote_host_opts.remote_host = g_strdup(host);
|
||||
global_remote_opts.remote_host_opts.remote_port = g_strdup(remote_host->remote_port);
|
||||
global_remote_opts.remote_host_opts.auth_type = remote_host->auth_type;
|
||||
global_remote_opts.remote_host_opts.auth_username = g_strdup(remote_host->auth_username);
|
||||
global_remote_opts.remote_host_opts.auth_password = g_strdup(remote_host->auth_password);
|
||||
global_remote_opts.remote_host_opts.datatx_udp = FALSE;
|
||||
global_remote_opts.remote_host_opts.nocap_rpcap = TRUE;
|
||||
global_remote_opts.remote_host_opts.nocap_local = FALSE;
|
||||
#ifdef HAVE_PCAP_SETSAMPLING
|
||||
global_remote_opts.sampling_method = CAPTURE_SAMP_NONE;
|
||||
global_remote_opts.sampling_param = 0;
|
||||
#endif
|
||||
GList *rlist = get_remote_interface_list(global_remote_opts.remote_host_opts.remote_host,
|
||||
global_remote_opts.remote_host_opts.remote_port,
|
||||
global_remote_opts.remote_host_opts.auth_type,
|
||||
global_remote_opts.remote_host_opts.auth_username,
|
||||
global_remote_opts.remote_host_opts.auth_password,
|
||||
&err, &err_str);
|
||||
if (rlist == NULL) {
|
||||
switch (err) {
|
||||
case 0:
|
||||
QMessageBox::warning(dialog, QObject::tr("Error"), QObject::tr("No remote interfaces found."));
|
||||
break;
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
QMessageBox::critical(dialog, QObject::tr("Error"), err_str);
|
||||
break;
|
||||
case DONT_HAVE_PCAP:
|
||||
QMessageBox::critical(dialog, QObject::tr("Error"), QObject::tr("PCAP not found"));
|
||||
break;
|
||||
default:
|
||||
QMessageBox::critical(dialog, QObject::tr("Error"), QObject::tr("Unknown error"));
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
emit dialog->remoteAdded(rlist, &global_remote_opts);
|
||||
}
|
||||
#endif /* HAVE_PCAP_REMOTE */
|
||||
|
||||
ManageInterfacesDialog::ManageInterfacesDialog(QWidget *parent) :
|
||||
GeometryStateDialog(parent),
|
||||
ui(new Ui::ManageInterfacesDialog)
|
||||
|
@ -152,6 +206,7 @@ ManageInterfacesDialog::ManageInterfacesDialog(QWidget *parent) :
|
|||
connect(this, SIGNAL(remoteAdded(GList*, remote_options*)), this, SLOT(addRemoteInterfaces(GList*, remote_options*)));
|
||||
connect(this, SIGNAL(remoteSettingsChanged(interface_t *)), this, SLOT(setRemoteSettings(interface_t *)));
|
||||
connect(ui->remoteList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(remoteSelectionChanged(QTreeWidgetItem*, int)));
|
||||
recent_remote_host_list_foreach(populateExistingRemotes, this);
|
||||
#endif
|
||||
|
||||
ui->tabWidget->setCurrentIndex(tab_local_);
|
||||
|
|
|
@ -490,7 +490,12 @@ capture_remote_combo_add_recent(const gchar *s)
|
|||
|
||||
if (valp) {
|
||||
/* Found value 2, this is the port number */
|
||||
rh->remote_port = (gchar *)g_strdup ((const gchar *)valp->data);
|
||||
if (!strcmp((const char*)valp->data, "0")) {
|
||||
/* Port 0 isn't valid, so leave port blank */
|
||||
rh->remote_port = (gchar *)g_strdup ("");
|
||||
} else {
|
||||
rh->remote_port = (gchar *)g_strdup ((const gchar *)valp->data);
|
||||
}
|
||||
valp = valp->next;
|
||||
} else {
|
||||
/* Did not find a port number */
|
||||
|
|
Loading…
Reference in New Issue