4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@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 DTCPPacket unit tests */
26 //#include "DTCPPacket.test.hh"
27 //#include "DTCPPacket.test.ih"
30 #include "DTCPPacket.hh"
31 #include <senf/Utils/String.hh>
33 #include <senf/Utils/auto_unit_test.hh>
34 #include <boost/test/test_tools.hpp>
37 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 SENF_AUTO_UNIT_TEST(dtcpPacket)
41 unsigned char data[] = {
42 0x11, // versionNumber = 1, command = JOIN
44 0x0A, 0x0B, // sequence number
45 0x14, // receiveCapable = true, ipVersion = 4
49 101, 102, 103, 104, // fbip1
50 201, 202, 203, 204 // fbip2
53 senf::DTCPHelloPacket hello (senf::DTCPHelloPacket::create(
54 boost::make_iterator_range(data, data+sizeof(data))));
56 BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
57 hello.data().begin(), hello.data().end() );
59 BOOST_CHECK_EQUAL( senf::bytes(hello.parser()), 16u );
61 BOOST_CHECK_EQUAL( hello->versionNumber(), 1u );
62 BOOST_CHECK_EQUAL( hello->command(), unsigned(senf::DTCPHelloPacket::Parser::JOIN) );
63 BOOST_CHECK_EQUAL( hello->interval(), 5u );
64 BOOST_CHECK_EQUAL( hello->sequenceNumber(), 0x0A0Bu );
65 BOOST_CHECK_EQUAL( hello->receiveCapableFeed(), true );
66 BOOST_CHECK_EQUAL( hello->ipVersion(), 4u );
67 BOOST_CHECK_EQUAL( hello->tunnelProtocol(), 23u );
68 BOOST_CHECK_EQUAL( hello->fbipCount(), 2u );
69 BOOST_CHECK( hello->has_v4fbipList() );
70 BOOST_CHECK_EQUAL( senf::str(hello->v4fbipList()[0]), "101.102.103.104" );
71 BOOST_CHECK_EQUAL( senf::str(hello->v4fbipList()[1]), "201.202.203.204" );
75 BOOST_CHECK_EQUAL( ss.str(),
76 "DTCP HELLO Packet:\n"
80 " sequence number : 2571\n"
81 " receive capable feed : yes\n"
83 " tunnel protocol : 23\n"
84 " number of BDL ips : 2\n"
87 " 201.202.203.204\n" );
89 senf::DTCPHelloPacket hello2 (senf::DTCPHelloPacket::create());
91 SENF_CHECK_NO_THROW( hello2->versionNumber() = 1u );
92 SENF_CHECK_NO_THROW( hello2->command() = senf::DTCPHelloPacket::Parser::JOIN );
93 SENF_CHECK_NO_THROW( hello2->interval() = 5u );
94 SENF_CHECK_NO_THROW( hello2->sequenceNumber() = 0x0A0B );
95 SENF_CHECK_NO_THROW( hello2->receiveCapableFeed() = true );
96 SENF_CHECK_NO_THROW( hello2->tunnelProtocol() = 23u );
97 SENF_CHECK_NO_THROW( hello2->init_v4fbipList() );
98 SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0x65666768u) ) );
99 SENF_CHECK_NO_THROW( hello2->v4fbipList().push_back( senf::INet4Address(0xC9CACBCCu) ) );
101 BOOST_CHECK_EQUAL( senf::bytes(hello2.parser()), 16u );
102 BOOST_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
103 hello2.data().begin(), hello2.data().end() );
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
113 // comment-column: 40
114 // c-file-style: "senf"
115 // indent-tabs-mode: nil
116 // ispell-local-dictionary: "american"
117 // compile-command: "scons -u test"