pcapplusplus: add new recipe
RFC PATCH 1/1 pcapplusplus: add new recipe
"A multiplatform C++ library for capturing, parsing and crafting of network packets"
PcapPlusPlus uses as custom build system (shell script + Makefile). There were attempts for using cmake but this work has never been finished.
---
v1 --> RFC:
------------
- move to Clément Péron's fork [branch: cmake-ng]
- change recipe to cmake
- add patch for -Wnarrowing warnings/errors
- build shared libraries
- remove RDEPENDS:${PN}-dev (main pkg contains now shared libs)
- add -Wno-psabi to CXXFLAGS
This is the 2nd attempt to move the build system of PcapPlusPlus to CMake. I highly suppose that this will get merged soon.
...-Fix-timeval-to-timespec-conversions.patch | 58 +++++++++++++++++++ .../pcapplusplus/pcapplusplus_21.11.bb | 33 +++++++++++ 2 files changed, 91 insertions(+) create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch new file +58 -0
@@ -0,0 +1,58 @@ +From 740971bb451e1147e19a1b0498436d2332b01293 Mon Sep 17 00:00:00 2001 +From: Christian Eggers <[email protected]> +Date: Mon, 21 Feb 2022 13:53:49 +0100 +Subject: [PATCH] Fix timeval-to-timespec conversions + +Time values returned by gettimeofday() have microseconds in +timeval::tv_usec while timespec::ts_nsec is nanoseconds. + +timeval::tv_usec is 64 bit (at least on some platforms), while +timespec::tv_nsec is always 'long'. An explicit cast is required to +avoid -Wnarrowing warnings/errors. + +Upstream-Status: Submitted [https://github.com/seladb/PcapPlusPlus/pull/814] + +Signed-off-by: Christian Eggers <[email protected]> +--- + Pcap++/src/NetworkUtils.cpp | 4 ++-- + Pcap++/src/PcapFileDevice.cpp | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/Pcap++/src/NetworkUtils.cpp b/Pcap++/src/NetworkUtils.cpp +index bdbf87f4c380..749853927ecd 100644 +--- a/Pcap++/src/NetworkUtils.cpp ++++ b/Pcap++/src/NetworkUtils.cpp +@@ -169,7 +169,7 @@ MacAddress NetworkUtils::getMacAddress(IPv4Address ipAddr, PcapLiveDevice* devic + // create the timeout + timespec timeout = { + now.tv_sec + arpTimeout, +- now.tv_usec ++ static_cast<long>(now.tv_usec * 1000) + }; + + // start capturing. The capture is done on another thread, hence "arpPacketRecieved" is running on that thread +@@ -436,7 +436,7 @@ IPv4Address NetworkUtils::getIPv4Address(std::string hostname, PcapLiveDevice* d + // create the timeout + timespec timeout = { + now.tv_sec + dnsTimeout, +- now.tv_usec ++ static_cast<long>(now.tv_usec * 1000) + }; + + // start capturing. The capture is done on another thread, hence "dnsResponseRecieved" is running on that thread +diff --git a/Pcap++/src/PcapFileDevice.cpp b/Pcap++/src/PcapFileDevice.cpp +index 6bf04c1dd31a..256554407c50 100644 +--- a/Pcap++/src/PcapFileDevice.cpp ++++ b/Pcap++/src/PcapFileDevice.cpp +@@ -188,7 +188,7 @@ bool PcapFileReaderDevice::getNextPacket(RawPacket& rawPacket) + uint8_t* pMyPacketData = new uint8_t[pkthdr.caplen]; + memcpy(pMyPacketData, pPacketData, pkthdr.caplen); + #if defined(PCAP_TSTAMP_PRECISION_NANO) +- timespec ts = { pkthdr.ts.tv_sec, pkthdr.ts.tv_usec }; //because we opened with nano second precision 'tv_usec' is actually nanos ++ timespec ts = { pkthdr.ts.tv_sec, static_cast<long>(pkthdr.ts.tv_usec) }; //because we opened with nano second precision 'tv_usec' is actually nanos + #else + struct timeval ts = pkthdr.ts; + #endif +-- +2.34.1 +
meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb new file +33 -0
@@ -0,0 +1,33 @@ +SUMMARY = "A multiplatform C++ library for capturing, parsing and crafting of network packets" +HOMEPAGE = "https://pcapplusplus.github.io/" +BUGTRACKER = "https://github.com/seladb/PcapPlusPlus/issues" +SECTION = "libs/network" +LICENSE = "Unlicense" +LIC_FILES_CHKSUM = "file://LICENSE;md5=911690f51af322440237a253d695d19f" + +DEPENDS = "libpcap" + +PV = "git${SRCPV}" + +# master branch with hand-crafted build system +#SRC_URI = "git://github.com/seladb/PcapPlusPlus.git;protocol=https;branch=master" + +# cmake-ng branch +SRC_URI = " \ + git://github.com/clementperon/PcapPlusPlus.git;protocol=https;branch=cmake-ng \ + file://0001-Fix-timeval-to-timespec-conversions.patch \ + " +SRCREV = "1360d0ed91640daf90b3713a4574b8b369990bb3" + +S = "${WORKDIR}/git" + +inherit cmake + +# When 'zstd' is not selected, cmake findPackage() finds files from zstd-native. +# They are not used, but is there a way to avoid this? +PACKAGECONFIG ??= "" +PACKAGECONFIG[zstd] = "-DLIGHT_PCAPNG_ZSTD=true,-DLIGHT_PCAPNG_ZSTD=false,zstd" + +EXTRA_OECMAKE:append = " -DBUILD_SHARED_LIBS=ON" +# get rid of "note: parameter passing for argument of type 'xxx' changed in GCC 7.1" +CXXFLAGS:append = " -Wno-psabi"
Signature · 1 line
2.34.1
https://errors.yoctoproject.org/Errors/Details/636127/
Quoted 143 lines · Christian Eggers
"A multiplatform C++ library for capturing, parsing and crafting of network packets"
PcapPlusPlus uses as custom build system (shell script +
Makefile). There were attempts for using cmake but this work has never been finished.Signed-off-by Christian Eggers <[email protected]>---
v1 --> RFC:
------------
- move to Clément Péron's fork [branch: cmake-ng]
- change recipe to cmake
- add patch for -Wnarrowing warnings/errors
- build shared libraries
- remove RDEPENDS:${PN}-dev (main pkg contains now shared libs)
- add -Wno-psabi to CXXFLAGSThis is the 2nd attempt to move the build system of PcapPlusPlus to CMake. I highly suppose that this will get merged soon.
...-Fix-timeval-to-timespec-conversions.patch | 58 +++++++++++++++++++ .../pcapplusplus/pcapplusplus_21.11.bb | 33 +++++++++++ 2 files changed, 91 insertions(+) create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch create mode 100644 meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bbmeta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch new file +58
-0@@ -0,0 +1,58 @@ +From 740971bb451e1147e19a1b0498436d2332b01293 Mon Sep 17 00:00:00 2001 +From: Christian Eggers <[email protected]> +Date: Mon, 21 Feb 2022 13:53:49 +0100 +Subject: [PATCH] Fix timeval-to-timespec conversions + +Time values returned by gettimeofday() have microseconds in +timeval::tv_usec while timespec::ts_nsec is nanoseconds. + +timeval::tv_usec is 64 bit (at least on some platforms), while +timespec::tv_nsec is always 'long'. An explicit cast is required to +avoid -Wnarrowing warnings/errors. + +Upstream-Status: Submitted [https://github.com/seladb/PcapPlusPlus/pull/814] + +Signed-off-by: Christian Eggers <[email protected]> +--- + Pcap++/src/NetworkUtils.cpp | 4 ++-- + Pcap++/src/PcapFileDevice.cpp | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/Pcap++/src/NetworkUtils.cpp b/Pcap++/src/NetworkUtils.cpp +index bdbf87f4c380..749853927ecd 100644 +--- a/Pcap++/src/NetworkUtils.cpp ++++ b/Pcap++/src/NetworkUtils.cpp +@@ -169,7 +169,7 @@ MacAddress NetworkUtils::getMacAddress(IPv4Address ipAddr, PcapLiveDevice* devic + // create the timeout + timespec timeout = { + now.tv_sec + arpTimeout, +- now.tv_usec ++ static_cast<long>(now.tv_usec * 1000) + }; + + // start capturing. The capture is done on another thread, hence "arpPacketRecieved" is running on that thread +@@ -436,7 +436,7 @@ IPv4Address NetworkUtils::getIPv4Address(std::string hostname, PcapLiveDevice* d + // create the timeout + timespec timeout = { + now.tv_sec + dnsTimeout, +- now.tv_usec ++ static_cast<long>(now.tv_usec * 1000) + }; + + // start capturing. The capture is done on another thread, hence "dnsResponseRecieved" is running on that thread +diff --git a/Pcap++/src/PcapFileDevice.cpp b/Pcap++/src/PcapFileDevice.cpp +index 6bf04c1dd31a..256554407c50 100644 +--- a/Pcap++/src/PcapFileDevice.cpp ++++ b/Pcap++/src/PcapFileDevice.cpp +@@ -188,7 +188,7 @@ bool PcapFileReaderDevice::getNextPacket(RawPacket& rawPacket) + uint8_t* pMyPacketData = new uint8_t[pkthdr.caplen]; + memcpy(pMyPacketData, pPacketData, pkthdr.caplen); + #if defined(PCAP_TSTAMP_PRECISION_NANO) +- timespec ts = { pkthdr.ts.tv_sec, pkthdr.ts.tv_usec }; //because we opened with nano second precision 'tv_usec' is actually nanos ++ timespec ts = { pkthdr.ts.tv_sec, static_cast<long>(pkthdr.ts.tv_usec) }; //because we opened with nano second precision 'tv_usec' is actually nanos + #else + struct timeval ts = pkthdr.ts; + #endif +-- +2.34.1 +meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb new file +33
-1@@ -0,0 +1,33 @@ +SUMMARY = "A multiplatform C++ library for capturing, parsing and crafting of network packets" +HOMEPAGE = "https://pcapplusplus.github.io/" +BUGTRACKER = "https://github.com/seladb/PcapPlusPlus/issues" +SECTION = "libs/network" +LICENSE = "Unlicense" +LIC_FILES_CHKSUM = "file://LICENSE;md5=911690f51af322440237a253d695d19f" + +DEPENDS = "libpcap" + +PV = "git${SRCPV}" + +# master branch with hand-crafted build system +#SRC_URI = "git://github.com/seladb/PcapPlusPlus.git;protocol=https;branch=master" + +# cmake-ng branch +SRC_URI = " \ + git://github.com/clementperon/PcapPlusPlus.git;protocol=https;branch=cmake-ng \ + file://0001-Fix-timeval-to-timespec-conversions.patch \ + " +SRCREV = "1360d0ed91640daf90b3713a4574b8b369990bb3" + +S = "${WORKDIR}/git" + +inherit cmake + +# When 'zstd' is not selected, cmake findPackage() finds files from zstd-native. +# They are not used, but is there a way to avoid this? +PACKAGECONFIG ??= "" +PACKAGECONFIG[zstd] = "-DLIGHT_PCAPNG_ZSTD=true,-DLIGHT_PCAPNG_ZSTD=false,zstd" + +EXTRA_OECMAKE:append = " -DBUILD_SHARED_LIBS=ON" +# get rid of "note: parameter passing for argument of type 'xxx' changed in GCC 7.1" +CXXFLAGS:append = " -Wno-psabi" --2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#95439): https://lists.openembedded.org/g/openembedded-devel/message/95439
Mute This Topic: https://lists.openembedded.org/mt/89312067/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Quoted 13 lines · Khem Raj
https://errors.yoctoproject.org/Errors/Details/636127/
NOTE: Applying patch '0001-Fix-timeval-to-timespec-conversions.patch' (
sources/meta-openembedded/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch)
ERROR: Applying patch '0001-Fix-timeval-to-timespec-conversions.patch' on target directory 'TOPDIR/build/tmp/work/mips32r2-yoe-linux/pcapplusplus/gitAUTOINC+1360d0ed91-r0/git' CmdError('quilt --quiltrc TOPDIR/build/tmp/work/mips32r2-yoe-linux/pcapplusplus/gitAUTOINC+1360d0ed91-r0/recipe-sysroot-native/etc/quiltrc push', 0, 'stdout: Applying patch 0001-Fix-timeval-to-timespec-conversions.patch patching file Pcap++/src/NetworkUtils.cpp
Hunk #1 FAILED at 169 (different line endings).
Hunk #2 FAILED at 436 (different line endings).
2 out of 2 hunks FAILED -- rejects in file Pcap++/src/NetworkUtils.cpp
patching file Pcap++/src/PcapFileDevice.cpp
Hunk #1 FAILED at 188 (different line endings).
1 out of 1 hunk FAILED -- rejects in file Pcap++/src/PcapFileDevice.cpp
Patch 0001-Fix-timeval-to-timespec-conversions.patch does not apply (enforce with -f)
After cloning PcapPlusPlus on my machine, Pcap++/src/PcapFileDevice.cpp has Windows line endings. The patch has the same for changed lines and the context.
Is there an implicit conversion from Windows to Unix line endings on the build machine (e.g. by git)? Are line feeds altered on when sent via git send-email?
For reference, I have a attached the patch file to this email.
regards
Christian
Quoted 20 lines · Christian Eggers
Quoted 13 lines · Khem Raj
https://errors.yoctoproject.org/Errors/Details/636127/
NOTE: Applying patch '0001-Fix-timeval-to-timespec-conversions.patch' (
sources/meta-openembedded/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch)
ERROR: Applying patch '0001-Fix-timeval-to-timespec-conversions.patch' on target directory 'TOPDIR/build/tmp/work/mips32r2-yoe-linux/pcapplusplus/gitAUTOINC+1360d0ed91-r0/git' CmdError('quilt --quiltrc TOPDIR/build/tmp/work/mips32r2-yoe-linux/pcapplusplus/gitAUTOINC+1360d0ed91-r0/recipe-sysroot-native/etc/quiltrc push', 0, 'stdout: Applying patch 0001-Fix-timeval-to-timespec-conversions.patch patching file Pcap++/src/NetworkUtils.cpp
Hunk #1 FAILED at 169 (different line endings).
Hunk #2 FAILED at 436 (different line endings).
2 out of 2 hunks FAILED -- rejects in file Pcap++/src/NetworkUtils.cpp
patching file Pcap++/src/PcapFileDevice.cpp
Hunk #1 FAILED at 188 (different line endings).
1 out of 1 hunk FAILED -- rejects in file Pcap++/src/PcapFileDevice.cpp
Patch 0001-Fix-timeval-to-timespec-conversions.patch does not apply (enforce with -f)After cloning PcapPlusPlus on my machine, Pcap++/src/PcapFileDevice.cpp has Windows line endings. The patch has the same for changed lines and the context.
Quoted 5 lines
Is there an implicit conversion from Windows to Unix line endings on the build machine (e.g. by git)? Are line feeds altered on when sent via
git send-email?For reference, I have a attached the patch file to this email.
maybe inheriting dos2unix would fix this.
Quoted 3 lines
regards
Christian