From: tho Date: Mon, 6 Aug 2007 14:54:43 +0000 (+0000) Subject: implemented nextPacketType/Range for SNDU (yeah!) X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=981204dbf160d3dd77e303b9bd133eb187e0384f implemented nextPacketType/Range for SNDU (yeah!) git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@380 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/DVBAdapter/SConscript b/Examples/DVBAdapter/SConscript index c1618e3..c6de76e 100644 --- a/Examples/DVBAdapter/SConscript +++ b/Examples/DVBAdapter/SConscript @@ -11,4 +11,5 @@ for f in glob.glob('*.cc'): SENFSCons.Binary(env, bin, f, LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ], - OBJECTS = [ '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o' ]); + OBJECTS = [ '#/Packets/DefaultBundle/DefaultBundle.o', + '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o' ]); diff --git a/Examples/DVBAdapter/ULEdec.cc b/Examples/DVBAdapter/ULEdec.cc index 786f07e..9eccad3 100644 --- a/Examples/DVBAdapter/ULEdec.cc +++ b/Examples/DVBAdapter/ULEdec.cc @@ -178,8 +178,7 @@ ULEdec::iterator ULEdec::readContSNDUPacket(iterator i, iterator const i_end) ULEdec::iterator ULEdec::readNewSNDUPacket(iterator i, iterator const i_end) { bool dbit = false; - senf::Packet::size_type sndu_length; - sndu_length = *i++ << 8 | *i++; + senf::Packet::size_type sndu_length = *i++ << 8 | *i++; if (sndu_length & 0x8000) { sndu_length &= 0x7FFF; dbit = true; @@ -229,6 +228,12 @@ void ULEdec::handleSNDUPacket() if (this->snduPacket->crc() != this->snduPacket->calcCrc()) { throw ULEdecException("CRC Error"); } +// senf::Packet nextPacket = this->snduPacket.next(); +// senf::hexdump( +// nextPacket.data().begin(), +// nextPacket.data().end(), +// std::cout); + } diff --git a/Packets/MPEGDVBBundle/SNDUPacket.cc b/Packets/MPEGDVBBundle/SNDUPacket.cc index 25ebb58..900b3db 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.cc +++ b/Packets/MPEGDVBBundle/SNDUPacket.cc @@ -29,6 +29,7 @@ // Custom includes #include #include "Utils/hexdump.hh" +#include "Packets/DefaultBundle/EthernetPacket.hh" #define prefix_ @@ -58,11 +59,51 @@ prefix_ boost::uint32_t senf::Parse_SNDUPacket::calcCrc() ule_crc32() ).checksum(); } +//prefix_ senf::SNDUPacketType::registry_key_t senf::SNDUPacketType::nextPacketKey(packet p) +//{ +// return p->type(); +//} + +prefix_ void senf::SNDUPacketType::init(packet p) +{ + p->init(); +} + +prefix_ senf::PacketInterpreterBase::factory_t senf::SNDUPacketType::nextPacketType(packet p) +{ + if (p.data().size() < 8) + return no_factory(); + PkReg_Entry const * e; + if (p->type() < 1536) + e = PacketRegistry::lookup( p->type(), nothrow ); + else + e = PacketRegistry::lookup( 0x86dd, nothrow ); + return e ? e->factory() : no_factory(); +} + +prefix_ senf::PacketInterpreterBase::optional_range +senf::SNDUPacketType::nextPacketRange(packet p) +{ + if (p.data().size() < 8) + return no_range(); + + size_type sz = 2 + 2; // D-Bit + 15 bits length + 16 bits type field + if (! p->d_bit() ) + sz += 6; // + 6 Byte NPA destination address + return range( + boost::next(p.data().begin(), sz), + boost::prior(p.data().end(), 4)); // - 32 bits crc +} + prefix_ void senf::SNDUPacketType::dump(packet p, std::ostream & os) { os << "SNDUPacket:\n" + << std::dec << " d_bit: " << p->d_bit() << "\n" << " length: " << unsigned(p->length()) << "\n" + << std::hex + << " type: 0x" << unsigned(p->type()) << "\n" + << std::dec << " crc: " << unsigned(p->crc()) << "\n"; } diff --git a/Packets/MPEGDVBBundle/SNDUPacket.hh b/Packets/MPEGDVBBundle/SNDUPacket.hh index 4ab5824..d2a00fa 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.hh +++ b/Packets/MPEGDVBBundle/SNDUPacket.hh @@ -86,6 +86,11 @@ namespace senf { boost::uint32_t calcCrc() const; }; + + struct ULEExtHeaderTypes { + typedef boost::uint16_t key_t; + }; + /** \brief ULE SNDU Packet \par Packet type (typedef): @@ -97,20 +102,29 @@ namespace senf { \ingroup protocolbundle_mpegdvb */ struct SNDUPacketType - : public PacketTypeBase, - public PacketTypeMixin + : public PacketTypeBase +// public PacketTypeMixin { - typedef PacketTypeMixin mixin; +// typedef PacketTypeMixin mixin; typedef ConcretePacket packet; typedef Parse_SNDUPacket parser; - using mixin::nextPacketRange; -// using mixin::nextPacketType; - using mixin::init; +// using mixin::nextPacketRange; +// using mixin::nextPacketType; +// using mixin::init; + +// static registry_key_t nextPacketKey(packet p); + + static void init(packet p); + + static factory_t nextPacketType(packet p); + + static optional_range nextPacketRange(packet p); static void dump(packet p, std::ostream & os); static PacketParserBase::size_type initSize(); + static PacketParserBase::size_type initHeadSize(); }; diff --git a/Packets/PacketType.hh b/Packets/PacketType.hh index 02a11c3..863f966 100644 --- a/Packets/PacketType.hh +++ b/Packets/PacketType.hh @@ -266,7 +266,7 @@ namespace senf { // Return the key in the registry under which the next packet // header is to be found. This member must be given if a Registry argument is // passed to the PacketTypeMixin template. - return i.fields().typeField(); + return p->typeField(); } static void finalize(packet p)