]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Not all Windows pcaps have pcap_wsockinit().
authorGuy Harris <[email protected]>
Mon, 29 Jan 2018 10:16:13 +0000 (02:16 -0800)
committerGuy Harris <[email protected]>
Mon, 29 Jan 2018 10:16:13 +0000 (02:16 -0800)
WinPcap 4.1.3 has only wsockinit(); check for both, on Windows.

CMakeLists.txt
cmakeconfig.h.in
tcpdump.c

index 848626f5b362aa525664006d990ad3c60b6f2b53..7e2b9db5b55e8c5ee3e40bddbd71420bfd2f89fc 100644 (file)
@@ -593,6 +593,17 @@ check_function_exists(pcap_dump_ftell64 HAVE_PCAP_DUMP_FTELL64)
 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
 #
index 039bc5f319a469fbe6472b90fecf99cd24a2cc06..2d28585e3cdb26785a3ad058926bb62a7866cf06 100644 (file)
 /* 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
 
 /* 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
 
index ddd5551d2e4dac110dd8f6ae35060c58cf4e3d37..b325b28c116b45f05b8ce3e70574c9c8660fa27f 100644 (file)
--- 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,