X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FEthernetPacket.cc;h=78fe56c3746ad495b91a1ba6b9f7fd7548db9073;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=937f21978a5ab431658a05e6da91a5e5f81ea90e;hpb=6bb3fa3caaa41dab4d5b451ca27e70f9e55e49d6;p=senf.git diff --git a/Packets/DefaultBundle/EthernetPacket.cc b/Packets/DefaultBundle/EthernetPacket.cc index 937f219..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,17 +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 : " - << 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) +{ + 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) @@ -64,10 +85,16 @@ prefix_ void senf::EthVLanPacketType::dump(packet p, std::ostream & os) << " priority : " << p->priority() << "\n" << " cfi : " << p->cfi() << "\n" << " vlan-ID : " << p->vlanId() << "\n" - << " ethertype : " + << " ethertype : 0x" << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n"; } +prefix_ void senf::EthVLanPacketType::finalize(packet p) +{ + p->type() << key(p.next(nothrow)); +} + + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_