7f1bcbcd6aa2d5e130c3f5a89aedab9429a376de
[senf.git] / Packets / DefaultBundle / IPv6Extensions.hh
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY 
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief IPv6Extensions public header */
25
26 #ifndef HH_IPv6Extensions_
27 #define HH_IPv6Extensions_ 1
28
29 // Custom includes
30 #include "IPv6Packet.hh"
31
32 //#include "IPv6Extensions.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
34
35 namespace senf {
36
37     /** \brief Parse in IPv6 fragment extension header
38         
39         Parser implementing the IPv6 fragment extension. The fields implemented are:
40
41         \see IPv6ExtensionType_Fragment \n
42             <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
43      */
44     struct IPv6PacketParserExtension_Fragment : public PacketParserBase
45     {
46 #       include SENF_FIXED_PARSER()
47
48         SENF_PARSER_FIELD( nextHeader     , UInt8Parser );
49         SENF_PARSER_FIELD( reserved1      , UInt8Parser );
50
51         SENF_PARSER_BITFIELD( fragmentOffset, 13, unsigned );
52         SENF_PARSER_BITFIELD( reserved2,       2, unsigned );
53         SENF_PARSER_BITFIELD( moreFragments,   1, bool     );
54
55         SENF_PARSER_FIELD( id             , UInt32Parser   );
56
57         SENF_PARSER_FINALIZE(IPv6PacketParserExtension_Fragment);
58     };
59
60     /** \brief IPv6 fragment extension
61
62         \par Packet type (typedef):
63             \ref IPv6Extension_Fragment
64
65         \par Fields:
66             \ref IPv6PacketParserExtension_Fragment
67         
68         \par Associated registries:
69             \par IpTypes
70         
71         \par Finalize action:
72             Set \a nextHeader from type of next packet if found in \ref IpTypes
73
74         \ingroup protocolbundle_default
75      */
76     struct IPv6ExtensionType_Fragment
77         : public PacketTypeBase,
78           public PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes>
79     {
80 #ifndef DOXYGEN
81         typedef PacketTypeMixin<IPv6ExtensionType_Fragment, IpTypes> mixin;
82         typedef ConcretePacket<IPv6ExtensionType_Fragment> packet;
83         typedef IPv6PacketParserExtension_Fragment parser;
84 #endif
85         using mixin::nextPacketRange;
86         using mixin::nextPacketType;
87         using mixin::initSize;
88         using mixin::init;
89
90         static registry_key_t nextPacketKey(packet p) 
91             { return p->nextHeader(); }
92         
93         static void dump(packet p, std::ostream & os);
94
95         static void finalize(packet p)
96             { p->nextHeader() << key(p.next(nothrow)); }
97     };
98
99     /** \brief IPv6 fragment extension packet typedef */
100     typedef ConcretePacket<IPv6ExtensionType_Fragment> IPv6Extension_Fragment;
101 }
102
103 ///////////////////////////////hh.e////////////////////////////////////////
104 #endif
105 #ifndef SENF_PACKETS_DECL_ONLY
106 //#include "IPv6Extensions.cci"
107 //#include "IPv6Extensions.ct"
108 //#include "IPv6Extensions.cti"
109 #endif
110
111 \f
112 // Local Variables:
113 // mode: c++
114 // fill-column: 100
115 // c-file-style: "senf"
116 // indent-tabs-mode: nil
117 // ispell-local-dictionary: "american"
118 // compile-command: "scons -u test"
119 // comment-column: 40
120 // End: