Packets: Clean up ParseHelpers implementation
[senf.git] / Packets / MPEGDVBBundle / DatagramSection.hh
1 // $Id:DatagramSection.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 //     Thorsten Horstmann <thorsten.horstmann@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 /** \brief
24     \file DatagramSection public header */
25
26 #ifndef HH_DatagramSection_
27 #define HH_DatagramSection_ 1
28
29 // Custom includes
30 #include <algorithm>
31 #include "../../Packets/Packets.hh"
32 #include "DSMCCSection.hh"
33
34
35 //#include "DatagramSection.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39
40     /** \brief Parse a Datagram Section
41     
42         Parser implementing the Datagram Section.
43     
44         \see DatagramSectionType
45      */
46     struct Parse_DatagramSection : public Parse_DSMCCSection
47     {
48 #       include SENF_FIXED_PARSER()
49
50         SENF_PARSER_INHERIT(Parse_DSMCCSection);
51
52         SENF_PARSE_FIELD( mac_addr_4, Parse_UInt8 );
53         SENF_PARSE_FIELD( mac_addr_3, Parse_UInt8 );
54         SENF_PARSE_FIELD( mac_addr_2, Parse_UInt8 );
55         SENF_PARSE_FIELD( mac_addr_1, Parse_UInt8 );
56
57         SENF_PARSER_FINALIZE(Parse_DatagramSection);
58
59         typedef Parse_UIntField < 2,  4 > Parse_payload_scrmbl_ctrl;
60         typedef Parse_UIntField < 4,  6 > Parse_addr_scrmbl_ctrl;
61         typedef Parse_Flag      <     6 > Parse_llc_snap_flag;
62
63         Parse_UInt8 mac_addr_6() const { return parse<Parse_UInt8>( 3 ); }
64         Parse_UInt8 mac_addr_5() const { return parse<Parse_UInt8>( 4 ); }
65
66         Parse_payload_scrmbl_ctrl payload_scrmbl_ctrl() const {
67             return parse<Parse_payload_scrmbl_ctrl>( 5 );
68         }
69
70         Parse_addr_scrmbl_ctrl addr_scrmbl_ctrl() const {
71             return parse<Parse_addr_scrmbl_ctrl>( 5 );
72         }
73
74         Parse_llc_snap_flag llc_snap_flag() const {
75             return parse<Parse_llc_snap_flag>( 5 );
76         }
77     };
78
79     /** \brief Datagram Section
80         
81         \par Packet type (typedef):
82             \ref DatagramSection
83
84         \par Fields:
85             \ref Parse_DatagramSection
86
87         \ingroup protocolbundle_mpegdvb
88      */
89     struct DatagramSectionType
90         : public DSMCCSectionType,
91           public PacketTypeMixin<DatagramSectionType>
92     {
93         typedef PacketTypeMixin<DatagramSectionType> mixin;
94         typedef ConcretePacket<DatagramSectionType> packet;
95         typedef Parse_DatagramSection parser;
96
97         using mixin::nextPacketRange;
98         using mixin::init;
99         
100         static void dump(packet p, std::ostream & os);
101         
102         static PacketParserBase::size_type initSize();
103         static PacketParserBase::size_type initHeadSize();
104     };
105         
106     typedef DatagramSectionType::packet DatagramSection;
107 }
108
109
110 ///////////////////////////////hh.e////////////////////////////////////////
111 //#include "DatagramSection.cci"
112 //#include "DatagramSection.ct"
113 //#include "DatagramSection.cti"
114 #endif
115
116 \f
117 // Local Variables:
118 // mode: c++
119 // fill-column: 100
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"
124 // comment-column: 40
125 // End: