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 <senf/Packets/DefaultBundle/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 IPv6Extensions_Fragment.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 IPv6Extensions_Routing.png
118 \see IPv6ExtensionType_Routing \n
119 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
121 struct IPv6PRoutingPacketParser : 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 ( IPv6PRoutingPacketParser );
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 IPv6PRoutingPacketParser 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 IPv6Extensions_HopByHop.png
223 \see IPv6ExtensionType_HopByHop \n
224 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
226 struct IPv6HopByHopOptionsPacketParser : public PacketParserBase {
227 # include SENF_PARSER()
229 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
230 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
232 typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
233 typedef detail::ListOptionTypeParser_Policy<
234 IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
235 typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
237 SENF_PARSER_FIELD ( options, ListOptionTypeParser);
239 SENF_PARSER_FINALIZE ( IPv6HopByHopOptionsPacketParser );
242 /** \brief IPv6 Hop-By-Hop extension
244 \par Packet type (typedef):
245 \ref IPv6HopByHopOptionsPacket
248 \ref IPv6HopByHopOptionsPacketParser
250 \par Associated registries:
253 \par Finalize action:
254 Set \a nextHeader from type of next packet if found in \ref IpTypes
256 \ingroup protocolbundle_default
258 struct IPv6HopByHopOptionsPacketType
259 : public PacketTypeBase,
260 public PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes>
263 typedef PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes> mixin;
265 /** \brief IPv6 Hop-By-Hop extension packet typedef */
266 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> packet;
267 /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
268 typedef IPv6HopByHopOptionsPacketParser parser;
270 using mixin::nextPacketRange;
271 using mixin::nextPacketType;
273 using mixin::initSize;
275 static key_t nextPacketKey(packet p)
276 { return p->nextHeader(); }
278 /** \brief Dump given IPv6HopByHopOptionsPacket in readable form to given output stream */
279 static void dump(packet p, std::ostream & os);
281 static void finalize(packet p) {
282 p->nextHeader() << key(p.next(nothrow)); }
285 /** \brief IPv6 routing Hop-By-Hop packet typedef */
286 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> IPv6HopByHopOptionsPacket;
288 // =====================================================================================================
290 /** \brief Parse in IPv6 Destination Options extension header
292 Parser implementing the IPv6 Destination Options Header extension.
293 The fields implemented are:
294 \image html IPv6Extensions_Destination.png
296 \see IPv6ExtensionType_Destination \n
297 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
299 struct IPv6DestinationOptionsPacketParser : public PacketParserBase
301 # include SENF_PARSER()
302 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
303 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
305 SENF_PARSER_FINALIZE ( IPv6DestinationOptionsPacketParser );
308 /** \brief IPv6 Destination Options extension
310 \par Packet type (typedef):
311 \ref IPv6DestinationOptionsPacket
314 \ref IPv6DestinationOptionsPacketParser
316 \par Associated registries:
319 \par Finalize action:
320 Set \a nextHeader from type of next packet if found in \ref IpTypes
322 \ingroup protocolbundle_default
324 struct IPv6DestinationOptionsPacketType
325 : public PacketTypeBase,
326 public PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes>
329 typedef PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes> mixin;
331 /** \brief IPv6 Destination Options extension packet typedef */
332 typedef ConcretePacket<IPv6DestinationOptionsPacketType> packet;
333 /** \brief typedef to the parser of IPv6 Destination Options extension packet */
334 typedef IPv6DestinationOptionsPacketParser parser;
336 using mixin::nextPacketRange;
337 using mixin::nextPacketType;
339 using mixin::initSize;
341 static key_t nextPacketKey(packet p)
342 { return p->nextHeader(); }
343 /** \brief Dump given IPv6DestinationOptionsPacket in readable form to given output stream */
344 static void dump(packet p, std::ostream & os);
346 static void finalize(packet p) {
347 p->nextHeader() << key(p.next(nothrow)); }
350 /** \brief IPv6 routing Destination Options packet typedef */
351 typedef ConcretePacket<IPv6DestinationOptionsPacketType> IPv6DestinationOptionsPacket;
355 ///////////////////////////////hh.e////////////////////////////////////////
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