Stefan doesn't like MPEG_DVBBundle; renamed to MPEGDVBBundle ;)
[senf.git] / Packets / MPEGDVBBundle / DatagramSection.hh
1 // $Id$
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 #ifndef HH_DatagramSection_
24 #define HH_DatagramSection_ 1
25
26 // Custom includes
27 #include <algorithm>
28 #include "Packets/PacketType.hh"
29 #include "Packets/ParseInt.hh"
30 #include "Packets/PacketRegistry.hh"
31 #include "Packets/PacketParser.hh"
32 #include "Packets/MPEGDVBBundle/DSMCCSection.hh"
33
34
35 //#include "DatagramSection.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39
40     struct Parse_DatagramSection : public Parse_DSMCCSection
41     {
42         //SENF_PACKET_PARSER_NO_INIT(Parse_DatagramSection);
43         Parse_DatagramSection(data_iterator i, state_type s) : senf::Parse_DSMCCSection(i,s) {}
44
45         ///////////////////////////////////////////////////////////////////////////
46
47         typedef Parse_UIntField < 2,  4 > Parse_payload_scrmbl_ctrl;
48         typedef Parse_UIntField < 4,  6 > Parse_addr_scrmbl_ctrl;
49         typedef Parse_Flag      <     6 > Parse_llc_snap_flag;
50                 
51         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS_OFFSET(Parse_DSMCCSection::fixed_bytes,
52             ((Field       ) ( mac_addr_4, Parse_UInt8 ))
53             ((Field       ) ( mac_addr_3, Parse_UInt8 ))
54             ((Field       ) ( mac_addr_2, Parse_UInt8 ))
55             ((Field       ) ( mac_addr_1, Parse_UInt8 ))
56         );
57         
58         Parse_UInt8 mac_addr_6() const { return parse<Parse_UInt8>( 3 ); }
59         Parse_UInt8 mac_addr_5() const { return parse<Parse_UInt8>( 4 ); }
60         Parse_payload_scrmbl_ctrl payload_scrmbl_ctrl() const {
61             return parse<Parse_payload_scrmbl_ctrl>( 5 );
62         }
63         Parse_addr_scrmbl_ctrl addr_scrmbl_ctrl() const {
64             return parse<Parse_addr_scrmbl_ctrl>( 5 );
65         }
66         Parse_llc_snap_flag llc_snap_flag() const {
67             return parse<Parse_llc_snap_flag>( 5 );
68         }
69         
70         void init() 
71         {
72             Parse_DSMCCSection::init();
73             defaultInit();
74         }  
75     };
76
77     struct DatagramSectionType
78         : public DSMCCSectionType,
79           public PacketTypeMixin<DatagramSectionType>
80     {
81         typedef PacketTypeMixin<DatagramSectionType> mixin;
82         typedef ConcretePacket<DatagramSectionType> packet;
83         typedef Parse_DatagramSection parser;
84
85         using mixin::nextPacketRange;
86 //          using mixin::nextPacketType;
87         //using mixin::initSize;
88         using mixin::init;
89         
90         static void dump(packet p, std::ostream & os);
91         
92         static PacketParserBase::size_type initSize();
93         static PacketParserBase::size_type initHeadSize();
94     };
95         
96     typedef DatagramSectionType::packet DatagramSection;
97 }
98
99
100 ///////////////////////////////hh.e////////////////////////////////////////
101 //#include "DatagramSection.cci"
102 //#include "DatagramSection.ct"
103 //#include "DatagramSection.cti"
104 #endif
105
106 \f
107 // Local Variables:
108 // mode: c++
109 // fill-column: 100
110 // c-file-style: "senf"
111 // indent-tabs-mode: nil
112 // ispell-local-dictionary: "american"
113 // compile-command: "scons -u test"
114 // comment-column: 40
115 // End: