X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FEthernetPacket.cc;h=78fe56c3746ad495b91a1ba6b9f7fd7548db9073;hb=1ac8479aaaa1491e2668c6f09d042ae9de1f2113;hp=907d4bfd48ea01730261a46847096dbde4190397;hpb=a18d131c38ffe7178ea4736ed3f584125e9903ae;p=senf.git diff --git a/Packets/DefaultBundle/EthernetPacket.cc b/Packets/DefaultBundle/EthernetPacket.cc index 907d4bf..78fe56c 100644 --- a/Packets/DefaultBundle/EthernetPacket.cc +++ b/Packets/DefaultBundle/EthernetPacket.cc @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ //#include "EthernetPacket.ih" // Custom includes +#include "LlcSnapPacket.hh" #include #include @@ -44,22 +45,37 @@ namespace { prefix_ void senf::EthernetPacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); - if (p->type() <= 1500) + if (p->type_length() <= 1500) os << "Ethernet 802.3"; - else if (p->type() >= 0x600) + else if (p->type_length() >= 0x600) os << "Ethernet II (DIX)"; else os << "Ethernet 802.3 (bad ethertype >1500 and <1536)"; os << ": \n" - << " destination : " << p->destination() << "\n" - << " source : " << p->source() << "\n" - << " ethertype : 0x" - << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n"; + << " destination : " << p->destination() << "\n" + << " source : " << p->source() << "\n" + << " type/length : 0x" + << std::hex << std::setw(4) << std::setfill('0') << p->type_length() << "\n"; +} + +prefix_ senf::PacketInterpreterBase::factory_t senf::EthernetPacketType::nextPacketType(packet p) +{ + if (p->type_length() >= 1536) return lookup(p->type_length()); + else if (p->type_length() <= 1500) return LlcSnapPacket::factory(); + else return no_factory(); } prefix_ void senf::EthernetPacketType::finalize(packet p) { - p->type() << key(p.next()); + Packet n (p.next(nothrow)); + if (n) { + optional_key_t k (key(n)); + if (k) + p->type_length() << k; + else if (n.is()) + p->type_length() << n.data().size(); + } + // 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) @@ -75,9 +91,10 @@ prefix_ void senf::EthVLanPacketType::dump(packet p, std::ostream & os) prefix_ void senf::EthVLanPacketType::finalize(packet p) { - p->type() << key(p.next()); + p->type() << key(p.next(nothrow)); } + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_