4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief IPv6Packet public header */
31 #ifndef HH_SENF_Packets_DefaultBundle_IPv6Packet_
32 #define HH_SENF_Packets_DefaultBundle_IPv6Packet_ 1
35 #include <senf/Socket/Protocols/INet/INet6Address.hh>
36 #include <senf/Packets/Packets.hh>
37 #include "IPv4Packet.hh"
39 //#include "IPv6Packet.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 /** \brief Parse an IPv6 address
48 struct INet6AddressParser
49 : public ValueParserBase<INet6AddressParser, INet6Address, 16u>
51 INet6AddressParser(data_iterator i, state_type s) : Base(i,s) {}
53 value_type value() const { return value_type::from_data(i()); }
54 void value(value_type const & v) { std::copy(v.begin(), v.end(), i()); }
56 using Base::operator=;
59 /** \brief Parse an IPv6 packet
61 \image html IPv6Packet.png
62 \see IPv6PacketType \n
63 <a href="http://tools.ietf.org/html/rfc2460">RFC 2460</a>
65 struct IPv6PacketParser : public PacketParserBase
67 # include SENF_FIXED_PARSER()
69 SENF_PARSER_BITFIELD( version, 4, unsigned );
70 SENF_PARSER_BITFIELD( trafficClass, 8, unsigned );
71 SENF_PARSER_BITFIELD( flowLabel, 20, unsigned );
73 SENF_PARSER_FIELD( length, UInt16Parser );
74 SENF_PARSER_FIELD( nextHeader, UInt8Parser );
75 SENF_PARSER_FIELD( hopLimit, UInt8Parser );
76 SENF_PARSER_FIELD( source, INet6AddressParser );
77 SENF_PARSER_FIELD( destination, INet6AddressParser );
83 SENF_PARSER_FINALIZE(IPv6PacketParser);
86 /** \brief IPv6 packet
88 \par Packet type (typedef):
94 <table class="packet" cellpadding="5" cellspacing="1" border="1">
96 <th width="12.5%">0</th> <th width="12.5%">4</th> <th width="12.5%">8</th>
97 <th width="12.5%">12</th> <th width="12.5%">16</th> <th width="12.5%">20</th>
98 <th width="12.5%">24</th> <th width="6.5%">28</th>
99 <th style="text-align:right" width="6%">31</th>
101 <td>\ref IPv6PacketParser::version() "Version"</td>
102 <td colspan="2">\ref IPv6PacketParser::trafficClass() "Traffic Class"</td>
103 <td colspan="6">\ref IPv6PacketParser::flowLabel() "Flow Label"</td>
105 <td colspan="4">\ref IPv6PacketParser::length() "Payload Length"</td>
106 <td colspan="2">\ref IPv6PacketParser::nextHeader() "Next Header"</td>
107 <td colspan="3">\ref IPv6PacketParser::hopLimit() "Hop Limit"</td>
109 <td colspan="9" style="height:8em">
110 \ref IPv6PacketParser::source() "Source Address"</td>
112 <td colspan="9" style="height:8em">
113 \ref IPv6PacketParser::destination() "Destination Address"</td>
117 \par Associated registries:
120 \par Finalize action:
121 \copydetails finalize()
123 \ingroup protocolbundle_default
125 struct IPv6PacketType
126 : public PacketTypeBase,
127 public PacketTypeMixin<IPv6PacketType, IpTypes>
130 typedef PacketTypeMixin<IPv6PacketType, IpTypes> mixin;
132 typedef ConcretePacket<IPv6PacketType> packet; ///< IPv6 packet typedef
133 typedef IPv6PacketParser parser; ///< typedef to the parser of IPv6 packet
135 using mixin::nextPacketRange;
136 using mixin::nextPacketType;
137 using mixin::initSize;
140 static key_t nextPacketKey(packet p)
141 { return p->nextHeader(); }
143 /** \brief Dump given IPv6Packet in readable form to given output stream */
144 static void dump(packet p, std::ostream & os);
146 static void finalize(packet p); ///< Finalize packet.
147 /**< \li set \ref IPv6PacketParser::length() "length"
149 \li set \ref IPv6PacketParser::nextHeader()
150 "nextHeader" from type of next packet if found
154 /** \brief IPv6 packet typedef
155 \ingroup protocolbundle_default
157 typedef ConcretePacket<IPv6PacketType> IPv6Packet;
160 //-/////////////////////////////////////////////////////////////////////////////////////////////////
161 //#include "IPv6Packet.cci"
162 //#include "IPv6Packet.ct"
163 //#include "IPv6Packet.cti"
170 // c-file-style: "senf"
171 // indent-tabs-mode: nil
172 // ispell-local-dictionary: "american"
173 // compile-command: "scons -u test"
174 // comment-column: 40