1 // $Id: IpV4Packet.hh 307 2007-07-14 21:31:12Z g0dil $
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
27 #include "Packets/PacketType.hh"
28 #include "Packets/ParseInt.hh"
29 #include "Packets/PacketRegistry.hh"
30 #include "Packets/PacketParser.hh"
32 //#include "IpV4Packet.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
37 ///\addtogroup protocolbundle_default
40 struct Parse_IpV4 : public PacketParserBase
42 SENF_PACKET_PARSER_NO_INIT(Parse_IpV4);
44 ///////////////////////////////////////////////////////////////////////////
46 typedef Parse_UIntField < 0, 4 > Parse_Version;
47 typedef Parse_UIntField < 4, 8 > Parse_IHL;
48 typedef Parse_UInt8 Parse_8bit;
49 typedef Parse_UInt16 Parse_16bit;
50 typedef Parse_Flag < 0 > Parse_R;
51 typedef Parse_Flag < 1 > Parse_DF;
52 typedef Parse_Flag < 2 > Parse_MF;
53 typedef Parse_UIntField < 3, 16 > Parse_Frag;
54 typedef Parse_UInt32 Parse_32bit;
56 SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
57 ((OverlayField)( version, Parse_Version ))
58 ((Field )( ihl, Parse_IHL ))
59 ((Field )( tos, Parse_8bit ))
60 ((Field )( length, Parse_16bit ))
61 ((Field )( identifier, Parse_16bit ))
62 ((OverlayField)( reserved, Parse_R ))
63 ((OverlayField)( df, Parse_DF ))
64 ((OverlayField)( mf, Parse_MF ))
65 ((Field )( frag, Parse_Frag ))
66 ((Field )( ttl, Parse_8bit ))
67 ((Field )( protocol, Parse_8bit ))
68 ((Field )( crc, Parse_16bit ))
69 ((Field )( source, Parse_32bit ))
70 ((Field )( destination, Parse_32bit )) );
78 // See http://www.iana.org/assignments/protocol-numbers
80 typedef boost::uint16_t key_t;
84 : public PacketTypeBase,
85 public PacketTypeMixin<IpV4PacketType, IpTypes>
87 typedef PacketTypeMixin<IpV4PacketType, IpTypes> mixin;
88 typedef ConcretePacket<IpV4PacketType> packet;
89 typedef Parse_IpV4 parser;
91 using mixin::nextPacketRange;
92 using mixin::nextPacketType;
93 using mixin::initSize;
96 static registry_key_t nextPacketKey(packet p)
97 { return p->protocol(); }
99 static void dump(packet p, std::ostream & os);
102 typedef IpV4PacketType::packet IpV4Packet;
108 ///////////////////////////////hh.e////////////////////////////////////////
109 //#include IpV4Packet.cci"
110 //#include "IpV4Packet.ct"
111 //#include "IpV4Packet.cti"
118 // c-file-style: "senf"
119 // indent-tabs-mode: nil
120 // ispell-local-dictionary: "american"
121 // compile-command: "scons -u test"
122 // comment-column: 40