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 struct ICMPv6EchoRequestType
47 : public PacketTypeBase,
48 public PacketTypeMixin<ICMPv6EchoRequestType>
50 typedef PacketTypeMixin<ICMPv6EchoRequestType> mixin;
51 typedef ConcretePacket<ICMPv6EchoRequestType> packet;
52 typedef ICMPv6EchoRequestParser parser;
54 using mixin::nextPacketRange;
56 using mixin::initSize;
59 typedef ConcretePacket<ICMPv6EchoRequestType> ICMPv6EchoRequest;
61 //#############################################################
63 //#############################################################
64 struct ICMPv6EchoReplyParser : public PacketParserBase
66 # include SENF_FIXED_PARSER()
67 SENF_PARSER_FIELD ( identifier, UInt16Parser );
68 SENF_PARSER_FIELD ( seqNr, UInt16Parser );
70 SENF_PARSER_FINALIZE ( ICMPv6EchoReplyParser );
73 struct ICMPv6EchoReplyType
74 : public PacketTypeBase,
75 public PacketTypeMixin<ICMPv6EchoReplyType>
77 typedef PacketTypeMixin<ICMPv6EchoReplyType> mixin;
78 typedef ConcretePacket<ICMPv6EchoReplyType> packet;
79 typedef ICMPv6EchoReplyParser parser;
81 using mixin::nextPacketRange;
83 using mixin::initSize;
86 typedef ConcretePacket<ICMPv6EchoReplyType> ICMPv6EchoReply;
88 //#############################################################
89 //ICMPv6 Error Destination Unreachable Message
90 //#############################################################
91 struct ICMPv6ErrDestUnreachableParser : public PacketParserBase
93 # include SENF_FIXED_PARSER()
95 //should be set static 0 by sender and ignored by receiver
96 SENF_PARSER_PRIVATE_FIELD ( unused, UInt32Parser );
101 /* Code 0 - No route to destination
102 1 - Communication with destination
103 administratively prohibited
104 2 - Beyond scope of source address
105 3 - Address unreachable
107 5 - Source address failed ingress/egress policy
108 6 - Reject route to destination */
109 void setErrCode(int code) {
110 ICMPv6Packet icmpv6 (senf::Packet().rfind<ICMPv6Packet>(senf::nothrow));
111 icmpv6->code() = code;
114 SENF_PARSER_FINALIZE ( ICMPv6ErrDestUnreachableParser );
117 struct ICMPv6ErrDestUnreachableType
118 : public PacketTypeBase,
119 public PacketTypeMixin<ICMPv6ErrDestUnreachableType>
121 typedef PacketTypeMixin<ICMPv6ErrDestUnreachableType> mixin;
122 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> packet;
123 typedef ICMPv6ErrDestUnreachableParser parser;
125 using mixin::nextPacketRange;
127 using mixin::initSize;
130 typedef ConcretePacket<ICMPv6ErrDestUnreachableType> ICMPv6ErrDestUnreachable;
132 //#############################################################
133 //ICMPv6 Error Packet Too Big Message
134 //#############################################################
135 struct ICMPv6ErrTooBigParser : public PacketParserBase
137 # include SENF_FIXED_PARSER()
138 SENF_PARSER_FIELD ( mtu, UInt32Parser );
140 /* Code static set to 0 */
141 // SENF_PARSER_INIT() {
142 // ICMPv6Packet icmpv6 (senf::Packet().rfind<ICMPv6Packet>(senf::nothrow));
143 // icmpv6->code() = 0;
146 SENF_PARSER_FINALIZE ( ICMPv6ErrTooBigParser );
149 struct ICMPv6ErrTooBigType
150 : public PacketTypeBase,
151 public PacketTypeMixin<ICMPv6ErrTooBigType>
153 typedef PacketTypeMixin<ICMPv6ErrTooBigType> mixin;
154 typedef ConcretePacket<ICMPv6ErrTooBigType> packet;
155 typedef ICMPv6ErrTooBigParser parser;
157 using mixin::nextPacketRange;
159 using mixin::initSize;
162 typedef ConcretePacket<ICMPv6ErrTooBigType> ICMPv6ErrTooBig;
164 //#############################################################
165 //ICMPv6 Error Time Exceeded Message
166 //#############################################################
167 struct ICMPv6ErrTimeExceededParser : public PacketParserBase
169 # include SENF_FIXED_PARSER()
170 //should be set static 0 by sender and ignored by receiver
171 SENF_PARSER_FIELD ( unused, UInt32Parser );
172 /* Code 0 - Hop limit exceeded in transit
173 1 - Fragment reassembly time exceeded */
174 void setErrCode(int code){
175 ICMPv6Packet icmpv6 (senf::Packet().rfind<ICMPv6Packet>(senf::nothrow));
176 icmpv6->code() = code;
179 SENF_PARSER_FINALIZE ( ICMPv6ErrTimeExceededParser );
182 struct ICMPv6ErrTimeExceededType
183 : public PacketTypeBase,
184 public PacketTypeMixin<ICMPv6ErrTimeExceededType>
186 typedef PacketTypeMixin<ICMPv6ErrTimeExceededType> mixin;
187 typedef ConcretePacket<ICMPv6ErrTimeExceededType> packet;
188 typedef ICMPv6ErrTimeExceededParser parser;
190 using mixin::nextPacketRange;
192 using mixin::initSize;
194 typedef ConcretePacket<ICMPv6ErrTimeExceededType> ICMPv6ErrTimeExceeded;
196 //#############################################################
197 //ICMPv6 Error Parameter Problem Message
198 //#############################################################
199 struct ICMPv6ErrParamProblemParser : public PacketParserBase
201 # include SENF_FIXED_PARSER()
202 //should be set static 0 by sender and ignored by receiver
203 SENF_PARSER_FIELD ( pointer, UInt32Parser );
204 /* Code 0 - Erroneous header field encountered
205 1 - Unrecognized Next Header type encountered
206 2 - Unrecognized IPv6 option encountered */
208 void setErrCode(int code){
209 ICMPv6Packet icmpv6 (senf::Packet().rfind<ICMPv6Packet>(senf::nothrow));
210 icmpv6->code() = code;
212 SENF_PARSER_FINALIZE ( ICMPv6ErrParamProblemParser );
215 struct ICMPv6ErrParamProblemType
216 : public PacketTypeBase,
217 public PacketTypeMixin<ICMPv6ErrParamProblemType>
219 typedef PacketTypeMixin<ICMPv6ErrParamProblemType> mixin;
220 typedef ConcretePacket<ICMPv6ErrParamProblemType> packet;
221 typedef ICMPv6ErrParamProblemParser parser;
223 using mixin::nextPacketRange;
225 using mixin::initSize;
227 typedef ConcretePacket<ICMPv6ErrParamProblemType> ICMPv6ErrParamProblem;
229 //#############################################################
230 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Query
231 //#############################################################
232 struct MLDv2ListenerQueryParser : public PacketParserBase
234 # include SENF_PARSER()
235 //need a variant here
236 // a.) maxResponseCode < 32768 =>Interger
237 // b.) maxResponseCode >=32768 => float (is there a float parser???)
239 float value as followed:
240 0 1 2 3 4 5 6 7 8 9 A B C D E F
241 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
243 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
245 SENF_PARSER_FIELD ( maxResponseCode, UInt16Parser );
246 SENF_PARSER_FIELD ( reserved, UInt16Parser ); // set to zero by default
247 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser );
248 SENF_PARSER_BITFIELD ( resv, 4, unsigned ); // set to zero by default
249 SENF_PARSER_BITFIELD ( sFlag, 1, unsigned );
250 SENF_PARSER_BITFIELD ( qrv, 3, unsigned );
251 SENF_PARSER_FIELD ( qqic, UInt8Parser );
252 SENF_PARSER_PRIVATE_FIELD ( nrSources, UInt16Parser );
253 SENF_PARSER_VECTOR (srcAddresses, nrSources, INet6AddressParser );
255 SENF_PARSER_FINALIZE ( MLDv2ListenerQueryParser );
263 struct MLDv2ListenerQueryType
264 : public PacketTypeBase,
265 public PacketTypeMixin<MLDv2ListenerQueryType>
267 typedef PacketTypeMixin<MLDv2ListenerQueryType> mixin;
268 typedef ConcretePacket<MLDv2ListenerQueryType> packet;
269 typedef MLDv2ListenerQueryParser parser;
271 using mixin::nextPacketRange;
273 using mixin::initSize;
276 typedef ConcretePacket<MLDv2ListenerQueryType> MLDv2ListenerQuery;
278 //#############################################################
279 //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Report Message
280 //#############################################################
281 //First: the Multicast Address Record Parser
282 struct MLDv2AddressRecordParser : public PacketParserBase
284 # include SENF_PARSER()
286 SENF_PARSER_FIELD ( recordType, UInt8Parser );
287 SENF_PARSER_PRIVATE_FIELD ( auxDataLen, UInt8Parser );
288 SENF_PARSER_PRIVATE_FIELD ( nrOfSrcs, UInt16Parser );
289 SENF_PARSER_FIELD ( mcAddress, INet6AddressParser);
290 SENF_PARSER_VECTOR ( srcAddresses, nrOfSrcs, INet6AddressParser );
291 SENF_PARSER_VECTOR ( auxData, auxDataLen, UInt32Parser );
293 SENF_PARSER_FINALIZE ( MLDv2AddressRecordParser );
296 struct MLDv2ListenerReportParser : public PacketParserBase
298 # include SENF_PARSER()
300 SENF_PARSER_FIELD ( reserved, UInt16Parser ); //set to zero by default
301 SENF_PARSER_PRIVATE_FIELD ( nrMcastAddrRecords_, UInt16Parser );
302 SENF_PARSER_LIST ( mcastAddrRecords, nrMcastAddrRecords_, MLDv2AddressRecordParser );
304 SENF_PARSER_FINALIZE ( MLDv2ListenerReportParser );
311 struct MLDv2ListenerReportType
312 : public PacketTypeBase,
313 public PacketTypeMixin<MLDv2ListenerReportType>
315 typedef PacketTypeMixin<MLDv2ListenerReportType> mixin;
316 typedef ConcretePacket<MLDv2ListenerReportType> packet;
317 typedef MLDv2ListenerReportParser parser;
319 using mixin::nextPacketRange;
321 using mixin::initSize;
324 typedef ConcretePacket<MLDv2ListenerReportType> MLDv2ListenerReport;