Packets/DefaultBundle: BUGFIX: Remove invalid EthernetPacket::type_length field overw...
[senf.git] / Packets / DefaultBundle / EthernetPacket.cc
index eced314..00ef6cb 100644 (file)
@@ -27,6 +27,7 @@
 //#include "EthernetPacket.ih"
 
 // Custom includes
+#include "LlcSnapPacket.hh"
 #include <iomanip>
 #include <boost/io/ios_state.hpp>
 
@@ -65,7 +66,7 @@ prefix_ senf::PacketInterpreterBase::factory_t senf::EthernetPacketType::nextPac
         return e ? e->factory() : no_factory();
     }
     if (p->type_length() <= 1500)
-        return EthLlcSnapPacket::factory();
+        return LlcSnapPacket::factory();
     return no_factory();
 }
 
@@ -75,10 +76,9 @@ prefix_ void senf::EthernetPacketType::finalize(packet p)
     if (k)
         p->type_length() << k;
     else
-        if (p.next().is<EthLlcSnapPacket>())
+        if (p.next().is<LlcSnapPacket>())
             p->type_length() << p.next().data().size();
-        else
-            p->type_length() << 0;
+    // Do NOT reset type_length if the type is not known ... doing this will destroy read packets
 }
 
 prefix_ void senf::EthVLanPacketType::dump(packet p, std::ostream & os)
@@ -97,24 +97,6 @@ prefix_ void senf::EthVLanPacketType::finalize(packet p)
     p->type() << key(p.next());
 }
 
-prefix_ void senf::EthLlcSnapPacketType::dump(packet p, std::ostream & os)
-{
-    boost::io::ios_all_saver ias(os);
-    os << "Ethernet LLC/SNAP"
-       << "  LLC\n"
-       << "    DSAP: " << p->dsap() << "\n"
-       << "    SSAP: " << p->ssap() << "\n"
-       << "  SNAP\n"
-       << "    ProtocolId: " << p->protocolId() << "\n"
-       << "    type      : 0x" 
-       << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n";
-}
-
-prefix_ void senf::EthLlcSnapPacketType::finalize(packet p)
-{
-    p->type() << key(p.next());
-}
-
 
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_