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/Packets.hh"
29 //#include "IpV4Packet.mpp"
30 ///////////////////////////////hh.p////////////////////////////////////////
34 ///\addtogroup protocolbundle_default
37 struct Parse_IpV4 : public PacketParserBase
39 SENF_PACKET_PARSER_NO_INIT(Parse_IpV4);
41 ///////////////////////////////////////////////////////////////////////////
43 typedef Parse_UIntField < 0, 4 > Parse_Version;
44 typedef Parse_UIntField < 4, 8 > Parse_IHL;
45 typedef Parse_UInt8 Parse_8bit;
46 typedef Parse_UInt16 Parse_16bit;
47 typedef Parse_Flag < 0 > Parse_R;
48 typedef Parse_Flag < 1 > Parse_DF;
49 typedef Parse_Flag < 2 > Parse_MF;
50 typedef Parse_UIntField < 3, 16 > Parse_Frag;
51 typedef Parse_UInt32 Parse_32bit;
53 SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
54 ((OverlayField)( version, Parse_Version ))
55 ((Field )( ihl, Parse_IHL ))
56 ((Field )( tos, Parse_8bit ))
57 ((Field )( length, Parse_16bit ))
58 ((Field )( identifier, Parse_16bit ))
59 ((OverlayField)( reserved, Parse_R ))
60 ((OverlayField)( df, Parse_DF ))
61 ((OverlayField)( mf, Parse_MF ))
62 ((Field )( frag, Parse_Frag ))
63 ((Field )( ttl, Parse_8bit ))
64 ((Field )( protocol, Parse_8bit ))
65 ((Field )( crc, Parse_16bit ))
66 ((Field )( source, Parse_32bit ))
67 ((Field )( destination, Parse_32bit )) );
75 // See http://www.iana.org/assignments/protocol-numbers
77 typedef boost::uint16_t key_t;
81 : public PacketTypeBase,
82 public PacketTypeMixin<IpV4PacketType, IpTypes>
84 typedef PacketTypeMixin<IpV4PacketType, IpTypes> mixin;
85 typedef ConcretePacket<IpV4PacketType> packet;
86 typedef Parse_IpV4 parser;
88 using mixin::nextPacketRange;
89 using mixin::nextPacketType;
90 using mixin::initSize;
93 static registry_key_t nextPacketKey(packet p)
94 { return p->protocol(); }
96 static void dump(packet p, std::ostream & os);
99 typedef IpV4PacketType::packet IpV4Packet;
105 ///////////////////////////////hh.e////////////////////////////////////////
107 #ifndef SENF_PACKETS_DECL_ONLY
108 //#include IpV4Packet.cci"
109 //#include "IpV4Packet.ct"
110 //#include "IpV4Packet.cti"
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // comment-column: 40