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.
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.
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.
24 \brief IPv6Extensions public header */
26 #ifndef HH_SENF_Packets_DefaultBundle_IPv6Extensions_
27 #define HH_SENF_Packets_DefaultBundle_IPv6Extensions_ 1
30 #include "IPv6Packet.hh"
32 //#include "IPv6Extensions.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
37 /** \brief Parse in IPv6 fragment extension header
39 Parser implementing the IPv6 fragment extension. The fields implemented are:
40 \image html IPv6Extensions_Fragment.png
42 \see IPv6ExtensionType_Fragment \n
43 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
45 struct IPv6PacketParserExtension_Fragment : public PacketParserBase
47 # include SENF_FIXED_PARSER()
49 SENF_PARSER_FIELD ( nextHeader , UInt8Parser );
50 SENF_PARSER_PRIVATE_FIELD ( reserved1 , UInt8Parser );
52 SENF_PARSER_BITFIELD ( fragmentOffset , 13, unsigned );
53 SENF_PARSER_PRIVATE_BITFIELD ( reserved2 , 2, unsigned );
54 SENF_PARSER_BITFIELD ( moreFragments , 1, bool );
56 SENF_PARSER_FIELD ( id , UInt32Parser );
58 SENF_PARSER_FINALIZE(IPv6PacketParserExtension_Fragment);
61 /** \brief IPv6 fragment extension
63 \par Packet type (typedef):
64 \ref IPv6Extension_Fragment
67 \ref IPv6PacketParserExtension_Fragment
69 \par Associated registries:
73 Set \a nextHeader from type of next packet if found in \ref IpTypes
75 \ingroup protocolbundle_default
77 struct IPv6ExtensionType_Fragment
78 : public PacketTypeBase,
79 public PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes>
82 typedef PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes> mixin;
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;
89 using mixin::nextPacketRange;
90 using mixin::nextPacketType;
91 using mixin::initSize;
94 static key_t nextPacketKey(packet p)
95 { return p->nextHeader(); }
97 /** \brief Dump given IPv6Extension_Fragment in readable form to given output stream */
98 static void dump(packet p, std::ostream & os);
100 static void finalize(packet p) {
101 p->nextHeader() << key(p.next(nothrow)); }
104 /** \brief IPv6 fragment extension packet typedef */
105 typedef ConcretePacket<IPv6ExtensionType_Fragment> IPv6Extension_Fragment;
107 // =====================================================================================================
109 /** \brief Parse in IPv6 routing extension header
111 Parser implementing the IPv6 routing Header extension. The fields implemented are:
112 \image html IPv6Extensions_Routing.png
114 \see IPv6ExtensionType_Routing \n
115 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
118 //Routing Header Extension (type 0 only)
119 struct IPv6PacketParserExtension_Routing : public PacketParserBase
122 The Type 0 Routing header has the following format: (RFC 2460)
124 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
125 | Next Header | Hdr Ext Len | Routing Type=0| Segments Left |
126 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
136 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
148 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151 # include SENF_PARSER()
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 );
160 SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_Routing );
162 //provisionary, since only type 0 is implemented
169 /** \brief IPv6 routing extension
171 \par Packet type (typedef):
172 \ref IPv6Extension_Routing
175 \ref IPv6PacketParserExtension_Routing
177 \par Associated registries:
180 \par Finalize action:
181 Set \a nextHeader from type of next packet if found in \ref IpTypes
183 \ingroup protocolbundle_default
186 struct IPv6ExtensionType_Routing
187 : public PacketTypeBase,
188 public PacketTypeMixin<IPv6ExtensionType_Routing, IpTypes>
192 typedef PacketTypeMixin<IPv6ExtensionType_Routing, IpTypes> mixin;
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;
199 using mixin::nextPacketRange;
200 using mixin::nextPacketType;
202 using mixin::initSize;
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);
209 static void finalize(packet p) {
210 p->nextHeader() << key(p.next(nothrow)); }
213 /** \brief IPv6 routing extension packet typedef */
214 typedef ConcretePacket<IPv6ExtensionType_Routing> IPv6Extension_Routing;
217 // =====================================================================================================
219 /** \brief Parse in IPv6 Hop-By-Hop extension header
221 Parser implementing the IPv6 routing Header extension. The fields implemented are:
222 \image html IPv6Extensions_HopByHop.png
224 \see IPv6ExtensionType_HopByHop \n
225 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
228 // Hop-By-Hop skeleton without Options
230 struct IPv6PacketParserExtension_HopByHop : public PacketParserBase {
231 # include SENF_PARSER()
232 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
233 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
235 SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_HopByHop );
238 /** \brief IPv6 Hop-By-Hop extension
240 \par Packet type (typedef):
241 \ref IPv6Extension_HopByHop
244 \ref IPv6PacketParserExtension_HopByHop
246 \par Associated registries:
249 \par Finalize action:
250 Set \a nextHeader from type of next packet if found in \ref IpTypes
252 \ingroup protocolbundle_default
255 struct IPv6ExtensionType_HopByHop
256 : public PacketTypeBase,
257 public PacketTypeMixin<IPv6ExtensionType_HopByHop, IpTypes>
260 typedef PacketTypeMixin<IPv6ExtensionType_HopByHop, IpTypes> mixin;
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;
267 using mixin::nextPacketRange;
268 using mixin::nextPacketType;
270 using mixin::initSize;
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);
277 static void finalize(packet p) {
278 p->nextHeader() << key(p.next(nothrow)); }
281 /** \brief IPv6 routing Hop-By-Hop packet typedef */
282 typedef ConcretePacket<IPv6ExtensionType_HopByHop> IPv6Extension_HopByHop;
284 // =====================================================================================================
286 /** \brief Parse in IPv6 Destination Options extension header
288 Parser implementing the IPv6 Destination Options Header extension. The fields implemented are:
289 \image html IPv6Extensions_Destination.png
291 \see IPv6ExtensionType_Destination \n
292 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
295 // Destination Options skeleton without TLV-Options
297 struct IPv6PacketParserExtension_Destination : public PacketParserBase {
298 # include SENF_PARSER()
299 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
300 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
302 SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_Destination );
305 /** \brief IPv6 Destination Options extension
307 \par Packet type (typedef):
308 \ref IPv6Extension_Destination
311 \ref IPv6PacketParserExtension_Destination
313 \par Associated registries:
316 \par Finalize action:
317 Set \a nextHeader from type of next packet if found in \ref IpTypes
319 \ingroup protocolbundle_default
322 struct IPv6ExtensionType_Destination
323 : public PacketTypeBase,
324 public PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes>
327 typedef PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes> mixin;
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;
334 using mixin::nextPacketRange;
335 using mixin::nextPacketType;
337 using mixin::initSize;
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);
344 static void finalize(packet p) {
345 p->nextHeader() << key(p.next(nothrow)); }
348 /** \brief IPv6 routing Destination Options packet typedef */
349 typedef ConcretePacket<IPv6ExtensionType_Destination> IPv6Extension_Destination;
353 ///////////////////////////////hh.e////////////////////////////////////////
355 #ifndef SENF_PACKETS_DECL_ONLY
356 //#include "IPv6Extensions.cci"
357 //#include "IPv6Extensions.ct"
358 //#include "IPv6Extensions.cti"
365 // c-file-style: "senf"
366 // indent-tabs-mode: nil
367 // ispell-local-dictionary: "american"
368 // compile-command: "scons -u test"
369 // comment-column: 40