added first structure for ULE SNDU Packet
[senf.git] / Packets / DefaultBundle / IpV6Packet.hh
1 // Copyright (C) 2007
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21 /** \file
22     \brief IpV6Packet public header */
23
24 #ifndef HH_IpV6Packet_
25 #define HH_IpV6Packet_ 1
26
27 // Custom includes
28 #include "Packets/Packets.hh"
29 #include "IpV4Packet.hh"
30
31 //#include "IpV6Packet.mpp"
32 ///////////////////////////////hh.p////////////////////////////////////////
33
34 namespace senf {
35
36     /** \brief Parse an IpV6 packet
37
38         Parser implementing the IpV6 header. The fields implemented are:
39
40         \see IpV6PacketType \n
41             <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
42      */
43     struct Parse_IpV6 : public PacketParserBase
44     {
45         typedef Parse_UIntField <  0,  4 > Parse_Version;
46         typedef Parse_UIntField <  4, 12 > Parse_Class;
47         typedef Parse_UIntField < 12, 32 > Parse_FlowLabel;
48         typedef Parse_UInt8                Parse_8bit;
49         typedef Parse_UInt16               Parse_16bit;
50
51         typedef Parse_Array < 16, Parse_8bit > Parse_Addr;
52
53 #       ifndef DOXYGEN
54
55         SENF_PACKET_PARSER_NO_INIT(Parse_IpV6);
56
57         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
58             ((OverlayField)( version,      Parse_Version   ))
59             ((OverlayField)( trafficClass, Parse_Class     ))
60             ((Field       )( flowLabel,    Parse_FlowLabel ))
61             ((Field       )( length,       Parse_16bit     ))
62             ((Field       )( nextHeader,   Parse_8bit      ))
63             ((Field       )( hopLimit,     Parse_8bit      ))
64             ((Field       )( source,       Parse_Addr      ))
65             ((Field       )( destination,  Parse_Addr      )) );
66
67 #       else
68
69         Parse_Version   version() const;
70         Parse_Class     trafficClass() const;
71         Parse_FlowLabel flowLabel() const;
72         Parse_16bit     length() const;
73         Parse_8bit      nextHeader() const;
74         Parse_8bit      hopLimit() const;
75         Parse_Addr      source() const;
76         Parse_Addr      destination() const;
77
78 #       endif
79
80         void init() {
81             version() = 6;
82         }
83     };
84
85     /** \brief IpV6 packet
86
87         \par Packet type (typedef):
88             \ref IpV6Packet
89         
90         \par Fields:
91             \ref Parse_IpV6
92
93         \par Associated registries:
94             \ref IpTypes
95
96         \ingroup protocolbundle_default
97      */
98     struct IpV6PacketType
99         : public PacketTypeBase,
100           public PacketTypeMixin<IpV6PacketType, IpTypes>
101     {
102         typedef PacketTypeMixin<IpV6PacketType, IpTypes> mixin;
103         typedef ConcretePacket<IpV6PacketType> packet;
104         typedef Parse_IpV6 parser;
105
106         using mixin::nextPacketRange;
107         using mixin::nextPacketType;
108         using mixin::initSize;
109         using mixin::init;
110
111         static registry_key_t nextPacketKey(packet p) 
112             { return p->nextHeader(); }
113         
114         static void dump(packet p, std::ostream & os);
115     };
116
117     /** \brief IpV6 packet typedef */
118     typedef IpV6PacketType::packet IpV6Packet;
119
120     ///@}
121 }
122
123 ///////////////////////////////hh.e////////////////////////////////////////
124 #endif
125 #ifndef SENF_PACKETS_DECL_ONLY
126 //#include "IpV6Packet.cci"
127 //#include "IpV6Packet.ct"
128 //#include "IpV6Packet.cti"
129 #endif
130
131 \f
132 // Local Variables:
133 // mode: c++
134 // fill-column: 100
135 // c-file-style: "senf"
136 // indent-tabs-mode: nil
137 // ispell-local-dictionary: "american"
138 // compile-command: "scons -u test"
139 // comment-column: 40
140 // End: