Parser for TLVPacket is working now, thanx to Stefan for the hint.
[senf.git] / Packets / MPEGDVBBundle / TLVPacket.cc
index d93d5c2..8d24a3f 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: SNDUPacket.cc 423 2007-08-31 22:05:37Z g0dil $
+// $Id$
 //
 // Copyright (C) 2007
 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief DSMCCSection non-inline non-template implementation */
+    \brief TLVPacket non-inline non-template implementation */
 
 #include "TLVPacket.hh"
 //#include "TLVPacket.ih"
 
 // Custom includes
 #include <iomanip>
-#include "../../Utils/hexdump.hh"
-#include "../../Packets/DefaultBundle/EthernetPacket.hh"
 
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
-
-prefix_ senf::PacketParserBase::size_type senf::Parse_TLVPacket::bytes()
-    const
-{
-    return 4 + senf::bytes( length() );
-}
-
-//prefix_ void senf::TLVPacketType::init(packet p)
-//{
-//    p->init();
-//}
-
 prefix_ void senf::TLVPacketType::dump(packet p, std::ostream & os)
 {
     os << "TLVPacket:\n"
@@ -55,15 +41,16 @@ prefix_ void senf::TLVPacketType::dump(packet p, std::ostream & os)
        << "  length: " << unsigned(p->length()) << "\n";
 }
 
-prefix_ senf::PacketParserBase::size_type senf::TLVPacketType::initSize()
+prefix_ senf::PacketInterpreterBase::optional_range 
+senf::TLVPacketType::nextPacketRange(packet p) 
 {
-    return 4 + 1;
+    if (p.data().size() < 6)
+        return no_range();
+    return range(
+            boost::next(p.data().begin(), 4 + senf::bytes(p->length()) ),
+            p.data().end() );
 }
 
-prefix_ senf::PacketParserBase::size_type senf::TLVPacketType::initHeadSize()
-{
-    return 4 + 1;
-}
 
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_