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 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 IPv6PRoutingPacketParser
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 typedef ConcretePacket<IPv6RoutingPacketType> IPv6RoutingPacket;
216 // =====================================================================================================
218 /** \brief Parse in IPv6 Hop-By-Hop extension header
220 Parser implementing the IPv6 routing Header extension. The fields implemented are:
221 \image html IPv6HopByHopOptionsPacket.png
223 \see IPv6ExtensionType_HopByHop \n
224 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
226 struct IPv6HopByHopOptionsPacketParser : public PacketParserBase
228 # include SENF_PARSER()
230 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
231 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
233 typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
234 typedef detail::ListOptionTypeParser_Policy<
235 IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
236 typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
238 SENF_PARSER_FIELD ( options, ListOptionTypeParser);
240 SENF_PARSER_FINALIZE ( IPv6HopByHopOptionsPacketParser );
243 /** \brief IPv6 Hop-By-Hop extension
245 \par Packet type (typedef):
246 \ref IPv6HopByHopOptionsPacket
249 \ref IPv6HopByHopOptionsPacketParser
251 \par Associated registries:
254 \par Finalize action:
255 Set \a nextHeader from type of next packet if found in \ref IpTypes
257 \ingroup protocolbundle_default
259 struct IPv6HopByHopOptionsPacketType
260 : public PacketTypeBase,
261 public PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes>
264 typedef PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes> mixin;
266 /** \brief IPv6 Hop-By-Hop extension packet typedef */
267 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> packet;
268 /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
269 typedef IPv6HopByHopOptionsPacketParser parser;
271 using mixin::nextPacketRange;
272 using mixin::nextPacketType;
274 using mixin::initSize;
276 static key_t nextPacketKey(packet p)
277 { return p->nextHeader(); }
279 /** \brief Dump given IPv6HopByHopOptionsPacket in readable form to given output stream */
280 static void dump(packet p, std::ostream & os);
282 static void finalize(packet p) {
283 p->nextHeader() << key(p.next(nothrow)); }
286 /** \brief IPv6 routing Hop-By-Hop packet typedef */
287 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> IPv6HopByHopOptionsPacket;
289 // =====================================================================================================
291 /** \brief Parse in IPv6 Destination Options extension header
293 Parser implementing the IPv6 Destination Options Header extension.
294 The fields implemented are:
295 \image html IPv6DestinationOptionsPacket.png
297 \see IPv6ExtensionType_Destination \n
298 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
300 struct IPv6DestinationOptionsPacketParser : public PacketParserBase
302 # include SENF_PARSER()
303 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
304 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
306 SENF_PARSER_FINALIZE ( IPv6DestinationOptionsPacketParser );
309 /** \brief IPv6 Destination Options extension
311 \par Packet type (typedef):
312 \ref IPv6DestinationOptionsPacket
315 \ref IPv6DestinationOptionsPacketParser
317 \par Associated registries:
320 \par Finalize action:
321 Set \a nextHeader from type of next packet if found in \ref IpTypes
323 \ingroup protocolbundle_default
325 struct IPv6DestinationOptionsPacketType
326 : public PacketTypeBase,
327 public PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes>
330 typedef PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes> mixin;
332 /** \brief IPv6 Destination Options extension packet typedef */
333 typedef ConcretePacket<IPv6DestinationOptionsPacketType> packet;
334 /** \brief typedef to the parser of IPv6 Destination Options extension packet */
335 typedef IPv6DestinationOptionsPacketParser parser;
337 using mixin::nextPacketRange;
338 using mixin::nextPacketType;
340 using mixin::initSize;
342 static key_t nextPacketKey(packet p)
343 { return p->nextHeader(); }
344 /** \brief Dump given IPv6DestinationOptionsPacket in readable form to given output stream */
345 static void dump(packet p, std::ostream & os);
347 static void finalize(packet p) {
348 p->nextHeader() << key(p.next(nothrow)); }
351 /** \brief IPv6 routing Destination Options packet typedef */
352 typedef ConcretePacket<IPv6DestinationOptionsPacketType> IPv6DestinationOptionsPacket;
356 ///////////////////////////////hh.e////////////////////////////////////////
357 //#include "IPv6Extensions.cci"
358 //#include "IPv6Extensions.ct"
359 //#include "IPv6Extensions.cti"
366 // c-file-style: "senf"
367 // indent-tabs-mode: nil
368 // ispell-local-dictionary: "american"
369 // compile-command: "scons -u test"
370 // comment-column: 40