Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Packets / DefaultBundle / IPv6Packet.hh
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.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 IPv6Packet public header */
25
26 #ifndef HH_SENF_Packets_DefaultBundle_IPv6Packet_
27 #define HH_SENF_Packets_DefaultBundle_IPv6Packet_ 1
28
29 // Custom includes
30 #include <senf/Socket/Protocols/INet/INet6Address.hh>
31 #include <senf/Packets/Packets.hh>
32 #include "IPv4Packet.hh"
33
34 //#include "IPv6Packet.mpp"
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36
37 namespace senf {
38
39     /** \brief Parse an IPv6 address
40
41         \see INet6Address
42      */
43     struct INet6AddressParser
44         : public ValueParserBase<INet6AddressParser, INet6Address, 16u>
45     {
46         INet6AddressParser(data_iterator i, state_type s) : Base(i,s) {}
47
48         value_type value() const { return value_type::from_data(i()); }
49         void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); }
50
51         using Base::operator=;
52     };
53
54     /** \brief Parse an IPv6 packet
55
56         \image html IPv6Packet.png
57         \see IPv6PacketType \n
58             <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
59      */
60     struct IPv6PacketParser : public PacketParserBase
61     {
62 #       include SENF_FIXED_PARSER()
63
64         SENF_PARSER_BITFIELD( version,       4, unsigned );
65         SENF_PARSER_BITFIELD( trafficClass,  8, unsigned );
66         SENF_PARSER_BITFIELD( flowLabel,    20, unsigned );
67
68         SENF_PARSER_FIELD( length,       UInt16Parser       );
69         SENF_PARSER_FIELD( nextHeader,   UInt8Parser        );
70         SENF_PARSER_FIELD( hopLimit,     UInt8Parser        );
71         SENF_PARSER_FIELD( source,       INet6AddressParser );
72         SENF_PARSER_FIELD( destination,  INet6AddressParser );
73
74         SENF_PARSER_INIT() {
75             version() = 6;
76         }
77
78         SENF_PARSER_FINALIZE(IPv6PacketParser);
79     };
80
81     /** \brief IPv6 packet
82
83         \par Packet type (typedef):
84             \ref IPv6Packet
85
86         \par Fields:
87             \ref IPv6PacketParser
88
89         <table class="packet" cellpadding="5" cellspacing="1" border="1">
90           <tr>
91             <th width="12.5%">0</th>  <th width="12.5%">4</th> <th width="12.5%">8</th>
92             <th width="12.5%">12</th> <th width="12.5%">16</th> <th width="12.5%">20</th>
93             <th width="12.5%">24</th> <th width="6.5%">28</th>
94             <th style="text-align:right" width="6%">31</th>
95           </tr><tr>
96             <td>\ref IPv6PacketParser::version() "Version"</td>
97             <td colspan="2">\ref IPv6PacketParser::trafficClass() "Traffic Class"</td>
98             <td colspan="6">\ref IPv6PacketParser::flowLabel() "Flow Label"</td>
99           </tr><tr>
100             <td colspan="4">\ref IPv6PacketParser::length() "Payload Length"</td>
101             <td colspan="2">\ref IPv6PacketParser::nextHeader() "Next Header"</td>
102             <td colspan="3">\ref IPv6PacketParser::hopLimit() "Hop Limit"</td>
103           </tr><tr>
104             <td colspan="9" style="height:8em">
105               \ref IPv6PacketParser::source() "Source Address"</td>
106           </tr><tr>
107             <td colspan="9" style="height:8em">
108               \ref IPv6PacketParser::destination()  "Destination Address"</td>
109           </tr>
110         </table>
111
112         \par Associated registries:
113             \ref IpTypes
114
115         \par Finalize action:
116             \copydetails finalize()
117
118         \ingroup protocolbundle_default
119      */
120     struct IPv6PacketType
121         : public PacketTypeBase,
122           public PacketTypeMixin<IPv6PacketType, IpTypes>
123     {
124 #ifndef DOXYGEN
125         typedef PacketTypeMixin<IPv6PacketType, IpTypes> mixin;
126 #endif
127         typedef ConcretePacket<IPv6PacketType> packet; ///< IPv6 packet typedef
128         typedef IPv6PacketParser parser;               ///< typedef to the parser of IPv6 packet
129
130         using mixin::nextPacketRange;
131         using mixin::nextPacketType;
132         using mixin::initSize;
133         using mixin::init;
134
135         static key_t nextPacketKey(packet p)
136             { return p->nextHeader(); }
137
138         /** \brief Dump given IPv6Packet in readable form to given output stream */
139         static void dump(packet p, std::ostream & os);
140
141         static void finalize(packet p); ///< Finalize packet.
142                                         /**< \li set \ref IPv6PacketParser::length() "length"
143                                                from payload size
144                                              \li set \ref IPv6PacketParser::nextHeader()
145                                                "nextHeader" from type of next packet if found
146                                                in \ref IpTypes */
147     };
148
149     /** \brief IPv6 packet typedef
150         \ingroup protocolbundle_default
151      */
152     typedef ConcretePacket<IPv6PacketType> IPv6Packet;
153 }
154
155 //-/////////////////////////////////////////////////////////////////////////////////////////////////
156 //#include "IPv6Packet.cci"
157 //#include "IPv6Packet.ct"
158 //#include "IPv6Packet.cti"
159 #endif
160
161 \f
162 // Local Variables:
163 // mode: c++
164 // fill-column: 100
165 // c-file-style: "senf"
166 // indent-tabs-mode: nil
167 // ispell-local-dictionary: "american"
168 // compile-command: "scons -u test"
169 // comment-column: 40
170 // End: