It looks like tcprewrite can't handle ICMPV6 packets and packets with ip options.

I've attached a patch.

Aaron Turner wrote:
Thanks to some feedback with pre2, I've fixed a compile-time issue.
No other real changes.

http://tcpreplay.synfin.net/tcpreplay-3.4.2pre3.tar.gz

--- tcpreplay-3.4.1.org/src/tcpedit/checksum.c  2009-01-18 19:47:38.000000000 
+0200
+++ tcpreplay-3.4.1.new/src/tcpedit/checksum.c  2009-05-17 12:51:31.000000000 
+0300
@@ -52,6 +52,7 @@
     tcp_hdr_t *tcp;
     udp_hdr_t *udp;
     icmpv4_hdr_t *icmp;
+    icmpv6_hdr_t *icmp6;
     int ip_hl;
     int sum;
     
@@ -69,7 +70,14 @@
     if (ipv4->ip_v == 6) {
         ipv6 = (ipv6_hdr_t *)data;
         ipv4 = NULL;
-        ip_hl = 40;
+
+        proto = get_ipv6_l4proto(ipv6);
+        dbgx(3, "layer4 proto is 0x%hhu", proto);
+
+        ip_hl = (u_char*)get_layer4_v6(ipv6) - (u_char*)data;
+        dbgx(3, "ip_hl proto is 0x%d", ip_hl);
+
+        len -= (ip_hl - TCPR_IPV6_H);
     } else {
         ip_hl = ipv4->ip_hl << 2;
     }
@@ -121,6 +129,17 @@
             icmp->icmp_sum = CHECKSUM_CARRY(sum);
             break;
         
+        case IPPROTO_ICMP6:
+            icmp6 = (icmpv6_hdr_t *)(data + ip_hl);
+            icmp6->icmp_sum = 0;
+            if (ipv6 != NULL) {
+                sum = do_checksum_math((u_int16_t *)&ipv6->ip_src, 32);
+            }
+            sum += ntohs(IPPROTO_ICMP6 + len);
+            sum += do_checksum_math((u_int16_t *)icmp6, len);
+            icmp6->icmp_sum = CHECKSUM_CARRY(sum);
+            break;
+
      
         case IPPROTO_IP:
             ipv4->ip_sum = 0;
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Tcpreplay-users mailing list
Tcpreplay-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcpreplay-users
Support Information: http://tcpreplay.synfin.net/trac/wiki/Support

Reply via email to