aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2023-05-25 01:24:39 +0100
committerJoão Valverde <j@v6e.pt>2023-05-26 00:18:59 +0100
commit8dc5d2d3486af6c00baa90704335769fe4a2e1c3 (patch)
tree1c3603cab0a86ff9366db9ee7c2fbdac827ad2ef
parent16b99b0270909ca0a1a9da9be107c0686edbdf91 (diff)
Fedora: Fix cross-compilation with mingw-wpcap
Fix various issues preventing compilation with Fedora's MinGW WinPcap package.
-rw-r--r--capture/capture-pcap-util.c6
-rw-r--r--cmake/modules/FindPCAP.cmake12
-rw-r--r--ui/qt/capture_filter_syntax_worker.cpp3
-rw-r--r--ui/qt/compiled_filter_output.cpp3
4 files changed, 21 insertions, 3 deletions
diff --git a/capture/capture-pcap-util.c b/capture/capture-pcap-util.c
index 191733e20f..d756a09a83 100644
--- a/capture/capture-pcap-util.c
+++ b/capture/capture-pcap-util.c
@@ -75,6 +75,8 @@
#ifndef _WIN32
#include <netinet/in.h>
+#else
+#include <ws2tcpip.h>
#endif
#ifdef _WIN32
@@ -1402,11 +1404,13 @@ open_capture_device_pcap_create(
sizeof *open_status_str);
break;
+#ifdef HAVE_PCAP_ERROR_PROMISC_PERM_DENIED
case PCAP_ERROR_PROMISC_PERM_DENIED:
*open_status = CAP_DEVICE_OPEN_ERROR_PROMISC_PERM_DENIED;
(void) g_strlcpy(*open_status_str, pcap_geterr(pcap_h),
sizeof *open_status_str);
break;
+#endif
case PCAP_ERROR_RFMON_NOTSUP:
*open_status = CAP_DEVICE_OPEN_ERROR_RFMON_NOTSUP;
@@ -1448,11 +1452,13 @@ open_capture_device_pcap_create(
sizeof *open_status_str);
break;
+#ifdef HAVE_PCAP_WARNING_TSTAMP_TYPE_NOTSUP
case PCAP_WARNING_TSTAMP_TYPE_NOTSUP:
*open_status = CAP_DEVICE_OPEN_WARNING_TSTAMP_TYPE_NOTSUP;
(void) g_strlcpy(*open_status_str, pcap_geterr(pcap_h),
sizeof *open_status_str);
break;
+#endif
case PCAP_WARNING:
*open_status = CAP_DEVICE_OPEN_WARNING_OTHER;
diff --git a/cmake/modules/FindPCAP.cmake b/cmake/modules/FindPCAP.cmake
index 0dec6edf8d..7e5f4fce1c 100644
--- a/cmake/modules/FindPCAP.cmake
+++ b/cmake/modules/FindPCAP.cmake
@@ -105,6 +105,8 @@ find_path(PCAP_INCLUDE_DIR
NAMES
pcap/pcap.h
pcap.h
+ PATH_SUFFIXES
+ wpcap
HINTS
${PC_PCAP_INCLUDE_DIRS}
${PCAP_CONFIG_INCLUDE_DIRS}
@@ -115,12 +117,13 @@ find_path(PCAP_INCLUDE_DIR
# capture\capture-wpcap.c. We don't want to link with pcap.lib since
# that would bring in the non-capturing (null) pcap.dll from the vcpkg
# library.
-if(WIN32)
+if(WIN32 AND NOT CMAKE_CROSSCOMPILING)
set(_pkg_required_vars PCAP_INCLUDE_DIR)
else()
find_library(PCAP_LIBRARY
NAMES
pcap
+ wpcap
HINTS
${PC_PCAP_LIBRARY_DIRS}
${PCAP_CONFIG_LIBRARY_DIRS}
@@ -185,7 +188,7 @@ if(PCAP_FOUND)
include(CheckSymbolExists)
- if(WIN32)
+ if(WIN32 AND NOT CMAKE_CROSSCOMPILING)
#
# Prepopulate some values. WinPcap 3.1 and later, and Npcap, have these
# in their SDK, and compilation checks on Windows can be slow. We check
@@ -238,7 +241,7 @@ if(PCAP_FOUND)
#
check_function_exists( "pcap_setsampling" HAVE_PCAP_SETSAMPLING )
endif( HAVE_PCAP_OPEN )
- endif(WIN32)
+ endif()
if( HAVE_PCAP_CREATE )
#
@@ -257,6 +260,9 @@ if(PCAP_FOUND)
set( HAVE_PCAP_REMOTE 1 )
endif()
+ check_symbol_exists(PCAP_ERROR_PROMISC_PERM_DENIED ${PCAP_INCLUDE_DIR}/pcap.h HAVE_PCAP_ERROR_PROMISC_PERM_DENIED)
+ check_symbol_exists(PCAP_WARNING_TSTAMP_TYPE_NOTSUP ${PCAP_INCLUDE_DIR}/pcap.h HAVE_PCAP_WARNING_TSTAMP_TYPE_NOTSUP)
+
cmake_pop_check_state()
endif()
diff --git a/ui/qt/capture_filter_syntax_worker.cpp b/ui/qt/capture_filter_syntax_worker.cpp
index f76df73082..030443945d 100644
--- a/ui/qt/capture_filter_syntax_worker.cpp
+++ b/ui/qt/capture_filter_syntax_worker.cpp
@@ -12,6 +12,9 @@
#ifdef HAVE_LIBPCAP
#include <glib.h>
+#ifdef __MINGW32__
+#include <_bsd_types.h>
+#endif
#include <pcap.h>
#include "capture_opts.h"
diff --git a/ui/qt/compiled_filter_output.cpp b/ui/qt/compiled_filter_output.cpp
index fc64b37c3c..1db9c899be 100644
--- a/ui/qt/compiled_filter_output.cpp
+++ b/ui/qt/compiled_filter_output.cpp
@@ -13,6 +13,9 @@
#include "compiled_filter_output.h"
#ifdef HAVE_LIBPCAP
+#ifdef __MINGW32__
+#include <_bsd_types.h>
+#endif
#include <pcap.h>
#endif