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 "../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;
71 typedef ConcretePacket<ICMPv6EchoRequestType> ICMPv6EchoRequest;
73 //#############################################################
75 //#############################################################
76 struct ICMPv6EchoReplyParser : public PacketParserBase
78 # include SENF_FIXED_PARSER()
79 SENF_PARSER_FIELD ( identifier, UInt16Parser );
80 SENF_PARSER_FIELD ( seqNr, UInt16Parser );
82 SENF_PARSER_FINALIZE ( ICMPv6EchoReplyParser );
85 /** \brief ICMPv6 Echo Reply
87 \par Packet type (typedef):
91 \ref ICMPv6EchoReplyParser
92 \image html ICMPv6EchoReply.png
94 \ingroup protocolbundle_default
96 struct ICMPv6EchoReplyType
97 : public PacketTypeBase,
98 public PacketTypeMixin<ICMPv6EchoReplyType>
100 typedef PacketTypeMixin<ICMPv6EchoReplyType> mixin;
101 typedef ConcretePacket<ICMPv6EchoReplyType> packet;
102 typedef ICMPv6EchoReplyParser parser;
104 using mixin::nextPacketRange;
106 using mixin::initSize;
109 typedef ConcretePacket<ICMPv6EchoReplyType> ICMPv6EchoReply;
111 //#############################################################
112 //ICMPv6 Error Destination Unreachable Message
113 //#############################################################
114 struct ICMPv6ErrDestUnreachableParser : public PacketParserBase
116 # include SENF_FIXED_PARSER()
118 //should be set static 0 by sender and ignored by receiver
119 SENF_PARSER_PRIVATE_FIELD ( unused, UInt32Parser );
124 /* Code 0 - No route to destination
125 1 - Communication with destination
126 administratively prohibited
127 2 - Beyond scope of source address
128 3 - Address unreachable
130 5 - Source address failed ingress/egress policy
131 6 - Reject route to destination */
132 void setErrCode(int code) {
133 ICMPv6Packet icmpv6 (senf::Packet().rfind<ICMPv6Packet>(senf::nothrow));
134 icmpv6->code() = code;
137 SENF_PARSER_FINALIZE ( ICMPv6ErrDestUnreachableParser );
140 /** \brief ICMPv6 Destination unreachable
142 \par Packet type (typedef):
143 \ref ICMPv6ErrDestUnreachable
146 \ref ICMPv6ErrDestUnreachableParser
147 \image html ICMPv6ErrDestUnreachable.png
149 \ingroup protocolbundle_default
151 struct ICMPv6ErrDestUnreachableType
152 : public PacketTypeBase,
153 public PacketTypeMixin<ICMPv6ErrDestUnreachableType>
155 typedef PacketTypeMixin<ICMPv6ErrDestUnreachableType> mixin;
156 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> packet;
157 typedef ICMPv6ErrDestUnreachableParser parser;
159 using mixin::nextPacketRange;
161 using mixin::initSize;
164 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> ICMPv6ErrDestUnreachable;
166 //#############################################################
167 //ICMPv6 Error Packet Too Big Message
168 //#############################################################
169 struct ICMPv6ErrTooBigParser : public PacketParserBase
171 # include SENF_FIXED_PARSER()
172 SENF_PARSER_FIELD ( mtu, UInt32Parser );
174 /* Code static set to 0 */
175 // SENF_PARSER_INIT() {
176 // ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
177 // icmpv6->code() = 0;
180 SENF_PARSER_FINALIZE ( ICMPv6ErrTooBigParser );
183 /** \brief ICMPv6 Packet to big
185 \par Packet type (typedef):
189 \ref ICMPv6ErrTooBigParser
190 \image html ICMPv6ErrTooBig.png
192 \ingroup protocolbundle_default
194 struct ICMPv6ErrTooBigType
195 : public PacketTypeBase,
196 public PacketTypeMixin<ICMPv6ErrTooBigType>
198 typedef PacketTypeMixin<ICMPv6ErrTooBigType> mixin;
199 typedef ConcretePacket<ICMPv6ErrTooBigType> packet;
200 typedef ICMPv6ErrTooBigParser parser;
202 using mixin::nextPacketRange;
204 using mixin::initSize;
207 typedef ConcretePacket<ICMPv6ErrTooBigType> ICMPv6ErrTooBig;
209 //#############################################################
210 //ICMPv6 Error Time Exceeded Message
211 //#############################################################
212 struct ICMPv6ErrTimeExceededParser : public PacketParserBase
214 # include SENF_FIXED_PARSER()
215 //should be set static 0 by sender and ignored by receiver
216 SENF_PARSER_FIELD ( unused, UInt32Parser );
217 /* Code 0 - Hop limit exceeded in transit
218 1 - Fragment reassembly time exceeded */
219 void setErrCode(int code){
220 ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
221 icmpv6->code() = code;
224 SENF_PARSER_FINALIZE ( ICMPv6ErrTimeExceededParser );
227 /** \brief ICMPv6 Time exceeded
229 \par Packet type (typedef):
230 \ref ICMPv6ErrTimeExceeded
233 \ref ICMPv6ErrTimeExceededParser
234 \image html ICMPv6ErrTimeExceeded.png
236 \ingroup protocolbundle_default
238 struct ICMPv6ErrTimeExceededType
239 : public PacketTypeBase,
240 public PacketTypeMixin<ICMPv6ErrTimeExceededType>
242 typedef PacketTypeMixin<ICMPv6ErrTimeExceededType> mixin;
243 typedef ConcretePacket<ICMPv6ErrTimeExceededType> packet;
244 typedef ICMPv6ErrTimeExceededParser parser;
246 using mixin::nextPacketRange;
248 using mixin::initSize;
250 typedef ConcretePacket<ICMPv6ErrTimeExceededType> ICMPv6ErrTimeExceeded;
252 //#############################################################
253 //ICMPv6 Error Parameter Problem Message
254 //#############################################################
255 struct ICMPv6ErrParamProblemParser : public PacketParserBase
257 # include SENF_FIXED_PARSER()
258 //should be set static 0 by sender and ignored by receiver
259 SENF_PARSER_FIELD ( pointer, UInt32Parser );
260 /* Code 0 - Erroneous header field encountered
261 1 - Unrecognized Next Header type encountered
262 2 - Unrecognized IPv6 option encountered */
264 void setErrCode(int code){
265 ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
266 icmpv6->code() = code;
268 SENF_PARSER_FINALIZE ( ICMPv6ErrParamProblemParser );
271 /** \brief ICMPv6 Parameter problem
273 \par Packet type (typedef):
274 \ref ICMPv6ErrParamProblem
277 \ref ICMPv6ErrParamProblemParser
278 \image html ICMPv6ErrParamProblem.png
280 \ingroup protocolbundle_default
282 struct ICMPv6ErrParamProblemType
283 : public PacketTypeBase,
284 public PacketTypeMixin<ICMPv6ErrParamProblemType>
286 typedef PacketTypeMixin<ICMPv6ErrParamProblemType> mixin;
287 typedef ConcretePacket<ICMPv6ErrParamProblemType> packet;
288 typedef ICMPv6ErrParamProblemParser parser;
290 using mixin::nextPacketRange;
292 using mixin::initSize;
294 typedef ConcretePacket<ICMPv6ErrParamProblemType> ICMPv6ErrParamProblem;
296 //#############################################################
297 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Query
298 //#############################################################
299 struct MLDv2ListenerQueryParser : public PacketParserBase
301 # include SENF_PARSER()
302 //need a variant here
303 // a.) maxResponseCode < 32768 =>Interger
304 // b.) maxResponseCode >=32768 => float (is there a float parser???)
306 float value as followed:
307 0 1 2 3 4 5 6 7 8 9 A B C D E F
308 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
310 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
312 SENF_PARSER_FIELD ( maxResponseCode, UInt16Parser );
313 SENF_PARSER_FIELD ( reserved, UInt16Parser ); // set to zero by default
314 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser );
315 SENF_PARSER_BITFIELD ( resv, 4, unsigned ); // set to zero by default
316 SENF_PARSER_BITFIELD ( sFlag, 1, unsigned );
317 SENF_PARSER_BITFIELD ( qrv, 3, unsigned );
318 SENF_PARSER_FIELD ( qqic, UInt8Parser );
319 SENF_PARSER_PRIVATE_FIELD ( nrSources, UInt16Parser );
320 SENF_PARSER_VECTOR (srcAddresses, nrSources, INet6AddressParser );
322 SENF_PARSER_FINALIZE ( MLDv2ListenerQueryParser );
330 /** \brief MLDv2 Listener query
332 \par Packet type (typedef):
333 \ref MLDv2ListenerQuery
336 \ref MLDv2ListenerQueryParser
337 \image html MLDv2ListenerQuery.png
339 \ingroup protocolbundle_default
341 struct MLDv2ListenerQueryType
342 : public PacketTypeBase,
343 public PacketTypeMixin<MLDv2ListenerQueryType>
345 typedef PacketTypeMixin<MLDv2ListenerQueryType> mixin;
346 typedef ConcretePacket<MLDv2ListenerQueryType> packet;
347 typedef MLDv2ListenerQueryParser parser;
349 using mixin::nextPacketRange;
351 using mixin::initSize;
354 typedef ConcretePacket<MLDv2ListenerQueryType> MLDv2ListenerQuery;
356 //#############################################################
357 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Report Message
358 //#############################################################
359 //First: the Multicast Address Record Parser
360 struct MLDv2AddressRecordParser : public PacketParserBase
362 # include SENF_PARSER()
364 SENF_PARSER_FIELD ( recordType, UInt8Parser );
365 SENF_PARSER_PRIVATE_FIELD ( auxDataLen, UInt8Parser );
366 SENF_PARSER_PRIVATE_FIELD ( nrOfSrcs, UInt16Parser );
367 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser);
368 SENF_PARSER_VECTOR ( srcAddresses, nrOfSrcs, INet6AddressParser );
369 SENF_PARSER_VECTOR ( auxData, auxDataLen, UInt32Parser );
371 SENF_PARSER_FINALIZE ( MLDv2AddressRecordParser );
374 struct MLDv2ListenerReportParser : public PacketParserBase
376 # include SENF_PARSER()
378 SENF_PARSER_FIELD ( reserved, UInt16Parser ); //set to zero by default
379 SENF_PARSER_PRIVATE_FIELD ( nrMcastAddrRecords_, UInt16Parser );
380 SENF_PARSER_LIST ( mcastAddrRecords, nrMcastAddrRecords_, MLDv2AddressRecordParser );
382 SENF_PARSER_FINALIZE ( MLDv2ListenerReportParser );
389 /** \brief MLDv2 Listener report
391 \par Packet type (typedef):
392 \ref MLDv2ListenerReport
395 \ref MLDv2ListenerReportParser
396 \image html MLDv2ListenerReport.png
397 \image html MLDv2AddressRecord.png
399 \ingroup protocolbundle_default
401 struct MLDv2ListenerReportType
402 : public PacketTypeBase,
403 public PacketTypeMixin<MLDv2ListenerReportType>
405 typedef PacketTypeMixin<MLDv2ListenerReportType> mixin;
406 typedef ConcretePacket<MLDv2ListenerReportType> packet;
407 typedef MLDv2ListenerReportParser parser;
409 using mixin::nextPacketRange;
411 using mixin::initSize;
414 typedef ConcretePacket<MLDv2ListenerReportType> MLDv2ListenerReport;
423 // c-file-style: "senf"
424 // indent-tabs-mode: nil
425 // ispell-local-dictionary: "american"
426 // compile-command: "scons -u test"
427 // comment-column: 40