summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-01-29 02:16:13 -0800
committerGuy Harris <guy@alum.mit.edu>2018-01-29 02:16:13 -0800
commit0fb509808c60edc0ed52ca355306452a4ca91286 (patch)
treeb4d6ccc462edd498010ac0c99de545703cc8d472
parentffe074feba0544bfd67104996b9fb6f13382741d (diff)
downloadtcpdump-0fb509808c60edc0ed52ca355306452a4ca91286.tar.gz
Not all Windows pcaps have pcap_wsockinit().
WinPcap 4.1.3 has only wsockinit(); check for both, on Windows.
-rw-r--r--CMakeLists.txt11
-rw-r--r--cmakeconfig.h.in6
-rw-r--r--tcpdump.c7
3 files changed, 22 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 848626f5..7e2b9db5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -594,6 +594,17 @@ check_function_exists(pcap_open HAVE_PCAP_OPEN)
check_function_exists(pcap_findalldevs_ex HAVE_PCAP_FINDALLDEVS_EX)
#
+# On Windows, check for pcap_wsockinit(); if we don't have it, check for
+# wsockinit().
+#
+if(WIN32)
+ check_function_exists(pcap_wsockinit HAVE_PCAP_WSOCKINIT)
+ if(NOT HAVE_PCAP_WSOCKINIT)
+ check_function_exists(wsockinit HAVE_WSOCKINIT)
+ endif(NOT HAVE_PCAP_WSOCKINIT)
+endif(WIN32)
+
+#
# Check for special debugging functions
#
check_function_exists(pcap_set_parser_debug HAVE_PCAP_SET_PARSER_DEBUG)
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 039bc5f3..2d28585e 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -174,6 +174,9 @@
/* define if libpcap has pcap_version */
#cmakedefine HAVE_PCAP_VERSION 1
+/* Define to 1 if you have the `pcap_wsockinit' function. */
+#cmakedefine HAVE_PCAP_WSOCKINIT 1
+
/* Define to 1 if you have the `pfopen' function. */
#cmakedefine HAVE_PFOPEN 1
@@ -240,6 +243,9 @@
/* Define to 1 if you have the `vsnprintf' function. */
#cmakedefine HAVE_VSNPRINTF 1
+/* Define to 1 if you have the `wsockinit' function. */
+#cmakedefine HAVE_WSOCKINIT 1
+
/* define if libpcap has yydebug */
#cmakedefine HAVE_YYDEBUG 1
diff --git a/tcpdump.c b/tcpdump.c
index ddd5551d..b325b28c 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1346,10 +1346,13 @@ main(int argc, char **argv)
else
ndo->program_name = program_name = argv[0];
-#ifdef _WIN32
+#if defined(HAVE_PCAP_WSOCKINIT)
if (pcap_wsockinit() != 0)
error("Attempting to initialize Winsock failed");
-#endif /* _WIN32 */
+#elif defined(HAVE_WSOCKINIT)
+ if (wsockinit() != 0)
+ error("Attempting to initialize Winsock failed");
+#endif
/*
* On platforms where the CPU doesn't support unaligned loads,