aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-usb-linux.c
diff options
context:
space:
mode:
authorguy <guy>2006-10-12 08:04:08 +0000
committerguy <guy>2006-10-12 08:04:08 +0000
commit08f2f1703b05ede3a444207d875903ce9b156491 (patch)
treeb53a7e5411402c3c664d0138253c2363d9424d04 /pcap-usb-linux.c
parent33c151f1e99ac75683e5dff05fb70e093e566446 (diff)
From Paolo Abeni:
The attached patch fix the parsing of setup data fields in current implementation of usb_read_data. Currently the "setup header is present" field is not marked so the relevant fields are ignored from caller. The patch contains also a little indentation fix, always in the same function.
Diffstat (limited to 'pcap-usb-linux.c')
-rw-r--r--pcap-usb-linux.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index f09d1fa..7094c2c 100644
--- a/pcap-usb-linux.c
+++ b/pcap-usb-linux.c
@@ -290,7 +290,7 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
/* check if this is a setup packet */
ret = sscanf(status, "%d", &dummy);
- if (ret == 0)
+ if (ret != 1)
{
/* this a setup packet, setup data can be filled with underscore if
* usbmon has not been able to read them, so we must parse this fields as
@@ -302,8 +302,8 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
if (ret < 5)
{
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't parse usb bus message '%s', too few token (expected 5 got %d)",
- string, ret);
+ "Can't parse usb bus message '%s', too few token (expected 5 got %d)",
+ string, ret);
return -1;
}
string += cnt;
@@ -315,10 +315,14 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
shdr->wValue = htons(strtoul(str3, 0, 16));
shdr->wIndex = htons(strtoul(str4, 0, 16));
shdr->wLength = htons(strtoul(str5, 0, 16));
+ uhdr->setup_packet = 1;
- pkth.caplen = sizeof(pcap_usb_setup);
+
+ pkth.caplen += sizeof(pcap_usb_setup);
rawdata += sizeof(pcap_usb_setup);
}
+ else
+ uhdr->setup_packet = 0;
/* read urb data */
ret = sscanf(string, " %d%n", &pkth.len, &cnt);