e53d068fa0757db4de829e5debdb80a763ff18c5
[senf.git] / Packets / MPEGDVBBundle / DSMCCSection.hh
1 // $Id:DSMCCSection.hh 327 2007-07-20 10:03:44Z tho $
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief DSMCCSection public header */
25
26 #ifndef HH_DSMCCSection_
27 #define HH_DSMCCSection_ 1
28
29 // Custom includes
30 #include <algorithm>
31 #include "Packets/PacketType.hh"
32 #include "Packets/ParseInt.hh"
33 #include "Packets/PacketParser.hh"
34
35 //#include "DSMCCSection.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39
40     /** \brief Parse a DSMCC Section
41     
42         Parser implementing the header of a DSMCC Section
43         
44         \see DSMCCSectionType
45      */
46     struct Parse_DSMCCSection : public PacketParserBase
47     {
48         typedef Parse_UInt8               Parse_table_id;
49         typedef Parse_Flag      <     0 > Parse_ssi;  // section_syntax_indicator
50         typedef Parse_Flag      <     1 > Parse_pi;   // private_indicator
51         typedef Parse_UIntField < 2,  4 > Parse_reserved_1;
52         typedef Parse_UIntField < 4, 16 > Parse_sec_length;
53         typedef Parse_UIntField < 0,  2 > Parse_reserved_2;
54         typedef Parse_UIntField < 2,  7 > Parse_version_num;
55         typedef Parse_Flag      <     7 > Parse_curr_next_indicator;
56
57 #       ifndef DOXYGEN
58         
59         SENF_PACKET_PARSER_INIT(Parse_DSMCCSection);
60
61         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
62             ((Field       ) ( table_id,            Parse_table_id            )) 
63             ((OverlayField) ( ssi,                 Parse_ssi                 ))
64             ((OverlayField) ( pi,                  Parse_pi                  ))
65             ((OverlayField) ( reserved_1,          Parse_reserved_1          ))
66             ((Field       ) ( sec_length,          Parse_sec_length          ))
67             ((Field       ) ( tabel_id_extension,  Parse_UInt16              ))
68             ((OverlayField) ( reserved_2,          Parse_reserved_2          ))
69             ((OverlayField) ( version_num,         Parse_version_num         ))
70             ((Field       ) ( curr_next_indicator, Parse_curr_next_indicator ))
71             ((Field       ) ( sec_num,             Parse_UInt8               ))
72             ((Field       ) ( last_sec_num,        Parse_UInt8               ))
73         );
74         
75 #       else
76         
77         Parse_table_id table_id() const;
78         Parse_ssi                 ssi() const;                 
79         Parse_pi                  pi() const;
80         Parse_reserved_1          reserved_1() const;
81         Parse_sec_length          sec_length const;
82         Parse_UInt16              tabel_id_extension() const;
83         Parse_reserved_2          reserved_2() const;
84         Parse_version_num         version_num() const;
85         Parse_curr_next_indicator curr_next_indicator() const;
86         Parse_UInt8               sec_num() const;
87         Parse_UInt8               last_sec_num() const;
88         
89 #       endif
90         
91         Parse_UInt32 crc() const { return parse<Parse_UInt32>( data().size()-4 ); }
92     };
93     
94     /** \brief DSMCC Section
95         
96         \par Packet type (typedef):
97             \ref DSMCCSection
98
99         \par Fields:
100             \ref Parse_DSMCCSection
101
102         \ingroup protocolbundle_mpegdvb
103      */
104     struct DSMCCSectionType
105         : public PacketTypeBase,
106           public PacketTypeMixin<DSMCCSectionType>
107     {
108         typedef PacketTypeMixin<DSMCCSectionType> mixin;
109         typedef ConcretePacket<DSMCCSectionType> packet;
110         typedef Parse_DSMCCSection parser;
111
112         using mixin::nextPacketRange;
113 //          using mixin::nextPacketType;
114         using mixin::init;
115         
116         static void dump(packet p, std::ostream & os);
117         
118         static PacketParserBase::size_type initSize();
119         static PacketParserBase::size_type initHeadSize();
120     };
121         
122     typedef DSMCCSectionType::packet DSMCCSection;
123 }
124
125
126 ///////////////////////////////hh.e////////////////////////////////////////
127 //#include "DSMCCSection.cci"
128 //#include "DSMCCSection.ct"
129 //#include "DSMCCSection.cti"
130 #endif
131
132 \f
133 // Local Variables:
134 // mode: c++
135 // fill-column: 100
136 // c-file-style: "senf"
137 // indent-tabs-mode: nil
138 // ispell-local-dictionary: "american"
139 // compile-command: "scons -u test"
140 // comment-column: 40
141 // End: