remove the footer saying that vim is the best editor -- anyone knows anyway
[pingcheck] / src / icmp / icmpdata_pingfailreply.h
CommitLineData
15023b99
CH
1/*
2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
4
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
7
8 As a special exception, if other files instantiate templates or use macros
9 or inline functions from this file, or you compile this file and link it
10 with other works to produce a work based on this file, this file
11 does not by itself cause the resulting work to be covered
12 by the GNU General Public License.
13
14 However the source code for this file must still be made available
15 in accordance with section (3) of the GNU General Public License.
16
17 This exception does not invalidate any other reasons why a work based
18 on this file might be covered by the GNU General Public License.
19
20 Christian Herdtweck, Intra2net AG 2015
21 Based on an example in Boost Documentation (by Christopher M. Kohlhoff)
22 and adaptation by Guilherme M. Ferreira
23 */
24
25
26#ifndef ICMP_DATA_PING_FAIL_REPLY_H
27#define ICMP_DATA_PING_FAIL_REPLY_H
28
29#include <stdint.h>
30#include "icmp/icmpdata.h"
31
32/**
33 * structure of DestinationUnreachable or TimeExceeded or Source Quench packets
34 * if originated from an ICMP request:
35 * +---------------------------+
36 * | reply IP header | 20/40 bytes --> not contained in here
37 * +---------------------------+
38 * | reply ICMP header: |
39 * | type | code | checksum | 4 byte --> not contained in here !
40 * | 4 uninteresting bytes | 4 byte --> contained in here!
41 * +---------------------------+
42 * | request | 20 / 40 bytes
43 * | IP header | for IP v4 / v6
44 * +---------------------------+
45 * | request ICMP packet: |
46 * | type | code | checksum | 1+1+2 byte
47 * | identifier | seq. number | 2+2 byte
48 * | data | 4 byte
49 * | data | 4 byte
50 * +---------------------------+
51 * (where "in here" means in variable raw_data of class
52 * IcmpData_PingFailReply)
53 *
54 * see also: https://tools.ietf.org/html/rfc792 (ICMP v4)
55 * https://tools.ietf.org/html/rfc4443 (ICMP v6)
56 * http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol
57 * http://en.wikipedia.org/wiki/ICMPv6
58 */
59
60/**
61 * contains the request IP and ICMP header and possibly more data from request
62 */
63class IcmpData_PingFailReply : public IcmpData
64{
65public:
66 IcmpData_PingFailReply(const std::size_t size_arg);
67
68 bool match_echo_reply(const uint16_t identifier,
69 const uint16_t sequence_number) const;
70
71 // not implementing match_destination_unreachable nor match_time_exceeded
72
73 uint16_t get_icmp_identifier() const;
74
75 uint16_t get_icmp_sequence_number() const;
76
7edd33cf
CH
77 uint8_t get_ip_ttl() const;
78
aadc7032
CH
79 int get_icmp_data_offset() const;
80
15023b99
CH
81 // not implementing print nor to_string
82
83protected:
7edd33cf 84 uint16_t get_icmp_request_data(const int icmp_start_byte) const;
15023b99
CH
85 bool match_ping_request(const uint16_t identifier,
86 const uint16_t sequence_number) const;
87
88};
89
90#endif
91