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 #ifndef HH_EthernetPacket_
24 #define HH_EthernetPacket_ 1
28 #include "ParseInt.hh"
29 #include "ParseArray.hh"
30 #include "PacketRegistry.hh"
32 //#include "EthernetPacket.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
38 template <class Iterator=nil, class IPacket=nil>
39 struct Parse_Ethernet : public ParserBase<Iterator,IPacket>
41 template <class I, class P=nil>
42 struct rebind { typedef Parse_Ethernet<I,P> parser; };
43 typedef Iterator byte_iterator;
46 Parse_Ethernet(Iterator const & i) : ParserBase<Iterator,IPacket>(i) {}
48 static unsigned bytes() { return 14; }
50 ///////////////////////////////////////////////////////////////////////////
52 typedef Parse_Array < 6, Parse_UInt8<>, Iterator > Parse_MAC;
53 typedef Parse_UInt16 < Iterator > Parse_Type;
55 Parse_MAC destination() const { return Parse_MAC (this->i() ); }
56 Parse_MAC source() const { return Parse_MAC (this->i() + Parse_MAC::size() ); }
57 Parse_Type type() const { return Parse_Type (this->i() + 2*Parse_MAC::size() ); }
61 // See http://www.iana.org/assignments/ethernet-numbers
62 typedef boost::uint16_t key_t;
67 public Parse_Ethernet<Packet::iterator, EthernetPacket>,
68 public PacketRegistryMixin<EtherTypes,EthernetPacket>
70 using PacketRegistryMixin<EtherTypes,EthernetPacket>::registerInterpreter;
72 ///////////////////////////////////////////////////////////////////////////
75 typedef ptr_t<EthernetPacket>::ptr ptr;
77 ///////////////////////////////////////////////////////////////////////////
81 EthernetPacket(Arg const & arg);
83 virtual void v_nextInterpreter() const;
84 virtual void v_finalize();
85 virtual void v_dump(std::ostream & os) const;
90 template <class Iterator=nil, class IPacket=nil>
91 struct Parse_EthVLan : public ParserBase<Iterator,IPacket>
93 template <class I, class P=nil>
94 struct rebind { typedef Parse_Ethernet<I,P> parser; };
95 typedef Iterator byte_iterator;
98 Parse_EthVLan(Iterator const & i) : ParserBase<Iterator,IPacket>(i) {}
100 static unsigned bytes() { return 4; }
102 ///////////////////////////////////////////////////////////////////////////
104 typedef Parse_UIntField < 0, 3, Iterator > Parse_Priority;
105 typedef Parse_Flag < 3, Iterator > Parse_CFI;
106 typedef Parse_UIntField < 4, 16, Iterator > Parse_VLanId;
107 typedef Parse_UInt16 < Iterator > Parse_Type;
109 Parse_Priority priority() const { return Parse_Priority(this->i()); }
110 Parse_CFI cfi() const { return Parse_CFI(this->i()); }
111 Parse_VLanId vlanId() const { return Parse_VLanId(this->i()); }
112 Parse_Type type() const { return Parse_Type(this->i()+2); }
117 public Parse_EthVLan<Packet::iterator, EthVLanPacket>,
118 public PacketRegistryMixin<EtherTypes, EthVLanPacket>
120 using PacketRegistryMixin<EtherTypes, EthVLanPacket>::registerInterpreter;
122 ///////////////////////////////////////////////////////////////////////////
125 typedef ptr_t<EthVLanPacket>::ptr ptr;
127 ///////////////////////////////////////////////////////////////////////////
131 EthVLanPacket(Arg const & arg);
133 virtual void v_nextInterpreter() const;
134 virtual void v_finalize();
135 virtual void v_dump(std::ostream & os) const;
143 ///////////////////////////////hh.e////////////////////////////////////////
144 //#include "EthernetPacket.cci"
145 //#include "EthernetPacket.ct"
146 #include "EthernetPacket.cti"
153 // c-file-style: "senf"
154 // indent-tabs-mode: nil
155 // ispell-local-dictionary: "american"