aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2015-04-10 19:04:22 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2015-04-13 17:43:40 +0000
commit2e8d8e12cdc490488b8dc221f430f62dc7ad171c (patch)
tree0c09b8c35858424a9a4a60036688f8730decaa51
parent9ea521532ee7fdf7c8962817592bb3d64723deb6 (diff)
dumpcap: fix opening of pipes on Windows broken since gbed29af
Previous code was assuming that all local pipes were of extcap type. Let's explicitly check for extcap prefix now. Bug: 10803 Change-Id: If955e77a9ee2af11b553740269964c40273d5177 Reviewed-on: https://code.wireshark.org/review/8013 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
-rw-r--r--dumpcap.c18
-rw-r--r--extcap.c3
-rw-r--r--extcap.h3
3 files changed, 20 insertions, 4 deletions
diff --git a/dumpcap.c b/dumpcap.c
index 9e59956a41..80eecd37e0 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -163,6 +163,10 @@
#include "caputils/ws80211_utils.h"
+#ifdef HAVE_EXTCAP
+#include "extcap.h"
+#endif
+
/*
* Get information about libpcap format from "wiretap/libpcap.h".
* XXX - can we just use pcap_open_offline() to read the pipe?
@@ -2045,6 +2049,10 @@ cap_pipe_open_live(char *pipename,
char *pncopy, *pos;
wchar_t *err_str;
interface_options interface_opts;
+#ifdef HAVE_EXTCAP
+ char* extcap_pipe_name;
+ gboolean extcap_pipe;
+#endif
#endif
ssize_t b;
int fd = -1, sel_ret;
@@ -2054,6 +2062,7 @@ cap_pipe_open_live(char *pipename,
#ifdef _WIN32
pcap_opts->cap_pipe_h = INVALID_HANDLE_VALUE;
#endif
+
g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "cap_pipe_open_live: %s", pipename);
/*
@@ -2181,13 +2190,20 @@ cap_pipe_open_live(char *pipename,
}
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, 0);
+#ifdef HAVE_EXTCAP
+ extcap_pipe_name = g_strconcat("\\\\.\\pipe\\", EXTCAP_PIPE_PREFIX, NULL);
+ extcap_pipe = strstr(interface_opts.name, extcap_pipe_name) ? TRUE : FALSE;
+ g_free(extcap_pipe_name);
+#endif
/* Wait for the pipe to appear */
while (1) {
- if(strncmp(interface_opts.name,"\\\\.\\pipe\\",9)== 0)
+#ifdef HAVE_EXTCAP
+ if(extcap_pipe)
pcap_opts->cap_pipe_h = GetStdHandle(STD_INPUT_HANDLE);
else
+#endif
pcap_opts->cap_pipe_h = CreateFile(utf_8to16(pipename), GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, NULL);
diff --git a/extcap.c b/extcap.c
index 82ae1fe8ca..6d9a5e5aed 100644
--- a/extcap.c
+++ b/extcap.c
@@ -62,9 +62,6 @@ static HANDLE pipe_h = NULL;
*/
static GHashTable *ifaces = NULL;
-/* Prefix for the pipe interfaces */
-#define EXTCAP_PIPE_PREFIX "wireshark_extcap"
-
/* Callback definition for extcap_foreach */
typedef gboolean (*extcap_cb_t)(const gchar *extcap, gchar *output, void *data,
gchar **err_str);
diff --git a/extcap.h b/extcap.h
index 66c88664dd..259c088d89 100644
--- a/extcap.h
+++ b/extcap.h
@@ -37,6 +37,9 @@
#ifdef HAVE_EXTCAP
+/* Prefix for the pipe interfaces */
+#define EXTCAP_PIPE_PREFIX "wireshark_extcap"
+
#define EXTCAP_ARGUMENT_CONFIG "--extcap-config"
#define EXTCAP_ARGUMENT_LIST_INTERFACES "--extcap-interfaces"
#define EXTCAP_ARGUMENT_INTERFACE "--extcap-interface"