Fix SCons 1.2.0 build failure
[senf.git] / senf / Packets / DefaultBundle / IPv6Extensions.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 //     Philipp Batroff <philipp.batroff@fokus.fraunhofer.de>
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 IPv6Extensions public header */
25
26 #ifndef HH_SENF_Packets_DefaultBundle_IPv6Extensions_
27 #define HH_SENF_Packets_DefaultBundle_IPv6Extensions_ 1
28
29 // Custom includes
30 #include "IPv6Packet.hh"
31
32 //#include "IPv6Extensions.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
34
35 namespace senf {
36
37     /** \brief Parse in IPv6 fragment extension header
38         
39         Parser implementing the IPv6 fragment extension. The fields implemented are:
40         \image html IPv6Extensions_Fragment.png
41
42         \see IPv6ExtensionType_Fragment \n
43             <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
44      */
45     struct IPv6PacketParserExtension_Fragment : public PacketParserBase
46     {
47 #       include SENF_FIXED_PARSER()
48
49         SENF_PARSER_FIELD            ( nextHeader     , UInt8Parser  );
50         SENF_PARSER_PRIVATE_FIELD    ( reserved1      , UInt8Parser  );
51
52         SENF_PARSER_BITFIELD         ( fragmentOffset , 13, unsigned );
53         SENF_PARSER_PRIVATE_BITFIELD ( reserved2      ,  2, unsigned );
54         SENF_PARSER_BITFIELD         ( moreFragments  ,  1, bool     );
55
56         SENF_PARSER_FIELD            ( id             , UInt32Parser );
57
58         SENF_PARSER_FINALIZE(IPv6PacketParserExtension_Fragment);
59     };
60
61     /** \brief IPv6 fragment extension
62
63         \par Packet type (typedef):
64             \ref IPv6Extension_Fragment
65
66         \par Fields:
67             \ref IPv6PacketParserExtension_Fragment
68         
69         \par Associated registries:
70             \ref IpTypes
71         
72         \par Finalize action:
73             Set \a nextHeader from type of next packet if found in \ref IpTypes
74
75         \ingroup protocolbundle_default
76      */
77     struct IPv6ExtensionType_Fragment
78         : public PacketTypeBase,
79           public PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes>
80     {
81 #ifndef DOXYGEN
82         typedef PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes> mixin;
83 #endif
84         /** \brief IPv6 fragment extension packet typedef */
85         typedef ConcretePacket<IPv6ExtensionType_Fragment> packet; 
86         /** \brief typedef to the parser of IPv6 fragment extension packet */
87         typedef IPv6PacketParserExtension_Fragment parser;
88
89         using mixin::nextPacketRange;
90         using mixin::nextPacketType;
91         using mixin::initSize;
92         using mixin::init;
93
94         static key_t nextPacketKey(packet p) 
95             { return p->nextHeader(); }
96         
97         /** \brief Dump given IPv6Extension_Fragment in readable form to given output stream */
98         static void dump(packet p, std::ostream & os); 
99
100         static void finalize(packet p) { 
101             p->nextHeader() << key(p.next(nothrow)); }
102     };
103
104     /** \brief IPv6 fragment extension packet typedef */
105     typedef ConcretePacket<IPv6ExtensionType_Fragment> IPv6Extension_Fragment;
106
107 // =====================================================================================================
108
109     /** \brief Parse in IPv6 routing extension header
110
111         Parser implementing the IPv6 routing Header extension. The fields implemented are:
112     \image html IPv6Extensions_Routing.png
113
114     \see IPv6ExtensionType_Routing \n
115     <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
116      */
117
118 //Routing Header Extension (type 0 only)
119     struct IPv6PacketParserExtension_Routing : public PacketParserBase
120     {
121 /*
122 The Type 0 Routing header has the following format: (RFC 2460)
123
124     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
125     |  Next Header  |  Hdr Ext Len  | Routing Type=0| Segments Left |
126     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
127     |                            Reserved                           |
128     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129     |                                                               |
130     +                                                               +
131     |                                                               |
132     +                           Address[1]                          +
133     |                                                               |
134     +                                                               +
135     |                                                               |
136     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
137     .                               .                               .
138     .                               .                               .
139     .                               .                               .
140     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141     |                                                               |
142     +                                                               +
143     |                                                               |
144     +                           Address[n]                          +
145     |                                                               |
146     +                                                               +
147     |                                                               |
148     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
149
150 */
151 #       include SENF_PARSER()
152         
153         SENF_PARSER_FIELD ( nextHeader, UInt8Parser      );
154         SENF_PARSER_FIELD ( headerLength, UInt8Parser    );
155         SENF_PARSER_FIELD ( routingType, UInt8Parser     ); //set to Zero for minimal implementation
156         SENF_PARSER_FIELD_RO ( segmentsLeft, UInt8Parser );
157         SENF_PARSER_FIELD ( reserved, UInt32Parser       ); //set to zero by RFC
158         SENF_PARSER_VECTOR ( hopAddresses, segmentsLeft, INet6AddressParser );
159         
160         SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_Routing );
161         
162         //provisionary, since only type 0 is implemented
163         SENF_PARSER_INIT() { 
164             routingType() = 0u;
165             reserved() = 0u; 
166         }
167     };
168     
169     /** \brief IPv6 routing extension
170
171         \par Packet type (typedef):
172     \ref IPv6Extension_Routing
173
174         \par Fields:
175     \ref IPv6PacketParserExtension_Routing
176         
177         \par Associated registries:
178     \ref IpTypes
179         
180         \par Finalize action:
181     Set \a nextHeader from type of next packet if found in \ref IpTypes
182
183     \ingroup protocolbundle_default
184          */
185     
186     struct IPv6ExtensionType_Routing
187     :   public PacketTypeBase,
188         public PacketTypeMixin<IPv6ExtensionType_Routing, IpTypes>
189
190     {
191 #ifndef DOXYGEN
192         typedef PacketTypeMixin<IPv6ExtensionType_Routing, IpTypes> mixin;
193 #endif
194         /** \brief IPv6 routing extension packet typedef */
195         typedef ConcretePacket<IPv6ExtensionType_Routing> packet;
196         /** \brief typedef to the parser of IPv6 routing extension packet */
197         typedef IPv6PacketParserExtension_Routing parser;
198         
199         using mixin::nextPacketRange;
200         using mixin::nextPacketType;
201         using mixin::init;
202         using mixin::initSize;
203         
204         static key_t nextPacketKey(packet p) 
205             { return p->nextHeader(); }
206         /** \brief Dump given IPv6Extension_Routing in readable form to given output stream */
207         static void dump(packet p, std::ostream & os); 
208         
209         static void finalize(packet p) { 
210             p->nextHeader() << key(p.next(nothrow)); }
211     };
212     
213     /** \brief IPv6 routing extension packet typedef */
214     typedef ConcretePacket<IPv6ExtensionType_Routing> IPv6Extension_Routing;
215
216     
217 // =====================================================================================================
218     
219     /** \brief Parse in IPv6 Hop-By-Hop extension header
220
221         Parser implementing the IPv6 routing Header extension. The fields implemented are:
222     \image html IPv6Extensions_HopByHop.png
223
224     \see IPv6ExtensionType_HopByHop \n
225     <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
226     */
227
228 // Hop-By-Hop skeleton without Options 
229
230     struct IPv6PacketParserExtension_HopByHop : public PacketParserBase {
231 #       include SENF_PARSER()
232         SENF_PARSER_FIELD ( nextHeader, UInt8Parser   );
233         SENF_PARSER_FIELD ( headerLength, UInt8Parser );
234         
235         SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_HopByHop );
236     };
237     
238     /** \brief IPv6 Hop-By-Hop extension
239
240         \par Packet type (typedef):
241     \ref IPv6Extension_HopByHop
242
243         \par Fields:
244     \ref IPv6PacketParserExtension_HopByHop
245         
246         \par Associated registries:
247     \ref IpTypes
248         
249         \par Finalize action:
250     Set \a nextHeader from type of next packet if found in \ref IpTypes
251
252     \ingroup protocolbundle_default
253     */
254     
255     struct IPv6ExtensionType_HopByHop
256     :   public PacketTypeBase,
257         public PacketTypeMixin<IPv6ExtensionType_HopByHop, IpTypes>
258     {
259 #ifndef DOXYGEN
260         typedef PacketTypeMixin<IPv6ExtensionType_HopByHop, IpTypes> mixin;
261 #endif
262         /** \brief IPv6 Hop-By-Hop extension packet typedef */
263         typedef ConcretePacket<IPv6ExtensionType_HopByHop> packet;
264         /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
265         typedef IPv6PacketParserExtension_HopByHop parser;
266         
267         using mixin::nextPacketRange;
268         using mixin::nextPacketType;
269         using mixin::init;
270         using mixin::initSize;
271         
272         static key_t nextPacketKey(packet p) 
273         { return p->nextHeader(); }
274         /** \brief Dump given IPv6Extension_HopByHop in readable form to given output stream */
275         static void dump(packet p, std::ostream & os); 
276         
277         static void finalize(packet p) { 
278             p->nextHeader() << key(p.next(nothrow)); }
279     };
280     
281     /** \brief IPv6 routing Hop-By-Hop packet typedef */
282     typedef ConcretePacket<IPv6ExtensionType_HopByHop> IPv6Extension_HopByHop;
283     
284 // =====================================================================================================
285     
286     /** \brief Parse in IPv6 Destination Options extension header
287
288         Parser implementing the IPv6 Destination Options Header extension. The fields implemented are:
289     \image html IPv6Extensions_Destination.png
290
291     \see IPv6ExtensionType_Destination \n
292     <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
293      */
294     
295     // Destination Options skeleton without TLV-Options
296
297     struct IPv6PacketParserExtension_Destination : public PacketParserBase {
298 #       include SENF_PARSER()
299         SENF_PARSER_FIELD ( nextHeader, UInt8Parser   );
300         SENF_PARSER_FIELD ( headerLength, UInt8Parser );
301         
302         SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_Destination );
303     };
304     
305     /** \brief IPv6 Destination Options extension
306
307         \par Packet type (typedef):
308     \ref IPv6Extension_Destination
309
310         \par Fields:
311     \ref IPv6PacketParserExtension_Destination
312         
313         \par Associated registries:
314     \ref IpTypes
315         
316         \par Finalize action:
317     Set \a nextHeader from type of next packet if found in \ref IpTypes
318
319     \ingroup protocolbundle_default
320          */
321     
322     struct IPv6ExtensionType_Destination
323     :   public PacketTypeBase,
324         public PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes>
325     {
326 #ifndef DOXYGEN
327         typedef PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes> mixin;
328 #endif
329         /** \brief IPv6 Destination Options extension packet typedef */
330         typedef ConcretePacket<IPv6ExtensionType_Destination> packet;
331         /** \brief typedef to the parser of IPv6 Destination Options extension packet */
332         typedef IPv6PacketParserExtension_Destination parser;
333         
334         using mixin::nextPacketRange;
335         using mixin::nextPacketType;
336         using mixin::init;
337         using mixin::initSize;
338         
339         static key_t nextPacketKey(packet p) 
340         { return p->nextHeader(); }
341         /** \brief Dump given IPv6Extension_Destination in readable form to given output stream */
342         static void dump(packet p, std::ostream & os); 
343         
344         static void finalize(packet p) { 
345             p->nextHeader() << key(p.next(nothrow)); }
346     };
347     
348     /** \brief IPv6 routing Destination Options packet typedef */
349     typedef ConcretePacket<IPv6ExtensionType_Destination> IPv6Extension_Destination;
350
351     
352 } //namespace senf
353 ///////////////////////////////hh.e////////////////////////////////////////
354 //#include "IPv6Extensions.cci"
355 //#include "IPv6Extensions.ct"
356 //#include "IPv6Extensions.cti"
357 #endif
358
359 \f
360 // Local Variables:
361 // mode: c++
362 // fill-column: 100
363 // c-file-style: "senf"
364 // indent-tabs-mode: nil
365 // ispell-local-dictionary: "american"
366 // compile-command: "scons -u test"
367 // comment-column: 40
368 // End: