PcapPlusPlus: enhance platform support and fix missing syslink on Windows (#5419)

* Add test to detect missing iphlpapi linkage on Windows

* Add the required iphlpapi linkage for Windows

* Add support for Mingw

* Simplify platform check

* Add MacOS, Android and BSD

* Add frameworks for MacOS

* accurate MacOS framework

* Fix complie issue on BSD caused by VLA usage

* Fix patch file name

* Add pthread syslink for Linux and BSD platforms
autoupdate-croaring-v4.2.1
Doekin 2 months ago committed by GitHub
parent 8fbf38d4ba
commit 98a37fb428
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 23
      packages/p/pcapplusplus/patches/v24.09/vla.patch
  2. 26
      packages/p/pcapplusplus/xmake.lua

@ -0,0 +1,23 @@
diff --git a/Pcap++/src/PcapLiveDevice.cpp b/Pcap++/src/PcapLiveDevice.cpp
index 7ac0f79e..5faa7c4d 100644
--- a/Pcap++/src/PcapLiveDevice.cpp
+++ b/Pcap++/src/PcapLiveDevice.cpp
@@ -1011,15 +1011,15 @@ namespace pcpp
return;
}
- uint8_t buf[len];
+ std::vector<uint8_t> buf(len);
- if (sysctl(mib, 6, buf, &len, nullptr, 0) < 0)
+ if (sysctl(mib, 6, buf.data(), &len, nullptr, 0) < 0)
{
PCPP_LOG_DEBUG("Error in retrieving MAC address: sysctl 2 error");
return;
}
- struct if_msghdr* ifm = (struct if_msghdr*)buf;
+ struct if_msghdr* ifm = (struct if_msghdr*)buf.data();
struct sockaddr_dl* sdl = (struct sockaddr_dl*)(ifm + 1);
uint8_t* ptr = (uint8_t*)LLADDR(sdl);
m_MacAddress = MacAddress(ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);

@ -9,22 +9,28 @@ package("pcapplusplus")
add_versions("v24.09", "0a9d80d09a906c08a1df5f5a937134355c7cb3fc8a599bf1a0f10002cf0285be")
add_versions("v23.09", "f2b92d817df6138363be0d144a61716f8ecc43216f0008135da2e0e15727d35a")
add_patches("v24.09", "patches/v24.09/vla.patch", "8c380468c78118b6d85f6b3856cd49c4d890fd326dde3400b8c47c01c885cef4")
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
add_links("Pcap++", "Packet++", "Common++")
if is_plat("windows") then
add_syslinks("ws2_32")
if is_plat("windows", "mingw") then
add_syslinks("ws2_32", "iphlpapi")
elseif is_plat("macosx") then
add_frameworks("CoreFoundation", "SystemConfiguration")
elseif is_plat("linux", "bsd") then
add_syslinks("pthread")
end
add_deps("cmake")
if is_plat("windows") then
if is_plat("windows", "mingw") then
add_deps("npcap_sdk")
elseif is_plat("linux") then
elseif is_plat("linux", "macosx", "android", "bsd") then
add_deps("libpcap")
end
on_install("windows", "linux", function (package)
on_install("windows", "mingw", "linux", "macosx", "android", "bsd", function (package)
local configs = {
"-DPCAPPP_BUILD_EXAMPLES=OFF",
"-DPCAPPP_BUILD_TESTS=OFF",
@ -35,11 +41,19 @@ package("pcapplusplus")
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <vector>
#include "pcapplusplus/IPv4Layer.h"
#include "pcapplusplus/Packet.h"
#include "pcapplusplus/PcapFileDevice.h"
void test() {
#include "pcapplusplus/PcapLiveDeviceList.h"
void testPcapFileReaderDevice() {
pcpp::PcapFileReaderDevice reader("1_packet.pcap");
}
void testPcapLiveDeviceList() {
std::vector<pcpp::PcapLiveDevice *> devList =
pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
}
]]}, {configs = {languages = "c++17"}}))
end)

Loading…
Cancel
Save