1.1 --- a/examples/wifi-ap.cc Mon Aug 25 15:16:35 2008 -0700
1.2 +++ b/examples/wifi-ap.cc Mon Aug 25 15:21:01 2008 -0700
1.3 @@ -110,7 +110,7 @@
1.4
1.5 int main (int argc, char *argv[])
1.6 {
1.7 - Packet::EnableMetadata ();
1.8 + Packet::EnablePrinting ();
1.9
1.10 // enable rts cts all the time.
1.11 Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
2.1 --- a/src/common/packet-metadata.cc Mon Aug 25 15:16:35 2008 -0700
2.2 +++ b/src/common/packet-metadata.cc Mon Aug 25 15:21:01 2008 -0700
2.3 @@ -32,6 +32,7 @@
2.4 namespace ns3 {
2.5
2.6 bool PacketMetadata::m_enable = false;
2.7 +bool PacketMetadata::m_enableChecking = false;
2.8 bool PacketMetadata::m_metadataSkipped = false;
2.9 uint32_t PacketMetadata::m_maxSize = 0;
2.10 uint16_t PacketMetadata::m_chunkUid = 0;
2.11 @@ -59,6 +60,13 @@
2.12 m_enable = true;
2.13 }
2.14
2.15 +void
2.16 +PacketMetadata::EnableChecking (void)
2.17 +{
2.18 + Enable ();
2.19 + m_enableChecking = true;
2.20 +}
2.21 +
2.22 void
2.23 PacketMetadata::ReserveCopy (uint32_t size)
2.24 {
2.25 @@ -630,13 +638,21 @@
2.26 if ((item.typeUid & 0xfffffffe) != uid ||
2.27 item.size != size)
2.28 {
2.29 - NS_FATAL_ERROR ("Removing unexpected header.");
2.30 + if (m_enableChecking)
2.31 + {
2.32 + NS_FATAL_ERROR ("Removing unexpected header.");
2.33 + }
2.34 + return;
2.35 }
2.36 else if (item.typeUid != uid &&
2.37 (extraItem.fragmentStart != 0 ||
2.38 extraItem.fragmentEnd != size))
2.39 {
2.40 - NS_FATAL_ERROR ("Removing incomplete header.");
2.41 + if (m_enableChecking)
2.42 + {
2.43 + NS_FATAL_ERROR ("Removing incomplete header.");
2.44 + }
2.45 + return;
2.46 }
2.47 if (m_head + read == m_used)
2.48 {
2.49 @@ -688,13 +704,21 @@
2.50 if ((item.typeUid & 0xfffffffe) != uid ||
2.51 item.size != size)
2.52 {
2.53 - NS_FATAL_ERROR ("Removing unexpected trailer.");
2.54 + if (m_enableChecking)
2.55 + {
2.56 + NS_FATAL_ERROR ("Removing unexpected trailer.");
2.57 + }
2.58 + return;
2.59 }
2.60 else if (item.typeUid != uid &&
2.61 (extraItem.fragmentStart != 0 ||
2.62 extraItem.fragmentEnd != size))
2.63 {
2.64 - NS_FATAL_ERROR ("Removing incomplete trailer.");
2.65 + if (m_enableChecking)
2.66 + {
2.67 + NS_FATAL_ERROR ("Removing incomplete trailer.");
2.68 + }
2.69 + return;
2.70 }
2.71 if (m_tail + read == m_used)
2.72 {
3.1 --- a/src/common/packet-metadata.h Mon Aug 25 15:16:35 2008 -0700
3.2 +++ b/src/common/packet-metadata.h Mon Aug 25 15:21:01 2008 -0700
3.3 @@ -125,6 +125,7 @@
3.4 };
3.5
3.6 static void Enable (void);
3.7 + static void EnableChecking (void);
3.8
3.9 inline PacketMetadata (uint32_t uid, uint32_t size);
3.10 inline PacketMetadata (PacketMetadata const &o);
3.11 @@ -279,6 +280,7 @@
3.12
3.13 static DataFreeList m_freeList;
3.14 static bool m_enable;
3.15 + static bool m_enableChecking;
3.16
3.17 // set to true when adding metadata to a packet is skipped because
3.18 // m_enable is false; used to detect enabling of metadata in the
4.1 --- a/src/common/packet.cc Mon Aug 25 15:16:35 2008 -0700
4.2 +++ b/src/common/packet.cc Mon Aug 25 15:21:01 2008 -0700
4.3 @@ -459,9 +459,23 @@
4.4 Packet::EnableMetadata (void)
4.5 {
4.6 NS_LOG_FUNCTION_NOARGS ();
4.7 + EnableChecking ();
4.8 +}
4.9 +
4.10 +void
4.11 +Packet::EnablePrinting (void)
4.12 +{
4.13 + NS_LOG_FUNCTION_NOARGS ();
4.14 PacketMetadata::Enable ();
4.15 }
4.16
4.17 +void
4.18 +Packet::EnableChecking (void)
4.19 +{
4.20 + NS_LOG_FUNCTION_NOARGS ();
4.21 + PacketMetadata::EnableChecking ();
4.22 +}
4.23 +
4.24 Buffer
4.25 Packet::Serialize (void) const
4.26 {
5.1 --- a/src/common/packet.h Mon Aug 25 15:16:35 2008 -0700
5.2 +++ b/src/common/packet.h Mon Aug 25 15:21:01 2008 -0700
5.3 @@ -30,6 +30,7 @@
5.4 #include "ns3/callback.h"
5.5 #include "ns3/assert.h"
5.6 #include "ns3/ptr.h"
5.7 +#include "ns3/deprecated.h"
5.8
5.9 namespace ns3 {
5.10
5.11 @@ -310,13 +311,17 @@
5.12
5.13 PacketMetadata::ItemIterator BeginItem (void) const;
5.14
5.15 + static void EnableMetadata (void) NS_DEPRECATED;
5.16 +
5.17 /**
5.18 * By default, packets do not keep around enough metadata to
5.19 * perform the operations requested by the Print methods. If you
5.20 * want to be able to invoke any of the two ::Print methods,
5.21 * you need to invoke this method at least once during the
5.22 * simulation setup and before any packet is created.
5.23 - *
5.24 + */
5.25 + static void EnablePrinting (void);
5.26 + /**
5.27 * The packet metadata is also used to perform extensive
5.28 * sanity checks at runtime when performing operations on a
5.29 * Packet. For example, this metadata is used to verify that
5.30 @@ -324,7 +329,7 @@
5.31 * was actually present at the front of the packet. These
5.32 * errors will be detected and will abort the program.
5.33 */
5.34 - static void EnableMetadata (void);
5.35 + static void EnableChecking (void);
5.36
5.37 /**
5.38 * \returns a byte buffer
6.1 --- a/src/helper/csma-helper.cc Mon Aug 25 15:16:35 2008 -0700
6.2 +++ b/src/helper/csma-helper.cc Mon Aug 25 15:21:01 2008 -0700
6.3 @@ -122,7 +122,7 @@
6.4 void
6.5 CsmaHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
6.6 {
6.7 - Packet::EnableMetadata ();
6.8 + Packet::EnablePrinting ();
6.9 std::ostringstream oss;
6.10 oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
6.11 Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os));
7.1 --- a/src/helper/point-to-point-helper.cc Mon Aug 25 15:16:35 2008 -0700
7.2 +++ b/src/helper/point-to-point-helper.cc Mon Aug 25 15:21:01 2008 -0700
7.3 @@ -122,7 +122,7 @@
7.4 void
7.5 PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
7.6 {
7.7 - Packet::EnableMetadata ();
7.8 + Packet::EnablePrinting ();
7.9 std::ostringstream oss;
7.10 oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
7.11 Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os));
8.1 --- a/src/helper/wifi-helper.cc Mon Aug 25 15:16:35 2008 -0700
8.2 +++ b/src/helper/wifi-helper.cc Mon Aug 25 15:21:01 2008 -0700
8.3 @@ -193,7 +193,7 @@
8.4 void
8.5 WifiHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
8.6 {
8.7 - Packet::EnableMetadata ();
8.8 + Packet::EnablePrinting ();
8.9 std::ostringstream oss;
8.10 oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/RxOk";
8.11 Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os));
9.1 --- a/utils/bench-packets.cc Mon Aug 25 15:16:35 2008 -0700
9.2 +++ b/utils/bench-packets.cc Mon Aug 25 15:21:01 2008 -0700
9.3 @@ -282,7 +282,7 @@
9.4 runBench (&benchC, n, "c");
9.5 runBench (&benchD, n, "d");
9.6
9.7 - Packet::EnableMetadata ();
9.8 + Packet::EnablePrinting ();
9.9 runBench (&benchA, n, "meta-a");
9.10 runBench (&benchB, n, "meta-b");
9.11 runBench (&benchC, n, "meta-c");