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
31 /** @brief first 4 byte of ICMP header (v4 and v6)
33 * In ICMP v4, the first 4 bytes are standardized, the other 4 depend on
34 * message type. In Icmp v6, the header IS only the first 4 bytes.
35 * So everything after those first 4 bytes is contained in IcmpData subclasses
42 IcmpHeader(const uint8_t type_arg, const uint8_t code_arg);
44 std::istream& read(std::istream &is);
45 std::ostream& write(std::ostream &os) const;
47 uint8_t get_type() const;
48 uint8_t get_code() const;
49 uint16_t get_checksum() const;
51 void calc_checksum( const uint32_t body_checksum_part );
53 // returns the amount of data represented by this class;
54 // for Icmp v4, the header is actually 8 bytes, see comments above
55 uint16_t get_header_length() const;
57 std::string to_string() const;
59 friend std::istream& operator>>(
63 friend std::ostream& operator<<(
65 const IcmpHeader &header
76 // (created using vim -- the world's best text editor)