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 TLVPacket public header */
27 #define HH_TLVPacket_ 1
31 #include "../../Packets/PacketType.hh"
32 #include "../../Packets/ParseInt.hh"
33 #include "../../Packets/PacketParser.hh"
35 //#include "TLVPacket.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
40 struct UnsuportedTLVPacketException : public std::exception
42 virtual char const * what() const throw() {
43 return "length of length can be max. 4 bytes. Sorry.";
47 class Parse_TLVPacketLength
48 : public detail::packet::ParseIntOps<Parse_TLVPacketLength, boost::uint32_t>,
49 public PacketParserBase
54 SENF_PACKET_PARSER_NO_INIT(Parse_TLVPacketLength);
58 typedef boost::uint32_t value_type;
60 value_type value() const;
62 void value(value_type const & v);
64 Parse_TLVPacketLength const & operator= (value_type other);
66 static const size_type init_bytes = 1;
68 size_type bytes() const;
73 typedef Parse_Flag < 0 > Parse_extended_length_flag;
74 typedef Parse_UIntField < 1, 8 > Parse_fixed_length;
76 Parse_extended_length_flag extended_length_flag() const {
77 return parse<Parse_extended_length_flag>( 0 );
80 Parse_fixed_length fixed_length_field() const {
81 return parse<Parse_fixed_length>( 0 );
84 void resize(size_type size);
87 /** \brief parse TLVPacket Packet
93 struct Parse_TLVPacket : public PacketParserBase
97 SENF_PACKET_PARSER_INIT(Parse_TLVPacket);
99 SENF_PACKET_PARSER_DEFINE_FIELDS(
100 ((Field)( type, Parse_UInt32 ))
101 ((Field)( length, Parse_TLVPacketLength ))
107 /** \brief TLV Packet
109 \par Packet type (typedef):
115 \ingroup protocolbundle_mpegdvb
118 : public PacketTypeBase
120 typedef ConcretePacket<TLVPacketType> packet;
121 typedef Parse_TLVPacket parser;
123 static optional_range nextPacketRange(packet p);
124 static void init(packet p);
125 static size_type initSize();
126 static void finalize(packet p);
127 static void dump(packet p, std::ostream & os);
130 typedef TLVPacketType::packet TLVPacket;
135 ///////////////////////////////hh.e////////////////////////////////////////
136 //#include "TLVPacket.cci"
137 //#include "TLVPacket.ct"
138 //#include "TLVPacket.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