X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FSNDUPacket.hh;h=7cb9e761e8ca1085c5c76e4648a4a7a4a7c7dee2;hb=759310ea14e1fa1eb65f029762efa32d52539e59;hp=19d9b8da5fefd4452e0e3bc45cf1c2e077f8f167;hpb=9f6bb706cb491d4da38f6472746b3076a66202e0;p=senf.git diff --git a/Packets/MPEGDVBBundle/SNDUPacket.hh b/Packets/MPEGDVBBundle/SNDUPacket.hh index 19d9b8d..7cb9e76 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.hh +++ b/Packets/MPEGDVBBundle/SNDUPacket.hh @@ -47,27 +47,32 @@ namespace senf { { # include SENF_PARSER() - SENF_PARSER_BITFIELD ( d_bit , 1 , bool ); - SENF_PARSER_BITFIELD ( length , 15 , unsigned ); + /* 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) ); + + SENF_PARSER_FINALIZE( Parse_SNDUPacket ); + + Parse_MAC destination() /// Only defined if d_bit() == \c false + { return destination_().get<0>(); } - SENF_PARSER_FIELD ( type , Parse_UInt16 ); + bool d_bit() /// Destination absent bit + { return d_bit_(); } - // This field only exists, if d_bit() is *not* set. New SNDUPackets are created with d_bit() - // set to 0, they have destination. We set the size of this field depending on the value of - // d_bit(), the init_bytes value is set to 6 bytes (the size of a MAC address) - SENF_PARSER_CUSTOM_FIELD ( destination , Parse_MAC , d_bit() ? 0 : 6 , 6 ) { - BOOST_ASSERT( ! d_bit() ); - return parse( destination_offset() ); - } + void withDestination() /// Clear destination absent bit + { destination_().init<0>(); } + + void withoutDestination() /// Set destination absent bit + { destination_().init<1>(); } - // This field is placed at the end of the parser. It is therefore only considered for - // calculating init_bytes but not for calculating bytes() - SENF_PARSER_CUSTOM_FIELD ( crc , Parse_UInt32 , 0 , 4 ) { - return parse( data().size() - 4 ); - } + Parse_UInt32 crc() + { return parse( data().size() - 4 ); } - SENF_PARSER_FINALIZE( Parse_SNDUPacket ); - boost::uint32_t calcCrc() const; };