extended ICMP packet dumping to parts after packet creation
[pingcheck] / src / ip / ipv4header.h
CommitLineData
0c0bb697
TJ
1// Copyright (c) 2003-2010 Christopher M. Kohlhoff
2// Modifications (c) 2011 by Guilherme Maciel Ferreira / Intra2net AG
3//
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)
0e2c8122
GMF
7#ifndef IPV4_HEADER_H
8#define IPV4_HEADER_H
4ea9706c 9
fd6ef587 10#include <stdint.h>
4ea9706c 11
9c55ecd3
GMF
12#include <boost/asio/ip/address_v4.hpp>
13
5d9d2808 14#include "ip/ipheader.h"
01e5134e 15
4c2a5ab5
GMF
16//-----------------------------------------------------------------------------
17// Ipv4Header
18//-----------------------------------------------------------------------------
4ea9706c 19
dfd89091
GMF
20/**
21 * @brief This class represents the IP version 4 Packet Header.
22 *
23 * The IPv4 header format is:
24 *
25 * @code
19adb95f 26 * 0 3 4 7 8 15 16 31
dfd89091
GMF
27 * +-------+-------+---------------+------------------------------+ ---
28 * | | | | | ^
0612cc8a
GMF
29 * |version|header | differentiated| total length in bytes | |
30 * | (4) | length| services | | |
dfd89091
GMF
31 * +-------+-------+---------------+-+-+-+------------------------+ |
32 * | | | | | | |
33 * | identification |0|D|M| fragment offset | |
34 * | | |F|F| | |
35 * +---------------+---------------+-+-+-+------------------------+ |
36 * | | | | |
37 * | time to live | protocol | header checksum | 20 bytes
38 * | | | | |
39 * +---------------+---------------+------------------------------+ |
40 * | | |
41 * | source IPv4 address | |
42 * | | |
43 * +--------------------------------------------------------------+ |
44 * | | |
45 * | destination IPv4 address | |
46 * | | v
47 * +--------------------------------------------------------------+ ---
48 * | | ^
49 * | | |
50 * / options (if any) / 0 - 40
51 * / / bytes
52 * | | |
53 * | | v
54 * +--------------------------------------------------------------+ ---
55 * @endcode
56 */
5d9d2808 57class Ipv4Header : public IpHeader
4ea9706c
GMF
58{
59public:
60 Ipv4Header();
61
fd6ef587
GMF
62 uint8_t get_version() const;
63 uint16_t get_header_length() const;
0612cc8a 64 uint8_t get_differentiated_services() const;
fd6ef587 65 uint16_t get_total_length() const;
4ea9706c 66
64c7fec3 67 uint16_t get_identification() const;
4ea9706c 68 bool dont_fragment() const;
64c7fec3 69 bool more_fragments() const;
fd6ef587 70 uint16_t get_fragment_offset() const;
64c7fec3 71
703f4d65 72 uint8_t get_time_to_live() const;
fd6ef587
GMF
73 uint8_t get_protocol() const;
74 uint16_t get_header_checksum() const;
4ea9706c 75
5d9d2808
CH
76 boost::asio::ip::address get_source_address() const;
77 boost::asio::ip::address get_destination_address() const;
4ea9706c 78
a4049623 79 friend std::istream &operator>>(
cb60ed91
GMF
80 std::istream &is,
81 Ipv4Header &header
82 );
4ea9706c 83
4ea9706c
GMF
84};
85
c85c0309 86#endif // IPV4_HEADER_H