Date: Tue, 10 Aug 2021 07:47:31 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: 972a2a5984b7 - main - sysutils/usbtop: Fixes for FreeBSD. Message-ID: <202108100747.17A7lVTh023469@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/ports/commit/?id=972a2a5984b72965bfe8cbdddeda0953d61610fa commit 972a2a5984b72965bfe8cbdddeda0953d61610fa Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2021-08-10 07:30:00 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> 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 <stdint.h> ++#include <sys/endian.h> ++#include <dev/usb/usb_pf.h> ++#endif ++ + #include <usbtop/usb_bus.h> + #include <usbtop/tools.h> + +@@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108100747.17A7lVTh023469>