X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FIpV6Packet.hh;h=112afdc99cb5a375ff36ae5123aadba817c646b8;hb=a4e052fb8832499ef5e3ae4e563ea01b834010c2;hp=d7809a365c7ec7f5a48fc04cd33eec0eddfb2833;hpb=31d85cd6b8e03c5ecc924ca8892906be1bab702f;p=senf.git diff --git a/Packets/DefaultBundle/IpV6Packet.hh b/Packets/DefaultBundle/IpV6Packet.hh index d7809a3..112afdc 100644 --- a/Packets/DefaultBundle/IpV6Packet.hh +++ b/Packets/DefaultBundle/IpV6Packet.hh @@ -25,10 +25,7 @@ #define HH_IpV6Packet_ 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.hh" //#include "IpV6Packet.mpp" @@ -36,70 +33,99 @@ namespace senf { - // See RFC2460 - template - struct Parse_IpV6 : public ParserBase - { - 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; } - - /////////////////////////////////////////////////////////////////////////// - - 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; + /** \brief Parse an IpV6 packet - 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 ); } - }; + Parser implementing the IpV6 header. The fields implemented are: - class IpV6Packet - : public Packet, - public Parse_IpV6, - public PacketRegistryMixin + \see IpV6PacketType \n + RFC 2460 + */ + struct Parse_IpV6 : public PacketParserBase { - using PacketRegistryMixin::registerInterpreter; - public: - /////////////////////////////////////////////////////////////////////////// - // Types - - typedef ptr_t::ptr ptr; + 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; + +# ifndef DOXYGEN + + SENF_PACKET_PARSER_NO_INIT(Parse_IpV6); + + 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 )) ); + +# else + + Parse_Version version(); + Parse_Class trafficClass(); + Parse_FlowLabel flowLabel(); + Parse_16bit length(); + Parse_8bit nextHeader(); + Parse_8bit hopLimit(); + Parse_Addr source(); + Parse_Addr destination(); + +# endif + + void init() { + version() = 6; + } + }; - /////////////////////////////////////////////////////////////////////////// + /** \brief IpV6 packet - private: - template - IpV6Packet(Arg const & arg); + \par Packet type (typedef): + \ref IpV6Packet + + \par Fields: + \ref Parse_IpV6 - virtual void v_nextInterpreter() const; - virtual void v_finalize(); - virtual void v_dump(std::ostream & os) const; + \par Associated registries: + \ref IpTypes - friend class Packet; + \ingroup protocolbundle_default + */ + struct IpV6PacketType + : public PacketTypeBase, + public PacketTypeMixin + { + 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); }; + /** \brief IpV6 packet typedef */ + typedef IpV6PacketType::packet IpV6Packet; + + ///@} } ///////////////////////////////hh.e//////////////////////////////////////// +#endif +#ifndef SENF_PACKETS_DECL_ONLY //#include "IpV6Packet.cci" //#include "IpV6Packet.ct" -#include "IpV6Packet.cti" +//#include "IpV6Packet.cti" #endif @@ -110,4 +136,5 @@ namespace senf { // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" +// comment-column: 40 // End: