src/common/packet-metadata.cc
changeset 3553 065488d0420c
parent 3526 076ae3766f27
--- a/src/common/packet-metadata.cc	Mon Aug 25 15:16:35 2008 -0700
+++ b/src/common/packet-metadata.cc	Mon Aug 25 15:21:01 2008 -0700
@@ -32,6 +32,7 @@
 namespace ns3 {
 
 bool PacketMetadata::m_enable = false;
+bool PacketMetadata::m_enableChecking = false;
 bool PacketMetadata::m_metadataSkipped = false;
 uint32_t PacketMetadata::m_maxSize = 0;
 uint16_t PacketMetadata::m_chunkUid = 0;
@@ -59,6 +60,13 @@
   m_enable = true;
 }
 
+void 
+PacketMetadata::EnableChecking (void)
+{
+  Enable ();
+  m_enableChecking = true;
+}
+
 void
 PacketMetadata::ReserveCopy (uint32_t size)
 {
@@ -630,13 +638,21 @@
   if ((item.typeUid & 0xfffffffe) != uid ||
       item.size != size)
     {
-      NS_FATAL_ERROR ("Removing unexpected header.");
+      if (m_enableChecking)
+        {
+          NS_FATAL_ERROR ("Removing unexpected header.");
+        }
+      return;
     }
   else if (item.typeUid != uid &&
            (extraItem.fragmentStart != 0 ||
             extraItem.fragmentEnd != size))
     {
-      NS_FATAL_ERROR ("Removing incomplete header.");
+      if (m_enableChecking)
+        {
+          NS_FATAL_ERROR ("Removing incomplete header.");
+        }
+      return;
     }
   if (m_head + read == m_used)
     {
@@ -688,13 +704,21 @@
   if ((item.typeUid & 0xfffffffe) != uid ||
       item.size != size)
     {
-      NS_FATAL_ERROR ("Removing unexpected trailer.");
+      if (m_enableChecking)
+        {
+          NS_FATAL_ERROR ("Removing unexpected trailer.");
+        }
+      return;
     }
   else if (item.typeUid != uid &&
            (extraItem.fragmentStart != 0 ||
             extraItem.fragmentEnd != size))
     {
-      NS_FATAL_ERROR ("Removing incomplete trailer.");
+      if (m_enableChecking)
+        {
+          NS_FATAL_ERROR ("Removing incomplete trailer.");
+        }
+      return;
     }
   if (m_tail + read == m_used)
     {