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 <senf/Packets/Packets.hh>
31 #include <senf/Packets/AuxParser.hh>
32 #include <senf/Packets/DefaultBundle/IPv6ExtOptionType.hh>
33 #include "ListOptionTypeParser.hh"
34 #include "IPv6Packet.hh"
36 //#include "IPv6Extensions.mpp"
37 ///////////////////////////////hh.p////////////////////////////////////////
41 /** \brief Parse in IPv6 fragment extension header
43 Parser implementing the IPv6 fragment extension. The fields implemented are:
44 \image html IPv6Extensions_Fragment.png
46 \see IPv6ExtensionType_Fragment \n
47 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
49 struct IPv6FragmentPacketParser : public PacketParserBase
51 # include SENF_FIXED_PARSER()
53 SENF_PARSER_FIELD ( nextHeader , UInt8Parser );
54 SENF_PARSER_PRIVATE_FIELD ( reserved1 , UInt8Parser );
55 SENF_PARSER_BITFIELD ( fragmentOffset , 13, unsigned );
56 SENF_PARSER_PRIVATE_BITFIELD ( reserved2 , 2, unsigned );
57 SENF_PARSER_BITFIELD ( moreFragments , 1, bool );
58 SENF_PARSER_FIELD ( id , UInt32Parser );
60 SENF_PARSER_FINALIZE(IPv6FragmentPacketParser);
63 /** \brief IPv6 fragment extension
65 \par Packet type (typedef):
66 \ref IPv6Extension_Fragment
69 \ref IPv6PacketParserExtension_Fragment
71 \par Associated registries:
75 Set \a nextHeader from type of next packet if found in \ref IpTypes
77 \ingroup protocolbundle_default
79 struct IPv6FragmentType
80 : public PacketTypeBase,
81 public PacketTypeMixin<IPv6FragmentType, IpTypes>
84 typedef PacketTypeMixin<IPv6FragmentType, IpTypes> mixin;
86 /** \brief IPv6 fragment extension packet typedef */
87 typedef ConcretePacket<IPv6FragmentType> packet;
88 /** \brief typedef to the parser of IPv6 fragment extension packet */
89 typedef IPv6FragmentPacketParser parser;
91 using mixin::nextPacketRange;
92 using mixin::nextPacketType;
93 using mixin::initSize;
96 static key_t nextPacketKey(packet p)
97 { return p->nextHeader(); }
99 /** \brief Dump given IPv6Extension_Fragment in readable form to given output stream */
100 static void dump(packet p, std::ostream & os);
102 static void finalize(packet p) {
103 p->nextHeader() << key(p.next(nothrow)); }
106 /** \brief IPv6 fragment extension packet typedef */
107 typedef ConcretePacket<IPv6FragmentType> IPv6Fragment;
109 // =====================================================================================================
111 /** \brief Parse in IPv6 routing extension header
113 Parser implementing the IPv6 routing Header extension. The fields implemented are:
114 \image html IPv6Extensions_Routing.png
116 \see IPv6ExtensionType_Routing \n
117 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
120 //Routing Header Extension (type 0 only)
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
153 # include SENF_PARSER()
155 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
156 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
157 SENF_PARSER_FIELD ( routingType, UInt8Parser ); //set to Zero for minimal implementation
158 SENF_PARSER_FIELD_RO ( segmentsLeft, UInt8Parser );
159 SENF_PARSER_FIELD ( reserved, UInt32Parser ); //set to zero by RFC
160 SENF_PARSER_VECTOR ( hopAddresses, segmentsLeft, INet6AddressParser );
162 SENF_PARSER_FINALIZE ( IPv6PRoutingPacketParser );
164 //provisionary, since only type 0 is implemented
171 /** \brief IPv6 routing extension
173 \par Packet type (typedef):
174 \ref IPv6Extension_Routing
177 \ref IPv6PacketParserExtension_Routing
179 \par Associated registries:
182 \par Finalize action:
183 Set \a nextHeader from type of next packet if found in \ref IpTypes
185 \ingroup protocolbundle_default
188 struct IPv6RoutingType
189 : public PacketTypeBase,
190 public PacketTypeMixin<IPv6RoutingType, IpTypes>
193 typedef PacketTypeMixin<IPv6RoutingType, IpTypes> mixin;
195 /** \brief IPv6 routing extension packet typedef */
196 typedef ConcretePacket<IPv6RoutingType> packet;
197 /** \brief typedef to the parser of IPv6 routing extension packet */
198 typedef IPv6PRoutingPacketParser 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 IPv6Extension_Routing 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 typedef ConcretePacket<IPv6RoutingType> IPv6Routing;
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 IPv6Extensions_HopByHop.png
225 \see IPv6ExtensionType_HopByHop \n
226 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
229 // Hop-By-Hop Extension Header
231 struct IPv6HopByHopPacketParser : public PacketParserBase {
232 # include SENF_PARSER()
233 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
234 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
236 typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
237 typedef detail::ListOptionTypeParser_Policy<GenericOptTypeTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
238 typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
240 SENF_PARSER_FIELD ( options, ListOptionTypeParser);
242 SENF_PARSER_FINALIZE ( IPv6HopByHopPacketParser );
245 /** \brief IPv6 Hop-By-Hop extension
247 \par Packet type (typedef):
248 \ref IPv6Extension_HopByHop
251 \ref IPv6PacketParserExtension_HopByHop
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
262 struct IPv6HopByHopType
263 : public PacketTypeBase,
264 public PacketTypeMixin<IPv6HopByHopType, IpTypes>
267 typedef PacketTypeMixin<IPv6HopByHopType, IpTypes> mixin;
269 /** \brief IPv6 Hop-By-Hop extension packet typedef */
270 typedef ConcretePacket<IPv6HopByHopType> packet;
271 /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
272 typedef IPv6HopByHopPacketParser parser;
274 using mixin::nextPacketRange;
275 using mixin::nextPacketType;
277 using mixin::initSize;
279 static key_t nextPacketKey(packet p)
280 { return p->nextHeader(); }
281 /** \brief Dump given IPv6Extension_HopByHop 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 typedef ConcretePacket<IPv6HopByHopType> IPv6HopByHop;
291 // =====================================================================================================
293 /** \brief Parse in IPv6 Destination Options extension header
295 Parser implementing the IPv6 Destination Options Header extension. The fields implemented are:
296 \image html IPv6Extensions_Destination.png
298 \see IPv6ExtensionType_Destination \n
299 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
302 // Destination Options skeleton without TLV-Options
304 struct IPv6DestinationPacketParser : public PacketParserBase {
306 # include SENF_PARSER()
307 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
308 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
310 SENF_PARSER_FINALIZE ( IPv6DestinationPacketParser );
313 /** \brief IPv6 Destination Options extension
315 \par Packet type (typedef):
316 \ref IPv6Extension_Destination
319 \ref IPv6PacketParserExtension_Destination
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
330 struct IPv6DestinationType
331 : public PacketTypeBase,
332 public PacketTypeMixin<IPv6DestinationType, IpTypes>
335 typedef PacketTypeMixin<IPv6DestinationType, IpTypes> mixin;
337 /** \brief IPv6 Destination Options extension packet typedef */
338 typedef ConcretePacket<IPv6DestinationType> packet;
339 /** \brief typedef to the parser of IPv6 Destination Options extension packet */
340 typedef IPv6DestinationPacketParser parser;
342 using mixin::nextPacketRange;
343 using mixin::nextPacketType;
345 using mixin::initSize;
347 static key_t nextPacketKey(packet p)
348 { return p->nextHeader(); }
349 /** \brief Dump given IPv6Extension_Destination in readable form to given output stream */
350 static void dump(packet p, std::ostream & os);
352 static void finalize(packet p) {
353 p->nextHeader() << key(p.next(nothrow)); }
356 /** \brief IPv6 routing Destination Options packet typedef */
357 typedef ConcretePacket<IPv6DestinationType> IPv6Destination;
361 ///////////////////////////////hh.e////////////////////////////////////////
362 //#include "IPv6Extensions.cci"
363 //#include "IPv6Extensions.ct"
364 //#include "IPv6Extensions.cti"
371 // c-file-style: "senf"
372 // indent-tabs-mode: nil
373 // ispell-local-dictionary: "american"
374 // compile-command: "scons -u test"
375 // comment-column: 40