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 "IPv6ExtOptions.hh"
32 #include "ListOptionTypeParser.hh"
33 #include "IPv6Packet.hh"
35 //#include "IPv6Extensions.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
40 /** \brief Parse in IPv6 fragment extension header
42 Parser implementing the IPv6 fragment extension. The fields implemented are:
43 \image html IPv6FragmentPacket.png
45 \see IPv6ExtensionType_Fragment \n
46 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
48 struct IPv6FragmentPacketParser : public PacketParserBase
50 # include SENF_FIXED_PARSER()
52 SENF_PARSER_FIELD ( nextHeader , UInt8Parser );
53 SENF_PARSER_PRIVATE_FIELD ( reserved1 , UInt8Parser );
54 SENF_PARSER_BITFIELD ( fragmentOffset , 13, unsigned );
55 SENF_PARSER_PRIVATE_BITFIELD ( reserved2 , 2, unsigned );
56 SENF_PARSER_BITFIELD ( moreFragments , 1, bool );
57 SENF_PARSER_FIELD ( id , UInt32Parser );
59 SENF_PARSER_FINALIZE(IPv6FragmentPacketParser);
62 /** \brief IPv6 fragment extension
64 \par Packet type (typedef):
65 \ref IPv6FragmentPacket
68 \ref IPv6FragmentPacketParser
70 \par Associated registries:
74 Set \a nextHeader from type of next packet if found in \ref IpTypes
76 \ingroup protocolbundle_default
78 struct IPv6FragmentPacketType
79 : public PacketTypeBase,
80 public PacketTypeMixin<IPv6FragmentPacketType, IpTypes>
83 typedef PacketTypeMixin<IPv6FragmentPacketType, IpTypes> mixin;
85 /** \brief IPv6 fragment extension packet typedef */
86 typedef ConcretePacket<IPv6FragmentPacketType> packet;
87 /** \brief typedef to the parser of IPv6 fragment extension packet */
88 typedef IPv6FragmentPacketParser parser;
90 using mixin::nextPacketRange;
91 using mixin::nextPacketType;
92 using mixin::initSize;
95 static key_t nextPacketKey(packet p)
96 { return p->nextHeader(); }
98 /** \brief Dump given IPv6FragmentPacket in readable form to given output stream */
99 static void dump(packet p, std::ostream & os);
101 static void finalize(packet p) {
102 p->nextHeader() << key(p.next(nothrow)); }
105 /** \brief IPv6 fragment extension packet typedef
106 \ingroup protocolbundle_default
108 typedef ConcretePacket<IPv6FragmentPacketType> IPv6FragmentPacket;
110 // =====================================================================================================
112 /** \brief Parse in IPv6 routing extension header
114 Parser implementing the IPv6 routing Header extension (type 0 only).
115 The fields implemented are:
116 \image html IPv6RoutingPacket.png
118 \see IPv6ExtensionType_Routing \n
119 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
121 struct IPv6RoutingPacketParser : public PacketParserBase
124 The Type 0 Routing header has the following format: (RFC 2460)
126 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
127 | Next Header | Hdr Ext Len | Routing Type=0| Segments Left |
128 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
138 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
142 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 # include SENF_PARSER()
154 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
155 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
156 SENF_PARSER_FIELD ( routingType, UInt8Parser ); //set to Zero for minimal implementation
157 SENF_PARSER_FIELD_RO ( segmentsLeft, UInt8Parser );
158 SENF_PARSER_FIELD ( reserved, UInt32Parser ); //set to zero by RFC
159 SENF_PARSER_VECTOR ( hopAddresses, segmentsLeft, INet6AddressParser );
161 SENF_PARSER_FINALIZE ( IPv6RoutingPacketParser );
163 //provisionary, since only type 0 is implemented
170 /** \brief IPv6 routing extension
172 \par Packet type (typedef):
173 \ref IPv6RoutingPacket
176 \ref IPv6RoutingPacketParser
178 \par Associated registries:
181 \par Finalize action:
182 Set \a nextHeader from type of next packet if found in \ref IpTypes
184 \ingroup protocolbundle_default
186 struct IPv6RoutingPacketType
187 : public PacketTypeBase,
188 public PacketTypeMixin<IPv6RoutingPacketType, IpTypes>
191 typedef PacketTypeMixin<IPv6RoutingPacketType, IpTypes> mixin;
193 /** \brief IPv6 routing extension packet typedef */
194 typedef ConcretePacket<IPv6RoutingPacketType> packet;
195 /** \brief typedef to the parser of IPv6 routing extension packet */
196 typedef IPv6RoutingPacketParser parser;
198 using mixin::nextPacketRange;
199 using mixin::nextPacketType;
201 using mixin::initSize;
203 static key_t nextPacketKey(packet p)
204 { return p->nextHeader(); }
205 /** \brief Dump given IPv6RoutingPacket in readable form to given output stream */
206 static void dump(packet p, std::ostream & os);
208 static void finalize(packet p) {
209 p->nextHeader() << key(p.next(nothrow)); }
212 /** \brief IPv6 routing extension packet typedef
213 \ingroup protocolbundle_default
215 typedef ConcretePacket<IPv6RoutingPacketType> IPv6RoutingPacket;
218 // =====================================================================================================
220 /** \brief Parse in IPv6 Hop-By-Hop extension header
222 Parser implementing the IPv6 routing Header extension. The fields implemented are:
223 \image html IPv6HopByHopOptionsPacket.png
225 \see IPv6ExtensionType_HopByHop \n
226 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
228 struct IPv6HopByHopOptionsPacketParser : public PacketParserBase
230 # include SENF_PARSER()
232 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
233 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
235 typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
236 typedef detail::ListOptionTypeParser_Policy<
237 IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
238 typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
240 SENF_PARSER_FIELD ( options, ListOptionTypeParser);
242 SENF_PARSER_FINALIZE ( IPv6HopByHopOptionsPacketParser );
245 /** \brief IPv6 Hop-By-Hop extension
247 \par Packet type (typedef):
248 \ref IPv6HopByHopOptionsPacket
251 \ref IPv6HopByHopOptionsPacketParser
253 \par Associated registries:
256 \par Finalize action:
257 Set \a nextHeader from type of next packet if found in \ref IpTypes
259 \ingroup protocolbundle_default
261 struct IPv6HopByHopOptionsPacketType
262 : public PacketTypeBase,
263 public PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes>
266 typedef PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes> mixin;
268 /** \brief IPv6 Hop-By-Hop extension packet typedef */
269 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> packet;
270 /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
271 typedef IPv6HopByHopOptionsPacketParser parser;
273 using mixin::nextPacketRange;
274 using mixin::nextPacketType;
276 using mixin::initSize;
278 static key_t nextPacketKey(packet p)
279 { return p->nextHeader(); }
281 /** \brief Dump given IPv6HopByHopOptionsPacket in readable form to given output stream */
282 static void dump(packet p, std::ostream & os);
284 static void finalize(packet p) {
285 p->nextHeader() << key(p.next(nothrow)); }
288 /** \brief IPv6 routing Hop-By-Hop packet typedef
289 \ingroup protocolbundle_default
291 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> IPv6HopByHopOptionsPacket;
293 // =====================================================================================================
295 /** \brief Parse in IPv6 Destination Options extension header
297 Parser implementing the IPv6 Destination Options Header extension.
298 The fields implemented are:
299 \image html IPv6DestinationOptionsPacket.png
301 \see IPv6ExtensionType_Destination \n
302 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
304 struct IPv6DestinationOptionsPacketParser : public PacketParserBase
306 # include SENF_PARSER()
307 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
308 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
310 SENF_PARSER_FINALIZE ( IPv6DestinationOptionsPacketParser );
313 /** \brief IPv6 Destination Options extension
315 \par Packet type (typedef):
316 \ref IPv6DestinationOptionsPacket
319 \ref IPv6DestinationOptionsPacketParser
321 \par Associated registries:
324 \par Finalize action:
325 Set \a nextHeader from type of next packet if found in \ref IpTypes
327 \ingroup protocolbundle_default
329 struct IPv6DestinationOptionsPacketType
330 : public PacketTypeBase,
331 public PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes>
334 typedef PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes> mixin;
336 /** \brief IPv6 Destination Options extension packet typedef */
337 typedef ConcretePacket<IPv6DestinationOptionsPacketType> packet;
338 /** \brief typedef to the parser of IPv6 Destination Options extension packet */
339 typedef IPv6DestinationOptionsPacketParser parser;
341 using mixin::nextPacketRange;
342 using mixin::nextPacketType;
344 using mixin::initSize;
346 static key_t nextPacketKey(packet p)
347 { return p->nextHeader(); }
348 /** \brief Dump given IPv6DestinationOptionsPacket in readable form to given output stream */
349 static void dump(packet p, std::ostream & os);
351 static void finalize(packet p) {
352 p->nextHeader() << key(p.next(nothrow)); }
355 /** \brief IPv6 routing Destination Options packet typedef
356 \ingroup protocolbundle_default
358 typedef ConcretePacket<IPv6DestinationOptionsPacketType> IPv6DestinationOptionsPacket;
362 ///////////////////////////////hh.e////////////////////////////////////////
363 //#include "IPv6Extensions.cci"
364 //#include "IPv6Extensions.ct"
365 //#include "IPv6Extensions.cti"
372 // c-file-style: "senf"
373 // indent-tabs-mode: nil
374 // ispell-local-dictionary: "american"
375 // compile-command: "scons -u test"
376 // comment-column: 40