From: ssauer Date: Thu, 29 Apr 2010 14:47:55 +0000 (+0000) Subject: Added dump information for NDP options to appropriate ICMPv6 types X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=b559d8e50f059a49d0ac98aba08b4480a3da5b22;p=senf.git Added dump information for NDP options to appropriate ICMPv6 types git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1609 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc b/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc index 2cd182b..1f014e2 100644 --- a/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc +++ b/senf/Packets/DefaultBundle/ICMPv6TypePacket.cc @@ -129,6 +129,11 @@ prefix_ void senf::NDPRouterSolicitationMessageType::dump(packet p, std::ostream { os << "ICMPv6 Neighbor Discovery Router Solicitation Message:\n" << senf::fieldName("Reserved(32Bit)") << unsigned(p->reserved()) << "\n"; + senf::NDPRouterSolicitationMessage::Parser::options_t::container optC(p->options() ); + senf::NDPRouterSolicitationMessage::Parser::options_t::container::const_iterator listIter (optC.begin()); + for (; listIter != optC.end(); ++listIter) { + listIter->dump(os); + } } prefix_ void senf::NDPRouterAdvertisementMessageType::dump(packet p, std::ostream & os) @@ -141,6 +146,11 @@ prefix_ void senf::NDPRouterAdvertisementMessageType::dump(packet p, std::ostrea << senf::fieldName("Router Lifetime") << unsigned(p->routerLifetime()) << "\n" << senf::fieldName("Reachable Time") << unsigned(p->reachableTime()) << "\n" << senf::fieldName("Retrans Timer") << unsigned(p->retransTimer()) << "\n"; + senf::NDPRouterAdvertisementMessage::Parser::options_t::container optC(p->options() ); + senf::NDPRouterAdvertisementMessage::Parser::options_t::container::const_iterator listIter (optC.begin()); + for (; listIter != optC.end(); ++listIter) { + listIter->dump(os); + } } prefix_ void senf::NDPNeighborSolicitationMessageType::dump(packet p, std::ostream & os) @@ -148,6 +158,11 @@ prefix_ void senf::NDPNeighborSolicitationMessageType::dump(packet p, std::ostre os << "ICMPv6 Neighbor Discovery Neighbor Solicitation Message:\n" << senf::fieldName("Reserved(32Bit)") << unsigned(p->reserved()) << "\n" << senf::fieldName("Target Address") << p->target() << "\n"; + senf::NDPNeighborSolicitationMessage::Parser::options_t::container optC(p->options() ); + senf::NDPNeighborSolicitationMessage::Parser::options_t::container::const_iterator listIter (optC.begin()); + for (; listIter != optC.end(); ++listIter) { + listIter->dump(os); + } } prefix_ void senf::NDPNeighborAdvertisementMessageType::dump(packet p, std::ostream & os) @@ -158,6 +173,11 @@ prefix_ void senf::NDPNeighborAdvertisementMessageType::dump(packet p, std::ostr << senf::fieldName("Override Flag") << unsigned(p->o()) << "\n" << senf::fieldName("Reserved(29Bit)") << unsigned(p->reserved()) << "\n" << senf::fieldName("Target Address") << p->target() << "\n"; + senf::NDPNeighborAdvertisementMessage::Parser::options_t::container optC(p->options() ); + senf::NDPNeighborAdvertisementMessage::Parser::options_t::container::const_iterator listIter (optC.begin()); + for (; listIter != optC.end(); ++listIter) { + listIter->dump(os); + } } prefix_ void senf::NDPRedirectMessageType::dump(packet p, std::ostream & os) @@ -166,6 +186,11 @@ prefix_ void senf::NDPRedirectMessageType::dump(packet p, std::ostream & os) << senf::fieldName("Reserved(32Bit)") << unsigned(p->reserved()) << "\n" << senf::fieldName("Target Address") << p->target() << "\n" << senf::fieldName("Destination Address") << p->destination() << "\n"; + senf::NDPRedirectMessage::Parser::options_t::container optC(p->options() ); + senf::NDPRedirectMessage::Parser::options_t::container::const_iterator listIter (optC.begin()); + for (; listIter != optC.end(); ++listIter) { + listIter->dump(os); + } } ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ diff --git a/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh b/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh index 4639499..78daaef 100644 --- a/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh +++ b/senf/Packets/DefaultBundle/ICMPv6TypePacket.hh @@ -439,7 +439,7 @@ namespace senf { struct NDPRouterSolicitationParser : public PacketParserBase { # include SENF_PARSER() - SENF_PARSER_FIELD ( reserved, UInt32Parser );// set to zero by default + SENF_PARSER_BITFIELD ( reserved, 32, unsigned );// set to zero by default SENF_PARSER_LIST ( options, packetSize(), senf::NDPGenericOptionParser ); SENF_PARSER_FINALIZE ( NDPRouterSolicitationParser ); diff --git a/senf/Packets/DefaultBundle/NDPMessage.test.cc b/senf/Packets/DefaultBundle/NDPMessage.test.cc index 35b3392..7817143 100644 --- a/senf/Packets/DefaultBundle/NDPMessage.test.cc +++ b/senf/Packets/DefaultBundle/NDPMessage.test.cc @@ -34,45 +34,35 @@ ///////////////////////////////cc.p//////////////////////////////////////// SENF_AUTO_UNIT_TEST(NDPMessage_create) { - senf::ICMPv6Packet icmp (senf::ICMPv6Packet::create()); - icmp->code() = 0; + unsigned char data[] = { + 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3a, 0xff, //IPv6 + 0x20, 0x01, 0x08, 0x90, 0x06, 0x00, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, + 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0xff, 0x03, 0x00, 0x02, + 0x87, 0x00, 0xaf, 0x30, //ICMPv6 + 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x08, 0x90, //Neighbor Solicitation + 0x60, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x03, 0x00, 0x02, + 0x01, 0x01, 0x00, 0x0d, //Source Option + 0x88, 0x70, 0xe4, 0xc0, + }; - senf::NDPNeighborAdvertisementMessage nadm (senf::NDPNeighborAdvertisementMessage::createAfter(icmp)); - nadm->r() = true; - nadm->s() = true; - nadm->o() = false; - nadm->target() = senf::INet6Address::Loopback; + senf::IPv6Packet ip (senf::IPv6Packet::create(data)); + senf::ICMPv6Packet icmp (ip.find()); - senf::NDPNeighborAdvertisementMessage::Parser::options_t::container optC(nadm->options()); - senf::NDPMTUTLVParser opt( - optC.push_back_space().init ()); - senf::NDPTargetLLAddressTLVParser opt2( - optC.push_back_space().init ()); - opt.mtu() = 1234u; - opt2.target() = senf::MACAddress::Broadcast; - - icmp.finalizeAll(); - - BOOST_CHECK_EQUAL(icmp->type(), 0x88 ); + BOOST_CHECK_EQUAL(icmp->type(), 0x87 ); BOOST_CHECK( icmp.next() ); - BOOST_CHECK( icmp.next().is() ); - senf::NDPNeighborAdvertisementMessage rnadm (icmp.next().as()); + BOOST_CHECK( icmp.next().is() ); + senf::NDPNeighborSolicitationMessage rnadm (icmp.next().as()); + BOOST_CHECK_EQUAL(rnadm.size(),28); - BOOST_CHECK_EQUAL( rnadm->r(), true ); - BOOST_CHECK_EQUAL( rnadm->s(), true ); - BOOST_CHECK_EQUAL( rnadm->o(), false ); - - senf::NDPNeighborAdvertisementMessage::Parser::options_t::container roptC(rnadm->options() ); - senf::NDPNeighborAdvertisementMessage::Parser::options_t::container::iterator listIter (roptC.begin()); - BOOST_CHECK( listIter->is() ); - BOOST_CHECK_EQUAL( listIter->type(), 5u ); - BOOST_CHECK_EQUAL( listIter->length(), 1u ); - senf::NDPMTUTLVParser mtuopt (listIter->as()); - BOOST_CHECK_EQUAL( mtuopt.mtu(), 1234u ); - listIter++; - BOOST_CHECK( listIter->is() ); - BOOST_CHECK_EQUAL( listIter->type(), 2u ); + senf::NDPNeighborSolicitationMessage::Parser::options_t::container roptC(rnadm->options() ); + senf::NDPNeighborSolicitationMessage::Parser::options_t::container::const_iterator listIter (roptC.begin()); + BOOST_CHECK( listIter->is() ); + BOOST_CHECK_EQUAL( listIter->type(), 1u ); BOOST_CHECK_EQUAL( listIter->length(), 1u ); + senf::NDPSourceLLAddressTLVParser llopt (listIter->as()); } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/senf/Packets/DefaultBundle/NDPOptions.cc b/senf/Packets/DefaultBundle/NDPOptions.cc index cc46aca..a76d41e 100644 --- a/senf/Packets/DefaultBundle/NDPOptions.cc +++ b/senf/Packets/DefaultBundle/NDPOptions.cc @@ -37,34 +37,34 @@ namespace { prefix_ void senf::NDPSourceLLAddressTLVParser::dump(std::ostream & os) const { - os << senf::fieldName(" Source Link-layer Address") << "\n"; - os << senf::fieldName(" Link-layer Address") << source() << "\n"; + os << "Source Link-layer Address Option:" << "\n"; + os << senf::fieldName("Link-layer Address") << source() << "\n"; } prefix_ void senf::NDPTargetLLAddressTLVParser::dump(std::ostream & os) const { - os << senf::fieldName(" Target Link-layer Address") << "\n"; - os << senf::fieldName(" Link-layer Address") << target() << "\n"; + os << "Target Link-layer Address Option:" << "\n"; + os << senf::fieldName("Link-layer Address") << target() << "\n"; } prefix_ void senf::NDPPrefixInformationTLVParser::dump(std::ostream & os) const { - os << senf::fieldName(" Prefix Information") << "\n"; - os << senf::fieldName(" Prefix Length") << unsigned(prefixLength()) << "\n"; - os << senf::fieldName(" On-link Flag") << unsigned(l()) << "\n"; - os << senf::fieldName(" Autonomous Address-configuration Flag") << unsigned(a()) << "\n"; - os << senf::fieldName(" Reserved(6Bit)") << unsigned(reserved1()) << "\n"; - os << senf::fieldName(" Valid Lifetime") << unsigned(validLifetime()) << "\n"; - os << senf::fieldName(" Preferred Lifetime") << unsigned(preferredLifetime()) << "\n"; - os << senf::fieldName(" Reserved(32Bit)") << unsigned(reserved2()) << "\n"; - os << senf::fieldName(" Prefix") << prefix() << "\n"; + os << "Prefix Information Option:" << "\n"; + os << senf::fieldName("Prefix Length") << unsigned(prefixLength()) << "\n"; + os << senf::fieldName("On-link Flag") << unsigned(l()) << "\n"; + os << senf::fieldName("Autonomous Address-configuration Flag") << unsigned(a()) << "\n"; + os << senf::fieldName("Reserved(6Bit)") << unsigned(reserved1()) << "\n"; + os << senf::fieldName("Valid Lifetime") << unsigned(validLifetime()) << "\n"; + os << senf::fieldName("Preferred Lifetime") << unsigned(preferredLifetime()) << "\n"; + os << senf::fieldName("Reserved(32Bit)") << unsigned(reserved2()) << "\n"; + os << senf::fieldName("Prefix") << prefix() << "\n"; } prefix_ void senf::NDPMTUTLVParser::dump(std::ostream & os) const { - os << senf::fieldName(" MTU Information") << "\n"; - os << senf::fieldName(" MTU") << unsigned(mtu()) << "\n"; + os << "MTU Information Option:" << "\n"; + os << senf::fieldName("MTU") << unsigned(mtu()) << "\n"; }