4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Christian Niephaus <cni@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 MPLSPacket unit tests */
26 //#include "MPLSPacket.test.hh"
27 //#include "MPLSPacket.test.ih"
30 #include "MPLSPacket.hh"
31 #include "EthernetPacket.hh"
34 #include "../../Utils/auto_unit_test.hh"
35 #include <boost/test/test_tools.hpp>
38 ///////////////////////////////cc.p////////////////////////////////////////
40 BOOST_AUTO_UNIT_TEST(mplsPacket_parse)
42 senf::PacketData::byte data[] = {
43 0x00, 0x3e, 0x90, 0x80, //1st mpls header
44 0x00, 0x3e, 0xb1, 0x80, // last mpls header
47 senf::MPLSPacket p (senf::MPLSPacket::create(data));
49 BOOST_CHECK_EQUAL( p->label(), 1001u);
50 BOOST_CHECK_EQUAL( p->tc(), 0u );
51 BOOST_CHECK( !p->s());
52 BOOST_CHECK_EQUAL( p->ttl(), 128u );
54 std::ostringstream oss (std::ostringstream::out);
55 SENF_CHECK_NO_THROW( p.dump( oss));
58 BOOST_AUTO_UNIT_TEST(mplsPacket_parse_chain)
60 senf::PacketData::byte data[] = {
61 0x00, 0x3e, 0x90, 0x80, //1st mpls header
62 0x00, 0x3e, 0xb1, 0x80, // last mpls header
66 senf::MPLSPacket p (senf::MPLSPacket::create(data));
68 BOOST_REQUIRE( p.next().is<senf::MPLSPacket>() );
69 senf::MPLSPacket p2 (p.next().as<senf::MPLSPacket>());
70 BOOST_CHECK( p2->s());
71 BOOST_REQUIRE( p2.next().is<senf::DataPacket>() );
74 BOOST_AUTO_UNIT_TEST(mplsPacket_create)
76 senf::EthernetPacket eth (senf::EthernetPacket::create());
77 eth->source() = senf::MACAddress::from_string("01:02:03:04:05:06");
78 eth->destination() = senf::MACAddress::from_string("07:08:09:0a:0b:0c");
80 senf::MPLSPacket p (senf::MPLSPacket::createAfter(eth));
85 senf::MPLSPacket p2 (senf::MPLSPacket::createAfter(p));
90 SENF_CHECK_NO_THROW(eth.finalizeAll());
92 BOOST_REQUIRE( eth.next().is<senf::MPLSPacket>() );
93 BOOST_REQUIRE( p.next().is<senf::MPLSPacket>() );
95 BOOST_CHECK( !p2->s());
100 ///////////////////////////////cc.e////////////////////////////////////////
107 // c-file-style: "senf"
108 // indent-tabs-mode: nil
109 // ispell-local-dictionary: "american"
110 // compile-command: "scons -u test"
111 // comment-column: 40