[meta-oe,RFC] pcapplusplus: add new recipe

Message ID 20220221174242.17760-1-ceggers@arri.de
State New
Headers show
Series [meta-oe,RFC] pcapplusplus: add new recipe | expand

Commit Message

Christian Eggers Feb. 21, 2022, 5:42 p.m. UTC
"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 <ceggers@arri.de>
---
v1 --> RFC:
------------
- move to Clément Péron's fork [branch: cmake-ng]
- change recipe to cmake
- add patch for -Wnarrowing warnings/errors

This is the 2nd attempt to move the build system of PcapPlusPlus to
CMake. Currently there is a QA issue when trying to build a shared
libraries.

 ...-Fix-timeval-to-timespec-conversions.patch | 58 +++++++++++++++++++
 .../pcapplusplus/pcapplusplus_21.11.bb        | 38 ++++++++++++
 2 files changed, 96 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

Comments

Clément Péron Sept. 27, 2023, 8:48 a.m. UTC | #1
Hi Christian,



On Mon, 21 Feb 2022 at 18:43, Christian Eggers <ceggers@arri.de> wrote:

> "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 <ceggers@arri.de>
> ---
> v1 --> RFC:
> ------------
> - move to Clément Péron's fork [branch: cmake-ng]
>

If you are still interested in adding PcapPlusPlus to openEmbedded we have
released a new version (23.09) with CMake support.

If you are no more interested let me know and I will propose a recipe.

Thanks,
Clement



> - change recipe to cmake
> - add patch for -Wnarrowing warnings/errors
>
> This is the 2nd attempt to move the build system of PcapPlusPlus to
> CMake. Currently there is a QA issue when trying to build a shared
> libraries.
>
> ...-Fix-timeval-to-timespec-conversions.patch | 58 +++++++++++++++++++
> .../pcapplusplus/pcapplusplus_21.11.bb | 38 ++++++++++++
> 2 files changed, 96 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
>
> diff --git
> a/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch
> b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch
> new file mode 100644
> index 000000000000..548a0f0ca0e2
> --- /dev/null
> +++
> b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch
> @@ -0,0 +1,58 @@
> +From 740971bb451e1147e19a1b0498436d2332b01293 Mon Sep 17 00:00:00 2001
> +
> _______________________________________________________
> Christian
> Eggers
> Software Engineer
> ARRI
> Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
> Arriweg 17 ,
> 83071
> Stephanskirchen
>
>
> *www.arri.com * <http://www.arri.com/>
> *+49 8036 3009-3118* <+49%208036%203009-3118>
> *CEggers@arri.de* <CEggers@arri.de>
>
> [image: Orbiter Docking Ring]
> <https://www.arri.com/en/lighting/led/orbiter-accessories/orbiter-dockingring/>
> Get all the latest information from *www.arri.com* <http://www.arri.com/>
> , *Facebook* <https://www.facebook.com/TeamARRI>, *Twitter*
> <https://twitter.com/ARRIChannel>, *Instagram* <http://instagram.com/arri>
>  and *YouTube* <http://www.youtube.com/user/ARRIChannel>.
>
> Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
>
> Sitz: München ‑ Registergericht: Amtsgericht München ‑ Handelsregisternummer: HRA 57918
> Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
>
> Sitz: München ‑ Registergericht: Amtsgericht München ‑ Handelsregisternummer: HRB 54477
>
> Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
>
>
> From: Christian Eggers <ceggers@arri.de>
> +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 <ceggers@arri.de>
> +---
> + 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
> +
> diff --git a/meta-oe/recipes-connectivity/pcapplusplus/
> pcapplusplus_21.11.bb b/meta-oe/recipes-connectivity/pcapplusplus/
> pcapplusplus_21.11.bb
> new file mode 100644
> index 000000000000..d7b88dfe2ef7
> --- /dev/null
> +++ b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
> @@ -0,0 +1,38 @@
> +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 = "1525e592596a1f38470488cbacb0d10f2cde5603"
> +
> +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"
> +
> +# ERROR: pcapplusplus-gitAUTOINC+1525e59259-r0 do_package_qa: QA Issue:
> +# -dev package pcapplusplus-dev contains non-symlink .so
> '/usr/lib/libpacket++.so'
> +# -dev package pcapplusplus-dev contains non-symlink .so
> '/usr/lib/libpcap++.so'
> +# -dev package pcapplusplus-dev contains non-symlink .so
> '/usr/lib/libcommon++.so' [dev-elf]
> +#EXTRA_OECMAKE:append = "-DBUILD_SHARED_LIBS=on"
> +
> +# main package is empty
> +ALLOW_EMPTY:${PN} = "1"
> --
> 2.34.1
>
>

Patch

diff --git a/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch
new file mode 100644
index 000000000000..548a0f0ca0e2
--- /dev/null
+++ b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus/0001-Fix-timeval-to-timespec-conversions.patch
@@ -0,0 +1,58 @@ 
+From 740971bb451e1147e19a1b0498436d2332b01293 Mon Sep 17 00:00:00 2001
+
_______________________________________________________
Christian 
Eggers
Software Engineer
​
ARRI
Arnold & Richter Cine Technik GmbH & Co. Betriebs KG 
Arriweg 17, 
83071 
Stephanskirchen
www.arri.com 

+49 8036 3009-3118
CEggers@arri.de

​
Get all the latest information from www.arri.com, Facebook, Twitter, Instagram and YouTube.

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRA 57918
Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRB 54477
Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler

​
From: Christian Eggers <ceggers@arri.de>
+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 <ceggers@arri.de>
+---
+ 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
+
diff --git a/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
new file mode 100644
index 000000000000..d7b88dfe2ef7
--- /dev/null
+++ b/meta-oe/recipes-connectivity/pcapplusplus/pcapplusplus_21.11.bb
@@ -0,0 +1,38 @@ 
+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 = "1525e592596a1f38470488cbacb0d10f2cde5603"
+
+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"
+
+# ERROR: pcapplusplus-gitAUTOINC+1525e59259-r0 do_package_qa: QA Issue:
+# -dev package pcapplusplus-dev contains non-symlink .so '/usr/lib/libpacket++.so'
+# -dev package pcapplusplus-dev contains non-symlink .so '/usr/lib/libpcap++.so'
+# -dev package pcapplusplus-dev contains non-symlink .so '/usr/lib/libcommon++.so' [dev-elf]
+#EXTRA_OECMAKE:append = "-DBUILD_SHARED_LIBS=on"
+
+# main package is empty
+ALLOW_EMPTY:${PN} = "1"