Bug 2018 - Packet::EnableChecking() also enables printing
Packet::EnableChecking() also enables printing
Status: CONFIRMED
Product: ns-3
Classification: Unclassified
Component: network
pre-release
PC Linux
: P5 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-11-14 17:47 EST by Tom Henderson
Modified: 2014-11-14 18:16 EST (History)
0 users

See Also:


Attachments
patch to documentation (if this solution is decided) (1006 bytes, patch)
2014-11-14 17:47 EST, Tom Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Henderson 2014-11-14 17:47:10 EST
Created attachment 1919 [details]
patch to documentation (if this solution is decided)

In contrast to the doxygen in packet.h, which states that Packet::EnableChecking() does not invoke the more expensive Packet::EnablePrinting() in the packet metadata, the current implementation behaves differently.    Packet::EnableChecking() calls PacketMetadata::Enable(), just as does Packet::EnablePrinting().  So Packet::EnableChecking() enables both printing and checking.

The attached doxygen patch would align the doxygen to the current implementation.  However, if the doxygen is to stay the same and the implementation to change back to the documentation, then PacketMetadata::EnableChecking() should not call Enable(), and the conditional that returns from RemoveHeader() if m_enable is false needs to be removed.  (this just from reading the code; I haven't tested it)
Comment 1 Tom Henderson 2014-11-14 18:16:08 EST
I wonder whether it ever worked as documented, since I found the first instance of PacketMetadata::EnableChecking() in revision 3553 also calls Enable():

hg diff -r3552:3553

diff -r b822851cb95d -r 065488d0420c src/common/packet-metadata.cc
--- 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;
+}
+