3f6eef84fcd61c16740ad2430b4c40bcc7b33d65
[pingcheck] / src / icmp / icmptimeexceededdata.h
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_TIME_EXCEEDED_DATA_H
27 #define ICMP_TIME_EXCEEDED_DATA_H
28
29 #include <stdint.h>
30 #include <boost/date_time/posix_time/ptime.hpp>
31 #include "icmp/icmpdata_pingfailreply.h"
32
33 #include <boost/asio/ip/address.hpp>
34 using boost::asio::ip::address;
35
36 /**
37  * Data for a DestinationUnreachableMessage
38  *
39  * has option to interpret data as containing a Ping packet as reason for
40  *   DestinationUnreachable reply
41  */
42 class IcmpTimeExceededData : public IcmpData_PingFailReply
43 {
44 public:
45     IcmpTimeExceededData(const std::size_t size_arg);
46
47     bool match_time_exceeded(const uint16_t identifier,
48                              const uint16_t sequence_number,
49                              const address &destination_address) const;
50
51     void print( const size_t &bytes_received,
52                 const boost::posix_time::ptime &time_packet_sent,
53                 const std::string &remote_address,
54                 const uint32_t ttl) const;
55
56     std::string to_string() const;
57
58 };
59
60 #endif
61
62 // (created using vim -- the world's best text editor)
63