1 // $Id: ICMPv6Packet.test.cc 1550 2010-01-26 09:34:24Z tho $
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Sauer <ssauer@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief ICMPv6Packet unit tests */
27 #include "ICMPv6Packet.hh"
28 #include "ICMPv6TypePacket.hh"
29 #include "NDPOptions.hh"
31 #include <senf/Utils/auto_unit_test.hh>
32 #include <boost/test/test_tools.hpp>
34 ///////////////////////////////cc.p////////////////////////////////////////
35 SENF_AUTO_UNIT_TEST(NDPMessage_create)
37 senf::ICMPv6Packet icmp (senf::ICMPv6Packet::create());
40 senf::NDPNeighborAdvertisementMessage nadm (senf::NDPNeighborAdvertisementMessage::createAfter(icmp));
44 nadm->target() = senf::INet6Address::Loopback;
46 senf::NDPNeighborAdvertisementMessage::Parser::options_t::container optC(nadm->options());
47 senf::NDPMTUTLVParser opt(
48 optC.push_back_space().init<senf::NDPMTUTLVParser> ());
49 senf::NDPTargetLLAddressTLVParser opt2(
50 optC.push_back_space().init<senf::NDPTargetLLAddressTLVParser> ());
52 opt2.target() = senf::MACAddress::Broadcast;
56 BOOST_CHECK_EQUAL(icmp->type(), 0x88 );
57 BOOST_CHECK( icmp.next() );
58 BOOST_CHECK( icmp.next().is<senf::NDPNeighborAdvertisementMessage>() );
59 senf::NDPNeighborAdvertisementMessage rnadm (icmp.next().as<senf::NDPNeighborAdvertisementMessage>());
61 BOOST_CHECK_EQUAL( rnadm->r(), true );
62 BOOST_CHECK_EQUAL( rnadm->s(), true );
63 BOOST_CHECK_EQUAL( rnadm->o(), false );
65 senf::NDPNeighborAdvertisementMessage::Parser::options_t::container roptC(rnadm->options() );
66 senf::NDPNeighborAdvertisementMessage::Parser::options_t::container::iterator listIter (roptC.begin());
67 BOOST_CHECK( listIter->is<senf::NDPMTUTLVParser>() );
68 BOOST_CHECK_EQUAL( listIter->type(), 5u );
69 BOOST_CHECK_EQUAL( listIter->length(), 1u );
70 senf::NDPMTUTLVParser mtuopt (listIter->as<senf::NDPMTUTLVParser>());
71 BOOST_CHECK_EQUAL( mtuopt.mtu(), 1234u );
73 BOOST_CHECK( listIter->is<senf::NDPTargetLLAddressTLVParser>() );
74 BOOST_CHECK_EQUAL( listIter->type(), 2u );
75 BOOST_CHECK_EQUAL( listIter->length(), 1u );
78 ///////////////////////////////cc.e////////////////////////////////////////
84 // c-file-style: "senf"
85 // indent-tabs-mode: nil
86 // ispell-local-dictionary: "american"
87 // compile-command: "scons -u test"