X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FSNDUPacket.hh;h=7cb9e761e8ca1085c5c76e4648a4a7a4a7c7dee2;hb=bbff2057f39e475b00e598cae018c68db0e16a82;hp=540927276b887f319c8215fad380b2445a75e324;hpb=ceba483d966a9fd884b30fb9dac07156b29a4b31;p=senf.git diff --git a/Packets/MPEGDVBBundle/SNDUPacket.hh b/Packets/MPEGDVBBundle/SNDUPacket.hh index 5409272..7cb9e76 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.hh +++ b/Packets/MPEGDVBBundle/SNDUPacket.hh @@ -29,11 +29,8 @@ // Custom includes #include #include -#include "Packets/PacketType.hh" -#include "Packets/ParseInt.hh" -#include "Packets/PacketRegistry.hh" -#include "Packets/PacketParser.hh" -#include "Packets/DefaultBundle/EthernetPacket.hh" +#include "../../Packets/Packets.hh" +#include "../DefaultBundle/EthernetPacket.hh" //#include "SNDUPacket.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -48,40 +45,33 @@ namespace senf { */ struct Parse_SNDUPacket : public PacketParserBase { -# ifndef DOXYGEN - - SENF_PACKET_PARSER_NO_INIT(Parse_SNDUPacket); +# include SENF_PARSER() -# endif - - 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 ); - } + /* 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. */ + + 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) ); - void init() const { - defaultInit(); - d_bit() = false; - } + 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; };