remove the footer saying that vim is the best editor -- anyone knows anyway
[pingcheck] / src / icmp / icmpechodata.h
CommitLineData
c120ad42
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
057e6cc9
CH
21 Based on an example in Boost Documentation (by Christopher M. Kohlhoff)
22 and adaptation by Guilherme M. Ferreira
c120ad42
CH
23 */
24
25#ifndef ICMP_ECHO_DATA_H
26#define ICMP_ECHO_DATA_H
27
28#include <stdint.h>
29#include "icmp/icmpdata.h"
30
31#include <boost/date_time/posix_time/ptime.hpp>
81c26517
CH
32#include <boost/asio/ip/address.hpp>
33using boost::asio::ip::address;
34
c120ad42
CH
35/** @brief Data part of ICMP echo request and echo reply packets
36 *
37 * represents the last 4 bytes of the ICMP header (for v4) and the 8 bytes
38 * of optional data; for v6 this (same amount of?!) data is defined as the
39 * body
40 */
41class IcmpEchoData : public IcmpData
42{
43public:
44 IcmpEchoData(const uint16_t identifier, const uint16_t sequence_number,
0ba8adc0
CH
45 const std::string &optional_data);
46
47 IcmpEchoData(const std::size_t size_arg);
c120ad42
CH
48
49 bool match_destination_unreachable(const uint16_t identifier,
81c26517
CH
50 const uint16_t sequence_number,
51 const address &destination_address) const;
c120ad42
CH
52
53 bool match_echo_reply(const uint16_t identifier,
0ba8adc0 54 const uint16_t sequence_number) const;
c120ad42 55
15023b99
CH
56 bool match_time_exceeded(const uint16_t identifier,
57 const uint16_t sequence_number) const;
58
0ba8adc0 59 uint16_t get_identifier() const;
c120ad42 60
0ba8adc0 61 uint16_t get_sequence_number() const;
c120ad42
CH
62
63 /**
64 * @brief Prints the ICMP echo reply messages.
65 *
66 * @return void
67 */
68 void print( const size_t &bytes_received,
69 const boost::posix_time::ptime &time_packet_sent,
70 const std::string &remote_address,
0ba8adc0
CH
71 const uint32_t ttl) const;
72
73 std::string to_string() const;
c120ad42
CH
74};
75
76#endif
77