aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-usb-linux.c
diff options
context:
space:
mode:
authorguy <guy>2008-11-24 18:49:57 +0000
committerguy <guy>2008-11-24 18:49:57 +0000
commitdfc31b2781e759cfcb5d86e96841c30f4083651d (patch)
tree25575b2416a625aa19d3a8a1dfcd57143f65432e /pcap-usb-linux.c
parent47dad25d57b85de9e2084a7d25e0b6e6daec1e3e (diff)
From Roberto Mariani: add support for the snapshot length to the
memory-mapped interface.
Diffstat (limited to 'pcap-usb-linux.c')
-rw-r--r--pcap-usb-linux.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c
index c79211e..4ff62ed 100644
--- a/pcap-usb-linux.c
+++ b/pcap-usb-linux.c
@@ -34,7 +34,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.c,v 1.26 2008-11-24 18:06:39 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.c,v 1.27 2008-11-24 18:49:57 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -655,6 +655,9 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
pcap_usb_header* hdr;
int nflush = 0;
int packets = 0;
+ int clen, max_clen;
+
+ max_clen = handle->snapshot - sizeof(pcap_usb_header);
for (;;) {
int i, ret;
@@ -695,8 +698,14 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
if (hdr->event_type == '@')
continue;
+ /* we can get less that than really captured from kernel, depending on
+ * snaplen, so adjust header accordingly */
+ clen = max_clen;
+ if (hdr->data_len < clen)
+ clen = hdr->data_len;
+
/* get packet info from header*/
- pkth.caplen = hdr->data_len + sizeof(pcap_usb_header);
+ pkth.caplen = clen + sizeof(pcap_usb_header);
pkth.len = hdr->urb_len + sizeof(pcap_usb_header);
pkth.ts.tv_sec = hdr->ts_sec;
pkth.ts.tv_usec = hdr->ts_usec;