//
// Copyright (C) 2010
// Fraunhofer Institute for Open Communication Systems (FOKUS)
-// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// Stefan Sauer <ssauer@berlios.de>
//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// The contents of this file are subject to the Fraunhofer FOKUS Public License
+// Version 1.0 (the "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+// http://senf.berlios.de/license.html
//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
+// The Fraunhofer FOKUS Public License Version 1.0 is based on,
+// but modifies the Mozilla Public License Version 1.1.
+// See the full license text for the amendments.
//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the
-// Free Software Foundation, Inc.,
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// Software distributed under the License is distributed on an "AS IS" basis,
+// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+// for the specific language governing rights and limitations under the License.
+//
+// The Original Code is Fraunhofer FOKUS code.
+//
+// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
+// (registered association), Hansastraße 27 c, 80686 Munich, Germany.
+// All Rights Reserved.
+//
+// Contributor(s):
+// Stefan Sauer <ssauer@berlios.de>
/** \file
\brief NDPMessage unit tests */
#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
SENF_AUTO_UNIT_TEST(NDPMessage_create)
{
- senf::ICMPv6Packet icmp (senf::ICMPv6Packet::create());
- icmp->code() = 0;
+ senf::dumpPacketRegistries(std::cout);
- senf::NDPNeighborAdvertisementMessage nadm (senf::NDPNeighborAdvertisementMessage::createAfter(icmp));
- nadm->r() = true;
- nadm->s() = true;
- nadm->o() = false;
- nadm->target() = senf::INet6Address::Loopback;
+ 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::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;
+ senf::IPv6Packet ip (senf::IPv6Packet::create(data));
+ senf::ICMPv6Packet icmp (ip.find<senf::ICMPv6Packet>());
- 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_EQUAL( rnadm->r(), true );
- BOOST_CHECK_EQUAL( rnadm->s(), true );
- BOOST_CHECK_EQUAL( rnadm->o(), false );
+ BOOST_CHECK( icmp.next().is<senf::NDPNeighborSolicitationMessage>() );
+ senf::NDPNeighborSolicitationMessage rnadm (icmp.next().as<senf::NDPNeighborSolicitationMessage>());
+ BOOST_CHECK_EQUAL(rnadm.size(),28);
- 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////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
// Local Variables: