4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
29 \brief SNDUPacket public header */
31 #ifndef HH_SENF_Packets_MPEGDVBBundle_SNDUPacket_
32 #define HH_SENF_Packets_MPEGDVBBundle_SNDUPacket_ 1
35 #include <boost/crc.hpp>
36 #include <senf/Packets/Packets.hh>
37 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
39 //#include "SNDUPacket.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 /** \brief parse ULE SNDU Packet
46 Parser implementing the header and trailer of a ULE SNDU Packet
50 struct SNDUPacketParser : public PacketParserBase
52 # include SENF_PARSER()
54 /* We first define the fields as they appear in the field. Some of the fields are declared
55 private. We provide custom accessors for those fields further down. */
57 SENF_PARSER_PRIVATE_BITFIELD ( d_bit_ , 1 , unsigned );
58 SENF_PARSER_BITFIELD ( length , 15 , unsigned );
59 SENF_PARSER_FIELD ( type , UInt16Parser );
60 SENF_PARSER_PRIVATE_VARIANT ( destination_ , d_bit_ ,
61 (MACAddressParser) (VoidPacketParser) );
63 SENF_PARSER_FINALIZE( SNDUPacketParser );
65 MACAddressParser destination() ///< Only defined if d_bit() == \c false
66 { return destination_().get<0>(); }
68 bool d_bit() ///< Destination absent bit
71 void withDestination() ///< Clear destination absent bit
72 { destination_().init<0>(); }
74 void withoutDestination() ///< Set destination absent bit
75 { destination_().init<1>(); }
78 { return parse<UInt32Parser>( data().size() - 4 ); }
80 boost::uint32_t calcCrc() const;
84 struct ULEExtHeaderTypes {
85 typedef boost::uint16_t key_t;
88 /** \brief ULE SNDU Packet
90 \par Packet type (typedef):
95 \image html SNDUPacket.png
97 \ingroup protocolbundle_mpegdvb
100 : public PacketTypeBase
101 // public PacketTypeMixin<SNDUPacketType, ULEExtHeaderTypes>
103 // typedef PacketTypeMixin<SNDUPacketType, ULEExtHeaderType> mixin;
104 typedef ConcretePacket<SNDUPacketType> packet;
105 typedef SNDUPacketParser parser;
107 // using mixin::nextPacketRange;
108 // using mixin::nextPacketType;
109 // using mixin::init;
111 // static key_t nextPacketKey(packet p);
113 static void init(packet p);
115 static factory_t nextPacketType(packet p);
117 static optional_range nextPacketRange(packet p);
119 static void dump(packet p, std::ostream & os);
121 static PacketParserBase::size_type initSize();
123 static PacketParserBase::size_type initHeadSize();
126 typedef SNDUPacketType::packet SNDUPacket;
128 typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> ule_crc32;
132 \def ULE_END_INDICATOR
133 ULE End Indicator; indicates to the receiver that there are no
134 further SNDUs present within the current TS packet.
136 # define ULE_END_INDICATOR 0xffff
140 //-/////////////////////////////////////////////////////////////////////////////////////////////////
141 //#include "SNDUPacket.cci"
142 //#include "SNDUPacket.ct"
143 //#include "SNDUPacket.cti"
150 // c-file-style: "senf"
151 // indent-tabs-mode: nil
152 // ispell-local-dictionary: "american"
153 // compile-command: "scons -u test"
154 // comment-column: 40