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/Packets.hh"
30 #include "ICMPv6Packet.hh"
34 //#############################################################
36 //#############################################################
37 struct ICMPv6EchoRequestParser : public PacketParserBase
39 # include SENF_FIXED_PARSER()
40 SENF_PARSER_FIELD ( identifier, UInt16Parser );
41 SENF_PARSER_FIELD ( seqNr, UInt16Parser );
43 SENF_PARSER_FINALIZE ( ICMPv6EchoRequestParser );
46 /** \brief ICMPv6 Echo Request
48 \par Packet type (typedef):
49 \ref ICMPv6EchoRequest
52 \ref ICMPv6EchoRequestParser
53 \image html ICMPv6EchoRequest.png
55 \ingroup protocolbundle_default
57 struct ICMPv6EchoRequestType
58 : public PacketTypeBase,
59 public PacketTypeMixin<ICMPv6EchoRequestType>
61 typedef PacketTypeMixin<ICMPv6EchoRequestType> mixin;
62 typedef ConcretePacket<ICMPv6EchoRequestType> packet;
63 typedef ICMPv6EchoRequestParser parser;
65 using mixin::nextPacketRange;
67 using mixin::initSize;
70 typedef ConcretePacket<ICMPv6EchoRequestType> ICMPv6EchoRequest;
72 //#############################################################
74 //#############################################################
75 struct ICMPv6EchoReplyParser : public PacketParserBase
77 # include SENF_FIXED_PARSER()
78 SENF_PARSER_FIELD ( identifier, UInt16Parser );
79 SENF_PARSER_FIELD ( seqNr, UInt16Parser );
81 SENF_PARSER_FINALIZE ( ICMPv6EchoReplyParser );
84 /** \brief ICMPv6 Echo Reply
86 \par Packet type (typedef):
90 \ref ICMPv6EchoReplyParser
91 \image html ICMPv6EchoReply.png
93 \ingroup protocolbundle_default
95 struct ICMPv6EchoReplyType
96 : public PacketTypeBase,
97 public PacketTypeMixin<ICMPv6EchoReplyType>
99 typedef PacketTypeMixin<ICMPv6EchoReplyType> mixin;
100 typedef ConcretePacket<ICMPv6EchoReplyType> packet;
101 typedef ICMPv6EchoReplyParser parser;
103 using mixin::nextPacketRange;
105 using mixin::initSize;
108 typedef ConcretePacket<ICMPv6EchoReplyType> ICMPv6EchoReply;
110 //#############################################################
111 //ICMPv6 Error Destination Unreachable Message
112 //#############################################################
113 struct ICMPv6ErrDestUnreachableParser : public PacketParserBase
115 # include SENF_FIXED_PARSER()
117 //should be set static 0 by sender and ignored by receiver
118 SENF_PARSER_PRIVATE_FIELD ( unused, UInt32Parser );
123 /* Code 0 - No route to destination
124 1 - Communication with destination
125 administratively prohibited
126 2 - Beyond scope of source address
127 3 - Address unreachable
129 5 - Source address failed ingress/egress policy
130 6 - Reject route to destination */
131 void setErrCode(int code) {
132 ICMPv6Packet icmpv6 (senf::Packet().rfind<ICMPv6Packet>(senf::nothrow));
133 icmpv6->code() = code;
136 SENF_PARSER_FINALIZE ( ICMPv6ErrDestUnreachableParser );
139 /** \brief ICMPv6 Destination unreachable
141 \par Packet type (typedef):
142 \ref ICMPv6ErrDestUnreachable
145 \ref ICMPv6ErrDestUnreachableParser
146 \image html ICMPv6ErrDestUnreachable.png
148 \ingroup protocolbundle_default
150 struct ICMPv6ErrDestUnreachableType
151 : public PacketTypeBase,
152 public PacketTypeMixin<ICMPv6ErrDestUnreachableType>
154 typedef PacketTypeMixin<ICMPv6ErrDestUnreachableType> mixin;
155 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> packet;
156 typedef ICMPv6ErrDestUnreachableParser parser;
158 using mixin::nextPacketRange;
160 using mixin::initSize;
163 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> ICMPv6ErrDestUnreachable;
165 //#############################################################
166 //ICMPv6 Error Packet Too Big Message
167 //#############################################################
168 struct ICMPv6ErrTooBigParser : public PacketParserBase
170 # include SENF_FIXED_PARSER()
171 SENF_PARSER_FIELD ( mtu, UInt32Parser );
173 /* Code static set to 0 */
174 // SENF_PARSER_INIT() {
175 // ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
176 // icmpv6->code() = 0;
179 SENF_PARSER_FINALIZE ( ICMPv6ErrTooBigParser );
182 /** \brief ICMPv6 Packet to big
184 \par Packet type (typedef):
188 \ref ICMPv6ErrTooBigParser
189 \image html ICMPv6ErrTooBig.png
191 \ingroup protocolbundle_default
193 struct ICMPv6ErrTooBigType
194 : public PacketTypeBase,
195 public PacketTypeMixin<ICMPv6ErrTooBigType>
197 typedef PacketTypeMixin<ICMPv6ErrTooBigType> mixin;
198 typedef ConcretePacket<ICMPv6ErrTooBigType> packet;
199 typedef ICMPv6ErrTooBigParser parser;
201 using mixin::nextPacketRange;
203 using mixin::initSize;
206 typedef ConcretePacket<ICMPv6ErrTooBigType> ICMPv6ErrTooBig;
208 //#############################################################
209 //ICMPv6 Error Time Exceeded Message
210 //#############################################################
211 struct ICMPv6ErrTimeExceededParser : public PacketParserBase
213 # include SENF_FIXED_PARSER()
214 //should be set static 0 by sender and ignored by receiver
215 SENF_PARSER_FIELD ( unused, UInt32Parser );
216 /* Code 0 - Hop limit exceeded in transit
217 1 - Fragment reassembly time exceeded */
218 void setErrCode(int code){
219 ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
220 icmpv6->code() = code;
223 SENF_PARSER_FINALIZE ( ICMPv6ErrTimeExceededParser );
226 /** \brief ICMPv6 Time exceeded
228 \par Packet type (typedef):
229 \ref ICMPv6ErrTimeExceeded
232 \ref ICMPv6ErrTimeExceededParser
233 \image html ICMPv6ErrTimeExceeded.png
235 \ingroup protocolbundle_default
237 struct ICMPv6ErrTimeExceededType
238 : public PacketTypeBase,
239 public PacketTypeMixin<ICMPv6ErrTimeExceededType>
241 typedef PacketTypeMixin<ICMPv6ErrTimeExceededType> mixin;
242 typedef ConcretePacket<ICMPv6ErrTimeExceededType> packet;
243 typedef ICMPv6ErrTimeExceededParser parser;
245 using mixin::nextPacketRange;
247 using mixin::initSize;
249 typedef ConcretePacket<ICMPv6ErrTimeExceededType> ICMPv6ErrTimeExceeded;
251 //#############################################################
252 //ICMPv6 Error Parameter Problem Message
253 //#############################################################
254 struct ICMPv6ErrParamProblemParser : public PacketParserBase
256 # include SENF_FIXED_PARSER()
257 //should be set static 0 by sender and ignored by receiver
258 SENF_PARSER_FIELD ( pointer, UInt32Parser );
259 /* Code 0 - Erroneous header field encountered
260 1 - Unrecognized Next Header type encountered
261 2 - Unrecognized IPv6 option encountered */
263 void setErrCode(int code){
264 ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
265 icmpv6->code() = code;
267 SENF_PARSER_FINALIZE ( ICMPv6ErrParamProblemParser );
270 /** \brief ICMPv6 Parameter problem
272 \par Packet type (typedef):
273 \ref ICMPv6ErrParamProblem
276 \ref ICMPv6ErrParamProblemParser
277 \image html ICMPv6ErrParamProblem.png
279 \ingroup protocolbundle_default
281 struct ICMPv6ErrParamProblemType
282 : public PacketTypeBase,
283 public PacketTypeMixin<ICMPv6ErrParamProblemType>
285 typedef PacketTypeMixin<ICMPv6ErrParamProblemType> mixin;
286 typedef ConcretePacket<ICMPv6ErrParamProblemType> packet;
287 typedef ICMPv6ErrParamProblemParser parser;
289 using mixin::nextPacketRange;
291 using mixin::initSize;
293 typedef ConcretePacket<ICMPv6ErrParamProblemType> ICMPv6ErrParamProblem;
295 //#############################################################
296 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Query
297 //#############################################################
298 struct MLDv2ListenerQueryParser : public PacketParserBase
300 # include SENF_PARSER()
301 //need a variant here
302 // a.) maxResponseCode < 32768 =>Interger
303 // b.) maxResponseCode >=32768 => float (is there a float parser???)
305 float value as followed:
306 0 1 2 3 4 5 6 7 8 9 A B C D E F
307 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
309 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
311 SENF_PARSER_FIELD ( maxResponseCode, UInt16Parser );
312 SENF_PARSER_FIELD ( reserved, UInt16Parser ); // set to zero by default
313 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser );
314 SENF_PARSER_BITFIELD ( resv, 4, unsigned ); // set to zero by default
315 SENF_PARSER_BITFIELD ( sFlag, 1, unsigned );
316 SENF_PARSER_BITFIELD ( qrv, 3, unsigned );
317 SENF_PARSER_FIELD ( qqic, UInt8Parser );
318 SENF_PARSER_PRIVATE_FIELD ( nrSources, UInt16Parser );
319 SENF_PARSER_VECTOR (srcAddresses, nrSources, INet6AddressParser );
321 SENF_PARSER_FINALIZE ( MLDv2ListenerQueryParser );
329 /** \brief MLDv2 Listener query
331 \par Packet type (typedef):
332 \ref MLDv2ListenerQuery
335 \ref MLDv2ListenerQueryParser
336 \image html MLDv2ListenerQuery.png
338 \ingroup protocolbundle_default
340 struct MLDv2ListenerQueryType
341 : public PacketTypeBase,
342 public PacketTypeMixin<MLDv2ListenerQueryType>
344 typedef PacketTypeMixin<MLDv2ListenerQueryType> mixin;
345 typedef ConcretePacket<MLDv2ListenerQueryType> packet;
346 typedef MLDv2ListenerQueryParser parser;
348 using mixin::nextPacketRange;
350 using mixin::initSize;
353 typedef ConcretePacket<MLDv2ListenerQueryType> MLDv2ListenerQuery;
355 //#############################################################
356 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Report Message
357 //#############################################################
358 //First: the Multicast Address Record Parser
359 struct MLDv2AddressRecordParser : public PacketParserBase
361 # include SENF_PARSER()
363 SENF_PARSER_FIELD ( recordType, UInt8Parser );
364 SENF_PARSER_PRIVATE_FIELD ( auxDataLen, UInt8Parser );
365 SENF_PARSER_PRIVATE_FIELD ( nrOfSrcs, UInt16Parser );
366 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser);
367 SENF_PARSER_VECTOR ( srcAddresses, nrOfSrcs, INet6AddressParser );
368 SENF_PARSER_VECTOR ( auxData, auxDataLen, UInt32Parser );
370 SENF_PARSER_FINALIZE ( MLDv2AddressRecordParser );
373 struct MLDv2ListenerReportParser : public PacketParserBase
375 # include SENF_PARSER()
377 SENF_PARSER_FIELD ( reserved, UInt16Parser ); //set to zero by default
378 SENF_PARSER_PRIVATE_FIELD ( nrMcastAddrRecords_, UInt16Parser );
379 SENF_PARSER_LIST ( mcastAddrRecords, nrMcastAddrRecords_, MLDv2AddressRecordParser );
381 SENF_PARSER_FINALIZE ( MLDv2ListenerReportParser );
388 /** \brief MLDv2 Listener report
390 \par Packet type (typedef):
391 \ref MLDv2ListenerReport
394 \ref MLDv2ListenerReportParser
395 \image html MLDv2ListenerReport.png
396 \image html MLDv2AddressRecord.png
398 \ingroup protocolbundle_default
400 struct MLDv2ListenerReportType
401 : public PacketTypeBase,
402 public PacketTypeMixin<MLDv2ListenerReportType>
404 typedef PacketTypeMixin<MLDv2ListenerReportType> mixin;
405 typedef ConcretePacket<MLDv2ListenerReportType> packet;
406 typedef MLDv2ListenerReportParser parser;
408 using mixin::nextPacketRange;
410 using mixin::initSize;
413 typedef ConcretePacket<MLDv2ListenerReportType> MLDv2ListenerReport;
422 // c-file-style: "senf"
423 // indent-tabs-mode: nil
424 // ispell-local-dictionary: "american"
425 // compile-command: "scons -u test"
426 // comment-column: 40