Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,6 @@ jobs:
cd Tests/Packet++Test
Bin/Packet++Test
- name: Test Pcap++
if: env.avx512 == 'true'
run: |
cd Tests/Pcap++Test
Bin/Pcap++Test
- name: Tests skipped (no AVX-512 hardware support)
if: env.avx512 == 'false'
run: echo "Skipping tests since AVX-512 is not supported on the current runner"
Expand Down Expand Up @@ -705,6 +699,43 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

windivert:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0

- name: Install WinPcap
run: |
ci\install_winpcap.bat
echo "PCAP_SDK_DIR=C:\\WpdPack" >> $env:GITHUB_ENV
- name: Set WinDivert root
run: echo "WINDIVERT_DIR=C:\\WinDivert" >> $env:GITHUB_ENV

- name: Install WinDivert
run: ci\install_windivert.bat $env:WINDIVERT_DIR

- name: Configure PcapPlusPlus (WinDivert)
run: cmake -A x64 -G "Visual Studio 17 2022" -DPCAP_ROOT=${{ env.PCAP_SDK_DIR }} -DPCAPPP_USE_WINDIVERT=ON -DWINDIVERT_ROOT=${{ env.WINDIVERT_DIR }} -S . -B "$env:BUILD_DIR"

- name: Build PcapPlusPlus
run: cmake --build $env:BUILD_DIR -j

- name: Install tcpreplay
run: ci\install_tcpreplay.bat

- name: Test PcapPlusPlus
shell: pwsh
run: |
Copy-Item "${{ env.WINDIVERT_DIR }}\x64\WinDivert.dll" "Tests\Pcap++Test\Bin\WinDivert.dll" -Force
Copy-Item "${{ env.WINDIVERT_DIR }}\x64\WinDivert64.sys" "Tests\Pcap++Test\Bin\WinDivert64.sys" -Force
python -m pip install -r ci\run_tests\requirements.txt
python ci\run_tests\run_tests_windows.py --include-tests windivert
freebsd:
runs-on: ubuntu-latest
strategy:
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ cmake_dependent_option(
)
option(PCAPPP_USE_PF_RING "Setup PcapPlusPlus with PF_RING. In this case you must also set PF_RING_ROOT")
option(PCAPPP_USE_XDP "Setup PcapPlusPlus with XDP")
option(PCAPPP_USE_WINDIVERT "Setup PcapPlusPlus with WinDivert")
option(PCAPPP_INSTALL "Install Pcap++" ${PCAPPP_MAIN_PROJECT})
option(PCAPPP_PACKAGE "Package Pcap++ could require a recent version of CMake" OFF)

Expand Down Expand Up @@ -284,6 +285,14 @@ if(PCAPPP_BUILD_PCAPPP)
endif()
add_definitions(-DUSE_XDP)
endif()

if(PCAPPP_USE_WINDIVERT)
find_package(WinDivert REQUIRED)
if(NOT WinDivert_FOUND)
message(FATAL_ERROR "WinDivert not found!")
endif()
Comment on lines +290 to +293
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The required flag on find_package will make the process fail if WinDivert is missing. There is no need for the if not found branch.

add_definitions(-DUSE_WINDIVERT)
endif()
endif()

if(NOT CMAKE_BUILD_TYPE)
Expand Down
6 changes: 6 additions & 0 deletions Pcap++/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ add_library(
$<$<BOOL:${PCAPPP_USE_XDP}>:src/XdpDevice.cpp>
src/RawSocketDevice.cpp
$<$<BOOL:${WIN32}>:src/WinPcapLiveDevice.cpp>
$<$<BOOL:${PCAPPP_USE_WINDIVERT}>:src/WinDivertDevice.cpp>
# Force light pcapng to be link fully static
$<TARGET_OBJECTS:light_pcapng>
)
Expand Down Expand Up @@ -54,6 +55,10 @@ if(PCAPPP_USE_XDP)
list(APPEND public_headers header/XdpDevice.h)
endif()

if(PCAPPP_USE_WINDIVERT)
list(APPEND public_headers header/WinDivertDevice.h)
endif()

if(LINUX)
list(APPEND public_headers header/LinuxNicInformationSocket.h)
endif()
Expand Down Expand Up @@ -97,6 +102,7 @@ target_link_libraries(
$<$<BOOL:${PCAPPP_USE_PF_RING}>:PF_RING::PF_RING>
$<$<BOOL:${PCAPPP_USE_DPDK}>:DPDK::DPDK>
$<$<BOOL:${PCAPPP_USE_XDP}>:BPF::BPF>
$<$<BOOL:${PCAPPP_USE_WINDIVERT}>:WinDivert::WinDivert>
PCAP::PCAP
Threads::Threads
)
Expand Down
Loading
Loading