1 // Copyright (c) 2003-2010 Christopher M. Kohlhoff
2 // Modifications (c) 2011 by Guilherme Maciel Ferreira / Intra2net AG
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
12 #include <boost/asio/ip/address_v4.hpp>
14 #include "ip/ipheader.h"
15 #include "host/messagepayload.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
22 * @brief This class represents the IP version 4 Packet Header.
24 * The IPv4 header format is:
28 * +-------+-------+---------------+------------------------------+ ---
30 * |version|header | differentiated| total length in bytes | |
31 * | (4) | length| services | | |
32 * +-------+-------+---------------+-+-+-+------------------------+ |
34 * | identification |0|D|M| fragment offset | |
36 * +---------------+---------------+-+-+-+------------------------+ |
38 * | time to live | protocol | header checksum | 20 bytes
40 * +---------------+---------------+------------------------------+ |
42 * | source IPv4 address | |
44 * +--------------------------------------------------------------+ |
46 * | destination IPv4 address | |
48 * +--------------------------------------------------------------+ ---
51 * / options (if any) / 0 - 40
55 * +--------------------------------------------------------------+ ---
58 class Ipv4Header : public IpHeader
63 uint8_t get_version() const;
64 uint16_t get_header_length() const;
65 uint8_t get_differentiated_services() const;
66 uint16_t get_total_length() const;
68 uint16_t get_identification() const;
69 bool dont_fragment() const;
70 bool more_fragments() const;
71 uint16_t get_fragment_offset() const;
73 uint8_t get_time_to_live() const;
74 uint8_t get_protocol() const;
75 uint16_t get_header_checksum() const;
77 boost::asio::ip::address get_source_address() const;
78 boost::asio::ip::address get_destination_address() const;
80 friend std::istream &operator>>(
86 MessagePayload Payload;
90 #endif // IPV4_HEADER_H