X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FDefaultBundle%2FIpV6Packet.hh;h=b93a81b42639b268f51bdde28dc88771833612bb;hb=f1fc7057fa65a9509651d08c6c134d136fbb0424;hp=b332a9846b5b892fd716d23f79ef3ba287012d31;hpb=2d6585ff852e9d282c17003ba1db0b73eb3a8500;p=senf.git diff --git a/Packets/DefaultBundle/IpV6Packet.hh b/Packets/DefaultBundle/IpV6Packet.hh index b332a98..b93a81b 100644 --- a/Packets/DefaultBundle/IpV6Packet.hh +++ b/Packets/DefaultBundle/IpV6Packet.hh @@ -25,6 +25,7 @@ #define HH_IpV6Packet_ 1 // Custom includes +#include "Socket/Protocols/INet/INet6Address.hh" #include "Packets/Packets.hh" #include "IpV4Packet.hh" @@ -33,23 +34,44 @@ namespace senf { - ///\addtogroup protocolbundle_default - ///@{ - - // See RFC2460 - struct Parse_IpV6 : public PacketParserBase + /** \brief Parse an IpV6 address + + \see INet6Address + */ + struct Parse_INet6Address : public PacketParserBase { - SENF_PACKET_PARSER_NO_INIT(Parse_IpV6); + Parse_INet6Address(data_iterator i, state_type s) : PacketParserBase(i,s,fixed_bytes) {} /////////////////////////////////////////////////////////////////////////// + typedef INet6Address value_type; + static const size_type fixed_bytes = 16u; + + value_type value() const { return value_type::from_data(i()); } + void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); } + operator value_type() { return value(); } + byte & operator[](size_type index) { return *boost::next(i(),index); } + Parse_INet6Address const & operator= (value_type const & other) + { value(other); return *this; } + }; + + /** \brief Parse an IpV6 packet + + \see IpV6PacketType \n + RFC 2460 + */ + struct Parse_IpV6 : public PacketParserBase + { 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_INet6Address Parse_Addr; - 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 )) @@ -61,11 +83,37 @@ namespace senf { ((Field )( source, Parse_Addr )) ((Field )( destination, Parse_Addr )) ); +# else + + Parse_Version version() const; + Parse_Class trafficClass() const; + Parse_FlowLabel flowLabel() const; + Parse_16bit length() const; + Parse_8bit nextHeader() const; + Parse_8bit hopLimit() const; + Parse_Addr source() const; + Parse_Addr destination() const; + +# endif + void init() { version() = 6; } }; + /** \brief IpV6 packet + + \par Packet type (typedef): + \ref IpV6Packet + + \par Fields: + \ref Parse_IpV6 + + \par Associated registries: + \ref IpTypes + + \ingroup protocolbundle_default + */ struct IpV6PacketType : public PacketTypeBase, public PacketTypeMixin @@ -85,6 +133,7 @@ namespace senf { static void dump(packet p, std::ostream & os); }; + /** \brief IpV6 packet typedef */ typedef IpV6PacketType::packet IpV6Packet; ///@}