Packets/DefaultBundle: Fix packet parser documentation using #ifndef DOXYGEN guards
[senf.git] / Packets / DefaultBundle / IpV4Packet.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
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_IpV4Packet_
24 #define HH_IpV4Packet_ 1
25
26 // Custom includes
27 #include "Packets/Packets.hh"
28
29 //#include "IpV4Packet.mpp"
30 ///////////////////////////////hh.p////////////////////////////////////////
31
32 namespace senf {
33
34     /** \brief Parse an IpV4 packet
35
36         Parser implementing the IpV4 header. The fields implemented are:
37
38         \see IpV4PacketType \n
39             <a href="http://tools.ietf.org/html/rfc791">RFC 791</a>
40
41         \todo Implement options
42      */
43     struct Parse_IpV4 : public PacketParserBase
44     {
45         typedef Parse_UIntField <  0,  4 > Parse_Version;
46         typedef Parse_UIntField <  4,  8 > Parse_IHL;
47         typedef Parse_UInt8                Parse_8bit;
48         typedef Parse_UInt16               Parse_16bit;
49         typedef Parse_Flag      <  0     > Parse_R;
50         typedef Parse_Flag      <  1     > Parse_DF;
51         typedef Parse_Flag      <  2     > Parse_MF;
52         typedef Parse_UIntField <  3, 16 > Parse_Frag;
53         typedef Parse_UInt32               Parse_32bit;
54
55 #       ifndef DOXYGEN
56
57         SENF_PACKET_PARSER_NO_INIT(Parse_IpV4);
58
59         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
60             ((OverlayField)( version,     Parse_Version ))
61             ((Field       )( ihl,         Parse_IHL     ))
62             ((Field       )( tos,         Parse_8bit    ))
63             ((Field       )( length,      Parse_16bit   ))
64             ((Field       )( identifier,  Parse_16bit   ))
65             ((OverlayField)( reserved,    Parse_R       ))
66             ((OverlayField)( df,          Parse_DF      ))
67             ((OverlayField)( mf,          Parse_MF      ))
68             ((Field       )( frag,        Parse_Frag    ))
69             ((Field       )( ttl,         Parse_8bit    ))
70             ((Field       )( protocol,    Parse_8bit    ))
71             ((Field       )( crc,         Parse_16bit   ))
72             ((Field       )( source,      Parse_32bit   ))
73             ((Field       )( destination, Parse_32bit   )) );
74
75 #       else
76
77         Parse_Version version();
78         Parse_IHL ihl();
79         Parse_8bit tos();
80         Parse_16bit length();
81         Parse_16bit identifier();
82         Parse_R reserved();
83         Parse_DF df();
84         Parse_MF mf();
85         Parse_Frag frag();
86         Parse_8bit ttl();
87         Parse_8bit protocol();
88         Parse_16bit crc();
89         Parse_32bit source();
90         Parse_32bit destination();
91
92 #       endif
93
94         void init() {
95             version() = 4;
96         }
97     };
98
99     /** \brief IP protocol number registry
100
101         This registeres packets with their IP protocol number.
102
103         \see <a href="http://www.iana.org/assignments/protocol-numbers">Protocol numbers</a>
104             PacketRegistry
105      */
106     struct IpTypes {
107         typedef boost::uint16_t key_t;
108     };
109
110     /** \brief IpV4 packet
111         
112         \par Packet type (typedef):
113             \ref IpV4Packet
114
115         \par Fields:
116             \ref Parse_IpV4
117
118         \par Associated registries:
119             \ref IpTypes
120
121         \ingroup protocolbundle_default
122      */
123     struct IpV4PacketType
124         : public PacketTypeBase,
125           public PacketTypeMixin<IpV4PacketType, IpTypes>
126     {
127         typedef PacketTypeMixin<IpV4PacketType, IpTypes> mixin;
128         typedef ConcretePacket<IpV4PacketType> packet;
129         typedef Parse_IpV4 parser;
130
131         using mixin::nextPacketRange;
132         using mixin::nextPacketType;
133         using mixin::initSize;
134         using mixin::init;
135
136         static registry_key_t nextPacketKey(packet p) 
137             { return p->protocol(); }
138
139         static void dump(packet p, std::ostream & os);
140     };
141         
142     /** \brief IpV4 packet typedef */
143     typedef IpV4PacketType::packet IpV4Packet;
144 }
145
146
147 ///////////////////////////////hh.e////////////////////////////////////////
148 #endif
149 #ifndef SENF_PACKETS_DECL_ONLY
150 //#include IpV4Packet.cci"
151 //#include "IpV4Packet.ct"
152 //#include "IpV4Packet.cti"
153 #endif
154
155 \f
156 // Local Variables:
157 // mode: c++
158 // fill-column: 100
159 // c-file-style: "senf"
160 // indent-tabs-mode: nil
161 // ispell-local-dictionary: "american"
162 // compile-command: "scons -u test"
163 // comment-column: 40
164 // End: