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 typedef boost::uint16_t key_t;
66 public Parse_Ethernet<Packet::iterator, EthernetPacket>,
67 public PacketRegistryMixin<EtherTypes,EthernetPacket>
69 using PacketRegistryMixin<EtherTypes,EthernetPacket>::registerInterpreter;
71 ///////////////////////////////////////////////////////////////////////////
74 typedef ptr_t<EthernetPacket>::ptr ptr;
76 ///////////////////////////////////////////////////////////////////////////
80 EthernetPacket(Arg const & arg);
82 virtual void v_nextInterpreter() const;
83 virtual void v_finalize();
84 virtual void v_dump(std::ostream & os) const;
89 template <class Iterator=nil, class IPacket=nil>
90 struct Parse_EthVLan : public ParserBase<Iterator,IPacket>
92 template <class I, class P=nil>
93 struct rebind { typedef Parse_Ethernet<I,P> parser; };
94 typedef Iterator byte_iterator;
97 Parse_EthVLan(Iterator const & i) : ParserBase<Iterator,IPacket>(i) {}
99 static unsigned bytes() { return 4; }
101 ///////////////////////////////////////////////////////////////////////////
103 typedef Parse_UIntField < 0, 3, Iterator > Parse_Priority;
104 typedef Parse_Flag < 3, Iterator > Parse_CFI;
105 typedef Parse_UIntField < 4, 16, Iterator > Parse_VLanId;
106 typedef Parse_UInt16 < Iterator > Parse_Type;
108 Parse_Priority priority() const { return Parse_Priority(this->i()); }
109 Parse_CFI cfi() const { return Parse_CFI(this->i()); }
110 Parse_VLanId vlanId() const { return Parse_VLanId(this->i()); }
111 Parse_Type type() const { return Parse_Type(this->i()+2); }
116 public Parse_EthVLan<Packet::iterator, EthVLanPacket>,
117 public PacketRegistryMixin<EtherTypes, EthVLanPacket>
119 using PacketRegistryMixin<EtherTypes, EthVLanPacket>::registerInterpreter;
121 ///////////////////////////////////////////////////////////////////////////
124 typedef ptr_t<EthVLanPacket>::ptr ptr;
126 ///////////////////////////////////////////////////////////////////////////
130 EthVLanPacket(Arg const & arg);
132 virtual void v_nextInterpreter() const;
133 virtual void v_finalize();
134 virtual void v_dump(std::ostream & os) const;
142 ///////////////////////////////hh.e////////////////////////////////////////
143 //#include "EthernetPacket.cci"
144 //#include "EthernetPacket.ct"
145 #include "EthernetPacket.cti"
151 // c-file-style: "satcom"