X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FTransportPacket.test.cc;h=50b2377ec974f8005f0b2f4738bd945f6acfe338;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=ee98b3c1b8d58ae54c3fca808064c5feca417351;hpb=74e753584f5271c3b9edffdb7ceee73a6a1de5c7;p=senf.git diff --git a/Packets/MPEGDVBBundle/TransportPacket.test.cc b/Packets/MPEGDVBBundle/TransportPacket.test.cc index ee98b3c..50b2377 100644 --- a/Packets/MPEGDVBBundle/TransportPacket.test.cc +++ b/Packets/MPEGDVBBundle/TransportPacket.test.cc @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -20,7 +20,8 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Unit tests +/** \file + \brief TransportPacket unit tests */ //#include "TransportPacket.test.hh" //#include "TransportPacket.test.ih" @@ -28,7 +29,7 @@ // Custom includes #include "TransportPacket.hh" -#include +#include "../../Utils/auto_unit_test.hh" #include #define prefix_ @@ -36,22 +37,30 @@ using namespace senf; -BOOST_AUTO_UNIT_TEST(transportPacket_packet) +BOOST_AUTO_UNIT_TEST(transportPacket_parse) { // TransportStream-Packet containing a ULE encoded IPv6 ping packet, // captured with dvbsnoop - unsigned char data[] = { - 0x47, 0x41, 0x0f, 0x1e, 0x00, 0x80, 0x4c, 0x86, - 0xdd, 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, - 0x40, 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, - 0xaf, 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x04 ,0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, - 0xe1, 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, - 0x00, 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, - 0x00, 0x1d, 0xc4, 0xe8, 0xc1, 0xff, 0xff, 0xff, + unsigned char data[] = { + // Transport Packet Header + 0x47, 0x41, 0x0f, 0x1e, + // Payload Pointer + 0x00, + // SNDU Header + 0x80, 0x4c, 0x86, 0xdd, + // IPv6 Packet + 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40, + 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf, + 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, + 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1, + 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00, + 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, + // SNDU footer (crc-32) + 0x1d, 0xc4, 0xe8, 0xc1, + // Transport Packet stuffing 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -64,25 +73,58 @@ BOOST_AUTO_UNIT_TEST(transportPacket_packet) 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - - senf::TransportPacket p (senf::TransportPacket::create(data)); - - BOOST_CHECK_EQUAL( p->sync_byte(), TRANSPORT_PACKET_SYNC_BYTE ); - BOOST_CHECK( ! p->transport_error_indicator() ); - BOOST_CHECK( p->pusi() ); - BOOST_CHECK( ! p->transport_priority() ); - BOOST_CHECK_EQUAL( p->pid(), 0x010fu ); - BOOST_CHECK_EQUAL( p->transport_scrmbl_ctrl(), 0x0u ); - BOOST_CHECK_EQUAL( p->adaptation_field_ctrl(), 0x1u ); - BOOST_CHECK_EQUAL( p->continuity_counter(), 0x0eu ); + + TransportPacket p (TransportPacket::create(data)); + + BOOST_CHECK_EQUAL( p->sync_byte(), TransportPacketType::SYNC_BYTE+0 ); + BOOST_CHECK( ! p->transport_error_indicator() ); + BOOST_CHECK( p->pusi() ); + BOOST_CHECK( ! p->transport_priority() ); + BOOST_CHECK_EQUAL( p->pid(), 0x010fu ); + BOOST_CHECK_EQUAL( p->transport_scrmbl_ctrl(), 0x0u ); + BOOST_CHECK_EQUAL( p->adaptation_field_ctrl(), 0x1u ); + BOOST_CHECK_EQUAL( p->continuity_counter(), 0x0eu ); + BOOST_CHECK_EQUAL( p->pointer_field(), 0x0u ); + + std::ostringstream oss (std::ostringstream::out); + SENF_CHECK_NO_THROW( p.dump( oss)); +} + + +BOOST_AUTO_UNIT_TEST(transportPacket_create_with_pusi) +{ + TransportPacket ts_packet (TransportPacket::create()); + ts_packet->setPUSI(true); + ts_packet->pid() = 0x010fu; + ts_packet->continuity_counter() = 0x0eu; + + unsigned char payload_data[] = { // see test above + // SNDU Header + 0x80, 0x4c, 0x86, 0xdd, + // IPv6 Packet + 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40, + 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf, + 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, + 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1, + 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00, + 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, + // SNDU footer (crc-32) + 0x1d, 0xc4, 0xe8, 0xc1 + }; + senf::DataPacket payload (senf::DataPacket::createAfter( ts_packet, payload_data)); + + // TODO: add method for stuffing } ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ - + // Local Variables: // mode: c++ // fill-column: 100