diff options
-rw-r--r-- | CMakeLists.txt | 11 | ||||
-rw-r--r-- | cmakeconfig.h.in | 6 | ||||
-rw-r--r-- | tcpdump.c | 7 |
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 @@ -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, |