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 SNDUPacketParser : public PacketParserBase
48 # include SENF_PARSER()
50 /* We first define the fields as they appear in the field. Some of the fields are declared
51 private. We provide custom accessors for those fields further down. */
53 SENF_PARSER_PRIVATE_BITFIELD ( d_bit_ , 1 , unsigned );
54 SENF_PARSER_BITFIELD ( length , 15 , unsigned );
55 SENF_PARSER_FIELD ( type , UInt16Parser );
56 SENF_PARSER_PRIVATE_VARIANT ( destination_ , d_bit_ ,
57 (MACAddressParser) (VoidPacketParser) );
59 SENF_PARSER_FINALIZE( SNDUPacketParser );
61 MACAddressParser destination() /// Only defined if d_bit() == \c false
62 { return destination_().get<0>(); }
64 bool d_bit() /// Destination absent bit
67 void withDestination() /// Clear destination absent bit
68 { destination_().init<0>(); }
70 void withoutDestination() /// Set destination absent bit
71 { destination_().init<1>(); }
74 { return parse<UInt32Parser>( data().size() - 4 ); }
76 boost::uint32_t calcCrc() const;
80 struct ULEExtHeaderTypes {
81 typedef boost::uint16_t key_t;
84 /** \brief ULE SNDU Packet
86 \par Packet type (typedef):
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 registry_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 ///////////////////////////////hh.e////////////////////////////////////////
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