aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture_opts.h8
-rw-r--r--caputils/capture_ifinfo.h2
-rw-r--r--ui/gtk/capture_dlg.c156
-rw-r--r--ui/gtk/capture_dlg.h10
-rw-r--r--ui/qt/CMakeLists.txt2
-rw-r--r--ui/qt/Makefile.common2
-rw-r--r--ui/qt/QtShark.pro2
-rw-r--r--ui/qt/capture_interface_dialog.cpp117
-rw-r--r--ui/qt/capture_interface_dialog.h54
-rw-r--r--ui/recent.c129
-rw-r--r--ui/recent.h52
11 files changed, 220 insertions, 314 deletions
diff --git a/capture_opts.h b/capture_opts.h
index 50894f5469..69f4d2d7bd 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -147,6 +147,14 @@ struct remote_host_info {
gboolean nocap_local;
};
+struct remote_host {
+ gchar *r_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 */
+};
+
typedef struct remote_options_tag {
capture_source src_type;
struct remote_host_info remote_host_opts;
diff --git a/caputils/capture_ifinfo.h b/caputils/capture_ifinfo.h
index f70bdf4ba5..7cb70abbdf 100644
--- a/caputils/capture_ifinfo.h
+++ b/caputils/capture_ifinfo.h
@@ -27,6 +27,8 @@
extern "C" {
#endif /* __cplusplus */
+#include <glib.h>
+
typedef enum {
IF_WIRED,
IF_AIRPCAP,
diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c
index 9fb207f7f4..24f6df7abd 100644
--- a/ui/gtk/capture_dlg.c
+++ b/ui/gtk/capture_dlg.c
@@ -239,7 +239,6 @@ static gint marked_interface;
static gint marked_row;
#ifdef HAVE_PCAP_REMOTE
-static GHashTable *remote_host_list=NULL;
static remote_options global_remote_opts;
static guint num_selected = 0;
#endif
@@ -1088,16 +1087,16 @@ iftype_combo_box_add (GtkWidget *iftype_cbx, interface_t *device)
gboolean create_new = FALSE;
gchar *string;
guint pos = REMOTE_HOST_START;
- struct remote_host_info *rh;
+ struct remote_host *rh;
- rh = g_hash_table_lookup (remote_host_list, device->remote_opts.remote_host_opts.remote_host);
+ rh = recent_get_remote_host(device->remote_opts.remote_host_opts.remote_host);
if (!rh) {
rh = g_malloc0 (sizeof (*rh));
- if (g_hash_table_size (remote_host_list) == 0) {
+ if (recent_get_remote_host_list_size() == 0) {
iftype_combo_box_add_remote_separators (iftype_cbx);
}
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(iftype_cbx), pos, device->remote_opts.remote_host_opts.remote_host);
- rh->remote_host = g_strdup (device->remote_opts.remote_host_opts.remote_host);
+ rh->r_host = g_strdup (device->remote_opts.remote_host_opts.remote_host);
create_new = TRUE;
} else {
model = (GtkTreeModel *)gtk_combo_box_get_model(GTK_COMBO_BOX(iftype_cbx));
@@ -1127,7 +1126,7 @@ iftype_combo_box_add (GtkWidget *iftype_cbx, interface_t *device)
rh->auth_password = g_strdup (device->remote_opts.remote_host_opts.auth_password);
if (create_new) {
- g_hash_table_insert (remote_host_list, g_strdup (device->remote_opts.remote_host_opts.remote_host), rh);
+ recent_add_remote_host(g_strdup (device->remote_opts.remote_host_opts.remote_host), rh);
}
g_object_set_data(G_OBJECT(iftype_cbx), E_CAP_CBX_IFTYPE_NOUPDATE_KEY, GINT_TO_POINTER(1));
@@ -1139,13 +1138,6 @@ static void
iftype_combo_box_add_remote_host (gpointer key, gpointer value _U_, gpointer user_data)
{
gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(user_data), REMOTE_HOST_START, key);
-
-/* if (g_array_index(global_capture_opts.ifaces, interface_options, 0).src_type == CAPTURE_IFREMOTE) {*/
- /* Ensure we select the correct entry */
- /* if (strcmp ((char *)key, g_array_index(global_capture_opts.ifaces, interface_options, 0).remote_host) == 0) {
- gtk_combo_box_set_active(GTK_COMBO_BOX(user_data), REMOTE_HOST_START);
- }
- }*/
}
/* Fill the menu of available types of interfaces */
@@ -1153,16 +1145,14 @@ static GtkWidget *
iftype_combo_box_new(void)
{
GtkWidget *iftype_cbx;
+ GHashTable *ht;
iftype_cbx = gtk_combo_box_text_new_with_entry();
- /* for (i = 0; i < sizeof(iftype) / sizeof(iftype[0]); i++) {
- gtk_combo_box_text_append_text(GTK_COMBO_BOX(iftype_cbx), iftype[i].name);
- }*/
-
- if (g_hash_table_size (remote_host_list) > 0) {
+ ht = get_remote_host_list();
+ if (g_hash_table_size (ht) > 0) {
/* Add remote hosts */
- g_hash_table_foreach (remote_host_list, iftype_combo_box_add_remote_host, iftype_cbx);
+ g_hash_table_foreach (ht, iftype_combo_box_add_remote_host, iftype_cbx);
iftype_combo_box_add_remote_separators (iftype_cbx);
}
@@ -1410,7 +1400,6 @@ update_interface_list(void)
global_remote_opts.remote_host_opts.auth_username,
global_remote_opts.remote_host_opts.auth_password,
&err, &err_str);
-
if_list = if_r_list;
} else {
if_list = capture_interface_list(&err, &err_str, main_window_update); /* Warning: see capture_prep_cb() */
@@ -1466,6 +1455,7 @@ capture_remote_ok_cb(GtkWidget *win _U_, GtkWidget *remote_w)
{
GtkWidget *host_te, *port_te, *username_te, *passwd_te, *auth_passwd_rb;
gchar *hostname;
+ struct remote_host *rh;
if (remote_w == NULL) {
return;
@@ -1494,6 +1484,15 @@ capture_remote_ok_cb(GtkWidget *win _U_, GtkWidget *remote_w)
global_remote_opts.remote_host_opts.auth_password =
g_strdup(gtk_entry_get_text(GTK_ENTRY(passwd_te)));
+ rh = g_malloc (sizeof (*rh));
+ rh->r_host = g_strdup(global_remote_opts.remote_host_opts.remote_host);
+ rh->remote_port = g_strdup(global_remote_opts.remote_host_opts.remote_port);
+ rh->auth_type = global_remote_opts.remote_host_opts.auth_type;
+ rh->auth_password = g_strdup("");
+ rh->auth_username = g_strdup("");
+
+ recent_add_remote_host(hostname, rh);
+
update_interface_list();
fill_remote_list();
window_destroy(GTK_WIDGET(g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY)));
@@ -1505,19 +1504,6 @@ capture_remote_cancel_cb(GtkWidget *win, gpointer data)
window_cancel_button_cb (win, data);
}
-static gboolean
-free_remote_host (gpointer key _U_, gpointer value, gpointer user _U_)
-{
- struct remote_host *rh = value;
-
- g_free (rh->remote_host);
- g_free (rh->remote_port);
- g_free (rh->auth_username);
- g_free (rh->auth_password);
-
- return TRUE;
-}
-
static void
select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data _U_)
{
@@ -1527,10 +1513,10 @@ select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data _U_)
struct remote_host *rh;
int new_iftype = gtk_combo_box_get_active(GTK_COMBO_BOX(iftype_cbx));
- gint num_remote = g_hash_table_size (remote_host_list);
+ gint num_remote = recent_get_remote_host_list_size();
if (new_iftype != -1 && new_iftype == num_remote+1) {
- g_hash_table_foreach_remove (remote_host_list, free_remote_host, NULL);
+ free_remote_host_list();
num_remote += 2;
while (num_remote--) { /* Remove separator lines and "Clear" item */
gtk_combo_box_text_remove (GTK_COMBO_BOX_TEXT(iftype_cbx), num_remote);
@@ -1540,7 +1526,7 @@ select_if_type_cb(GtkComboBox *iftype_cbx, gpointer data _U_)
capture_remote_cb(GTK_WIDGET(iftype_cbx), FALSE);
} else {
string = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(iftype_cbx));
- rh = g_hash_table_lookup (remote_host_list, string);
+ rh = recent_get_remote_host(string);
g_free (string);
if (rh) {
remote_w = g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
@@ -1930,81 +1916,6 @@ options_remote_cb(GtkWidget *w _U_, gpointer d _U_)
window_present(opt_remote_w);
}
-static void
-recent_print_remote_host (gpointer key _U_, gpointer value, gpointer user)
-{
- FILE *rf = user;
- struct remote_host_info *ri = value;
-
- fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", ri->remote_host, ri->remote_port, ri->auth_type);
-}
-
-void
-capture_remote_combo_recent_write_all(FILE *rf)
-{
- if (remote_host_list && g_hash_table_size (remote_host_list) > 0) {
- /* Write all remote interfaces to the recent file */
- g_hash_table_foreach (remote_host_list, recent_print_remote_host, rf);
- }
-}
-
-gboolean
-capture_remote_combo_add_recent(const gchar *s)
-{
- GList *vals = prefs_get_string_list (s);
- GList *valp = vals;
- gint auth_type;
- char *p;
- struct remote_host_info *rh;
-
- if (valp == NULL)
- return FALSE;
-
- if (remote_host_list == NULL) {
- remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
- }
-
- rh = g_malloc (sizeof (*rh));
-
- /* First value is the host */
- rh->remote_host = g_strdup (valp->data);
- if (strlen(rh->remote_host) == 0) {
- /* Empty remote host */
- g_free(rh->remote_host);
- g_free(rh);
- return FALSE;
- }
- rh->auth_type = CAPTURE_AUTH_NULL;
- valp = valp->next;
-
- if (valp) {
- /* Found value 2, this is the port number */
- rh->remote_port = g_strdup (valp->data);
- valp = valp->next;
- } else {
- /* Did not find a port number */
- rh->remote_port = g_strdup ("");
- }
-
- if (valp) {
- /* Found value 3, this is the authentication type */
- auth_type = strtol(valp->data, &p, 0);
- if (p != valp->data && *p == '\0') {
- rh->auth_type = auth_type;
- }
- }
-
- /* Do not store username and password */
- rh->auth_username = g_strdup ("");
- rh->auth_password = g_strdup ("");
-
- prefs_clear_string_list(vals);
-
- g_hash_table_insert (remote_host_list, g_strdup(rh->remote_host), rh);
-
- return TRUE;
-}
-
#endif /* HAVE_PCAP_REMOTE */
#if defined(HAVE_PCAP_OPEN_DEAD) && defined(HAVE_BPF_IMAGE)
@@ -3667,6 +3578,14 @@ pipe_sel_list_cb(GtkTreeSelection *sel, gpointer data _U_)
static void
cancel_pipe_cb (gpointer w _U_)
{
+#ifdef HAVE_PCAP_REMOTE
+ GtkWidget *remote_w;
+ if (interface_management_w && G_IS_OBJECT(interface_management_w)) {
+ remote_w = g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
+ }
+ if (remote_w != NULL && G_IS_OBJECT(remote_w))
+ window_destroy(remote_w);
+#endif
window_destroy(GTK_WIDGET(interface_management_w));
pipe_name = NULL;
}
@@ -4623,12 +4542,6 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
gtk_container_set_border_width(GTK_CONTAINER(capture_vb), DLG_OUTER_MARGIN);
gtk_container_add(GTK_CONTAINER(capture_fr), capture_vb);
-#if defined (HAVE_PCAP_REMOTE)
- if (remote_host_list == NULL) {
- remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
- }
-#endif
-
swindow = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_size_request(swindow, 676, 100);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swindow), GTK_SHADOW_IN);
@@ -5829,7 +5742,6 @@ capture_prep_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
GtkWidget *fs;
#ifdef HAVE_PCAP_REMOTE
GList *if_list;
- GtkWidget *remote_w = NULL;
#endif
if (!cap_open_w || !G_IS_OBJECT(cap_open_w))
@@ -5858,14 +5770,6 @@ capture_prep_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
if (airpcap_if_active)
airpcap_set_toolbar_stop_capture(airpcap_if_active);
#endif
-
-#ifdef HAVE_PCAP_REMOTE
- if (interface_management_w && G_IS_OBJECT(interface_management_w)) {
- remote_w = g_object_get_data(G_OBJECT(interface_management_w), E_CAP_REMOTE_DIALOG_PTR_KEY);
- }
- if (remote_w != NULL)
- window_destroy(remote_w);
-#endif
}
diff --git a/ui/gtk/capture_dlg.h b/ui/gtk/capture_dlg.h
index 812ce8528f..d6cf21b6b6 100644
--- a/ui/gtk/capture_dlg.h
+++ b/ui/gtk/capture_dlg.h
@@ -75,16 +75,6 @@ void capture_restart_cb(GtkWidget *widget, gpointer data);
void
capture_air_cb(GtkWidget *widget, 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 */
-};
-#endif
-
gboolean
capture_dlg_window_present(void);
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 0e01ac0fde..c58063e66f 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -31,7 +31,6 @@ set(WIRESHARK_QT_HEADERS
capture_filter_edit.h
capture_filter_syntax_worker.h
capture_info_dialog.h
- capture_interface_dialog.h
capture_interfaces_dialog.h
capture_preferences_frame.h
color_dialog.h
@@ -113,7 +112,6 @@ set(WIRESHARK_QT_SRC
capture_filter_edit.cpp
capture_filter_syntax_worker.cpp
capture_info_dialog.cpp
- capture_interface_dialog.cpp
capture_interfaces_dialog.cpp
color_dialog.cpp
color_utils.cpp
diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common
index 5c80ae8dbe..75157073c9 100644
--- a/ui/qt/Makefile.common
+++ b/ui/qt/Makefile.common
@@ -117,7 +117,6 @@ MOC_HDRS = \
capture_filter_edit.h \
capture_filter_syntax_worker.h \
capture_info_dialog.h \
- capture_interface_dialog.h \
capture_interfaces_dialog.h \
color_dialog.h \
color_utils.h \
@@ -295,7 +294,6 @@ WIRESHARK_QT_SRC = \
capture_filter_edit.cpp \
capture_filter_syntax_worker.cpp \
capture_info_dialog.cpp \
- capture_interface_dialog.cpp \
capture_interfaces_dialog.cpp \
color_dialog.cpp \
color_utils.cpp \
diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro
index f9a447b57e..b992f773f3 100644
--- a/ui/qt/QtShark.pro
+++ b/ui/qt/QtShark.pro
@@ -536,7 +536,6 @@ HEADERS += \
capture_filter_edit.h \
capture_filter_syntax_worker.h \
capture_info_dialog.h \
- capture_interface_dialog.h \
color_dialog.h \
color_utils.h \
display_filter_combo.h \
@@ -579,7 +578,6 @@ SOURCES += \
capture_filter_edit.cpp \
capture_filter_syntax_worker.cpp \
capture_info_dialog.cpp \
- capture_interface_dialog.cpp \
capture_interfaces_dialog.cpp \
capture_preferences_frame.cpp \
color_dialog.cpp \
diff --git a/ui/qt/capture_interface_dialog.cpp b/ui/qt/capture_interface_dialog.cpp
deleted file mode 100644
index 9919ecb70b..0000000000
--- a/ui/qt/capture_interface_dialog.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/* capture_interface_dialog.cpp
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "capture_interface_dialog.h"
-
-#ifdef HAVE_PCAP_REMOTE
-
-#include "qt_ui_utils.h"
-
-#include "ui/recent.h"
-#include "ui/recent_utils.h"
-
-#include "capture_opts.h"
-
-#include <epan/prefs.h>
-
-#include <QHash>
-
-QHash<QString, remote_host_t *> remote_host_list;
-
-// xxx - copied from capture_dlg.c
-void
-capture_remote_combo_recent_write_all(FILE *rf)
-{
- remote_host_t *rh;
- foreach (rh, remote_host_list) {
- fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", rh->remote_host, rh->remote_port, rh->auth_type);
- }
-}
-
-gboolean
-capture_remote_combo_add_recent(const gchar *s)
-{
- GList *vals = prefs_get_string_list (s);
- GList *valp = vals;
- struct remote_host_t *rh;
- gint auth_type;
- char *p;
-
- if (valp == NULL)
- return FALSE;
-
- if (strlen((const gchar*) valp->data) == 0)
- /* Empty remote host */
- return FALSE;
-
- rh = g_new (remote_host_t, 1);
-
- /* First value is the host */
- rh->remote_host = g_strdup ((const gchar *) valp->data);
- rh->auth_type = CAPTURE_AUTH_NULL;
- valp = valp->next;
-
- if (valp) {
- /* Found value 2, this is the port number */
- rh->remote_port = g_strdup ((const gchar *) valp->data);
- valp = valp->next;
- } else {
- /* Did not find a port number */
- rh->remote_port = g_strdup ("");
- }
-
- if (valp) {
- /* Found value 3, this is the authentication type */
- auth_type = strtol((const gchar *) valp->data, &p, 0);
- if (p != valp->data && *p == '\0') {
- rh->auth_type = auth_type;
- }
- }
-
- /* Do not store username and password */
- rh->auth_username = g_strdup ("");
- rh->auth_password = g_strdup ("");
-
- prefs_clear_string_list(vals);
-
- remote_host_list.insert(QString::fromUtf8(rh->remote_host), rh);
-
- return TRUE;
-}
-#endif /* HAVE_PCAP_REMOTE */
-
-CaptureInterfaceDialog::CaptureInterfaceDialog(QWidget *parent) :
- QDialog(parent)
-{
-}
-
-/*
- * Editor modelines
- *
- * Local Variables:
- * c-basic-offset: 4
- * tab-width: 8
- * indent-tabs-mode: nil
- * End:
- *
- * ex: set shiftwidth=4 tabstop=8 expandtab:
- * :indentSize=4:tabSize=8:noTabs=true:
- */
diff --git a/ui/qt/capture_interface_dialog.h b/ui/qt/capture_interface_dialog.h
deleted file mode 100644
index 53cee2f644..0000000000
--- a/ui/qt/capture_interface_dialog.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* capture_interface_dialog.h
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef CAPTURE_INTERFACE_DIALOG_H
-#define CAPTURE_INTERFACE_DIALOG_H
-
-#include "config.h"
-
-#include <QDialog>
-
-class CaptureInterfaceDialog : public QDialog
-{
- Q_OBJECT
-public:
- explicit CaptureInterfaceDialog(QWidget *parent = 0);
-
-signals:
-
-public slots:
-
-};
-
-#endif // CAPTURE_INTERFACE_DIALOG_H
-
-/*
- * Editor modelines
- *
- * Local Variables:
- * c-basic-offset: 4
- * tab-width: 8
- * indent-tabs-mode: nil
- * End:
- *
- * ex: set shiftwidth=4 tabstop=8 expandtab:
- * :indentSize=4:tabSize=8:noTabs=true:
- */
diff --git a/ui/recent.c b/ui/recent.c
index efbc598feb..e25cb78b23 100644
--- a/ui/recent.c
+++ b/ui/recent.c
@@ -29,6 +29,7 @@
#include <ctype.h>
#include <errno.h>
+#include "capture_opts.h"
#include <epan/epan.h>
#include <wsutil/filesystem.h>
#include <epan/emem.h>
@@ -365,6 +366,134 @@ recent_add_cfilter(const gchar *ifname, const gchar *s)
g_hash_table_insert(per_interface_cfilter_lists_hash, g_strdup(ifname), cfilter_list);
}
+#ifdef HAVE_PCAP_REMOTE
+static GHashTable *remote_host_list=NULL;
+
+int recent_get_remote_host_list_size()
+{
+ return g_hash_table_size (remote_host_list);
+}
+
+void recent_add_remote_host(gchar *host, struct remote_host *rh)
+{
+ if (remote_host_list == NULL) {
+ remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+ g_hash_table_insert (remote_host_list, g_strdup(host), rh);
+}
+
+static gboolean
+free_remote_host (gpointer key _U_, gpointer value, gpointer user _U_)
+{
+ struct remote_host *rh = value;
+
+ g_free (rh->r_host);
+ g_free (rh->remote_port);
+ g_free (rh->auth_username);
+ g_free (rh->auth_password);
+
+ return TRUE;
+}
+
+GHashTable *get_remote_host_list()
+{
+ return remote_host_list;
+}
+
+static void
+recent_print_remote_host (gpointer key _U_, gpointer value, gpointer user)
+{
+ FILE *rf = user;
+ struct remote_host_info *ri = value;
+
+ fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", ri->remote_host, ri->remote_port, ri->auth_type);
+}
+
+void
+capture_remote_combo_recent_write_all(FILE *rf)
+{
+ if (remote_host_list && g_hash_table_size (remote_host_list) > 0) {
+ /* Write all remote interfaces to the recent file */
+ g_hash_table_foreach (remote_host_list, recent_print_remote_host, rf);
+ }
+}
+
+
+void free_remote_host_list()
+{
+ g_hash_table_foreach_remove(remote_host_list, free_remote_host, NULL);
+}
+
+struct remote_host *
+recent_get_remote_host(const gchar *host)
+{
+ if (host == NULL)
+ return NULL;
+ if (remote_host_list == NULL) {
+ /* No such host exist. */
+ return NULL;
+ }
+ return (struct remote_host *)g_hash_table_lookup(remote_host_list, host);
+}
+
+gboolean
+capture_remote_combo_add_recent(const gchar *s)
+{
+ GList *vals = prefs_get_string_list (s);
+ GList *valp = vals;
+ gint auth_type;
+ char *p;
+ struct remote_host *rh;
+
+ if (valp == NULL)
+ return FALSE;
+
+ if (remote_host_list == NULL) {
+ remote_host_list = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+
+ rh = g_malloc (sizeof (*rh));
+
+ /* First value is the host */
+ rh->r_host = g_strdup (valp->data);
+ if (strlen(rh->r_host) == 0) {
+ /* Empty remote host */
+ g_free(rh->r_host);
+ g_free(rh);
+ return FALSE;
+ }
+ rh->auth_type = CAPTURE_AUTH_NULL;
+ valp = valp->next;
+
+ if (valp) {
+ /* Found value 2, this is the port number */
+ rh->remote_port = g_strdup (valp->data);
+ valp = valp->next;
+ } else {
+ /* Did not find a port number */
+ rh->remote_port = g_strdup ("");
+ }
+
+ if (valp) {
+ /* Found value 3, this is the authentication type */
+ auth_type = strtol(valp->data, &p, 0);
+ if (p != valp->data && *p == '\0') {
+ rh->auth_type = auth_type;
+ }
+ }
+
+ /* Do not store username and password */
+ rh->auth_username = g_strdup ("");
+ rh->auth_password = g_strdup ("");
+
+ prefs_clear_string_list(vals);
+
+ g_hash_table_insert (remote_host_list, g_strdup(rh->r_host), rh);
+
+ return TRUE;
+}
+#endif
+
static void
cfilter_recent_write_all_list(FILE *rf, const gchar *ifname, GList *cfilter_list)
{
diff --git a/ui/recent.h b/ui/recent.h
index 8261ef0845..bc7aa92771 100644
--- a/ui/recent.h
+++ b/ui/recent.h
@@ -29,7 +29,7 @@ extern "C" {
#endif /* __cplusplus */
#include <glib.h>
-
+#include <stdio.h>
#include "epan/timestamp.h"
#include "ui/ui_util.h"
@@ -196,6 +196,56 @@ extern GList *recent_get_cfilter_list(const gchar *ifname);
*/
extern void recent_add_cfilter(const gchar *ifname, const gchar *s);
+/**
+ * Get the value of a remote host from the remote_host_list.
+ *
+ * @param host Host's address
+ */
+extern struct remote_host *recent_get_remote_host(const gchar *host);
+
+/**
+ * Get the number of entries of the remote_host_list.
+ *
+ * @return size of the hash table
+ */
+extern int recent_get_remote_host_list_size();
+
+/**
+ * Get the pointer of the remote_host_list.
+ *
+ * @return Pointer to the hash table
+ */
+extern GHashTable *get_remote_host_list();
+
+/**
+ * Free all entries of the remote_host_list.
+ *
+ */
+extern void free_remote_host_list();
+
+/**
+ * Add an entry to the remote_host_list.
+ *
+ * @param host Key of the entry
+ * @param rh Vakue of the entry
+ */
+extern void recent_add_remote_host(gchar *host, struct remote_host *rh);
+
+/**
+ * Fill the remote_host_list with the entries stored in the 'recent' file.
+ *
+ * @param s String to be filled from the 'recent' file.
+ * @return True, if the list was written successfully, False otherwise.
+ */
+extern gboolean capture_remote_combo_add_recent(const gchar *s);
+
+/**
+ * Write the contents of the remote_host_list to the 'recent' file.
+ *
+ * @param rf File to write to.
+ */
+extern void capture_remote_combo_recent_write_all(FILE *rf);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */