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_IpV4Packet_
24 #define HH_IpV4Packet_ 1
28 #include "ParseInt.hh"
29 #include "ParseArray.hh"
30 #include "PacketRegistry.hh"
32 //#include "IpV4Packet.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
38 template <class Iterator=nil, class IpV4Packet=nil>
39 struct Parse_IpV4 : public ParserBase<Iterator,IpV4Packet>
41 template <class I, class P=nil>
42 struct rebind { typedef Parse_IpV4<I,P> parser; };
43 typedef Iterator byte_iterator;
46 Parse_IpV4(Iterator const & i) : ParserBase<Iterator,IpV4Packet>(i) {}
48 static unsigned bytes() { return 20; }
50 ///////////////////////////////////////////////////////////////////////////
52 typedef Parse_UIntField < 0, 4, Iterator > Parse_Version;
53 typedef Parse_UIntField < 4, 8, Iterator > Parse_IHL;
54 typedef Parse_UInt8 < Iterator > Parse_8bit;
55 typedef Parse_UInt16 < Iterator > Parse_16bit;
56 typedef Parse_Flag < 0, Iterator > Parse_R;
57 typedef Parse_Flag < 1, Iterator > Parse_DF;
58 typedef Parse_Flag < 2, Iterator > Parse_MF;
59 typedef Parse_UIntField < 3, 16, Iterator > Parse_Frag;
60 typedef Parse_UInt32 < Iterator > Parse_32bit;
62 Parse_Version version() const { return Parse_Version (this->i() ); }
63 Parse_IHL ihl() const { return Parse_IHL (this->i() ); }
64 Parse_8bit tos() const { return Parse_8bit (this->i() + 1 ); }
65 Parse_16bit length() const { return Parse_16bit (this->i() + 2 ); }
66 Parse_16bit identifier() const { return Parse_16bit (this->i() + 4 ); }
67 Parse_R reserved() const { return Parse_R (this->i() + 6 ); }
68 Parse_DF df() const { return Parse_DF (this->i() + 6 ); }
69 Parse_MF mf() const { return Parse_MF (this->i() + 6 ); }
70 Parse_Frag frag() const { return Parse_Frag (this->i() + 6 ); }
71 Parse_8bit ttl() const { return Parse_8bit (this->i() + 8 ); }
72 Parse_8bit protocol() const { return Parse_8bit (this->i() + 9 ); }
73 Parse_16bit crc() const { return Parse_16bit (this->i() + 10 ); }
74 Parse_32bit source() const { return Parse_32bit (this->i() + 12 ); }
75 Parse_32bit destination() const { return Parse_32bit (this->i() + 16 ); }
79 typedef boost::uint16_t key_t;
84 public Parse_IpV4<Packet::iterator,IpV4Packet>,
85 public PacketRegistryMixin<IpV4Types,IpV4Packet>
87 using PacketRegistryMixin<IpV4Types,IpV4Packet>::registerInterpreter;
89 ///////////////////////////////////////////////////////////////////////////
92 typedef ptr_t<IpV4Packet>::ptr ptr;
94 ///////////////////////////////////////////////////////////////////////////
98 IpV4Packet(Arg const & arg);
100 virtual void v_nextInterpreter() const;
101 virtual void v_finalize();
102 virtual void v_dump(std::ostream & os) const;
109 ///////////////////////////////hh.e////////////////////////////////////////
110 //#include IpV4Packet.cci"
111 //#include "IpV4Packet.ct"
112 #include "IpV4Packet.cti"
118 // c-file-style: "satcom"