aboutsummaryrefslogtreecommitdiffstats
path: root/capture_ifinfo.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2011-08-05 07:19:17 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2011-08-05 07:19:17 +0000
commiteaffdfeaaa572bb818f116afb3c63b3d43c153ea (patch)
treec8c59bb819cd73d2b526ae2f3f9406f3d1bd1a93 /capture_ifinfo.c
parent7f895c681b301d23f0f42d8b96114e5b124a42b5 (diff)
Add support for multiple interfaces to the capture options dialog.
Obtained from Irene Ruengeler. svn path=/trunk/; revision=38350
Diffstat (limited to 'capture_ifinfo.c')
-rw-r--r--capture_ifinfo.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/capture_ifinfo.c b/capture_ifinfo.c
index f4dffd4530..be57f02ebd 100644
--- a/capture_ifinfo.c
+++ b/capture_ifinfo.c
@@ -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 */