From a053b599a53ecf6ac40c3f79d52b35a56fc841d0 Mon Sep 17 00:00:00 2001 From: pug <pug@wiback.org> Date: Thu, 9 Apr 2009 08:52:01 +0000 Subject: [PATCH] added Destination Options skeleton for IPv6 extension Header and added that to IpTypes registry --- Packets/DefaultBundle/IPv6Extensions.cc | 9 +++ Packets/DefaultBundle/IPv6Extensions.hh | 68 ++++++++++++++++++++ Packets/DefaultBundle/IPv6Extensions.test.cc | 6 +- 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/Packets/DefaultBundle/IPv6Extensions.cc b/Packets/DefaultBundle/IPv6Extensions.cc index 6ccd8654..f6739869 100644 --- a/Packets/DefaultBundle/IPv6Extensions.cc +++ b/Packets/DefaultBundle/IPv6Extensions.cc @@ -39,6 +39,8 @@ namespace { registerIPv6ExtensionType_Routing (43); senf::PacketRegistry<senf::IpTypes>::RegistrationProxy<senf::IPv6Extension_HopByHop> registerIPv6ExtensionType_HopByHop (0u); + senf::PacketRegistry<senf::IpTypes>::RegistrationProxy<senf::IPv6Extension_Destination> + registerIPv6ExtensionType_Destination (60u); } prefix_ void senf::IPv6ExtensionType_Fragment::dump(packet p, std::ostream & os) @@ -72,6 +74,13 @@ prefix_ void senf::IPv6ExtensionType_HopByHop::dump(packet p, std::ostream & os) << " header length : " << unsigned (p->headerLength()) << "\n"; } +prefix_ void senf::IPv6ExtensionType_Destination::dump(packet p, std::ostream & os) +{ + os << "Internet protocol Version 6 Destination Options extension:\n" + << " next header : " << unsigned (p->nextHeader()) << "\n" + << " header length : " << unsigned (p->headerLength()) << "\n"; +} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "IPv6Extensions.mpp" diff --git a/Packets/DefaultBundle/IPv6Extensions.hh b/Packets/DefaultBundle/IPv6Extensions.hh index f768c1b6..5e08e4ae 100644 --- a/Packets/DefaultBundle/IPv6Extensions.hh +++ b/Packets/DefaultBundle/IPv6Extensions.hh @@ -281,6 +281,74 @@ The Type 0 Routing header has the following format: (RFC 2460) /** \brief IPv6 routing Hop-By-Hop packet typedef */ typedef ConcretePacket<IPv6ExtensionType_HopByHop> IPv6Extension_HopByHop; +// ===================================================================================================== + + /** \brief Parse in IPv6 Destination Options extension header + + Parser implementing the IPv6 Destination Options Header extension. The fields implemented are: + \image html IPv6Extensions_Destination.png + + \see IPv6ExtensionType_Destination \n + <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a> + */ + + // Destination Options skeleton without TLV-Options + + struct IPv6PacketParserExtension_Destination : public PacketParserBase { +# include SENF_PARSER() + SENF_PARSER_FIELD ( nextHeader, UInt8Parser ); + SENF_PARSER_FIELD ( headerLength, UInt8Parser ); + + SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_Destination ); + }; + + /** \brief IPv6 Destination Options extension + + \par Packet type (typedef): + \ref IPv6Extension_Destination + + \par Fields: + \ref IPv6PacketParserExtension_Destination + + \par Associated registries: + \ref IpTypes + + \par Finalize action: + Set \a nextHeader from type of next packet if found in \ref IpTypes + + \ingroup protocolbundle_default + */ + + struct IPv6ExtensionType_Destination + : public PacketTypeBase, + public PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes> + { +#ifndef DOXYGEN + typedef PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes> mixin; +#endif + /** \brief IPv6 Destination Options extension packet typedef */ + typedef ConcretePacket<IPv6ExtensionType_Destination> packet; + /** \brief typedef to the parser of IPv6 Destination Options extension packet */ + typedef IPv6PacketParserExtension_Destination parser; + + using mixin::nextPacketRange; + using mixin::nextPacketType; + using mixin::init; + using mixin::initSize; + + static key_t nextPacketKey(packet p) + { return p->nextHeader(); } + /** \brief Dump given IPv6Extension_Destination in readable form to given output stream */ + static void dump(packet p, std::ostream & os); + + static void finalize(packet p) { + p->nextHeader() << key(p.next(nothrow)); } + }; + + /** \brief IPv6 routing Destination Options packet typedef */ + typedef ConcretePacket<IPv6ExtensionType_Destination> IPv6Extension_Destination; + + } //namespace senf ///////////////////////////////hh.e//////////////////////////////////////// #endif diff --git a/Packets/DefaultBundle/IPv6Extensions.test.cc b/Packets/DefaultBundle/IPv6Extensions.test.cc index bace7a8b..beb8c79b 100644 --- a/Packets/DefaultBundle/IPv6Extensions.test.cc +++ b/Packets/DefaultBundle/IPv6Extensions.test.cc @@ -147,7 +147,11 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions) BOOST_CHECK_EQUAL( pICMPv6->code(), 0u); BOOST_CHECK_EQUAL( pICMPv6->checksum(), 0xa3d3); } - + //============================================================================================== + + /* + no unittests for Hop by Hop - and Destination - Options extension Header yet. No real implementation there, only IPv6 extension skeleton implemented. + */ ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ -- GitLab