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 "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 IPv6FragmentPacket.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 IPv6FragmentPacket
69 \ref IPv6FragmentPacketParser
71 \par Associated registries:
75 Set \a nextHeader from type of next packet if found in \ref IpTypes
77 \ingroup protocolbundle_default
79 struct IPv6FragmentPacketType
80 : public PacketTypeBase,
81 public PacketTypeMixin<IPv6FragmentPacketType, IpTypes>
84 typedef PacketTypeMixin<IPv6FragmentPacketType, IpTypes> mixin;
86 /** \brief IPv6 fragment extension packet typedef */
87 typedef ConcretePacket<IPv6FragmentPacketType> 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 IPv6FragmentPacket 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 \ingroup protocolbundle_default
109 typedef ConcretePacket<IPv6FragmentPacketType> IPv6FragmentPacket;
111 // =====================================================================================================
113 /** \brief Parse in IPv6 routing extension header
115 Parser implementing the IPv6 routing Header extension (type 0 only).
116 The fields implemented are:
117 \image html IPv6RoutingPacket.png
119 \see IPv6ExtensionType_Routing \n
120 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
122 struct IPv6RoutingPacketParser : public PacketParserBase
125 The Type 0 Routing header has the following format: (RFC 2460)
127 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128 | Next Header | Hdr Ext Len | Routing Type=0| Segments Left |
129 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
151 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
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 ( IPv6RoutingPacketParser );
164 //provisionary, since only type 0 is implemented
171 /** \brief IPv6 routing extension
173 \par Packet type (typedef):
174 \ref IPv6RoutingPacket
177 \ref IPv6RoutingPacketParser
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
187 struct IPv6RoutingPacketType
188 : public PacketTypeBase,
189 public PacketTypeMixin<IPv6RoutingPacketType, IpTypes>
192 typedef PacketTypeMixin<IPv6RoutingPacketType, IpTypes> mixin;
194 /** \brief IPv6 routing extension packet typedef */
195 typedef ConcretePacket<IPv6RoutingPacketType> packet;
196 /** \brief typedef to the parser of IPv6 routing extension packet */
197 typedef IPv6RoutingPacketParser parser;
199 using mixin::nextPacketRange;
200 using mixin::nextPacketType;
202 using mixin::initSize;
204 static key_t nextPacketKey(packet p)
205 { return p->nextHeader(); }
206 /** \brief Dump given IPv6RoutingPacket in readable form to given output stream */
207 static void dump(packet p, std::ostream & os);
209 static void finalize(packet p) {
210 p->nextHeader() << key(p.next(nothrow)); }
213 /** \brief IPv6 routing extension packet typedef
214 \ingroup protocolbundle_default
216 typedef ConcretePacket<IPv6RoutingPacketType> IPv6RoutingPacket;
219 // =====================================================================================================
221 /** \brief Parse in IPv6 Hop-By-Hop extension header
223 Parser implementing the IPv6 routing Header extension. The fields implemented are:
224 \image html IPv6HopByHopOptionsPacket.png
226 \see IPv6ExtensionType_HopByHop \n
227 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
229 struct IPv6HopByHopOptionsPacketParser : public PacketParserBase
231 # 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<
238 IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
239 typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
241 SENF_PARSER_FIELD ( options, ListOptionTypeParser);
243 SENF_PARSER_FINALIZE ( IPv6HopByHopOptionsPacketParser );
246 /** \brief IPv6 Hop-By-Hop extension
248 \par Packet type (typedef):
249 \ref IPv6HopByHopOptionsPacket
252 \ref IPv6HopByHopOptionsPacketParser
254 \par Associated registries:
257 \par Finalize action:
258 Set \a nextHeader from type of next packet if found in \ref IpTypes
260 \ingroup protocolbundle_default
262 struct IPv6HopByHopOptionsPacketType
263 : public PacketTypeBase,
264 public PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes>
267 typedef PacketTypeMixin<IPv6HopByHopOptionsPacketType, IpTypes> mixin;
269 /** \brief IPv6 Hop-By-Hop extension packet typedef */
270 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> packet;
271 /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
272 typedef IPv6HopByHopOptionsPacketParser parser;
274 using mixin::nextPacketRange;
275 using mixin::nextPacketType;
277 using mixin::initSize;
279 static key_t nextPacketKey(packet p)
280 { return p->nextHeader(); }
282 /** \brief Dump given IPv6HopByHopOptionsPacket in readable form to given output stream */
283 static void dump(packet p, std::ostream & os);
285 static void finalize(packet p) {
286 p->nextHeader() << key(p.next(nothrow)); }
289 /** \brief IPv6 routing Hop-By-Hop packet typedef
290 \ingroup protocolbundle_default
292 typedef ConcretePacket<IPv6HopByHopOptionsPacketType> IPv6HopByHopOptionsPacket;
294 // =====================================================================================================
296 /** \brief Parse in IPv6 Destination Options extension header
298 Parser implementing the IPv6 Destination Options Header extension.
299 The fields implemented are:
300 \image html IPv6DestinationOptionsPacket.png
302 \see IPv6ExtensionType_Destination \n
303 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
305 struct IPv6DestinationOptionsPacketParser : public PacketParserBase
307 # include SENF_PARSER()
308 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
309 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
311 SENF_PARSER_FINALIZE ( IPv6DestinationOptionsPacketParser );
314 /** \brief IPv6 Destination Options extension
316 \par Packet type (typedef):
317 \ref IPv6DestinationOptionsPacket
320 \ref IPv6DestinationOptionsPacketParser
322 \par Associated registries:
325 \par Finalize action:
326 Set \a nextHeader from type of next packet if found in \ref IpTypes
328 \ingroup protocolbundle_default
330 struct IPv6DestinationOptionsPacketType
331 : public PacketTypeBase,
332 public PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes>
335 typedef PacketTypeMixin<IPv6DestinationOptionsPacketType, IpTypes> mixin;
337 /** \brief IPv6 Destination Options extension packet typedef */
338 typedef ConcretePacket<IPv6DestinationOptionsPacketType> packet;
339 /** \brief typedef to the parser of IPv6 Destination Options extension packet */
340 typedef IPv6DestinationOptionsPacketParser 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 IPv6DestinationOptionsPacket 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 \ingroup protocolbundle_default
359 typedef ConcretePacket<IPv6DestinationOptionsPacketType> IPv6DestinationOptionsPacket;
363 ///////////////////////////////hh.e////////////////////////////////////////
364 //#include "IPv6Extensions.cci"
365 //#include "IPv6Extensions.ct"
366 //#include "IPv6Extensions.cti"
373 // c-file-style: "senf"
374 // indent-tabs-mode: nil
375 // ispell-local-dictionary: "american"
376 // compile-command: "scons -u test"
377 // comment-column: 40