4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.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 IPv6Packet public header */
26 #ifndef HH_SENF_Packets_DefaultBundle_IPv6Packet_
27 #define HH_SENF_Packets_DefaultBundle_IPv6Packet_ 1
30 #include <senf/Socket/Protocols/INet/INet6Address.hh>
31 #include <senf/Packets/Packets.hh>
32 #include "IPv4Packet.hh"
34 //#include "IPv6Packet.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
39 /** \brief Parse an IPv6 address
43 struct INet6AddressParser
44 : public ValueParserBase<INet6AddressParser, INet6Address, 16u>
46 INet6AddressParser(data_iterator i, state_type s) : Base(i,s) {}
48 value_type value() const { return value_type::from_data(i()); }
49 void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); }
51 using Base::operator=;
54 /** \brief Parse an IPv6 packet
56 \image html IPv6Packet.png
57 \see IPv6PacketType \n
58 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
60 struct IPv6PacketParser : public PacketParserBase
62 # include SENF_FIXED_PARSER()
64 SENF_PARSER_BITFIELD( version, 4, unsigned );
65 SENF_PARSER_BITFIELD( trafficClass, 8, unsigned );
66 SENF_PARSER_BITFIELD( flowLabel, 20, unsigned );
68 SENF_PARSER_FIELD( length, UInt16Parser );
69 SENF_PARSER_FIELD( nextHeader, UInt8Parser );
70 SENF_PARSER_FIELD( hopLimit, UInt8Parser );
71 SENF_PARSER_FIELD( source, INet6AddressParser );
72 SENF_PARSER_FIELD( destination, INet6AddressParser );
78 SENF_PARSER_FINALIZE(IPv6PacketParser);
81 /** \brief IPv6 packet
83 \par Packet type (typedef):
89 <table class="packet" cellpadding="5" cellspacing="1" border="1">
91 <th width="12.5%">0</th> <th width="12.5%">4</th> <th width="12.5%">8</th>
92 <th width="12.5%">12</th> <th width="12.5%">16</th> <th width="12.5%">20</th>
93 <th width="12.5%">24</th> <th width="6.5%">28</th>
94 <th style="text-align:right" width="6%">31</th>
96 <td>\ref IPv6PacketParser::version() "Version"</td>
97 <td colspan="2">\ref IPv6PacketParser::trafficClass() "Traffic Class"</td>
98 <td colspan="6">\ref IPv6PacketParser::flowLabel() "Flow Label"</td>
100 <td colspan="4">\ref IPv6PacketParser::length() "Payload Length"</td>
101 <td colspan="2">\ref IPv6PacketParser::nextHeader() "Next Header"</td>
102 <td colspan="3">\ref IPv6PacketParser::hopLimit() "Hop Limit"</td>
104 <td colspan="9" style="height:8em">
105 \ref IPv6PacketParser::source() "Source Address"</td>
107 <td colspan="9" style="height:8em">
108 \ref IPv6PacketParser::destination() "Destination Address"</td>
112 \par Associated registries:
115 \par Finalize action:
116 \copydetails finalize()
118 \ingroup protocolbundle_default
120 struct IPv6PacketType
121 : public PacketTypeBase,
122 public PacketTypeMixin<IPv6PacketType, IpTypes>
125 typedef PacketTypeMixin<IPv6PacketType, IpTypes> mixin;
127 typedef ConcretePacket<IPv6PacketType> packet; ///< IPv6 packet typedef
128 typedef IPv6PacketParser parser; ///< typedef to the parser of IPv6 packet
130 using mixin::nextPacketRange;
131 using mixin::nextPacketType;
132 using mixin::initSize;
135 static key_t nextPacketKey(packet p)
136 { return p->nextHeader(); }
138 /** \brief Dump given IPv6Packet in readable form to given output stream */
139 static void dump(packet p, std::ostream & os);
141 static void finalize(packet p); ///< Finalize packet.
142 /**< \li set \ref IPv6PacketParser::length() "length"
144 \li set \ref IPv6PacketParser::nextHeader()
145 "nextHeader" from type of next packet if found
149 /** \brief IPv6 packet typedef
150 \ingroup protocolbundle_default
152 typedef ConcretePacket<IPv6PacketType> IPv6Packet;
155 ///////////////////////////////hh.e////////////////////////////////////////
156 //#include "IPv6Packet.cci"
157 //#include "IPv6Packet.ct"
158 //#include "IPv6Packet.cti"
165 // c-file-style: "senf"
166 // indent-tabs-mode: nil
167 // ispell-local-dictionary: "american"
168 // compile-command: "scons -u test"
169 // comment-column: 40