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.
24 \brief IpV4Packet public header */
26 #ifndef HH_IpV4Packet_
27 #define HH_IpV4Packet_ 1
30 #include "Packets/Packets.hh"
32 //#include "IpV4Packet.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
37 /** \brief Parse an IpV4 packet
39 Parser implementing the IpV4 header. The fields implemented are:
41 \see IpV4PacketType \n
42 <a href="http://tools.ietf.org/html/rfc791">RFC 791</a>
44 \todo Implement options
46 struct Parse_IpV4 : public PacketParserBase
48 typedef Parse_UIntField < 0, 4 > Parse_Version;
49 typedef Parse_UIntField < 4, 8 > Parse_IHL;
50 typedef Parse_UInt8 Parse_8bit;
51 typedef Parse_UInt16 Parse_16bit;
52 typedef Parse_Flag < 0 > Parse_R;
53 typedef Parse_Flag < 1 > Parse_DF;
54 typedef Parse_Flag < 2 > Parse_MF;
55 typedef Parse_UIntField < 3, 16 > Parse_Frag;
56 typedef Parse_UInt32 Parse_32bit;
60 SENF_PACKET_PARSER_NO_INIT(Parse_IpV4);
62 SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
63 ((OverlayField)( version, Parse_Version ))
64 ((Field )( ihl, Parse_IHL ))
65 ((Field )( tos, Parse_8bit ))
66 ((Field )( length, Parse_16bit ))
67 ((Field )( identifier, Parse_16bit ))
68 ((OverlayField)( reserved, Parse_R ))
69 ((OverlayField)( df, Parse_DF ))
70 ((OverlayField)( mf, Parse_MF ))
71 ((Field )( frag, Parse_Frag ))
72 ((Field )( ttl, Parse_8bit ))
73 ((Field )( protocol, Parse_8bit ))
74 ((Field )( crc, Parse_16bit ))
75 ((Field )( source, Parse_32bit ))
76 ((Field )( destination, Parse_32bit )) );
80 Parse_Version version();
84 Parse_16bit identifier();
90 Parse_8bit protocol();
93 Parse_32bit destination();
102 /** \brief IP protocol number registry
104 This registeres packets with their IP protocol number.
106 \see <a href="http://www.iana.org/assignments/protocol-numbers">Protocol numbers</a> \n
110 typedef boost::uint16_t key_t;
113 /** \brief IpV4 packet
115 \par Packet type (typedef):
121 \par Associated registries:
124 \ingroup protocolbundle_default
126 struct IpV4PacketType
127 : public PacketTypeBase,
128 public PacketTypeMixin<IpV4PacketType, IpTypes>
130 typedef PacketTypeMixin<IpV4PacketType, IpTypes> mixin;
131 typedef ConcretePacket<IpV4PacketType> packet;
132 typedef Parse_IpV4 parser;
134 using mixin::nextPacketRange;
135 using mixin::nextPacketType;
136 using mixin::initSize;
139 static registry_key_t nextPacketKey(packet p)
140 { return p->protocol(); }
142 static void dump(packet p, std::ostream & os);
145 /** \brief IpV4 packet typedef */
146 typedef IpV4PacketType::packet IpV4Packet;
150 ///////////////////////////////hh.e////////////////////////////////////////
152 #ifndef SENF_PACKETS_DECL_ONLY
153 //#include IpV4Packet.cci"
154 //#include "IpV4Packet.ct"
155 //#include "IpV4Packet.cti"
162 // c-file-style: "senf"
163 // indent-tabs-mode: nil
164 // ispell-local-dictionary: "american"
165 // compile-command: "scons -u test"
166 // comment-column: 40