2 The software in this package is distributed under the GNU General
3 Public License version 2 (with a special exception described below).
5 A copy of GNU General Public License (GPL) is included in this distribution,
6 in the file COPYING.GPL.
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.
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.
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.
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
30 #include <boost/shared_ptr.hpp>
31 #include <boost/date_time/posix_time/ptime.hpp>
32 #include <boost/asio/ip/address.hpp>
33 #include "host/messagepayload.h"
34 #include "ip/ipheader.h"
36 using boost::asio::ip::address;
38 /** @brief contents of ICMP packets after the first 4 bytes of the ICMP header
39 * used for ICMPv4 and ICMPv6
41 * subclasses only have to specify which part of raw_data to access for which
49 IcmpData(const std::size_t size_arg);
51 virtual ~IcmpData() {};
53 virtual bool match_echo_reply(const uint16_t identifier,
54 const uint16_t sequence_number) const;
56 virtual bool match_destination_unreachable(const uint16_t identifier,
57 const uint16_t sequence_number,
58 const address &destination_address) const;
60 virtual bool match_time_exceeded(const uint16_t identifier,
61 const uint16_t sequence_number,
62 const address &destination_address) const;
64 // including 4 bytes from ICMPv4 header
65 std::size_t get_size() const;
67 IpHeaderPtr get_ip_header() const;
69 uint32_t calc_checksum_part() const;
70 int get_ip_version() const;
72 virtual void print( const size_t &bytes_received,
73 const boost::posix_time::ptime &time_packet_sent,
74 const std::string &remote_address,
75 const uint32_t ttl) const;
77 virtual std::string to_string() const;
79 virtual std::istream& read( std::istream &is);
80 virtual std::ostream& write(std::ostream &os) const;
82 friend std::istream& operator>>(
86 friend std::ostream& operator<<(
94 MessagePayload raw_data;
97 typedef boost::shared_ptr<IcmpData> IcmpDataPtr;