]> mj.ucw.cz Git - netgrind.git/commitdiff
Added an option to accept broken checksums
authorMartin Mares <mj@ucw.cz>
Mon, 17 Jun 2013 16:27:20 +0000 (18:27 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 17 Jun 2013 16:27:20 +0000 (18:27 +0200)
This is needed for example when capturing on network interfaces
which make use of hardware checksum offloading.

netgrind/ip.c
netgrind/netgrind.c
netgrind/netgrind.h

index b021335cfb090a8e1464bbaed3fccaec2d758cf8..5280b9e76f3373e4a62b37ded74bb0b1949e0bbc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     Netgrind -- IP Layer Analyser
  *
- *     (c) 2003 Martin Mares <mj@ucw.cz>
+ *     (c) 2003--2013 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU General Public License.
@@ -15,6 +15,8 @@
 #include <netinet/in.h>
 #include <netinet/ip.h>
 
+uns accept_broken_checksums;
+
 uns tcpip_calc_checksum(void *data, uns len, uns csum)
 {
   /* FIXME: This is awfully slow and it probably consumes most of our run time */
@@ -45,7 +47,10 @@ uns tcpip_calc_checksum(void *data, uns len, uns csum)
 
 uns tcpip_verify_checksum(uns csum)
 {
-  return (csum == 0xffff);
+  if (accept_broken_checksums)
+    return 1;
+  else
+    return (csum == 0xffff);
 }
 
 struct pkt_stats stat_ip_in, stat_ip_invalid, stat_ip_uninteresting, stat_ip_fragmented, stat_ip_badsum;
index b3d1a3c621c516c2c38e17a6990d4590e23ccf5c..c20524dbd78700d21ae59ac35496e52cef9b2aa5 100644 (file)
@@ -117,6 +117,7 @@ static void usage(void)
   fprintf(stderr, "Usage: netgrind [<switches>] <capture-files>\n\
 \n\
 -a             TCP: Record arrival times instead of processing times\n\
+-b             Accept broken checksums\n\
 -c <count>     Stop after processing <count> packets\n\
 -d <dir>       Dump connections to a given directory\n\
 -D <dir>       Dump connections with more details\n\
@@ -142,12 +143,15 @@ int main(int argc, char **argv)
   byte *histogram = NULL;
 
   tcp_default_appl = &appl_mux;
-  while ((c = getopt(argc, argv, "ac:d:D:f:h:stwx:")) >= 0)
+  while ((c = getopt(argc, argv, "abc:d:D:f:h:stwx:")) >= 0)
     switch (c)
       {
       case 'a':
        tcp_arrival_times = 1;
        break;
+      case 'b':
+       accept_broken_checksums = 1;
+       break;
       case 'c':
        max_packets = atol(optarg);
        break;
index a72fc3d64ae84c3d03bc68ba9bcffde9c17c7936..b32fe743da021e038e2efa50a9e7acb708db0c28 100644 (file)
@@ -18,6 +18,7 @@ void link_eth_got_packet(struct pkt *p);
 /* ip.c */
 
 extern struct pkt_stats stat_ip_in, stat_ip_invalid, stat_ip_uninteresting, stat_ip_fragmented, stat_ip_badsum;
+extern uns accept_broken_checksums;
 
 uns tcpip_calc_checksum(void *data, uns len, uns csum);
 uns tcpip_verify_checksum(uns csum);