WinPcap 4.1.3 has only wsockinit(); check for both, on Windows.
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
#
/* 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
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,