tcpdump mailing list archives

Re: [Patch 4-4] pcap-usb-linux.c


From: Jean-Louis <jelot-tcpdump () jelot it>
Date: Thu, 30 Oct 2008 03:35:27 +0100

Jean-Louis ha scritto:
today I have found some bug on pcap-usb-linux.c

now i can try to tell you which are


Added possibility to set "snaplen" also in "mmap mode"
Index: pcap-usb-linux.c
===================================================================
RCS file: /home/jean-louis/cvsroot/libpcap/pcap-usb-linux.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -c -r1.4 -r1.5
*** pcap-usb-linux.c    29 Oct 2008 16:03:01 -0000      1.4
--- pcap-usb-linux.c    29 Oct 2008 19:54:46 -0000      1.5
***************
*** 639,644 ****
--- 639,648 ----
        pcap_usb_header* hdr;
        int nflush = 0;
        int packets = 0;
+       int clen, clen_bak;
+ 
+       clen_bak = handle->snapshot - sizeof(pcap_usb_header);
+ 
  
        for (;;) {
                int i, ret;
***************
*** 679,686 ****
                        if (hdr->event_type == '@') 
                                continue;
  
                        /* get packet info from header*/
!                       pkth.caplen = hdr->data_len + 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;
--- 683,696 ----
                        if (hdr->event_type == '@') 
                                continue;
  
+                       /* we can get less that than really captured from kernel, depending on
+                       * snaplen, so adjust header accordingly */
+                       clen = clen_bak;
+                       if (hdr->data_len < clen)
+                               clen = hdr->data_len;
+ 
                        /* get packet info from 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;
-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.

Current thread: