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.
25 //#include "TransportPacket.test.hh"
26 //#include "TransportPacket.test.ih"
29 #include "TransportPacket.hh"
31 #include "../../Utils/auto_unit_test.hh"
32 #include <boost/test/test_tools.hpp>
35 ///////////////////////////////cc.p////////////////////////////////////////
39 BOOST_AUTO_UNIT_TEST(transportPacket_parse)
41 // TransportStream-Packet containing a ULE encoded IPv6 ping packet,
42 // captured with dvbsnoop
43 unsigned char data[] = {
44 // Transport Packet Header
45 0x47, 0x41, 0x0f, 0x1e,
49 0x80, 0x4c, 0x86, 0xdd,
51 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40,
52 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf,
54 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04,
56 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1,
57 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00,
58 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00,
60 // SNDU footer (crc-32)
61 0x1d, 0xc4, 0xe8, 0xc1,
62 // Transport Packet stuffing
63 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
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
78 TransportPacket p (TransportPacket::create(data));
80 BOOST_CHECK_EQUAL( p->sync_byte(), TransportPacketType::SYNC_BYTE+0 );
81 BOOST_CHECK( ! p->transport_error_indicator() );
82 BOOST_CHECK( p->pusi() );
83 BOOST_CHECK( ! p->transport_priority() );
84 BOOST_CHECK_EQUAL( p->pid(), 0x010fu );
85 BOOST_CHECK_EQUAL( p->transport_scrmbl_ctrl(), 0x0u );
86 BOOST_CHECK_EQUAL( p->adaptation_field_ctrl(), 0x1u );
87 BOOST_CHECK_EQUAL( p->continuity_counter(), 0x0eu );
88 BOOST_CHECK_EQUAL( p->pointer_field(), 0x0u );
90 std::ostringstream oss (std::ostringstream::out);
91 SENF_CHECK_NO_THROW( p.dump( oss));
95 BOOST_AUTO_UNIT_TEST(transportPacket_create_with_pusi)
97 TransportPacket ts_packet (TransportPacket::create());
98 ts_packet->setPUSI(true);
99 ts_packet->pid() = 0x010fu;
100 ts_packet->continuity_counter() = 0x0eu;
102 unsigned char payload_data[] = { // see test above
104 0x80, 0x4c, 0x86, 0xdd,
106 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40,
107 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
108 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf,
109 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04,
111 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1,
112 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00,
113 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00,
114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00,
115 // SNDU footer (crc-32)
116 0x1d, 0xc4, 0xe8, 0xc1
118 senf::DataPacket payload (senf::DataPacket::createAfter( ts_packet, payload_data));
120 // TODO: add method for stuffing
123 ///////////////////////////////cc.e////////////////////////////////////////
130 // c-file-style: "senf"
131 // indent-tabs-mode: nil
132 // ispell-local-dictionary: "american"
133 // compile-command: "scons -u test"
134 // comment-column: 40