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"
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
21 * @brief This class represents the IP version 4 Packet Header.
23 * The IPv4 header format is:
27 * +-------+-------+---------------+------------------------------+ ---
29 * |version|header | differentiated| total length in bytes | |
30 * | (4) | length| services | | |
31 * +-------+-------+---------------+-+-+-+------------------------+ |
33 * | identification |0|D|M| fragment offset | |
35 * +---------------+---------------+-+-+-+------------------------+ |
37 * | time to live | protocol | header checksum | 20 bytes
39 * +---------------+---------------+------------------------------+ |
41 * | source IPv4 address | |
43 * +--------------------------------------------------------------+ |
45 * | destination IPv4 address | |
47 * +--------------------------------------------------------------+ ---
50 * / options (if any) / 0 - 40
54 * +--------------------------------------------------------------+ ---
57 class Ipv4Header : public IpHeader
62 uint8_t get_version() const;
63 uint16_t get_header_length() const;
64 uint8_t get_differentiated_services() const;
65 uint16_t get_total_length() const;
67 uint16_t get_identification() const;
68 bool dont_fragment() const;
69 bool more_fragments() const;
70 uint16_t get_fragment_offset() const;
72 uint8_t get_time_to_live() const;
73 uint8_t get_protocol() const;
74 uint16_t get_header_checksum() const;
76 boost::asio::ip::address get_source_address() const;
77 boost::asio::ip::address get_destination_address() const;
79 friend std::istream &operator>>(
86 #endif // IPV4_HEADER_H