Utils/Logger: Completed documentation
[senf.git] / Packets / MPEGDVBBundle / GREPacket.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 //     Joachim Kaeber <joachim.kaeber@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 GREPacket public header */
25
26 #ifndef HH_GREPacket
27 #define HH_GREPacket 1
28
29 // Custom includes
30 #include <algorithm>
31 #include "../../Packets/Packets.hh"
32
33 //#include "GREPacket.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
35
36 namespace senf {
37
38     /** \brief Parse a GRE packet
39
40         Parser implementing the header of a General Routing Encapsulation (GRE, RFC 2784) Packet
41         
42         \see GREPacketType
43      */
44     struct Parse_GREPacket : public PacketParserBase
45     {
46 #       include SENF_PARSER()
47
48         SENF_PARSER_BITFIELD         ( checksum_present,  1, bool );
49         SENF_PARSER_PRIVATE_BITFIELD ( reserved0_,       12, unsigned ); // TODO: SKIP !!
50         SENF_PARSER_BITFIELD_RO      ( version_number,    3, unsigned ); // TODO: Always Zero !!
51         SENF_PARSER_FIELD            ( protocol_type,    Parse_UInt16 );
52         SENF_PARSER_PRIVATE_VARIANT  ( checksum_,  checksum_present,
53                                                    (VoidPacketParser) (Parse_UInt16) );
54         SENF_PARSER_PRIVATE_VARIANT  ( reserved1_, checksum_present,
55                                                    (VoidPacketParser) (Parse_UInt16) );
56
57         SENF_PARSER_FINALIZE( Parse_GREPacket );
58
59       private: 
60         Parse_UInt16 checksum() const /// only defined if checksum_present() == \c true
61              { return checksum_().get<1>(); }
62     };
63     
64     /** \brief GRE packet
65         
66         \par Packet type (typedef):
67             \ref GREPacket
68
69         \par Fields:
70             \ref Parse_GREPacket
71
72         \ingroup protocolbundle_mpegdvb
73      */
74     struct GREPacketType
75         : public PacketTypeBase,
76           public PacketTypeMixin<GREPacketType>
77     {
78         typedef PacketTypeMixin<GREPacketType> mixin;
79         typedef ConcretePacket<GREPacketType> packet;
80         typedef Parse_GREPacket parser;
81     
82         using mixin::nextPacketRange;
83         using mixin::init;
84         using mixin::initSize;
85         
86         static void dump(packet p, std::ostream & os);
87     };
88     
89     /** \brief GRE packet typedef */
90     typedef GREPacketType::packet GREPacket;
91     
92   
93 }
94
95
96 ///////////////////////////////hh.e////////////////////////////////////////
97 //#include "TransportPacket.cci"
98 //#include "TransportPacket.ct"
99 //#include "TransportPacket.cti"
100 #endif
101
102 \f
103 // Local Variables:
104 // mode: c++
105 // fill-column: 100
106 // c-file-style: "senf"
107 // indent-tabs-mode: nil
108 // ispell-local-dictionary: "american"
109 // compile-command: "scons -u test"
110 // comment-column: 40
111 // End: