aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-usb-linux.c
diff options
context:
space:
mode:
authorguy <guy>2006-10-15 18:20:26 +0000
committerguy <guy>2006-10-15 18:20:26 +0000
commit24f60579bc70a94e29256b92f81f6b7e3a85f1b8 (patch)
tree1c082b7d7af38efad6ae0ba7292c973febca64f6 /pcap-usb-linux.c
parent455aff8ba9495985ee622ce38d69dd5795d6e2de (diff)
From Paolo Abeni:
The attached patch fix an off by one in current usb sniffing code. It also substitute the kernel-provided timestamp with gettimeofday. The kernel provided timestamp use 32 bits to represent a struct timeval (8 bits for tv_sec and 24 for tv_usec), so it's content is quite misleading.
Diffstat (limited to 'pcap-usb-linux.c')
-rw-r--r--pcap-usb-linux.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index f01a28b..29d7ba7 100644
--- a/pcap-usb-linux.c
+++ b/pcap-usb-linux.c
@@ -241,8 +241,15 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
uhdr->endpoint_number = htonl(ep_num);
uhdr->device_address = htonl(dev_addr);
string += cnt;
- pkth.ts.tv_sec = timestamp / 1000000;
- pkth.ts.tv_usec = timestamp % 1000000;
+
+ /* don't use usbmon provided timestamp, since it have low precision*/
+ if (gettimeofday(&pkth.ts, NULL) < 0)
+ {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "Can't get timestamp for message '%s' %d:%s",
+ string, errno, strerror(errno));
+ return -1;
+ }
/* parse endpoint information */
if (pipeid1 == 'C')
@@ -353,6 +360,9 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
if (urb_tag != '=')
goto got;
+ /* skip urb tag and following space */
+ string += 3;
+
/* read all urb data; if urb length is greater then the usbmon internal
* buffer length used by the kernel to spool the URB, we get only
* a partial information.