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>
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation; either version 2 of the License, or
12 // (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the
21 // Free Software Foundation, Inc.,
22 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 \brief IPv6Extensions public header */
27 #ifndef HH_SENF_Packets_DefaultBundle_IPv6Extensions_
28 #define HH_SENF_Packets_DefaultBundle_IPv6Extensions_ 1
31 #include <senf/Packets/Packets.hh>
32 #include <senf/Packets/AuxParser.hh>
33 #include "IPv6ExtOptionType.hh"
34 #include "ListOptionTypeParser.hh"
35 #include "IPv6Packet.hh"
37 //#include "IPv6Extensions.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
42 /** \brief Parse in IPv6 fragment extension header
44 Parser implementing the IPv6 fragment extension. The fields implemented are:
45 \image html IPv6FragmentPacket.png
47 \see IPv6ExtensionType_Fragment \n
48 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
50 struct IPv6FragmentPacketParser : public PacketParserBase
52 # include SENF_FIXED_PARSER()
54 SENF_PARSER_FIELD ( nextHeader , UInt8Parser );
55 SENF_PARSER_PRIVATE_FIELD ( reserved1 , UInt8Parser );
56 SENF_PARSER_BITFIELD ( fragmentOffset , 13, unsigned );
57 SENF_PARSER_PRIVATE_BITFIELD ( reserved2 , 2, unsigned );
58 SENF_PARSER_BITFIELD ( moreFragments , 1, bool );
59 SENF_PARSER_FIELD ( id , UInt32Parser );
61 SENF_PARSER_FINALIZE(IPv6FragmentPacketParser);
64 /** \brief IPv6 fragment extension
66 \par Packet type (typedef):
67 \ref IPv6FragmentPacket
70 \ref IPv6FragmentPacketParser
72 \par Associated registries:
76 Set \a nextHeader from type of next packet if found in \ref IpTypes
78 \ingroup protocolbundle_default
80 struct IPv6FragmentPacketType
81 : public PacketTypeBase,
82 public PacketTypeMixin<IPv6FragmentPacketType, IpTypes>
85 typedef PacketTypeMixin<IPv6FragmentPacketType, IpTypes> mixin;
87 /** \brief IPv6 fragment extension packet typedef */
88 typedef ConcretePacket<IPv6FragmentPacketType> packet;
89 /** \brief typedef to the parser of IPv6 fragment extension packet */
90 typedef IPv6FragmentPacketParser parser;
92 using mixin::nextPacketRange;
93 using mixin::nextPacketType;
94 using mixin::initSize;
97 static key_t nextPacketKey(packet p)
98 { return p->nextHeader(); }
100 /** \brief Dump given IPv6FragmentPacket in readable form to given output stream */
101 static void dump(packet p, std::ostream & os);
103 static void finalize(packet p) {
104 p->nextHeader() << key(p.next(nothrow)); }
107 /** \brief IPv6 fragment extension packet typedef
108 \ingroup protocolbundle_default
110 typedef ConcretePacket<IPv6FragmentPacketType> IPv6FragmentPacket;
112 // =====================================================================================================
114 /** \brief Parse in IPv6 routing extension header
116 Parser implementing the IPv6 routing Header extension (type 0 only).
117 The fields implemented are:
118 \image html IPv6RoutingPacket.png
120 \see IPv6ExtensionType_Routing \n
121 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
123 struct IPv6RoutingPacketParser : public PacketParserBase
126 The Type 0 Routing header has the following format: (RFC 2460)
128 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129 | Next Header | Hdr Ext Len | Routing Type=0| Segments Left |
130 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
144 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 # include SENF_PARSER()
156 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
157 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
158 SENF_PARSER_FIELD ( routingType, UInt8Parser ); //set to Zero for minimal implementation
159 SENF_PARSER_FIELD_RO ( segmentsLeft, UInt8Parser );
160 SENF_PARSER_FIELD ( reserved, UInt32Parser ); //set to zero by RFC
161 SENF_PARSER_VECTOR ( hopAddresses, segmentsLeft, INet6AddressParser );
163 SENF_PARSER_FINALIZE ( IPv6RoutingPacketParser );
165 //provisionary, since only type 0 is implemented
172 /** \brief IPv6 routing extension
174 \par Packet type (typedef):
175 \ref IPv6RoutingPacket
178 \ref IPv6RoutingPacketParser
180 \par Associated registries:
183 \par Finalize action:
184 Set \a nextHeader from type of next packet if found in \ref IpTypes
186 \ingroup protocolbundle_default
188 struct IPv6RoutingPacketType
189 : public PacketTypeBase,
190 public PacketTypeMixin<IPv6RoutingPacketType, IpTypes>
193 typedef PacketTypeMixin<IPv6RoutingPacketType, IpTypes> mixin;
195 /** \brief IPv6 routing extension packet typedef */
196 typedef ConcretePacket<IPv6RoutingPacketType> packet;
197 /** \brief typedef to the parser of IPv6 routing extension packet */
198 typedef IPv6RoutingPacketParser parser;
200 using mixin::nextPacketRange;
201 using mixin::nextPacketType;
203 using mixin::initSize;
205 static key_t nextPacketKey(packet p)
206 { return p->nextHeader(); }
207 /** \brief Dump given IPv6RoutingPacket in readable form to given output stream */
208 static void dump(packet p, std::ostream & os);
210 static void finalize(packet p) {
211 p->nextHeader() << key(p.next(nothrow)); }
214 /** \brief IPv6 routing extension packet typedef
215 \ingroup protocolbundle_default
217 typedef ConcretePacket<IPv6RoutingPacketType> IPv6RoutingPacket;
220 // =====================================================================================================
222 /** \brief Parse in IPv6 Hop-By-Hop extension header
224 Parser implementing the IPv6 routing Header extension. The fields implemented are:
225 \image html IPv6HopByHopOptionsPacket.png
227 \see IPv6ExtensionType_HopByHop \n
228 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
230 struct IPv6HopByHopOptionsPacketParser : public PacketParserBase
232 # include SENF_PARSER()
234 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
235 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
237 typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
238 typedef detail::ListOptionTypeParser_Policy<
239 IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
240 typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
242 SENF_PARSER_FIELD ( options, ListOptionTypeParser);
244 SENF_PARSER_FINALIZE ( IPv6HopByHopOptionsPacketParser );
247 /** \brief IPv6 Hop-By-Hop extension
249 \par Packet type (typedef):
250 \ref IPv6HopByHopOptionsPacket
253 \ref IPv6HopByHopOptionsPacketParser
255 \par Associated registries:
258 \par Finalize action:
259 Set \a nextHeader from type of next packet if found in \ref IpTypes
261 \ingroup protocolbundle_default
263 struct IPv6HopByHopOptionsPacketType
264 : public PacketTypeBase,
265 public PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes>
268 typedef PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes> mixin;
270 /** \brief IPv6 Hop-By-Hop extension packet typedef */
271 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> packet;
272 /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
273 typedef IPv6HopByHopOptionsPacketParser parser;
275 using mixin::nextPacketRange;
276 using mixin::nextPacketType;
278 using mixin::initSize;
280 static key_t nextPacketKey(packet p)
281 { return p->nextHeader(); }
283 /** \brief Dump given IPv6HopByHopOptionsPacket in readable form to given output stream */
284 static void dump(packet p, std::ostream & os);
286 static void finalize(packet p) {
287 p->nextHeader() << key(p.next(nothrow)); }
290 /** \brief IPv6 routing Hop-By-Hop packet typedef
291 \ingroup protocolbundle_default
293 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> IPv6HopByHopOptionsPacket;
295 // =====================================================================================================
297 /** \brief Parse in IPv6 Destination Options extension header
299 Parser implementing the IPv6 Destination Options Header extension.
300 The fields implemented are:
301 \image html IPv6DestinationOptionsPacket.png
303 \see IPv6ExtensionType_Destination \n
304 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
306 struct IPv6DestinationOptionsPacketParser : public PacketParserBase
308 # include SENF_PARSER()
309 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
310 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
312 SENF_PARSER_FINALIZE ( IPv6DestinationOptionsPacketParser );
315 /** \brief IPv6 Destination Options extension
317 \par Packet type (typedef):
318 \ref IPv6DestinationOptionsPacket
321 \ref IPv6DestinationOptionsPacketParser
323 \par Associated registries:
326 \par Finalize action:
327 Set \a nextHeader from type of next packet if found in \ref IpTypes
329 \ingroup protocolbundle_default
331 struct IPv6DestinationOptionsPacketType
332 : public PacketTypeBase,
333 public PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes>
336 typedef PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes> mixin;
338 /** \brief IPv6 Destination Options extension packet typedef */
339 typedef ConcretePacket<IPv6DestinationOptionsPacketType> packet;
340 /** \brief typedef to the parser of IPv6 Destination Options extension packet */
341 typedef IPv6DestinationOptionsPacketParser parser;
343 using mixin::nextPacketRange;
344 using mixin::nextPacketType;
346 using mixin::initSize;
348 static key_t nextPacketKey(packet p)
349 { return p->nextHeader(); }
350 /** \brief Dump given IPv6DestinationOptionsPacket in readable form to given output stream */
351 static void dump(packet p, std::ostream & os);
353 static void finalize(packet p) {
354 p->nextHeader() << key(p.next(nothrow)); }
357 /** \brief IPv6 routing Destination Options packet typedef
358 \ingroup protocolbundle_default
360 typedef ConcretePacket<IPv6DestinationOptionsPacketType> IPv6DestinationOptionsPacket;
364 ///////////////////////////////hh.e////////////////////////////////////////
365 //#include "IPv6Extensions.cci"
366 //#include "IPv6Extensions.ct"
367 //#include "IPv6Extensions.cti"
374 // c-file-style: "senf"
375 // indent-tabs-mode: nil
376 // ispell-local-dictionary: "american"
377 // compile-command: "scons -u test"
378 // comment-column: 40