Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jun 2006 12:15:00 GMT
From:      Clément Lecigne <clem1@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 100136 for review
Message-ID:  <200606271215.k5RCF0i1027991@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100136

Change 100136 by clem1@clem1_ipv6vulns on 2006/06/27 12:14:08

	libnet improvements around extension headers and checksum calculation.	

Affected files ...

.. //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_build_ip.c#3 edit
.. //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_internal.c#3 edit
.. //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_link_bpf.c#2 edit
.. //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_pblock.c#4 edit
.. //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_write.c#2 edit

Differences ...

==== //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_build_ip.c#3 (text+ko) ====

@@ -519,6 +519,8 @@
         }
     }
 
+    libnet_pblock_record_ip_offset(l, l->total_size);
+
     /* no checksum for IPv6 */
     return (ptag ? ptag : libnet_pblock_update(l, p, LIBNET_IPV6_H,
             LIBNET_PBLOCK_IPV6_H));
@@ -599,6 +601,8 @@
         }
     }
 
+    libnet_pblock_record_ip_offset(l, l->total_size);
+
     /*
      *  Update the protocol block's meta information and return the protocol
      *  tag id of this pblock.  This tag will be used to locate the pblock
@@ -686,6 +690,8 @@
         }
     }
 
+    libnet_pblock_record_ip_offset(l, l->total_size);
+    
     /*
      *  Update the protocol block's meta information and return the protocol
      *  tag id of this pblock.  This tag will be used to locate the pblock
@@ -770,6 +776,8 @@
         }
     }
 
+    libnet_pblock_record_ip_offset(l, l->total_size);
+    
     /*
      *  Update the protocol block's meta information and return the protocol
      *  tag id of this pblock.  This tag will be used to locate the pblock
@@ -854,6 +862,8 @@
         }
     }
 
+    libnet_pblock_record_ip_offset(l, l->total_size);
+    
     /*
      *  Update the protocol block's meta information and return the protocol
      *  tag id of this pblock.  This tag will be used to locate the pblock

==== //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_internal.c#3 (text+ko) ====


==== //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_link_bpf.c#2 (text+ko) ====


==== //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_pblock.c#4 (text+ko) ====

@@ -389,37 +389,8 @@
             {
                 if ((q->flags) & LIBNET_PBLOCK_DO_CHECKSUM)
                 {
-                    int offset;
-                    if (l->injection_type != LIBNET_LINK)
-                    {
-                        offset = (l->total_size + l->aligner) - q->ip_offset;
-                    }
-                    else
-                    {
-                        offset = l->aligner;
-                        switch(l->pblock_end->type){
-                            case LIBNET_PBLOCK_ETH_H:
-                                offset += LIBNET_ETH_H;
-                                break;
-                            case LIBNET_PBLOCK_TOKEN_RING_H:
-                                offset += LIBNET_TOKEN_RING_H;
-                                break;
-                            case LIBNET_PBLOCK_FDDI_H:
-                                offset += LIBNET_FDDI_H;
-                                break;
-                            case LIBNET_PBLOCK_802_1Q_H:
-                                offset += LIBNET_802_1Q_H;
-                                break;
-                            case LIBNET_PBLOCK_ISL_H:
-                                offset += LIBNET_ISL_H;
-                                break;
-                            case LIBNET_PBLOCK_802_3_H:
-                                offset += LIBNET_802_3_H;
-                                break;
-                            default:
-                                break;
-                        }       
-                    }
+                    int offset = (l->total_size + l->aligner) - q->ip_offset;
+                    
                     c = libnet_do_checksum(l, *packet + offset,
                             libnet_pblock_p2p(q->type), q->h_len);
                     if (c == -1)
@@ -546,9 +517,20 @@
 
     do
     {
-        p->ip_offset = offset;
+        /*
+         * update ip offset only if it was not set before.
+         */
+        if (p->ip_offset == 0)
+        {
+            p->ip_offset = offset;
+        }
         p = p->prev;
-    } while (p && p->type != LIBNET_PBLOCK_IPV4_H);
+    } while (p && (p->type != LIBNET_PBLOCK_IPV4_H || 
+                p->type != LIBNET_PBLOCK_IPV6_H || 
+                p->type != LIBNET_PBLOCK_IPV6_FRAG_H ||
+                p->type != LIBNET_PBLOCK_IPV6_ROUTING_H ||
+                p->type != LIBNET_PBLOCK_IPV6_DESTOPTS_H ||
+                p->type != LIBNET_PBLOCK_IPV6_HBHOPTS_H));
 }
 
 

==== //depot/projects/soc2006/clem1_ipv6vulns/libnet/src/libnet_write.c#2 (text+ko) ====




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606271215.k5RCF0i1027991>