From owner-dev-commits-ports-all@freebsd.org Tue Aug 10 07:47:32 2021 Return-Path: Delivered-To: dev-commits-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2A97C663C66; Tue, 10 Aug 2021 07:47:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GkQ5w0Yg6z3R2s; Tue, 10 Aug 2021 07:47:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF427179FB; Tue, 10 Aug 2021 07:47:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 17A7lV42023470; Tue, 10 Aug 2021 07:47:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17A7lVTh023469; Tue, 10 Aug 2021 07:47:31 GMT (envelope-from git) Date: Tue, 10 Aug 2021 07:47:31 GMT Message-Id: <202108100747.17A7lVTh023469@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 972a2a5984b7 - main - sysutils/usbtop: Fixes for FreeBSD. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 972a2a5984b72965bfe8cbdddeda0953d61610fa Auto-Submitted: auto-generated X-BeenThere: dev-commits-ports-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the ports repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Aug 2021 07:47:32 -0000 The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/ports/commit/?id=972a2a5984b72965bfe8cbdddeda0953d61610fa commit 972a2a5984b72965bfe8cbdddeda0953d61610fa Author: Hans Petter Selasky AuthorDate: 2021-08-10 07:30:00 +0000 Commit: Hans Petter Selasky CommitDate: 2021-08-10 07:47:03 +0000 sysutils/usbtop: Fixes for FreeBSD. Add patches needed for proper operation under FreeBSD. Approved by: yuri (maintainer) --- sysutils/usbtop/files/patch-src_usb__bus.cpp | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/sysutils/usbtop/files/patch-src_usb__bus.cpp b/sysutils/usbtop/files/patch-src_usb__bus.cpp new file mode 100644 index 000000000000..58cb2eb3ede6 --- /dev/null +++ b/sysutils/usbtop/files/patch-src_usb__bus.cpp @@ -0,0 +1,47 @@ +--- src/usb_bus.cpp.orig 2021-08-09 11:19:20 UTC ++++ src/usb_bus.cpp +@@ -28,6 +28,12 @@ + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + ++#ifdef __FreeBSD__ ++#include ++#include ++#include ++#endif ++ + #include + #include + +@@ -41,8 +47,26 @@ usbtop::UsbBus::~UsbBus() + } + } + ++#ifdef __FreeBSD__ + void usbtop::UsbBus::push(const pcap_pkthdr* h, const u_char* bytes) + { ++ const size_t psize = h->len; ++ const double time = (double)h->ts.tv_sec + ((double)h->ts.tv_usec) / 1000000.0; ++ const struct usbpf_pkthdr *up = (const struct usbpf_pkthdr *)bytes; ++ size_t payload; ++ UsbStats::direction_type direction; ++ ++ if (psize < sizeof(*up)) ++ return; ++ ++ payload = le32toh(up->up_totlen) - sizeof(*up) - le32toh(up->up_frames) * USBPF_FRAME_HDR_LEN; ++ direction = (up->up_type == USBPF_XFERTAP_DONE) ? UsbStats::from_device : UsbStats::to_device; ++ _stats.push(time, payload, direction); ++ get_device(up->up_address).push(time, payload, direction); ++} ++#else ++void usbtop::UsbBus::push(const pcap_pkthdr* h, const u_char* bytes) ++{ + // Get the packet size and timestamp + const size_t psize = h->len; + const double time = (double)h->ts.tv_sec + ((double)h->ts.tv_usec)/(1000000.0); +@@ -72,3 +96,4 @@ void usbtop::UsbBus::push(const pcap_pkthdr* h, const + _stats.push(time, psize, direction); + get_device(device_id).push(time, psize, direction); + } ++#endif