4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief SNDUPacket public header */
26 #ifndef HH_SENF_Packets_MPEGDVBBundle_SNDUPacket_
27 #define HH_SENF_Packets_MPEGDVBBundle_SNDUPacket_ 1
30 #include <boost/crc.hpp>
31 #include <senf/Packets/Packets.hh>
32 #include <senf/Packets/DefaultBundle/EthernetPacket.hh>
34 //#include "SNDUPacket.mpp"
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 /** \brief parse ULE SNDU Packet
41 Parser implementing the header and trailer of a ULE SNDU Packet
45 struct SNDUPacketParser : public PacketParserBase
47 # include SENF_PARSER()
49 /* We first define the fields as they appear in the field. Some of the fields are declared
50 private. We provide custom accessors for those fields further down. */
52 SENF_PARSER_PRIVATE_BITFIELD ( d_bit_ , 1 , unsigned );
53 SENF_PARSER_BITFIELD ( length , 15 , unsigned );
54 SENF_PARSER_FIELD ( type , UInt16Parser );
55 SENF_PARSER_PRIVATE_VARIANT ( destination_ , d_bit_ ,
56 (MACAddressParser) (VoidPacketParser) );
58 SENF_PARSER_FINALIZE( SNDUPacketParser );
60 MACAddressParser destination() ///< Only defined if d_bit() == \c false
61 { return destination_().get<0>(); }
63 bool d_bit() ///< Destination absent bit
66 void withDestination() ///< Clear destination absent bit
67 { destination_().init<0>(); }
69 void withoutDestination() ///< Set destination absent bit
70 { destination_().init<1>(); }
73 { return parse<UInt32Parser>( data().size() - 4 ); }
75 boost::uint32_t calcCrc() const;
79 struct ULEExtHeaderTypes {
80 typedef boost::uint16_t key_t;
83 /** \brief ULE SNDU Packet
85 \par Packet type (typedef):
90 \image html SNDUPacket.png
92 \ingroup protocolbundle_mpegdvb
95 : public PacketTypeBase
96 // public PacketTypeMixin<SNDUPacketType, ULEExtHeaderTypes>
98 // typedef PacketTypeMixin<SNDUPacketType, ULEExtHeaderType> mixin;
99 typedef ConcretePacket<SNDUPacketType> packet;
100 typedef SNDUPacketParser parser;
102 // using mixin::nextPacketRange;
103 // using mixin::nextPacketType;
104 // using mixin::init;
106 // static key_t nextPacketKey(packet p);
108 static void init(packet p);
110 static factory_t nextPacketType(packet p);
112 static optional_range nextPacketRange(packet p);
114 static void dump(packet p, std::ostream & os);
116 static PacketParserBase::size_type initSize();
118 static PacketParserBase::size_type initHeadSize();
121 typedef SNDUPacketType::packet SNDUPacket;
123 typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> ule_crc32;
127 \def ULE_END_INDICATOR
128 ULE End Indicator; indicates to the receiver that there are no
129 further SNDUs present within the current TS packet.
131 # define ULE_END_INDICATOR 0xffff
135 //-/////////////////////////////////////////////////////////////////////////////////////////////////
136 //#include "SNDUPacket.cci"
137 //#include "SNDUPacket.ct"
138 //#include "SNDUPacket.cti"
145 // c-file-style: "senf"
146 // indent-tabs-mode: nil
147 // ispell-local-dictionary: "american"
148 // compile-command: "scons -u test"
149 // comment-column: 40