4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Philipp Batroff <pug@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.
23 // Definition of non-inline non-template functions
25 #ifndef HH_SENF_Packets_DefaultBundle_ICMPv6TypePacket_
26 #define HH_SENF_Packets_DefaultBundle_ICMPv6TypePacket_ 1
29 #include <senf/Packets/Packets.hh>
30 #include "IPv6Packet.hh"
31 #include "ICMPv6Packet.hh"
35 //#############################################################
37 //#############################################################
38 struct ICMPv6EchoRequestParser : public PacketParserBase
40 # include SENF_FIXED_PARSER()
41 SENF_PARSER_FIELD ( identifier, UInt16Parser );
42 SENF_PARSER_FIELD ( seqNr, UInt16Parser );
44 SENF_PARSER_FINALIZE ( ICMPv6EchoRequestParser );
47 /** \brief ICMPv6 Echo Request
49 \par Packet type (typedef):
50 \ref ICMPv6EchoRequest
53 \ref ICMPv6EchoRequestParser
54 \image html ICMPv6EchoRequest.png
56 \ingroup protocolbundle_default
58 struct ICMPv6EchoRequestType
59 : public PacketTypeBase,
60 public PacketTypeMixin<ICMPv6EchoRequestType>
62 typedef PacketTypeMixin<ICMPv6EchoRequestType> mixin;
63 typedef ConcretePacket<ICMPv6EchoRequestType> packet;
64 typedef ICMPv6EchoRequestParser parser;
66 using mixin::nextPacketRange;
68 using mixin::initSize;
70 static void dump(packet p, std::ostream & os);
73 typedef ConcretePacket<ICMPv6EchoRequestType> ICMPv6EchoRequest;
75 //#############################################################
77 //#############################################################
78 struct ICMPv6EchoReplyParser : public PacketParserBase
80 # include SENF_FIXED_PARSER()
81 SENF_PARSER_FIELD ( identifier, UInt16Parser );
82 SENF_PARSER_FIELD ( seqNr, UInt16Parser );
84 SENF_PARSER_FINALIZE ( ICMPv6EchoReplyParser );
87 /** \brief ICMPv6 Echo Reply
89 \par Packet type (typedef):
93 \ref ICMPv6EchoReplyParser
94 \image html ICMPv6EchoReply.png
96 \ingroup protocolbundle_default
98 struct ICMPv6EchoReplyType
99 : public PacketTypeBase,
100 public PacketTypeMixin<ICMPv6EchoReplyType>
102 typedef PacketTypeMixin<ICMPv6EchoReplyType> mixin;
103 typedef ConcretePacket<ICMPv6EchoReplyType> packet;
104 typedef ICMPv6EchoReplyParser parser;
106 using mixin::nextPacketRange;
108 using mixin::initSize;
110 static void dump(packet p, std::ostream & os);
113 typedef ConcretePacket<ICMPv6EchoReplyType> ICMPv6EchoReply;
115 //#############################################################
116 //ICMPv6 Error Destination Unreachable Message
117 //#############################################################
118 struct ICMPv6ErrDestUnreachableParser : public PacketParserBase
120 # include SENF_FIXED_PARSER()
122 //should be set static 0 by sender and ignored by receiver
123 SENF_PARSER_PRIVATE_FIELD ( unused, UInt32Parser );
128 /* Code 0 - No route to destination
129 1 - Communication with destination
130 administratively prohibited
131 2 - Beyond scope of source address
132 3 - Address unreachable
134 5 - Source address failed ingress/egress policy
135 6 - Reject route to destination */
136 void setErrCode(int code) {
137 ICMPv6Packet icmpv6 (senf::Packet().rfind<ICMPv6Packet>(senf::nothrow));
138 icmpv6->code() = code;
141 SENF_PARSER_FINALIZE ( ICMPv6ErrDestUnreachableParser );
144 /** \brief ICMPv6 Destination unreachable
146 \par Packet type (typedef):
147 \ref ICMPv6ErrDestUnreachable
150 \ref ICMPv6ErrDestUnreachableParser
151 \image html ICMPv6ErrDestUnreachable.png
153 \ingroup protocolbundle_default
155 struct ICMPv6ErrDestUnreachableType
156 : public PacketTypeBase,
157 public PacketTypeMixin<ICMPv6ErrDestUnreachableType>
159 typedef PacketTypeMixin<ICMPv6ErrDestUnreachableType> mixin;
160 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> packet;
161 typedef ICMPv6ErrDestUnreachableParser parser;
163 using mixin::nextPacketRange;
165 using mixin::initSize;
167 static void dump(packet p, std::ostream & os);
170 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> ICMPv6ErrDestUnreachable;
172 //#############################################################
173 //ICMPv6 Error Packet Too Big Message
174 //#############################################################
175 struct ICMPv6ErrTooBigParser : public PacketParserBase
177 # include SENF_FIXED_PARSER()
178 SENF_PARSER_FIELD ( mtu, UInt32Parser );
180 /* Code static set to 0 */
182 ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
186 SENF_PARSER_FINALIZE ( ICMPv6ErrTooBigParser );
189 /** \brief ICMPv6 Packet to big
191 \par Packet type (typedef):
195 \ref ICMPv6ErrTooBigParser
196 \image html ICMPv6ErrTooBig.png
198 \ingroup protocolbundle_default
200 struct ICMPv6ErrTooBigType
201 : public PacketTypeBase,
202 public PacketTypeMixin<ICMPv6ErrTooBigType>
204 typedef PacketTypeMixin<ICMPv6ErrTooBigType> mixin;
205 typedef ConcretePacket<ICMPv6ErrTooBigType> packet;
206 typedef ICMPv6ErrTooBigParser parser;
208 using mixin::nextPacketRange;
210 using mixin::initSize;
212 static void dump(packet p, std::ostream & os);
215 typedef ConcretePacket<ICMPv6ErrTooBigType> ICMPv6ErrTooBig;
217 //#############################################################
218 //ICMPv6 Error Time Exceeded Message
219 //#############################################################
220 struct ICMPv6ErrTimeExceededParser : public PacketParserBase
222 # include SENF_FIXED_PARSER()
223 //should be set static 0 by sender and ignored by receiver
224 SENF_PARSER_FIELD ( unused, UInt32Parser );
225 /* Code 0 - Hop limit exceeded in transit
226 1 - Fragment reassembly time exceeded */
227 void setErrCode(int code){
228 ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
229 icmpv6->code() = code;
232 SENF_PARSER_FINALIZE ( ICMPv6ErrTimeExceededParser );
235 /** \brief ICMPv6 Time exceeded
237 \par Packet type (typedef):
238 \ref ICMPv6ErrTimeExceeded
241 \ref ICMPv6ErrTimeExceededParser
242 \image html ICMPv6ErrTimeExceeded.png
244 \ingroup protocolbundle_default
246 struct ICMPv6ErrTimeExceededType
247 : public PacketTypeBase,
248 public PacketTypeMixin<ICMPv6ErrTimeExceededType>
250 typedef PacketTypeMixin<ICMPv6ErrTimeExceededType> mixin;
251 typedef ConcretePacket<ICMPv6ErrTimeExceededType> packet;
252 typedef ICMPv6ErrTimeExceededParser parser;
254 using mixin::nextPacketRange;
256 using mixin::initSize;
258 static void dump(packet p, std::ostream & os);
260 typedef ConcretePacket<ICMPv6ErrTimeExceededType> ICMPv6ErrTimeExceeded;
262 //#############################################################
263 //ICMPv6 Error Parameter Problem Message
264 //#############################################################
265 struct ICMPv6ErrParamProblemParser : public PacketParserBase
267 # include SENF_FIXED_PARSER()
268 //should be set static 0 by sender and ignored by receiver
269 SENF_PARSER_FIELD ( pointer, UInt32Parser );
270 /* Code 0 - Erroneous header field encountered
271 1 - Unrecognized Next Header type encountered
272 2 - Unrecognized IPv6 option encountered */
274 void setErrCode(int code){
275 ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
276 icmpv6->code() = code;
278 SENF_PARSER_FINALIZE ( ICMPv6ErrParamProblemParser );
281 /** \brief ICMPv6 Parameter problem
283 \par Packet type (typedef):
284 \ref ICMPv6ErrParamProblem
287 \ref ICMPv6ErrParamProblemParser
288 \image html ICMPv6ErrParamProblem.png
290 \ingroup protocolbundle_default
292 struct ICMPv6ErrParamProblemType
293 : public PacketTypeBase,
294 public PacketTypeMixin<ICMPv6ErrParamProblemType>
296 typedef PacketTypeMixin<ICMPv6ErrParamProblemType> mixin;
297 typedef ConcretePacket<ICMPv6ErrParamProblemType> packet;
298 typedef ICMPv6ErrParamProblemParser parser;
300 using mixin::nextPacketRange;
302 using mixin::initSize;
304 static void dump(packet p, std::ostream & os);
306 typedef ConcretePacket<ICMPv6ErrParamProblemType> ICMPv6ErrParamProblem;
308 //#############################################################
309 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Query
310 //#############################################################
311 struct MLDv2ListenerQueryParser : public PacketParserBase
313 # include SENF_PARSER()
314 //need a variant here
315 // a.) maxResponseCode < 32768 =>Interger
316 // b.) maxResponseCode >=32768 => float (is there a float parser???)
318 float value as followed:
319 0 1 2 3 4 5 6 7 8 9 A B C D E F
320 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
322 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
324 SENF_PARSER_FIELD ( maxResponseCode, UInt16Parser );
325 SENF_PARSER_FIELD ( reserved, UInt16Parser ); // set to zero by default
326 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser );
327 SENF_PARSER_BITFIELD ( resv, 4, unsigned ); // set to zero by default
328 SENF_PARSER_BITFIELD ( sFlag, 1, unsigned );
329 SENF_PARSER_BITFIELD ( qrv, 3, unsigned );
330 SENF_PARSER_FIELD ( qqic, UInt8Parser );
331 SENF_PARSER_PRIVATE_FIELD ( nrSources, UInt16Parser );
332 SENF_PARSER_VECTOR (srcAddresses, nrSources, INet6AddressParser );
334 SENF_PARSER_FINALIZE ( MLDv2ListenerQueryParser );
342 /** \brief MLDv2 Listener query
344 \par Packet type (typedef):
345 \ref MLDv2ListenerQuery
348 \ref MLDv2ListenerQueryParser
349 \image html MLDv2ListenerQuery.png
351 \ingroup protocolbundle_default
353 struct MLDv2ListenerQueryType
354 : public PacketTypeBase,
355 public PacketTypeMixin<MLDv2ListenerQueryType>
357 typedef PacketTypeMixin<MLDv2ListenerQueryType> mixin;
358 typedef ConcretePacket<MLDv2ListenerQueryType> packet;
359 typedef MLDv2ListenerQueryParser parser;
361 using mixin::nextPacketRange;
363 using mixin::initSize;
365 static void dump(packet p, std::ostream & os);
368 typedef ConcretePacket<MLDv2ListenerQueryType> MLDv2ListenerQuery;
370 //#############################################################
371 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Report Message
372 //#############################################################
373 //First: the Multicast Address Record Parser
374 struct MLDv2AddressRecordParser : public PacketParserBase
376 # include SENF_PARSER()
378 SENF_PARSER_FIELD ( recordType, UInt8Parser );
379 SENF_PARSER_PRIVATE_FIELD ( auxDataLen, UInt8Parser );
380 SENF_PARSER_PRIVATE_FIELD ( nrOfSrcs, UInt16Parser );
381 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser);
382 SENF_PARSER_VECTOR ( srcAddresses, nrOfSrcs, INet6AddressParser );
383 SENF_PARSER_VECTOR ( auxData, auxDataLen, UInt32Parser );
385 SENF_PARSER_FINALIZE ( MLDv2AddressRecordParser );
388 struct MLDv2ListenerReportParser : public PacketParserBase
390 # include SENF_PARSER()
392 SENF_PARSER_FIELD ( reserved, UInt16Parser ); //set to zero by default
393 SENF_PARSER_PRIVATE_FIELD ( nrMcastAddrRecords_, UInt16Parser );
394 SENF_PARSER_LIST ( mcastAddrRecords, nrMcastAddrRecords_, MLDv2AddressRecordParser );
396 SENF_PARSER_FINALIZE ( MLDv2ListenerReportParser );
403 /** \brief MLDv2 Listener report
405 \par Packet type (typedef):
406 \ref MLDv2ListenerReport
409 \ref MLDv2ListenerReportParser
410 \image html MLDv2ListenerReport.png
411 \image html MLDv2AddressRecord.png
413 \ingroup protocolbundle_default
415 struct MLDv2ListenerReportType
416 : public PacketTypeBase,
417 public PacketTypeMixin<MLDv2ListenerReportType>
419 typedef PacketTypeMixin<MLDv2ListenerReportType> mixin;
420 typedef ConcretePacket<MLDv2ListenerReportType> packet;
421 typedef MLDv2ListenerReportParser parser;
423 using mixin::nextPacketRange;
425 using mixin::initSize;
427 static void dump(packet p, std::ostream & os);
430 typedef ConcretePacket<MLDv2ListenerReportType> MLDv2ListenerReport;
439 // c-file-style: "senf"
440 // indent-tabs-mode: nil
441 // ispell-local-dictionary: "american"
442 // compile-command: "scons -u test"
443 // comment-column: 40