31fd8ef39f145b0f3afc21c39cace617b5b90fcc
[pingcheck] / src / ip / ipv6header.h
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)
7 #ifndef IPV6_HEADER_H
8 #define IPV6_HEADER_H
9
10 #include <stdint.h>
11
12 #include <boost/asio/ip/address_v6.hpp>
13
14 #include "ip/ipheader.h"
15 #include "host/messagepayload.h"
16
17 //-----------------------------------------------------------------------------
18 // Ipv6Header
19 //-----------------------------------------------------------------------------
20
21 /**
22  * @brief This class represents the IP version 6 Packet Header.
23  *
24  * The IPv6 header format is:
25  *
26  * @code
27  * 0      3 4            11 12   15 16          23 24            31
28  * +-------+---------------+--------------------------------------+      ---
29  * |       |               |                                      |       ^
30  * |version| traffic class |              flow label              |       |
31  * |  (6)  |               |                                      |       |
32  * +-------+---------------+-------+--------------+---------------+       |
33  * |                               |              |               |       |
34  * |    payload length in bytes    | next header  |   hop limit   |       |
35  * |                               |              |               |       |
36  * +---------------+---------------+--------------+---------------+       |
37  * |                                                              |       |
38  * |                                                              |       |
39  * |                                                              |       |
40  * |                                                              |       |
41  * |                                                              |       |
42  * |                      source IPv6 address                     |       |
43  * |                                                              |   40 bytes
44  * |                                                              |       |
45  * |                                                              |       |
46  * |                                                              |       |
47  * |                                                              |       |
48  * |                                                              |       |
49  * +--------------------------------------------------------------+       |
50  * |                                                              |       |
51  * |                                                              |       |
52  * |                                                              |       |
53  * |                                                              |       |
54  * |                                                              |       |
55  * |                   destination IPv6 address                   |       |
56  * |                                                              |       |
57  * |                                                              |       |
58  * |                                                              |       |
59  * |                                                              |       |
60  * |                                                              |       |
61  * |                                                              |       v
62  * +--------------------------------------------------------------+      ---
63  * @endcode
64  */
65 class Ipv6Header : public IpHeader
66 {
67 public:
68     Ipv6Header();
69
70     uint8_t get_version() const;
71     uint8_t get_differentiated_services() const;
72     uint32_t get_flow_label() const;
73
74     uint16_t get_payload_length() const;
75     uint8_t get_next_header() const;
76     uint8_t get_hop_limit() const;
77
78     uint16_t get_header_length() const;
79
80     uint16_t get_total_length() const;
81
82     // in IPv6, this corresponds to the "HOP limit"
83     uint8_t get_time_to_live() const;
84
85     boost::asio::ip::address get_source_address() const;
86     boost::asio::ip::address get_destination_address() const;
87
88     friend std::istream &operator>>(
89             std::istream &is,
90             Ipv6Header &header
91     );
92
93 private:
94     MessagePayload Payload;
95
96 };
97
98 #endif // IPV6_HEADER_H