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/ListOptionTypeParser.hh>
33 #include <senf/Packets/DefaultBundle/IPv6ExtOptionType.hh>
35 #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 IPv6PacketParserExtension_Fragment : public PacketParserBase
51 # include SENF_FIXED_PARSER()
53 SENF_PARSER_FIELD ( nextHeader , UInt8Parser );
54 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 );
60 SENF_PARSER_FIELD ( id , UInt32Parser );
62 SENF_PARSER_FINALIZE(IPv6PacketParserExtension_Fragment);
65 /** \brief IPv6 fragment extension
67 \par Packet type (typedef):
68 \ref IPv6Extension_Fragment
71 \ref IPv6PacketParserExtension_Fragment
73 \par Associated registries:
77 Set \a nextHeader from type of next packet if found in \ref IpTypes
79 \ingroup protocolbundle_default
81 struct IPv6ExtensionType_Fragment
82 : public PacketTypeBase,
83 public PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes>
86 typedef PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes> mixin;
88 /** \brief IPv6 fragment extension packet typedef */
89 typedef ConcretePacket<IPv6ExtensionType_Fragment> packet;
90 /** \brief typedef to the parser of IPv6 fragment extension packet */
91 typedef IPv6PacketParserExtension_Fragment parser;
93 using mixin::nextPacketRange;
94 using mixin::nextPacketType;
95 using mixin::initSize;
98 static key_t nextPacketKey(packet p)
99 { return p->nextHeader(); }
101 /** \brief Dump given IPv6Extension_Fragment in readable form to given output stream */
102 static void dump(packet p, std::ostream & os);
104 static void finalize(packet p) {
105 p->nextHeader() << key(p.next(nothrow)); }
108 /** \brief IPv6 fragment extension packet typedef */
109 typedef ConcretePacket<IPv6ExtensionType_Fragment> IPv6Extension_Fragment;
111 // =====================================================================================================
113 /** \brief Parse in IPv6 routing extension header
115 Parser implementing the IPv6 routing Header extension. 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>
122 //Routing Header Extension (type 0 only)
123 struct IPv6PacketParserExtension_Routing : public PacketParserBase
126 The Type 0 Routing header has the following format: (RFC 2460)
128 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129 | Next Header | Hdr Ext Len | Routing Type=0| Segments Left |
130 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
144 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
155 # include SENF_PARSER()
157 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
158 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
159 SENF_PARSER_FIELD ( routingType, UInt8Parser ); //set to Zero for minimal implementation
160 SENF_PARSER_FIELD_RO ( segmentsLeft, UInt8Parser );
161 SENF_PARSER_FIELD ( reserved, UInt32Parser ); //set to zero by RFC
162 SENF_PARSER_VECTOR ( hopAddresses, segmentsLeft, INet6AddressParser );
164 SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_Routing );
166 //provisionary, since only type 0 is implemented
173 /** \brief IPv6 routing extension
175 \par Packet type (typedef):
176 \ref IPv6Extension_Routing
179 \ref IPv6PacketParserExtension_Routing
181 \par Associated registries:
184 \par Finalize action:
185 Set \a nextHeader from type of next packet if found in \ref IpTypes
187 \ingroup protocolbundle_default
190 struct IPv6ExtensionType_Routing
191 : public PacketTypeBase,
192 public PacketTypeMixin<IPv6ExtensionType_Routing, IpTypes>
196 typedef PacketTypeMixin<IPv6ExtensionType_Routing, IpTypes> mixin;
198 /** \brief IPv6 routing extension packet typedef */
199 typedef ConcretePacket<IPv6ExtensionType_Routing> packet;
200 /** \brief typedef to the parser of IPv6 routing extension packet */
201 typedef IPv6PacketParserExtension_Routing parser;
203 using mixin::nextPacketRange;
204 using mixin::nextPacketType;
206 using mixin::initSize;
208 static key_t nextPacketKey(packet p)
209 { return p->nextHeader(); }
210 /** \brief Dump given IPv6Extension_Routing in readable form to given output stream */
211 static void dump(packet p, std::ostream & os);
213 static void finalize(packet p) {
214 p->nextHeader() << key(p.next(nothrow)); }
217 /** \brief IPv6 routing extension packet typedef */
218 typedef ConcretePacket<IPv6ExtensionType_Routing> IPv6Extension_Routing;
221 // =====================================================================================================
223 /** \brief Parse in IPv6 Hop-By-Hop extension header
225 Parser implementing the IPv6 routing Header extension. The fields implemented are:
226 \image html IPv6Extensions_HopByHop.png
228 \see IPv6ExtensionType_HopByHop \n
229 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
232 // Hop-By-Hop Extension Header
234 struct IPv6PacketParserExtension_HopByHop : public PacketParserBase {
235 # include SENF_PARSER()
236 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
237 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
239 typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
240 typedef detail::ListOptionTypeParser_Policy<GenericOptTypeTLVPacketParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
241 typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
243 SENF_PARSER_FIELD ( options, ListOptionTypeParser);
245 SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_HopByHop );
248 /** \brief IPv6 Hop-By-Hop extension
250 \par Packet type (typedef):
251 \ref IPv6Extension_HopByHop
254 \ref IPv6PacketParserExtension_HopByHop
256 \par Associated registries:
259 \par Finalize action:
260 Set \a nextHeader from type of next packet if found in \ref IpTypes
262 \ingroup protocolbundle_default
265 struct IPv6ExtensionType_HopByHop
266 : public PacketTypeBase,
267 public PacketTypeMixin<IPv6ExtensionType_HopByHop, IpTypes>
270 typedef PacketTypeMixin<IPv6ExtensionType_HopByHop, IpTypes> mixin;
272 /** \brief IPv6 Hop-By-Hop extension packet typedef */
273 typedef ConcretePacket<IPv6ExtensionType_HopByHop> packet;
274 /** \brief typedef to the parser of IPv6 Hop-By-Hop extension packet */
275 typedef IPv6PacketParserExtension_HopByHop parser;
277 using mixin::nextPacketRange;
278 using mixin::nextPacketType;
280 using mixin::initSize;
282 static key_t nextPacketKey(packet p)
283 { return p->nextHeader(); }
284 /** \brief Dump given IPv6Extension_HopByHop in readable form to given output stream */
285 static void dump(packet p, std::ostream & os);
287 static void finalize(packet p) {
288 p->nextHeader() << key(p.next(nothrow)); }
291 /** \brief IPv6 routing Hop-By-Hop packet typedef */
292 typedef ConcretePacket<IPv6ExtensionType_HopByHop> IPv6Extension_HopByHop;
294 // =====================================================================================================
296 /** \brief Parse in IPv6 Destination Options extension header
298 Parser implementing the IPv6 Destination Options Header extension. The fields implemented are:
299 \image html IPv6Extensions_Destination.png
301 \see IPv6ExtensionType_Destination \n
302 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
305 // Destination Options skeleton without TLV-Options
307 struct IPv6PacketParserExtension_Destination : public PacketParserBase {
309 # include SENF_PARSER()
310 SENF_PARSER_FIELD ( nextHeader, UInt8Parser );
311 SENF_PARSER_FIELD ( headerLength, UInt8Parser );
313 SENF_PARSER_FINALIZE ( IPv6PacketParserExtension_Destination );
316 /** \brief IPv6 Destination Options extension
318 \par Packet type (typedef):
319 \ref IPv6Extension_Destination
322 \ref IPv6PacketParserExtension_Destination
324 \par Associated registries:
327 \par Finalize action:
328 Set \a nextHeader from type of next packet if found in \ref IpTypes
330 \ingroup protocolbundle_default
333 struct IPv6ExtensionType_Destination
334 : public PacketTypeBase,
335 public PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes>
338 typedef PacketTypeMixin<IPv6ExtensionType_Destination, IpTypes> mixin;
340 /** \brief IPv6 Destination Options extension packet typedef */
341 typedef ConcretePacket<IPv6ExtensionType_Destination> packet;
342 /** \brief typedef to the parser of IPv6 Destination Options extension packet */
343 typedef IPv6PacketParserExtension_Destination parser;
345 using mixin::nextPacketRange;
346 using mixin::nextPacketType;
348 using mixin::initSize;
350 static key_t nextPacketKey(packet p)
351 { return p->nextHeader(); }
352 /** \brief Dump given IPv6Extension_Destination in readable form to given output stream */
353 static void dump(packet p, std::ostream & os);
355 static void finalize(packet p) {
356 p->nextHeader() << key(p.next(nothrow)); }
359 /** \brief IPv6 routing Destination Options packet typedef */
360 typedef ConcretePacket<IPv6ExtensionType_Destination> IPv6Extension_Destination;
364 ///////////////////////////////hh.e////////////////////////////////////////
365 //#include "IPv6Extensions.cci"
366 //#include "IPv6Extensions.ct"
367 //#include "IPv6Extensions.cti"
374 // c-file-style: "senf"
375 // indent-tabs-mode: nil
376 // ispell-local-dictionary: "american"
377 // compile-command: "scons -u test"
378 // comment-column: 40