X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FMPEGDVBBundle%2FSNDUPacket.hh;h=4f296acf2fa3f792f19ad8749eebc4c4d9907851;hb=165ec46dc3d091c354ef8dbda67dcf7b1a97fc7d;hp=19d9b8da5fefd4452e0e3bc45cf1c2e077f8f167;hpb=f87667d7d3b3edafba7e67d6fc33168c4e1af620;p=senf.git diff --git a/Packets/MPEGDVBBundle/SNDUPacket.hh b/Packets/MPEGDVBBundle/SNDUPacket.hh index 19d9b8d..4f296ac 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.hh +++ b/Packets/MPEGDVBBundle/SNDUPacket.hh @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Thorsten Horstmann +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// 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 @@ -23,8 +23,8 @@ /** \file \brief SNDUPacket public header */ -#ifndef HH_SNDUPacket_ -#define HH_SNDUPacket_ 1 +#ifndef HH_SENF_Packets_MPEGDVBBundle_SNDUPacket_ +#define HH_SENF_Packets_MPEGDVBBundle_SNDUPacket_ 1 // Custom includes #include @@ -43,31 +43,36 @@ namespace senf { \see SNDUPacketType */ - struct Parse_SNDUPacket : public PacketParserBase + struct SNDUPacketParser : public PacketParserBase { # 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_FIELD ( type , Parse_UInt16 ); - - // 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() ); - } + SENF_PARSER_PRIVATE_BITFIELD ( d_bit_ , 1 , unsigned ); + SENF_PARSER_BITFIELD ( length , 15 , unsigned ); + SENF_PARSER_FIELD ( type , UInt16Parser ); + SENF_PARSER_PRIVATE_VARIANT ( destination_ , d_bit_ , + (MACAddressParser) (VoidPacketParser) ); + + SENF_PARSER_FINALIZE( SNDUPacketParser ); + + MACAddressParser destination() /// Only defined if d_bit() == \c false + { return destination_().get<0>(); } - // 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 ); - } + bool d_bit() /// Destination absent bit + { return d_bit_(); } - SENF_PARSER_FINALIZE( Parse_SNDUPacket ); + void withDestination() /// Clear destination absent bit + { destination_().init<0>(); } + void withoutDestination() /// Set destination absent bit + { destination_().init<1>(); } + + UInt32Parser crc() + { return parse( data().size() - 4 ); } + boost::uint32_t calcCrc() const; }; @@ -82,7 +87,7 @@ namespace senf { \ref SNDUPacket \par Fields: - \ref Parse_SNDUPacket + \ref SNDUPacketParser \ingroup protocolbundle_mpegdvb */ @@ -92,13 +97,13 @@ namespace senf { { // typedef PacketTypeMixin mixin; typedef ConcretePacket packet; - typedef Parse_SNDUPacket parser; + typedef SNDUPacketParser parser; // using mixin::nextPacketRange; // using mixin::nextPacketType; // using mixin::init; -// static registry_key_t nextPacketKey(packet p); +// static key_t nextPacketKey(packet p); static void init(packet p);