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 senf::PacketRegistry<senf::EtherTypes>::RegistrationProxy<senf::EthVLanPacket>
37 registerEthVLanPacket(0x8100);
40 prefix_ void senf::EthernetPacket::v_nextInterpreter()
43 /** \todo Add LLC/SNAP support -> only use the registry
44 for type() values >=1536, otherwise expect an LLC header */
45 registerInterpreter(type(),begin()+bytes(),end());
50 void dumpmac(std::ostream & os, senf::EthernetPacket::Parse_MAC mac)
52 for (unsigned i = 0; i < 6; ++i) {
55 os << std::hex << std::setw(2) << std::setfill('0')
62 prefix_ void senf::EthernetPacket::v_dump(std::ostream & os)
66 os << "Ethernet 802.3";
67 else if (type() >= 0x600)
68 os << "Ethernet II (DIX)";
70 os << "Ethernet 802.3 (bad ethertype >1500 and <1536)";
73 dumpmac(os,destination());
78 << " ethertype : " << std::hex << std::setw(4) << std::setfill('0')
79 << unsigned(type()) << "\n" << std::dec;
82 prefix_ void senf::EthernetPacket::v_finalize()
85 prefix_ void senf::EthVLanPacket::v_nextInterpreter()
88 /** \todo Add LLC/SNAP support (see above) */
89 registerInterpreter(type(),begin()+bytes(),end());
92 prefix_ void senf::EthVLanPacket::v_finalize()
95 prefix_ void senf::EthVLanPacket::v_dump(std::ostream & os)
98 os << "Ethernet 802.1q (VLAN):\n"
99 << " priority : " << priority() << "\n"
100 << " cfi : " << cfi() << "\n"
101 << " vlan-ID : " << vlanId() << "\n"
102 << " ethertype : " << boost::format("%04x") % type() << "\n";
105 ///////////////////////////////cc.e////////////////////////////////////////
111 // c-file-style: "senf"