aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--capture-pcap-util-int.h9
-rw-r--r--capture-pcap-util-unix.c30
-rw-r--r--capture-pcap-util.c40
-rw-r--r--capture-wpcap.c16
-rw-r--r--gtk/capture_dlg.c16
5 files changed, 63 insertions, 48 deletions
diff --git a/capture-pcap-util-int.h b/capture-pcap-util-int.h
index ccdd54dfdb..80a60764e7 100644
--- a/capture-pcap-util-int.h
+++ b/capture-pcap-util-int.h
@@ -29,9 +29,9 @@
#ifdef HAVE_PCAP_REMOTE
#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
+#endif /* HAVE_CONFIG_H */
#include <pcap.h>
-#endif
+#endif /* HAVE_PCAP_REMOTE */
extern if_info_t *if_info_new(char *name, char *description);
extern void if_info_add_address(if_info_t *if_info, struct sockaddr *addr);
@@ -39,10 +39,9 @@ extern void if_info_add_address(if_info_t *if_info, struct sockaddr *addr);
#ifdef HAVE_PCAP_REMOTE
extern GList *get_interface_list_findalldevs_ex(const char *source,
struct pcap_rmtauth *auth, int *err, char **err_str);
-#else
+#endif /* HAVE_PCAP_REMOTE */
extern GList *get_interface_list_findalldevs(int *err, char **err_str);
-#endif
-#endif
+#endif /* HAVE_PCAP_FINDALLDEVS */
/*
* Get an error message string for a CANT_GET_INTERFACE_LIST error from
diff --git a/capture-pcap-util-unix.c b/capture-pcap-util-unix.c
index c1a6720a00..589ac7d744 100644
--- a/capture-pcap-util-unix.c
+++ b/capture-pcap-util-unix.c
@@ -82,10 +82,7 @@ get_remote_interface_list(const char *hostname, const char *port,
struct pcap_rmtauth auth;
char source[PCAP_BUF_SIZE];
char errbuf[PCAP_ERRBUF_SIZE];
-
- auth.type = auth_type;
- auth.username = username;
- auth.password = passwd;
+ GList *result;
if (pcap_createsrcstr(source, PCAP_SRC_IFREMOTE, hostname, port,
NULL, errbuf) == -1) {
@@ -94,7 +91,16 @@ get_remote_interface_list(const char *hostname, const char *port,
*err_str = cant_get_if_list_error_message(errbuf);
return NULL;
}
- return get_interface_list_findalldevs_ex(source, &auth, err, err_str);
+
+ auth.type = auth_type;
+ auth.username = g_strdup(username);
+ auth.password = g_strdup(passwd);
+
+ result = get_interface_list_findalldevs_ex(source, &auth, err, err_str);
+ g_free(auth.username);
+ g_free(auth.password);
+
+ return result;
}
#endif
@@ -102,21 +108,7 @@ GList *
get_interface_list(int *err, char **err_str)
{
#ifdef HAVE_PCAP_FINDALLDEVS
-#ifdef HAVE_PCAP_REMOTE
- char source[PCAP_BUF_SIZE];
- char errbuf[PCAP_ERRBUF_SIZE];
-
- if (pcap_createsrcstr(source, PCAP_SRC_IFLOCAL,
- NULL, NULL, NULL, errbuf) == -1) {
- *err = CANT_GET_INTERFACE_LIST;
- if (err_str != NULL)
- *err_str = cant_get_if_list_error_message(errbuf);
- return NULL;
- }
- return get_interface_list_findalldevs_ex(source, NULL, err, err_str);
-#else
return get_interface_list_findalldevs(err, err_str);
-#endif
#else
GList *il = NULL;
gint nonloopback_pos = 0;
diff --git a/capture-pcap-util.c b/capture-pcap-util.c
index 54c572609a..aeb1153ab4 100644
--- a/capture-pcap-util.c
+++ b/capture-pcap-util.c
@@ -254,21 +254,49 @@ GList *
get_interface_list_findalldevs_ex(const char *source,
struct pcap_rmtauth *auth,
int *err, char **err_str)
-#else
+{
+ GList *il = NULL;
+ pcap_if_t *alldevs, *dev;
+ if_info_t *if_info;
+ char errbuf[PCAP_ERRBUF_SIZE];
+
+ if (pcap_findalldevs_ex((char *)source, auth, &alldevs, errbuf) == -1) {
+ *err = CANT_GET_INTERFACE_LIST;
+ if (err_str != NULL)
+ *err_str = cant_get_if_list_error_message(errbuf);
+ return NULL;
+ }
+
+ if (alldevs == NULL) {
+ /*
+ * No interfaces found.
+ */
+ *err = NO_INTERFACES_FOUND;
+ if (err_str != NULL)
+ *err_str = NULL;
+ return NULL;
+ }
+
+ for (dev = alldevs; dev != NULL; dev = dev->next) {
+ if_info = if_info_new(dev->name, dev->description);
+ il = g_list_append(il, if_info);
+ if_info_ip(if_info, dev);
+ }
+ pcap_freealldevs(alldevs);
+
+ return il;
+}
+#endif
+
GList *
get_interface_list_findalldevs(int *err, char **err_str)
-#endif
{
GList *il = NULL;
pcap_if_t *alldevs, *dev;
if_info_t *if_info;
char errbuf[PCAP_ERRBUF_SIZE];
-#ifdef HAVE_PCAP_REMOTE
- if (pcap_findalldevs_ex((char *)source, auth, &alldevs, errbuf) == -1) {
-#else
if (pcap_findalldevs(&alldevs, errbuf) == -1) {
-#endif
*err = CANT_GET_INTERFACE_LIST;
if (err_str != NULL)
*err_str = cant_get_if_list_error_message(errbuf);
diff --git a/capture-wpcap.c b/capture-wpcap.c
index 90baec774b..400b89f08b 100644
--- a/capture-wpcap.c
+++ b/capture-wpcap.c
@@ -612,29 +612,14 @@ get_remote_interface_list(const char *hostname, const char *port,
GList *
get_interface_list(int *err, char **err_str)
{
-#ifdef HAVE_PCAP_REMOTE
- char source[PCAP_BUF_SIZE];
-#else
GList *il = NULL;
wchar_t *names;
char *win95names;
char ascii_name[MAX_WIN_IF_NAME_LEN + 1];
char ascii_desc[MAX_WIN_IF_NAME_LEN + 1];
int i, j;
-#endif
char errbuf[PCAP_ERRBUF_SIZE];
-#ifdef HAVE_PCAP_REMOTE
- if (p_pcap_createsrcstr(source, PCAP_SRC_IFLOCAL, NULL, NULL,
- NULL, errbuf) == -1) {
- *err = CANT_GET_INTERFACE_LIST;
- if (err_str != NULL)
- *err_str = cant_get_if_list_error_message(errbuf);
- return NULL;
- }
- return get_interface_list_findalldevs_ex(source, NULL, err, err_str);
-#else
-
#ifdef HAVE_PCAP_FINDALLDEVS
if (p_pcap_findalldevs != NULL)
return get_interface_list_findalldevs(err, err_str);
@@ -775,7 +760,6 @@ get_interface_list(int *err, char **err_str)
}
return il;
-#endif /* HAVE_PCAP_REMOTE */
}
/*
diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c
index 66b1d0ed10..52bfaa8be8 100644
--- a/gtk/capture_dlg.c
+++ b/gtk/capture_dlg.c
@@ -288,7 +288,19 @@ set_link_type_list(GtkWidget *linktype_om, GtkWidget *entry)
/*
* Try to get the list of known interfaces.
*/
+#ifdef HAVE_PCAP_REMOTE
+ if (global_capture_opts.src_type == CAPTURE_IFREMOTE)
+ if_list = get_remote_interface_list(global_capture_opts.remote_host,
+ global_capture_opts.remote_port,
+ global_capture_opts.auth_type,
+ global_capture_opts.auth_username,
+ global_capture_opts.auth_password,
+ &err, NULL);
+ else
+ if_list = capture_interface_list(&err, NULL);
+#else
if_list = capture_interface_list(&err, NULL);
+#endif
if (if_list != NULL) {
/*
* We have the list - check it.
@@ -671,7 +683,7 @@ update_interface_list()
global_capture_opts.auth_password,
&err, &err_str);
else
- if_list = get_interface_list(&err, &err_str);
+ if_list = capture_interface_list(&err, &err_str);
if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
@@ -1005,7 +1017,7 @@ capture_prep_cb(GtkWidget *w _U_, gpointer d _U_)
global_capture_opts.auth_password,
&err, &err_str);
else
- if_list = get_interface_list(&err, &err_str);
+ if_list = capture_interface_list(&err, &err_str);
#else
if_list = capture_interface_list(&err, &err_str);
#endif