Fedora: Fix cross-compilation with mingw-wpcap

Fix various issues preventing compilation with Fedora's
MinGW WinPcap package.
This commit is contained in:
João Valverde 2023-05-25 01:24:39 +01:00
parent 16b99b0270
commit 8dc5d2d348
4 changed files with 21 additions and 3 deletions

View File

@ -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;

View File

@ -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()

View File

@ -12,6 +12,9 @@
#ifdef HAVE_LIBPCAP
#include <glib.h>
#ifdef __MINGW32__
#include <_bsd_types.h>
#endif
#include <pcap.h>
#include "capture_opts.h"

View File

@ -13,6 +13,9 @@
#include "compiled_filter_output.h"
#ifdef HAVE_LIBPCAP
#ifdef __MINGW32__
#include <_bsd_types.h>
#endif
#include <pcap.h>
#endif