X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FIpV4Packet.hh;h=773345eb77226210b28812fdb43c24f348bb63b6;hb=1f3b4447179d0cd771037d02b9a5671eeaaaec8d;hp=94a3a911535de2543e3adbc04a6d60f0493f3096;hpb=9357448dc66bc9acfd3bd8db423deb75bcd6a2c4;p=senf.git
diff --git a/Packets/DefaultBundle/IpV4Packet.hh b/Packets/DefaultBundle/IpV4Packet.hh
index 94a3a91..773345e 100644
--- a/Packets/DefaultBundle/IpV4Packet.hh
+++ b/Packets/DefaultBundle/IpV4Packet.hh
@@ -20,98 +20,139 @@
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+/** \file
+ \brief IpV4Packet public header */
+
#ifndef HH_IpV4Packet_
#define HH_IpV4Packet_ 1
// Custom includes
-#include "Packets/Packet.hh"
-#include "Packets/ParseInt.hh"
-#include "Packets/ParseArray.hh"
-#include "Packets/PacketRegistry.hh"
+#include "Packets/Packets.hh"
//#include "IpV4Packet.mpp"
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
+ /** \brief Parse an IpV4 packet
+
+ Parser implementing the IpV4 header. The fields implemented are:
+
+ \see IpV4PacketType \n
+ RFC 791
- template
- struct Parse_IpV4 : public ParserBase
+ \todo Implement options
+ */
+ struct Parse_IpV4 : public PacketParserBase
{
- template
- struct rebind { typedef Parse_IpV4 parser; };
- typedef Iterator byte_iterator;
-
- Parse_IpV4() {}
- Parse_IpV4(Iterator const & i) : ParserBase(i) {}
-
- static unsigned bytes() { return 20; }
-
- ///////////////////////////////////////////////////////////////////////////
-
- typedef Parse_UIntField < 0, 4, Iterator > Parse_Version;
- typedef Parse_UIntField < 4, 8, Iterator > Parse_IHL;
- typedef Parse_UInt8 < Iterator > Parse_8bit;
- typedef Parse_UInt16 < Iterator > Parse_16bit;
- typedef Parse_Flag < 0, Iterator > Parse_R;
- typedef Parse_Flag < 1, Iterator > Parse_DF;
- typedef Parse_Flag < 2, Iterator > Parse_MF;
- typedef Parse_UIntField < 3, 16, Iterator > Parse_Frag;
- typedef Parse_UInt32 < Iterator > Parse_32bit;
-
- Parse_Version version() const { return Parse_Version (this->i() ); }
- Parse_IHL ihl() const { return Parse_IHL (this->i() ); }
- Parse_8bit tos() const { return Parse_8bit (this->i() + 1 ); }
- Parse_16bit length() const { return Parse_16bit (this->i() + 2 ); }
- Parse_16bit identifier() const { return Parse_16bit (this->i() + 4 ); }
- Parse_R reserved() const { return Parse_R (this->i() + 6 ); }
- Parse_DF df() const { return Parse_DF (this->i() + 6 ); }
- Parse_MF mf() const { return Parse_MF (this->i() + 6 ); }
- Parse_Frag frag() const { return Parse_Frag (this->i() + 6 ); }
- Parse_8bit ttl() const { return Parse_8bit (this->i() + 8 ); }
- Parse_8bit protocol() const { return Parse_8bit (this->i() + 9 ); }
- Parse_16bit crc() const { return Parse_16bit (this->i() + 10 ); }
- Parse_32bit source() const { return Parse_32bit (this->i() + 12 ); }
- Parse_32bit destination() const { return Parse_32bit (this->i() + 16 ); }
+ typedef Parse_UIntField < 0, 4 > Parse_Version;
+ typedef Parse_UIntField < 4, 8 > Parse_IHL;
+ typedef Parse_UInt8 Parse_8bit;
+ typedef Parse_UInt16 Parse_16bit;
+ typedef Parse_Flag < 0 > Parse_R;
+ typedef Parse_Flag < 1 > Parse_DF;
+ typedef Parse_Flag < 2 > Parse_MF;
+ typedef Parse_UIntField < 3, 16 > Parse_Frag;
+ typedef Parse_UInt32 Parse_32bit;
+
+# ifndef DOXYGEN
+
+ SENF_PACKET_PARSER_NO_INIT(Parse_IpV4);
+
+ SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
+ ((OverlayField)( version, Parse_Version ))
+ ((Field )( ihl, Parse_IHL ))
+ ((Field )( tos, Parse_8bit ))
+ ((Field )( length, Parse_16bit ))
+ ((Field )( identifier, Parse_16bit ))
+ ((OverlayField)( reserved, Parse_R ))
+ ((OverlayField)( df, Parse_DF ))
+ ((OverlayField)( mf, Parse_MF ))
+ ((Field )( frag, Parse_Frag ))
+ ((Field )( ttl, Parse_8bit ))
+ ((Field )( protocol, Parse_8bit ))
+ ((Field )( crc, Parse_16bit ))
+ ((Field )( source, Parse_32bit ))
+ ((Field )( destination, Parse_32bit )) );
+
+# else
+
+ Parse_Version version();
+ Parse_IHL ihl();
+ Parse_8bit tos();
+ Parse_16bit length();
+ Parse_16bit identifier();
+ Parse_R reserved();
+ Parse_DF df();
+ Parse_MF mf();
+ Parse_Frag frag();
+ Parse_8bit ttl();
+ Parse_8bit protocol();
+ Parse_16bit crc();
+ Parse_32bit source();
+ Parse_32bit destination();
+
+# endif
+
+ void init() {
+ version() = 4;
+ }
};
+ /** \brief IP protocol number registry
+
+ This registeres packets with their IP protocol number.
+
+ \see Protocol numbers \n
+ PacketRegistry
+ */
struct IpTypes {
- // See http://www.iana.org/assignments/protocol-numbers
- // Also used by IPv6
typedef boost::uint16_t key_t;
};
- class IpV4Packet
- : public Packet,
- public Parse_IpV4,
- public PacketRegistryMixin
- {
- using PacketRegistryMixin::registerInterpreter;
- public:
- ///////////////////////////////////////////////////////////////////////////
- // Types
+ /** \brief IpV4 packet
+
+ \par Packet type (typedef):
+ \ref IpV4Packet
+
+ \par Fields:
+ \ref Parse_IpV4
- typedef ptr_t::ptr ptr;
+ \par Associated registries:
+ \ref IpTypes
- ///////////////////////////////////////////////////////////////////////////
+ \ingroup protocolbundle_default
+ */
+ struct IpV4PacketType
+ : public PacketTypeBase,
+ public PacketTypeMixin
+ {
+ typedef PacketTypeMixin mixin;
+ typedef ConcretePacket packet;
+ typedef Parse_IpV4 parser;
- private:
- template
- IpV4Packet(Arg const & arg);
+ using mixin::nextPacketRange;
+ using mixin::nextPacketType;
+ using mixin::initSize;
+ using mixin::init;
- virtual void v_nextInterpreter() const;
- virtual void v_finalize();
- virtual void v_dump(std::ostream & os) const;
+ static registry_key_t nextPacketKey(packet p)
+ { return p->protocol(); }
- friend class Packet;
+ static void dump(packet p, std::ostream & os);
};
+
+ /** \brief IpV4 packet typedef */
+ typedef IpV4PacketType::packet IpV4Packet;
}
///////////////////////////////hh.e////////////////////////////////////////
+#endif
+#ifndef SENF_PACKETS_DECL_ONLY
//#include IpV4Packet.cci"
//#include "IpV4Packet.ct"
-#include "IpV4Packet.cti"
+//#include "IpV4Packet.cti"
#endif
@@ -121,4 +162,6 @@ namespace senf {
// c-file-style: "senf"
// indent-tabs-mode: nil
// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
// End: