{
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)
<< 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)
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)
<< 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)
<< 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_
///////////////////////////////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::ICMPv6Packet>());
- senf::NDPNeighborAdvertisementMessage::Parser::options_t::container optC(nadm->options());
- senf::NDPMTUTLVParser opt(
- optC.push_back_space().init<senf::NDPMTUTLVParser> ());
- senf::NDPTargetLLAddressTLVParser opt2(
- optC.push_back_space().init<senf::NDPTargetLLAddressTLVParser> ());
- 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>() );
- senf::NDPNeighborAdvertisementMessage rnadm (icmp.next().as<senf::NDPNeighborAdvertisementMessage>());
+ BOOST_CHECK( icmp.next().is<senf::NDPNeighborSolicitationMessage>() );
+ senf::NDPNeighborSolicitationMessage rnadm (icmp.next().as<senf::NDPNeighborSolicitationMessage>());
+ 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<senf::NDPMTUTLVParser>() );
- BOOST_CHECK_EQUAL( listIter->type(), 5u );
- BOOST_CHECK_EQUAL( listIter->length(), 1u );
- senf::NDPMTUTLVParser mtuopt (listIter->as<senf::NDPMTUTLVParser>());
- BOOST_CHECK_EQUAL( mtuopt.mtu(), 1234u );
- listIter++;
- BOOST_CHECK( listIter->is<senf::NDPTargetLLAddressTLVParser>() );
- 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<senf::NDPSourceLLAddressTLVParser>() );
+ BOOST_CHECK_EQUAL( listIter->type(), 1u );
BOOST_CHECK_EQUAL( listIter->length(), 1u );
+ senf::NDPSourceLLAddressTLVParser llopt (listIter->as<senf::NDPSourceLLAddressTLVParser>());
}
///////////////////////////////cc.e////////////////////////////////////////
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";
}