4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Thorsten Horstmann <thorsten.horstmann@fokus.fraunhofer.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_SNDUPacket_
27 #define HH_SNDUPacket_ 1
31 #include <boost/crc.hpp>
32 #include "../../Packets/Packets.hh"
33 #include "../DefaultBundle/EthernetPacket.hh"
35 //#include "SNDUPacket.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
40 /** \brief parse ULE SNDU Packet
42 Parser implementing the header and trailer of a ULE SNDU Packet
46 struct Parse_SNDUPacket : public PacketParserBase
48 # include SENF_PARSER()
50 SENF_PARSER_BITFIELD ( d_bit , 1 , bool );
51 SENF_PARSER_BITFIELD ( length , 15 , unsigned );
53 SENF_PARSER_FIELD ( type , Parse_UInt16 );
55 // This field only exists, if d_bit() is *not* set. New SNDUPackets are created with d_bit()
56 // set to 0, they have destination. We set the size of this field depending on the value of
57 // d_bit(), the init_bytes value is set to 6 bytes (the size of a MAC address)
58 SENF_PARSER_CUSTOM_FIELD ( destination , Parse_MAC , d_bit() ? 0 : 6 , 6 ) {
59 BOOST_ASSERT( ! d_bit() );
60 return parse<destination_t>( destination_offset() );
63 // This field is placed at the end of the parser. It is therefore only considered for
64 // calculating init_bytes but not for calculating bytes()
65 SENF_PARSER_CUSTOM_FIELD ( crc , Parse_UInt32 , 0 , 4 ) {
66 return parse<crc_t>( data().size() - 4 );
69 SENF_PARSER_FINALIZE( Parse_SNDUPacket );
71 boost::uint32_t calcCrc() const;
75 struct ULEExtHeaderTypes {
76 typedef boost::uint16_t key_t;
79 /** \brief ULE SNDU Packet
81 \par Packet type (typedef):
87 \ingroup protocolbundle_mpegdvb
90 : public PacketTypeBase
91 // public PacketTypeMixin<SNDUPacketType, ULEExtHeaderTypes>
93 // typedef PacketTypeMixin<SNDUPacketType, ULEExtHeaderType> mixin;
94 typedef ConcretePacket<SNDUPacketType> packet;
95 typedef Parse_SNDUPacket parser;
97 // using mixin::nextPacketRange;
98 // using mixin::nextPacketType;
101 // static registry_key_t nextPacketKey(packet p);
103 static void init(packet p);
105 static factory_t nextPacketType(packet p);
107 static optional_range nextPacketRange(packet p);
109 static void dump(packet p, std::ostream & os);
111 static PacketParserBase::size_type initSize();
113 static PacketParserBase::size_type initHeadSize();
116 typedef SNDUPacketType::packet SNDUPacket;
118 typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> ule_crc32;
122 \def ULE_END_INDICATOR
123 ULE End Indicator; indicates to the receiver that there are no
124 further SNDUs present within the current TS packet.
126 # define ULE_END_INDICATOR 0xffff
130 ///////////////////////////////hh.e////////////////////////////////////////
131 //#include "SNDUPacket.cci"
132 //#include "SNDUPacket.ct"
133 //#include "SNDUPacket.cti"
140 // c-file-style: "senf"
141 // indent-tabs-mode: nil
142 // ispell-local-dictionary: "american"
143 // compile-command: "scons -u test"
144 // comment-column: 40