From 5df17f003960f8b14e1046786f42f3e8654dd7d3 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 22 Sep 2019 01:56:56 +0200 Subject: Rework control frame format --- usbdump.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/usbdump.c b/usbdump.c index 8e002cf..d7fe328 100644 --- a/usbdump.c +++ b/usbdump.c @@ -123,17 +123,15 @@ void process_packet(struct usbmon_packet *hdr, char *data) start_ts_us = hdr->ts_usec; } - if (hdr->epnum & USB_DIR_IN) - snprintf(linebuf+strlen(linebuf), LINEBUF_LEN-strlen(linebuf), "%d<-- ", hdr->epnum & 0x7f); - else - snprintf(linebuf+strlen(linebuf), LINEBUF_LEN-strlen(linebuf), "-->%d ", hdr->epnum & 0x7f); - if (hdr->xfer_type == XFER_TYPE_CONTROL) { + const char *dir = hdr->type == 'C' ? "%d<-- " : "-->%d "; + snprintf(linebuf+strlen(linebuf), LINEBUF_LEN-strlen(linebuf), dir, hdr->epnum & 0x7f); + if (hdr->xfer_type == XFER_TYPE_CONTROL && hdr->flag_setup == 0) { uint8_t bmRequestType = hdr->s.setup[0]; uint8_t bRequest = hdr->s.setup[1]; uint16_t wValue = hdr->s.setup[2] | (hdr->s.setup[3] << 8); uint16_t wIndex = hdr->s.setup[4] | (hdr->s.setup[5] << 8); - snprintf(linebuf+strlen(linebuf), LINEBUF_LEN-strlen(linebuf), "%02x %d %04x %04x ", bmRequestType, bRequest, wValue, wIndex); + snprintf(linebuf+strlen(linebuf), LINEBUF_LEN-strlen(linebuf), "[%02x %d %04x %04x] ", bmRequestType, bRequest, wValue, wIndex); } if (hdr->len_cap > 0) { -- cgit v1.2.3