X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FIpV6Packet.hh;h=0f1aafbf9baec42bd572d775b925c7276b9b0855;hb=2c10a733c69cd95e10a312a471c84d07d52b7755;hp=32fd8078322e118ce7d8824b2141fd8986afe458;hpb=9357448dc66bc9acfd3bd8db423deb75bcd6a2c4;p=senf.git diff --git a/Packets/DefaultBundle/IpV6Packet.hh b/Packets/DefaultBundle/IpV6Packet.hh index 32fd807..0f1aafb 100644 --- a/Packets/DefaultBundle/IpV6Packet.hh +++ b/Packets/DefaultBundle/IpV6Packet.hh @@ -25,10 +25,11 @@ #define HH_IpV6Packet_ 1 // Custom includes -#include "Packets/Packet.hh" +#include "Packets/PacketType.hh" #include "Packets/ParseInt.hh" -#include "Packets/ParseArray.hh" #include "Packets/PacketRegistry.hh" +#include "Packets/PacketParser.hh" +#include "Packets/ParseArray.hh" #include "IpV4Packet.hh" //#include "IpV6Packet.mpp" @@ -36,70 +37,67 @@ namespace senf { + ///\addtogroup protocolbundle_default + ///@{ + // See RFC2460 - template - struct Parse_IpV6 : public ParserBase + struct Parse_IpV6 : public PacketParserBase { - template - struct rebind { typedef Parse_IpV6 parser; }; - typedef Iterator byte_iterator; - - Parse_IpV6() {} - Parse_IpV6(Iterator const & i) : ParserBase(i) {} - - static unsigned bytes() { return 40; } + SENF_PACKET_PARSER_NO_INIT(Parse_IpV6); /////////////////////////////////////////////////////////////////////////// - typedef Parse_UIntField < 0, 4, Iterator > Parse_Version; - typedef Parse_UIntField < 4, 12, Iterator > Parse_Class; - typedef Parse_UIntField < 12, 32, Iterator > Parse_FlowLabel; - typedef Parse_UInt8 < Iterator > Parse_8bit; - typedef Parse_UInt16 < Iterator > Parse_16bit; - - typedef Parse_Array < 16, Parse_8bit, Iterator > Parse_Addr; - - Parse_Version version() const { return Parse_Version (this->i() ); } - Parse_Class trafficClass() const { return Parse_Class (this->i() ); } - Parse_FlowLabel flowLabel() const { return Parse_FlowLabel (this->i() ); } - Parse_16bit length() const { return Parse_16bit (this->i() + 4 ); } - Parse_8bit nextHeader() const { return Parse_8bit (this->i() + 6 ); } - Parse_8bit hopLimit() const { return Parse_8bit (this->i() + 7 ); } - Parse_Addr source() const { return Parse_Addr (this->i() + 8 ); } - Parse_Addr destination() const { return Parse_Addr (this->i() + 24 ); } + typedef Parse_UIntField < 0, 4 > Parse_Version; + typedef Parse_UIntField < 4, 12 > Parse_Class; + typedef Parse_UIntField < 12, 32 > Parse_FlowLabel; + typedef Parse_UInt8 Parse_8bit; + typedef Parse_UInt16 Parse_16bit; + + typedef Parse_Array < 16, Parse_8bit > Parse_Addr; + + SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS( + ((OverlayField)( version, Parse_Version )) + ((OverlayField)( trafficClass, Parse_Class )) + ((Field )( flowLabel, Parse_FlowLabel )) + ((Field )( length, Parse_16bit )) + ((Field )( nextHeader, Parse_8bit )) + ((Field )( hopLimit, Parse_8bit )) + ((Field )( source, Parse_Addr )) + ((Field )( destination, Parse_Addr )) ); + + void init() { + version() = 6; + } }; - class IpV6Packet - : public Packet, - public Parse_IpV6, - public PacketRegistryMixin + struct IpV6PacketType + : public PacketTypeBase, + public PacketTypeMixin { - using PacketRegistryMixin::registerInterpreter; - public: - /////////////////////////////////////////////////////////////////////////// - // Types - - typedef ptr_t::ptr ptr; - - /////////////////////////////////////////////////////////////////////////// - - private: - template - IpV6Packet(Arg const & arg); - - virtual void v_nextInterpreter() const; - virtual void v_finalize(); - virtual void v_dump(std::ostream & os) const; - - friend class Packet; + typedef PacketTypeMixin mixin; + typedef ConcretePacket packet; + typedef Parse_IpV6 parser; + + using mixin::nextPacketRange; + using mixin::nextPacketType; + using mixin::initSize; + using mixin::init; + + static registry_key_t nextPacketKey(packet p) + { return p->nextHeader(); } + + static void dump(packet p, std::ostream & os); }; + typedef IpV6PacketType::packet IpV6Packet; + + ///@} } ///////////////////////////////hh.e//////////////////////////////////////// //#include "IpV6Packet.cci" //#include "IpV6Packet.ct" -#include "IpV6Packet.cti" +//#include "IpV6Packet.cti" #endif @@ -109,4 +107,6 @@ namespace senf { // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: