aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usbdump.c10
1 files 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) {