4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@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 TransportPacket unit tests */
26 //#include "TransportPacket.test.hh"
27 //#include "TransportPacket.test.ih"
30 #include "TransportPacket.hh"
32 #include <senf/Utils/auto_unit_test.hh>
33 #include <boost/test/test_tools.hpp>
36 ///////////////////////////////cc.p////////////////////////////////////////
40 BOOST_AUTO_UNIT_TEST(transportPacket_parse)
42 // TransportStream-Packet containing a ULE encoded IPv6 ping packet,
43 // captured with dvbsnoop
44 unsigned char data[] = {
45 // Transport Packet Header
46 0x47, 0x41, 0x0f, 0x1e,
50 0x80, 0x4c, 0x86, 0xdd,
52 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40,
53 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf,
55 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04,
57 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1,
58 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00,
59 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00,
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00,
61 // SNDU footer (crc-32)
62 0x1d, 0xc4, 0xe8, 0xc1,
63 // Transport Packet stuffing
64 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
65 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
66 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
67 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
68 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
69 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
70 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
71 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
72 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
73 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
74 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
75 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
76 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
79 TransportPacket p (TransportPacket::create(data));
81 BOOST_CHECK_EQUAL( p->sync_byte(), TransportPacketType::SYNC_BYTE+0 );
82 BOOST_CHECK( ! p->transport_error_indicator() );
83 BOOST_CHECK( p->pusi() );
84 BOOST_CHECK( ! p->transport_priority() );
85 BOOST_CHECK_EQUAL( p->pid(), 0x010fu );
86 BOOST_CHECK_EQUAL( p->transport_scrmbl_ctrl(), 0x0u );
87 BOOST_CHECK_EQUAL( p->adaptation_field_ctrl(), 0x1u );
88 BOOST_CHECK_EQUAL( p->continuity_counter(), 0x0eu );
89 BOOST_CHECK_EQUAL( p->pointer_field(), 0x0u );
91 std::ostringstream oss (std::ostringstream::out);
92 SENF_CHECK_NO_THROW( p.dump( oss));
96 BOOST_AUTO_UNIT_TEST(transportPacket_create_with_pusi)
98 TransportPacket ts_packet (TransportPacket::create());
99 ts_packet->setPUSI(true);
100 ts_packet->pid() = 0x010fu;
101 ts_packet->continuity_counter() = 0x0eu;
103 unsigned char payload_data[] = { // see test above
105 0x80, 0x4c, 0x86, 0xdd,
107 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40,
108 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf,
110 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04,
112 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1,
113 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00,
114 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00,
115 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00,
116 // SNDU footer (crc-32)
117 0x1d, 0xc4, 0xe8, 0xc1
119 senf::DataPacket payload (senf::DataPacket::createAfter( ts_packet, payload_data));
121 // TODO: add method for stuffing
124 ///////////////////////////////cc.e////////////////////////////////////////
131 // c-file-style: "senf"
132 // indent-tabs-mode: nil
133 // ispell-local-dictionary: "american"
134 // compile-command: "scons -u test"
135 // comment-column: 40