X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FSNDUPacket.hh;h=7cb9e761e8ca1085c5c76e4648a4a7a4a7c7dee2;hb=ff0f2fabb3dbb76ee9383a98291a1420d2a59a7f;hp=bb219ca60c1ac917c3a9ae9a373fad798d603e30;hpb=aa8de2975f5365cd4f29f6f337f93ad328f6685c;p=senf.git diff --git a/Packets/MPEGDVBBundle/SNDUPacket.hh b/Packets/MPEGDVBBundle/SNDUPacket.hh index bb219ca..7cb9e76 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.hh +++ b/Packets/MPEGDVBBundle/SNDUPacket.hh @@ -1,9 +1,9 @@ -// $Id:DSMCCSection.hh 327 2007-07-20 10:03:44Z tho $ +// $Id$ // // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 @@ -28,11 +28,9 @@ // Custom includes #include -#include "Packets/PacketType.hh" -#include "Packets/ParseInt.hh" -#include "Packets/PacketRegistry.hh" -#include "Packets/PacketParser.hh" -#include "Packets/DefaultBundle/EthernetPacket.hh" +#include +#include "../../Packets/Packets.hh" +#include "../DefaultBundle/EthernetPacket.hh" //#include "SNDUPacket.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -47,37 +45,42 @@ namespace senf { */ struct Parse_SNDUPacket : public PacketParserBase { -# ifndef DOXYGEN - - SENF_PACKET_PARSER_INIT(Parse_SNDUPacket); +# include SENF_PARSER() + + /* We first define the fields as they appear in the field. Some of the fields are declared + private. We provide custom accessors for those fields further down. */ -# endif + SENF_PARSER_PRIVATE_BITFIELD ( d_bit_ , 1 , unsigned ); + SENF_PARSER_BITFIELD ( length , 15 , unsigned ); + SENF_PARSER_FIELD ( type , Parse_UInt16 ); + SENF_PARSER_PRIVATE_VARIANT ( destination_ , d_bit_ , + (Parse_MAC) (VoidPacketParser) ); - typedef Parse_Flag < 0 > Parse_daaf; // Destination Address Absent Field - typedef Parse_UIntField < 1, 16 > Parse_length; - - Parse_daaf d_bit() const { - return parse( 0 ); - } - Parse_length length() const { - return parse( 0 ); - } - Parse_UInt16 type() const { - return parse( 2 ); - } - Parse_MAC destination() const { - BOOST_ASSERT( ! d_bit() ); - return parse( 4 ); - } - Parse_UInt32 crc() const { - return parse( data().size()-4 ); - } + SENF_PARSER_FINALIZE( Parse_SNDUPacket ); - PacketParserBase::size_type bytes() const; + Parse_MAC destination() /// Only defined if d_bit() == \c false + { return destination_().get<0>(); } + + bool d_bit() /// Destination absent bit + { return d_bit_(); } + + void withDestination() /// Clear destination absent bit + { destination_().init<0>(); } - static const size_type init_bytes = 2+2+4; // D-Bit + 15 bits length + 16 bits type field + 32 bits crc + void withoutDestination() /// Set destination absent bit + { destination_().init<1>(); } + + Parse_UInt32 crc() + { return parse( data().size() - 4 ); } + + boost::uint32_t calcCrc() const; }; + + struct ULEExtHeaderTypes { + typedef boost::uint16_t key_t; + }; + /** \brief ULE SNDU Packet \par Packet type (typedef): @@ -89,29 +92,41 @@ 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(); }; typedef SNDUPacketType::packet SNDUPacket; + + typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> ule_crc32; + /*! \def ULE_END_INDICATOR - ULE End Indicator; indicates to the Receiver that there are no - further SNDUs present within the current TS Packet. + ULE End Indicator; indicates to the receiver that there are no + further SNDUs present within the current TS packet. */ # define ULE_END_INDICATOR 0xffff }