fix uleb128 reading bug
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 07 Jun 2007 13:16:15 +0200
changeset 884 f3836277079e
parent 883 4d2da35c09b0
child 885 4f385160b3d5
fix uleb128 reading bug
src/common/packet-metadata.cc
utils/bench-packets.cc
--- a/src/common/packet-metadata.cc	Thu Jun 07 12:51:57 2007 +0200
+++ b/src/common/packet-metadata.cc	Thu Jun 07 13:16:15 2007 +0200
@@ -127,28 +127,28 @@
       return result;
     }
   byte = buffer[1];
-  result = (byte & (~0x80)) << 7;
+  result |= (byte & (~0x80)) << 7;
   if (!(byte & 0x80))
     {
       *pBuffer = buffer + 2;
       return result;
     }
   byte = buffer[2];
-  result = (byte & (~0x80)) << 14;
+  result |= (byte & (~0x80)) << 14;
   if (!(byte & 0x80))
     {
       *pBuffer = buffer + 3;
       return result;
     }
   byte = buffer[3];
-  result = (byte & (~0x80)) << 21;
+  result |= (byte & (~0x80)) << 21;
   if (!(byte & 0x80))
     {
       *pBuffer = buffer + 4;
       return result;
     }
   byte = buffer[4];
-  result = (byte & (~0x80)) << 28;
+  result |= (byte & (~0x80)) << 28;
   if (!(byte & 0x80))
     {
       *pBuffer = buffer + 5;
@@ -1619,7 +1619,10 @@
   CHECK_HISTORY (p2, 1, 1);
   p1.AddAtEnd (p2);
   CHECK_HISTORY (p1, 2, 4, 1);
-  
+
+
+  p = Packet (2000);
+  CHECK_HISTORY (p, 1, 2000);
   
 
 
--- a/utils/bench-packets.cc	Thu Jun 07 12:51:57 2007 +0200
+++ b/utils/bench-packets.cc	Thu Jun 07 13:16:15 2007 +0200
@@ -156,6 +156,22 @@
   }
 }
 
+static void
+benchPrint (uint32_t n)
+{
+  PacketPrinter printer;
+  BenchHeader<25> ipv4;
+  BenchHeader<8> udp;
+  Packet p (2000);
+  p.AddHeader (udp);
+  p.AddHeader (ipv4);
+
+  for (uint32_t i = 0; i < n; i++) 
+    {
+      p.Print (std::cerr, printer);
+    }  
+}
+
 
 static void
 runBench (void (*bench) (uint32_t), uint32_t n, char const *name)
@@ -188,6 +204,7 @@
   }
 
 
+  runBench (&benchPrint, n, "print");
   PacketMetadata::SetOptOne (false);
   runBench (&benchPtrA, n, "a");
   runBench (&benchPtrB, n, "b");