nun mach' ich erst einmal Urlaub....
[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/PacketType.hh"
32 #include "Packets/ParseInt.hh"
33 #include "Packets/PacketRegistry.hh"
34 #include "Packets/PacketParser.hh"
35 #include "Packets/MPEGDVBBundle/DSMCCSection.hh"
36
37
38 //#include "DatagramSection.mpp"
39 ///////////////////////////////hh.p////////////////////////////////////////
40
41 namespace senf {
42
43     /** \brief Parse a Datagram Section
44     
45         Parser implementing the Datagram Section.
46     
47         \see DatagramSectionType
48      */
49     struct Parse_DatagramSection : public Parse_DSMCCSection
50     {
51         Parse_DatagramSection(data_iterator i, state_type s) : senf::Parse_DSMCCSection(i,s) {}
52
53         typedef Parse_UIntField < 2,  4 > Parse_payload_scrmbl_ctrl;
54         typedef Parse_UIntField < 4,  6 > Parse_addr_scrmbl_ctrl;
55         typedef Parse_Flag      <     6 > Parse_llc_snap_flag;
56                 
57 #       ifndef DOXYGEN
58         
59         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(Parse_DSMCCSection::fixed_bytes,
60             ((Field       ) ( mac_addr_4, Parse_UInt8 ))
61             ((Field       ) ( mac_addr_3, Parse_UInt8 ))
62             ((Field       ) ( mac_addr_2, Parse_UInt8 ))
63             ((Field       ) ( mac_addr_1, Parse_UInt8 ))
64         );
65         
66 #       else
67         
68         Parse_UInt8 mac_addr_4() const;
69         Parse_UInt8 mac_addr_3() const;
70         Parse_UInt8 mac_addr_2() const;
71         Parse_UInt8 mac_addr_1() const;
72         
73 #       endif
74         
75         Parse_UInt8 mac_addr_6() const { return parse<Parse_UInt8>( 3 ); }
76         Parse_UInt8 mac_addr_5() const { return parse<Parse_UInt8>( 4 ); }
77         Parse_payload_scrmbl_ctrl payload_scrmbl_ctrl() const {
78             return parse<Parse_payload_scrmbl_ctrl>( 5 );
79         }
80         Parse_addr_scrmbl_ctrl addr_scrmbl_ctrl() const {
81             return parse<Parse_addr_scrmbl_ctrl>( 5 );
82         }
83         Parse_llc_snap_flag llc_snap_flag() const {
84             return parse<Parse_llc_snap_flag>( 5 );
85         }
86         
87         void init() 
88         {
89             Parse_DSMCCSection::init();
90             defaultInit();
91         }  
92     };
93
94     /** \brief Datagram Section
95         
96         \par Packet type (typedef):
97             \ref DatagramSection
98
99         \par Fields:
100             \ref Parse_DatagramSection
101
102         \ingroup protocolbundle_mpegdvb
103      */
104     struct DatagramSectionType
105         : public DSMCCSectionType,
106           public PacketTypeMixin<DatagramSectionType>
107     {
108         typedef PacketTypeMixin<DatagramSectionType> mixin;
109         typedef ConcretePacket<DatagramSectionType> packet;
110         typedef Parse_DatagramSection parser;
111
112         using mixin::nextPacketRange;
113 //          using mixin::nextPacketType;
114         //using mixin::initSize;
115         using mixin::init;
116         
117         static void dump(packet p, std::ostream & os);
118         
119         static PacketParserBase::size_type initSize();
120         static PacketParserBase::size_type initHeadSize();
121     };
122         
123     typedef DatagramSectionType::packet DatagramSection;
124 }
125
126
127 ///////////////////////////////hh.e////////////////////////////////////////
128 //#include "DatagramSection.cci"
129 //#include "DatagramSection.ct"
130 //#include "DatagramSection.cti"
131 #endif
132
133 \f
134 // Local Variables:
135 // mode: c++
136 // fill-column: 100
137 // c-file-style: "senf"
138 // indent-tabs-mode: nil
139 // ispell-local-dictionary: "american"
140 // compile-command: "scons -u test"
141 // comment-column: 40
142 // End: