X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FMPESection.test.cc;h=66bca28bbb6fb7e65a1796dadf36e153877cceef;hb=a1fdb7bb122f0b05be809a922d4b7ef5e125fa67;hp=91ba6773ed10d42b2ac7045f96f128b5016cce1e;hpb=c0b5c560da72983939b286632ac481e076649ddb;p=senf.git diff --git a/Packets/MPEGDVBBundle/MPESection.test.cc b/Packets/MPEGDVBBundle/MPESection.test.cc index 91ba677..66bca28 100644 --- a/Packets/MPEGDVBBundle/MPESection.test.cc +++ b/Packets/MPEGDVBBundle/MPESection.test.cc @@ -20,20 +20,20 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Unit tests +/** \file + \brief MPESection unit tests */ //#include "MPESection.test.hh" //#include "MPESection.test.ih" // Custom includes #include "MPESection.hh" - -#include "../../Utils/auto_unit_test.hh" #include "../../Packets/DefaultBundle/LlcSnapPacket.hh" #include "../../Packets/DefaultBundle/EthernetPacket.hh" #include "../../Packets/DefaultBundle/IPv4Packet.hh" + +#include "../../Utils/auto_unit_test.hh" #include -#include #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// @@ -43,7 +43,7 @@ using namespace senf; BOOST_AUTO_UNIT_TEST(MPESection_parse_chain) { // MPE section captured with dvbsnoop - unsigned char data[] = { + unsigned char data[] = { // MPE Header 0x3e, 0xb0, 0x77, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x04, 0xd8, 0x12, 0x0c, @@ -51,26 +51,26 @@ BOOST_AUTO_UNIT_TEST(MPESection_parse_chain) 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x00, 0x62, // Ethernet Header 0x01, 0x00, 0x5e, 0x01, 0x02, 0x03, 0x12, 0xb0, - 0x43, 0x61, 0x5d, 0x99, 0x08, 0x00, + 0x43, 0x61, 0x5d, 0x99, 0x08, 0x00, // IPv4 Header 0x45, 0x00, 0x00, 0x54, 0x00, 0x00, 0x40, 0x00, 0x01, 0x01, 0xc6, 0xfb, 0xc0, 0xa8, 0x01, 0x01, - 0xef, 0x01, 0x02, 0x03, + 0xef, 0x01, 0x02, 0x03, // Payload (ICMP) - 0x08, 0x00, 0x0e, 0xa3, 0xf2, 0x72, 0x55, 0xea, - 0xa2, 0xae, 0x56, 0x47, 0xbb, 0x06, 0x02, 0x00, + 0x08, 0x00, 0x0e, 0xa3, 0xf2, 0x72, 0x55, 0xea, + 0xa2, 0xae, 0x56, 0x47, 0xbb, 0x06, 0x02, 0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, // MPE Trailer (crc) 0xb5, 0x77, 0x4c, 0x3c }; - + senf::MPESection sec (senf::MPESection::create(data)); - + BOOST_CHECK_EQUAL( sec->table_id(), 0x3eu ); BOOST_CHECK( sec->section_syntax_indicator() ); BOOST_CHECK( ! sec->private_indicator() ); @@ -89,7 +89,10 @@ BOOST_AUTO_UNIT_TEST(MPESection_parse_chain) BOOST_CHECK_EQUAL( sec->real_time_parameters().address(), 0x120cu ); BOOST_CHECK_EQUAL( sec->crc(), 3044494396u ); BOOST_CHECK_EQUAL( sec->crc(), sec->calcCrc() ); - + + std::ostringstream oss (std::ostringstream::out); + SENF_CHECK_NO_THROW( sec.dump( oss)); + BOOST_REQUIRE( sec.next().is() ); senf::LlcSnapPacket llcsnap (sec.next().as()); @@ -97,21 +100,21 @@ BOOST_AUTO_UNIT_TEST(MPESection_parse_chain) BOOST_CHECK_EQUAL( llcsnap->ssap(), 0xaau ); BOOST_CHECK_EQUAL( llcsnap->ctrl(), 0x3u ); BOOST_CHECK_EQUAL( llcsnap->protocolId(), 0x0u ); - // in the captured section the llcsnap type/length field was set to the + // in the captured section the llcsnap type/length field was set to the // length of the following ethernet packet; the ethertype 0x6558 (Trans // Ether Bridging [RFC1701]) would be possible as well (see next test) BOOST_CHECK_EQUAL( llcsnap->type_length(), 0x62u ); BOOST_REQUIRE( llcsnap.next().is() ); senf::EthernetPacket eth (llcsnap.next().as()); - + BOOST_CHECK_EQUAL( eth->destination().value(), senf::MACAddress::from_string("01:00:5e:01:02:03") ); BOOST_CHECK_EQUAL( eth->source().value(), senf::MACAddress::from_string("12:b0:43:61:5d:99") ); BOOST_CHECK_EQUAL( eth->type_length(), 0x800u ); BOOST_REQUIRE( eth.next().is() ); senf::IPv4Packet ip (eth.next().as()); - + BOOST_CHECK_EQUAL( ip->version(), 0x4u ); BOOST_CHECK_EQUAL( ip->ihl(), 0x5u ); BOOST_CHECK_EQUAL( ip->tos(), 0x0u ); @@ -135,23 +138,23 @@ BOOST_AUTO_UNIT_TEST(MPESection_create) sec->real_time_parameters().table_boundary() = 1; sec->real_time_parameters().frame_boundary() = 0; sec->real_time_parameters().address() = 0xfffffu; - + // the type/length field will be set to the ethertype 0x6558 (Trans - // Ether Bridging [RFC1701]) on finalize() + // Ether Bridging [RFC1701]) on finalize() senf::LlcSnapPacket llcsnap (senf::LlcSnapPacket::createAfter(sec)); - + senf::EthernetPacket eth (senf::EthernetPacket::createAfter(llcsnap)); eth->destination() = senf::MACAddress::from_string("01:00:5e:01:02:03"); eth->source() = senf::MACAddress::from_string("92:4c:a2:1c:da:81"); - + senf::IPv4Packet ip (senf::IPv4Packet::createAfter(eth)); ip->df() = 1; ip->ttl() = 1; ip->protocol() = 1; ip->source() = senf::INet4Address::from_string("10.1.2.2"); ip->destination() = senf::INet4Address::from_string("239.1.2.3"); - - unsigned char payload_data[] = { + + unsigned char payload_data[] = { // Payload (ICMP) 0x08, 0x00, 0x52, 0x73, 0x0e, 0x02, 0x00, 0x20, 0xa4, 0x3a, 0xb4, 0x47, 0x4f, 0xe5, 0x04, 0x00, @@ -163,9 +166,9 @@ BOOST_AUTO_UNIT_TEST(MPESection_create) 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 }; senf::DataPacket payload (senf::DataPacket::createAfter(ip, payload_data)); - - sec.finalize(); - + + sec.finalizeAll(); + unsigned char sec_data[] = { 0x3e, 0xb0, 0x77, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x02, 0x7b, 0xff, 0xff, 0xaa, 0xaa, 0x03, 0x00, @@ -183,14 +186,14 @@ BOOST_AUTO_UNIT_TEST(MPESection_create) 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x52, 0xdf, 0x6a, 0x1d - }; + }; BOOST_CHECK( equal( sec.data().begin(), sec.data().end(), sec_data )); } ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ - + // Local Variables: // mode: c++ // fill-column: 100