4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Definition of non-inline non-template functions
25 #include "EthernetPacket.hh"
26 //#include "EthernetPacket.ih"
30 #include <boost/format.hpp>
33 ///////////////////////////////cc.p////////////////////////////////////////
36 namespace pkf = satcom::pkf;
37 pkf::PacketRegistry<pkf::EtherTypes>::RegistrationProxy<pkf::EthVLanPacket>
38 registerEthVLanPacket(0x8100);
41 prefix_ void satcom::pkf::EthernetPacket::v_nextInterpreter()
44 // TODO: Add LLC/SNAP support -> only use the registry
45 // for type() values >=1536, otherwise expect an LLC header
46 registerInterpreter(type(),begin()+bytes(),end());
51 void dumpmac(std::ostream & os, satcom::pkf::EthernetPacket::Parse_MAC mac)
53 for (unsigned i = 0; i < 6; ++i) {
56 os << std::hex << std::setw(2) << std::setfill('0')
63 prefix_ void satcom::pkf::EthernetPacket::v_dump(std::ostream & os)
67 os << "Ethernet 802.3";
68 else if (type() >= 0x600)
69 os << "Ethernet II (DIX)";
71 os << "Ethernet 802.3 (bad ethertype >1500 and <1536)";
74 dumpmac(os,destination());
79 << " ethertype : " << std::hex << std::setw(4) << std::setfill('0')
80 << unsigned(type()) << "\n" << std::dec;
83 prefix_ void satcom::pkf::EthernetPacket::v_finalize()
86 prefix_ void satcom::pkf::EthVLanPacket::v_nextInterpreter()
89 // TODO: Add LLC/SNAP support -> only use the registry
90 // for type() values >=1536, otherwise expect an LLC header
91 registerInterpreter(type(),begin()+bytes(),end());
94 prefix_ void satcom::pkf::EthVLanPacket::v_finalize()
97 prefix_ void satcom::pkf::EthVLanPacket::v_dump(std::ostream & os)
100 os << "Ethernet 802.1q (VLAN):\n"
101 << " priority : " << priority() << "\n"
102 << " cfi : " << cfi() << "\n"
103 << " vlan-ID : " << vlanId() << "\n"
104 << " ethertype : " << boost::format("%04x") % type() << "\n";
107 ///////////////////////////////cc.e////////////////////////////////////////
113 // c-file-style: "satcom"