? add_guards_to_sll.patch ? ascii_conversion_and_snaplen_fix.patch ? diffs ? libpcap.so.0.9-PRE-CVS ? test ? test.c ? test1 ? test2 Index: pcap-usb-linux.c =================================================================== RCS file: /tcpdump/master/libpcap/pcap-usb-linux.c,v retrieving revision 1.2 diff -u -r1.2 pcap-usb-linux.c --- pcap-usb-linux.c 4 Oct 2006 18:09:22 -0000 1.2 +++ pcap-usb-linux.c 5 Oct 2006 16:24:09 -0000 @@ -149,7 +149,7 @@ free(handle); return NULL; } - + handle->buffer = malloc(handle->bufsize + handle->offset); if (!handle->buffer) { snprintf(errmsg, PCAP_ERRBUF_SIZE, @@ -181,7 +181,7 @@ static inline int ascii_to_int(char c) { - return c < 'A' ? c- '0': ((c<'a') ? c- 'A': c-'a'); + return c < 'A' ? c- '0': ((c<'a') ? c - 'A' + 10: c-'a'+10); } /* @@ -331,12 +331,13 @@ string += cnt; handle->md.packets_read++; - /* urb tag is not present if urb length is 0 */ - pkth.len += pkth.caplen; + /* urb tag is not present if urb length is 0, so we can stop here + * text parsing */ + pkth.len += pkth.caplen; if (pkth.len == pkth.caplen) return 1; - /* check for data presence */ + /* check for data presence; data is present if and only if urb tag is '=' */ if (sscanf(string, " %c", &urb_tag) != 1) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, @@ -347,9 +348,12 @@ if (urb_tag != '=') goto got; - /* read all urb data; if urb length is less then our string we get only - * a partial information */ - while ((string[0] != 0) && (string[1] != 0)) + /* 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. + * At least until linux 2.6.17 there is no way to set usbmon intenal buffer + * length and default value is 130. */ + while ((string[0] != 0) && (string[1] != 0) && (pkth.caplen < handle->snapshot)) { rawdata[0] = ascii_to_int(string[0]) * 16 + ascii_to_int(string[1]); rawdata++; @@ -361,8 +365,6 @@ got: handle->md.packets_read++; - if (pkth.caplen > handle->snapshot) - pkth.caplen = handle->snapshot; callback(user, &pkth, handle->buffer); return 1;