ensure that out PcapTraces are generated in a consistant format to allow simple comparison of traces against a single set of reference traces.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 11 Apr 2008 11:19:54 -0700
changeset 2906 5a7ae076410e
parent 2905 9fa2f44cdafa
child 2907 ebc23fe98852
ensure that out PcapTraces are generated in a consistant format to allow simple comparison of traces against a single set of reference traces.
src/common/pcap-writer.cc
--- a/src/common/pcap-writer.cc	Thu Apr 10 14:08:14 2008 -0700
+++ b/src/common/pcap-writer.cc	Fri Apr 11 11:19:54 2008 -0700
@@ -111,12 +111,20 @@
 void
 PcapWriter::Write32 (uint32_t data)
 {
-  WriteData ((uint8_t*)&data, 4);
+  uint8_t buffer[4];
+  buffer[0] = (data >> 0) & 0xff;
+  buffer[1] = (data >> 8) & 0xff;
+  buffer[2] = (data >> 16) & 0xff;
+  buffer[3] = (data >> 24) & 0xff;
+  WriteData (buffer, 4);
 }
 void
 PcapWriter::Write16 (uint16_t data)
 {
-  WriteData((uint8_t*)&data, 2);
+  uint8_t buffer[2];
+  buffer[0] = (data >> 0) & 0xff;
+  buffer[1] = (data >> 8) & 0xff;
+  WriteData (buffer, 2);
 }
 
 } // namespace ns3