// $Id$
//
// Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-// Thorsten Horstmann <thorsten.horstmann@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Thorsten Horstmann <tho@berlios.de>
//
// 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
/** \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 <algorithm>
\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_t>( 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<crc_t>( 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<UInt32Parser>( data().size() - 4 ); }
+
boost::uint32_t calcCrc() const;
};
\ref SNDUPacket
\par Fields:
- \ref Parse_SNDUPacket
+ \ref SNDUPacketParser
+ \image html SNDUPacket.png
\ingroup protocolbundle_mpegdvb
*/
{
// typedef PacketTypeMixin<SNDUPacketType, ULEExtHeaderType> mixin;
typedef ConcretePacket<SNDUPacketType> 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);