/* The software in this package is distributed under the GNU General Public License version 2 (with a special exception described below). A copy of GNU General Public License (GPL) is included in this distribution, in the file COPYING.GPL. As a special exception, if other files instantiate templates or use macros or inline functions from this file, or you compile this file and link it with other works to produce a work based on this file, this file does not by itself cause the resulting work to be covered by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License. This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. Christian Herdtweck, Intra2net AG 2015 Based on an example in Boost Documentation (by Christopher M. Kohlhoff) and adaptation by Guilherme M. Ferreira */ #ifndef ICMP_DATA_PING_FAIL_REPLY_H #define ICMP_DATA_PING_FAIL_REPLY_H #include #include "icmp/icmpdata.h" /** * structure of DestinationUnreachable or TimeExceeded or Source Quench packets * if originated from an ICMP request: * +---------------------------+ * | reply IP header | 20/40 bytes --> not contained in here * +---------------------------+ * | reply ICMP header: | * | type | code | checksum | 4 byte --> not contained in here ! * | 4 uninteresting bytes | 4 byte --> contained in here! * +---------------------------+ * | request | 20 / 40 bytes * | IP header | for IP v4 / v6 * +---------------------------+ * | request ICMP packet: | * | type | code | checksum | 1+1+2 byte * | identifier | seq. number | 2+2 byte * | data | 4 byte * | data | 4 byte * +---------------------------+ * (where "in here" means in variable raw_data of class * IcmpData_PingFailReply) * * see also: https://tools.ietf.org/html/rfc792 (ICMP v4) * https://tools.ietf.org/html/rfc4443 (ICMP v6) * http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol * http://en.wikipedia.org/wiki/ICMPv6 */ /** * contains the request IP and ICMP header and possibly more data from request */ class IcmpData_PingFailReply : public IcmpData { public: IcmpData_PingFailReply(const std::size_t size_arg); bool match_echo_reply(const uint16_t identifier, const uint16_t sequence_number) const; // not implementing match_destination_unreachable nor match_time_exceeded uint16_t get_icmp_identifier() const; uint16_t get_icmp_sequence_number() const; uint8_t get_ip_ttl() const; int get_icmp_data_offset() const; // not implementing print nor to_string protected: uint16_t get_icmp_request_data(const int icmp_start_byte) const; bool match_ping_request(const uint16_t identifier, const uint16_t sequence_number) const; }; #endif