added crc calculation to SNDU Packet
[senf.git] / Packets / MPEGDVBBundle / SNDUPacket.cc
index 2e52a84..e55812f 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: DSMCCSection.cc 350 2007-07-25 08:26:41Z g0dil $
+// $Id$
 //
 // Copyright (C) 2007
 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
@@ -28,6 +28,8 @@
 
 // Custom includes
 #include <iomanip>
+#include "Utils/hexdump.hh"
+#include "Packets/PacketData.hh"
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
@@ -47,9 +49,23 @@ prefix_ senf::PacketParserBase::size_type senf::Parse_SNDUPacket::bytes()
         return 2 + 2 + 4 + 6;  // + 6 Byte NPA destination address
 }
 
+prefix_ boost::uint32_t senf::Parse_SNDUPacket::calcCrc()
+    const
+{
+    ule_crc32 result;
+    senf::PacketData::iterator i (data().begin());
+    senf::PacketData::iterator const i_end(boost::prior(data().end(),4));
+    for (; i!=i_end; ++i) 
+        result.process_byte(*i);
+    return result.checksum(); 
+}
+
 prefix_ void senf::SNDUPacketType::dump(packet p, std::ostream & os)
 {
-    os << "SNDUPacket:\n";
+    os << "SNDUPacket:\n"
+       << "  d_bit: " << p->d_bit() << "\n"
+       << "  length: " << unsigned(p->length()) << "\n"
+       << "  crc: " << unsigned(p->crc()) << "\n";
 }
 
 prefix_ senf::PacketParserBase::size_type senf::SNDUPacketType::initSize()