// Copyright (c) 2003-2010 Christopher M. Kohlhoff // Modifications (c) 2011 by Guilherme Maciel Ferreira / Intra2net AG // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef IPV4_HEADER_H #define IPV4_HEADER_H #include #include #include "ip/ipheader.h" //----------------------------------------------------------------------------- // Ipv4Header //----------------------------------------------------------------------------- /** * @brief This class represents the IP version 4 Packet Header. * * The IPv4 header format is: * * @code * 0 3 4 7 8 15 16 31 * +-------+-------+---------------+------------------------------+ --- * | | | | | ^ * |version|header | differentiated| total length in bytes | | * | (4) | length| services | | | * +-------+-------+---------------+-+-+-+------------------------+ | * | | | | | | | * | identification |0|D|M| fragment offset | | * | | |F|F| | | * +---------------+---------------+-+-+-+------------------------+ | * | | | | | * | time to live | protocol | header checksum | 20 bytes * | | | | | * +---------------+---------------+------------------------------+ | * | | | * | source IPv4 address | | * | | | * +--------------------------------------------------------------+ | * | | | * | destination IPv4 address | | * | | v * +--------------------------------------------------------------+ --- * | | ^ * | | | * / options (if any) / 0 - 40 * / / bytes * | | | * | | v * +--------------------------------------------------------------+ --- * @endcode */ class Ipv4Header : public IpHeader { public: Ipv4Header(); uint8_t get_version() const; uint16_t get_header_length() const; uint8_t get_differentiated_services() const; uint16_t get_total_length() const; uint16_t get_identification() const; bool dont_fragment() const; bool more_fragments() const; uint16_t get_fragment_offset() const; uint8_t get_time_to_live() const; uint8_t get_protocol() const; uint16_t get_header_checksum() const; boost::asio::ip::address get_source_address() const; boost::asio::ip::address get_destination_address() const; friend std::istream &operator>>( std::istream &is, Ipv4Header &header ); }; #endif // IPV4_HEADER_H