Replace all relative includes with abolute ones
[senf.git] / senf / Packets / DefaultBundle / ICMPv6TypePacket.hh
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Philipp Batroff <pug@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 // Definition of non-inline non-template functions
24
25 #ifndef HH_SENF_Packets_DefaultBundle_ICMPv6TypePacket_
26 #define HH_SENF_Packets_DefaultBundle_ICMPv6TypePacket_ 1
27
28 // Custom includes
29 #include <senf/Packets/Packets.hh>
30 #include "IPv6Packet.hh"
31 #include "ICMPv6Packet.hh"
32
33 namespace senf {
34
35     //#############################################################
36     //ICMPv6 Echo Request
37     //#############################################################
38     struct ICMPv6EchoRequestParser : public PacketParserBase
39     {
40 #       include SENF_FIXED_PARSER()
41         SENF_PARSER_FIELD ( identifier, UInt16Parser );
42         SENF_PARSER_FIELD ( seqNr,      UInt16Parser );
43         
44         SENF_PARSER_FINALIZE ( ICMPv6EchoRequestParser );
45     };
46     
47     /** \brief ICMPv6 Echo Request
48
49         \par Packet type (typedef):
50             \ref ICMPv6EchoRequest
51
52         \par Fields:
53             \ref ICMPv6EchoRequestParser
54             \image html ICMPv6EchoRequest.png
55
56         \ingroup protocolbundle_default
57      */
58     struct ICMPv6EchoRequestType
59         : public PacketTypeBase,
60           public PacketTypeMixin<ICMPv6EchoRequestType>
61     {
62         typedef PacketTypeMixin<ICMPv6EchoRequestType> mixin;
63         typedef ConcretePacket<ICMPv6EchoRequestType> packet;
64         typedef ICMPv6EchoRequestParser parser;
65         
66         using mixin::nextPacketRange;
67         using mixin::init;
68         using mixin::initSize;
69     };
70     
71     typedef ConcretePacket<ICMPv6EchoRequestType> ICMPv6EchoRequest;
72     
73     //#############################################################
74     //ICMPv6 Echo Reply
75     //#############################################################
76     struct ICMPv6EchoReplyParser : public PacketParserBase
77     {
78 #       include SENF_FIXED_PARSER()
79         SENF_PARSER_FIELD ( identifier, UInt16Parser );
80         SENF_PARSER_FIELD ( seqNr,      UInt16Parser );
81         
82         SENF_PARSER_FINALIZE ( ICMPv6EchoReplyParser );
83     };
84     
85     /** \brief ICMPv6 Echo Reply
86
87         \par Packet type (typedef):
88             \ref ICMPv6EchoReply
89
90         \par Fields:
91             \ref ICMPv6EchoReplyParser
92             \image html ICMPv6EchoReply.png
93
94         \ingroup protocolbundle_default
95      */
96     struct ICMPv6EchoReplyType
97         : public PacketTypeBase,
98           public PacketTypeMixin<ICMPv6EchoReplyType>
99     {
100         typedef PacketTypeMixin<ICMPv6EchoReplyType> mixin;
101         typedef ConcretePacket<ICMPv6EchoReplyType> packet;
102         typedef ICMPv6EchoReplyParser parser;
103         
104         using mixin::nextPacketRange;
105         using mixin::init;
106         using mixin::initSize;
107     };
108         
109     typedef ConcretePacket<ICMPv6EchoReplyType> ICMPv6EchoReply;
110     
111     //#############################################################
112     //ICMPv6 Error Destination Unreachable Message
113     //#############################################################
114     struct ICMPv6ErrDestUnreachableParser : public PacketParserBase
115     {
116 #       include SENF_FIXED_PARSER()
117         
118         //should be set static 0 by sender and ignored by receiver
119         SENF_PARSER_PRIVATE_FIELD ( unused, UInt32Parser );
120         
121         SENF_PARSER_INIT() { 
122             unused() = 0; 
123         }
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
129                     4 - Port 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;
135         }
136         
137         SENF_PARSER_FINALIZE ( ICMPv6ErrDestUnreachableParser );
138     };
139     
140     /** \brief ICMPv6 Destination unreachable
141
142         \par Packet type (typedef):
143             \ref ICMPv6ErrDestUnreachable
144
145         \par Fields:
146             \ref ICMPv6ErrDestUnreachableParser
147             \image html ICMPv6ErrDestUnreachable.png
148  
149         \ingroup protocolbundle_default
150     */
151     struct ICMPv6ErrDestUnreachableType
152         : public PacketTypeBase,
153           public PacketTypeMixin<ICMPv6ErrDestUnreachableType>
154     {
155         typedef PacketTypeMixin<ICMPv6ErrDestUnreachableType> mixin;
156         typedef ConcretePacket<ICMPv6ErrDestUnreachableType> packet;
157         typedef ICMPv6ErrDestUnreachableParser parser;
158         
159         using mixin::nextPacketRange;
160         using mixin::init;
161         using mixin::initSize;
162     };
163         
164     typedef ConcretePacket<ICMPv6ErrDestUnreachableType> ICMPv6ErrDestUnreachable;
165     
166     //#############################################################
167     //ICMPv6 Error Packet Too Big Message
168     //#############################################################
169     struct ICMPv6ErrTooBigParser : public PacketParserBase
170     {
171 #       include SENF_FIXED_PARSER()
172         SENF_PARSER_FIELD ( mtu, UInt32Parser );
173     
174         /*   Code     static set to 0       */
175     //     SENF_PARSER_INIT() {
176     //         ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
177     //         icmpv6->code() = 0;
178     //     }
179         
180         SENF_PARSER_FINALIZE ( ICMPv6ErrTooBigParser );
181     };
182     
183     /** \brief ICMPv6 Packet to big
184
185         \par Packet type (typedef):
186             \ref ICMPv6ErrTooBig
187
188         \par Fields:
189             \ref ICMPv6ErrTooBigParser
190             \image html ICMPv6ErrTooBig.png
191
192         \ingroup protocolbundle_default
193      */
194     struct ICMPv6ErrTooBigType
195         : public PacketTypeBase,
196           public PacketTypeMixin<ICMPv6ErrTooBigType>
197     {
198         typedef PacketTypeMixin<ICMPv6ErrTooBigType> mixin;
199         typedef ConcretePacket<ICMPv6ErrTooBigType> packet;
200         typedef ICMPv6ErrTooBigParser parser;
201         
202         using mixin::nextPacketRange;
203         using mixin::init;
204         using mixin::initSize;
205     };
206
207     typedef ConcretePacket<ICMPv6ErrTooBigType> ICMPv6ErrTooBig;
208     
209     //#############################################################
210     //ICMPv6 Error Time Exceeded Message
211     //#############################################################
212     struct ICMPv6ErrTimeExceededParser : public PacketParserBase
213     {
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;
222         }
223         
224         SENF_PARSER_FINALIZE ( ICMPv6ErrTimeExceededParser );
225     };
226     
227     /** \brief ICMPv6 Time exceeded
228
229         \par Packet type (typedef):
230             \ref ICMPv6ErrTimeExceeded
231
232         \par Fields:
233             \ref ICMPv6ErrTimeExceededParser
234             \image html ICMPv6ErrTimeExceeded.png
235
236         \ingroup protocolbundle_default
237      */
238     struct ICMPv6ErrTimeExceededType
239         : public PacketTypeBase,
240           public PacketTypeMixin<ICMPv6ErrTimeExceededType>
241     {
242         typedef PacketTypeMixin<ICMPv6ErrTimeExceededType> mixin;
243         typedef ConcretePacket<ICMPv6ErrTimeExceededType> packet;
244         typedef ICMPv6ErrTimeExceededParser parser;
245         
246         using mixin::nextPacketRange;
247         using mixin::init;
248         using mixin::initSize;
249     };
250     typedef ConcretePacket<ICMPv6ErrTimeExceededType> ICMPv6ErrTimeExceeded;
251     
252     //#############################################################
253     //ICMPv6 Error Parameter Problem Message
254     //#############################################################
255     struct ICMPv6ErrParamProblemParser : public PacketParserBase
256     {
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          */
263         
264         void setErrCode(int code){
265             ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
266             icmpv6->code() = code;
267         }
268         SENF_PARSER_FINALIZE ( ICMPv6ErrParamProblemParser );
269     };
270     
271     /** \brief ICMPv6 Parameter problem
272
273         \par Packet type (typedef):
274             \ref ICMPv6ErrParamProblem
275
276         \par Fields:
277             \ref ICMPv6ErrParamProblemParser
278             \image html ICMPv6ErrParamProblem.png
279
280         \ingroup protocolbundle_default
281      */
282     struct ICMPv6ErrParamProblemType
283         : public PacketTypeBase,
284           public PacketTypeMixin<ICMPv6ErrParamProblemType>
285     {
286         typedef PacketTypeMixin<ICMPv6ErrParamProblemType> mixin;
287         typedef ConcretePacket<ICMPv6ErrParamProblemType> packet;
288         typedef ICMPv6ErrParamProblemParser parser;
289         
290         using mixin::nextPacketRange;
291         using mixin::init;
292         using mixin::initSize;
293     };
294     typedef ConcretePacket<ICMPv6ErrParamProblemType> ICMPv6ErrParamProblem;
295     
296     //#############################################################
297     //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Query
298     //#############################################################
299     struct MLDv2ListenerQueryParser : public PacketParserBase
300     {
301 #      include SENF_PARSER()
302         //need a variant here
303         // a.) maxResponseCode < 32768 =>Interger
304         // b.) maxResponseCode >=32768 => float (is there a float parser???)
305         /* 
306         float value as followed: 
307         0 1 2 3 4 5 6 7 8 9 A B C D E F
308         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
309         |1| exp |          mant         |
310         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
311         
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 );
321         
322         SENF_PARSER_FINALIZE ( MLDv2ListenerQueryParser );
323         
324         SENF_PARSER_INIT() { 
325             reserved() = 0; 
326             resv() = 0;
327         }
328     };
329     
330     /** \brief MLDv2 Listener query
331
332         \par Packet type (typedef):
333             \ref MLDv2ListenerQuery
334
335         \par Fields:
336             \ref MLDv2ListenerQueryParser
337             \image html MLDv2ListenerQuery.png
338
339         \ingroup protocolbundle_default
340      */
341     struct MLDv2ListenerQueryType
342         : public PacketTypeBase,
343           public PacketTypeMixin<MLDv2ListenerQueryType>
344     {
345         typedef PacketTypeMixin<MLDv2ListenerQueryType> mixin;
346         typedef ConcretePacket<MLDv2ListenerQueryType> packet;
347         typedef MLDv2ListenerQueryParser parser;
348         
349         using mixin::nextPacketRange;
350         using mixin::init;
351         using mixin::initSize;
352     };
353         
354     typedef ConcretePacket<MLDv2ListenerQueryType> MLDv2ListenerQuery;
355     
356     //#############################################################
357     //ICMPv6 MLDv2 (RFC 3810) Multicast Listener Report Message
358     //#############################################################
359     //First: the Multicast Address Record Parser
360     struct MLDv2AddressRecordParser : public PacketParserBase
361     {
362 #       include SENF_PARSER()
363         
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 );
370         
371         SENF_PARSER_FINALIZE ( MLDv2AddressRecordParser );
372     };
373     
374     struct MLDv2ListenerReportParser : public PacketParserBase
375     {
376 #       include SENF_PARSER()
377         
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 );
381         
382         SENF_PARSER_FINALIZE ( MLDv2ListenerReportParser );
383         
384         SENF_PARSER_INIT() { 
385             reserved() = 0; 
386         }
387     };
388     
389     /** \brief MLDv2 Listener report
390
391         \par Packet type (typedef):
392             \ref MLDv2ListenerReport
393
394         \par Fields:
395             \ref MLDv2ListenerReportParser
396             \image html MLDv2ListenerReport.png
397             \image html MLDv2AddressRecord.png
398
399         \ingroup protocolbundle_default
400      */
401     struct MLDv2ListenerReportType
402         : public PacketTypeBase,
403           public PacketTypeMixin<MLDv2ListenerReportType>
404     {
405         typedef PacketTypeMixin<MLDv2ListenerReportType> mixin;
406         typedef ConcretePacket<MLDv2ListenerReportType> packet;
407         typedef MLDv2ListenerReportParser parser;
408         
409         using mixin::nextPacketRange;
410         using mixin::init;
411         using mixin::initSize;
412     };
413         
414     typedef ConcretePacket<MLDv2ListenerReportType> MLDv2ListenerReport;
415 }
416
417 #endif
418
419 \f
420 // Local Variables:
421 // mode: c++
422 // fill-column: 100
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
428 // End: