--- /dev/null
+/*
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
+
+#define BOOST_TEST_DYN_LINK
+
+#include <streambuf>
+
+#include <boost/test/unit_test.hpp>
+
+#include "ip/ipv6header.h"
+
+BOOST_AUTO_TEST_SUITE( TestIpv6Header )
+
+BOOST_AUTO_TEST_CASE( icmpv6_packet )
+{
+ uint8_t raw_packet_stream[] = {
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x14, 0x3a, 0x40, 0x20, 0x01, 0x12, 0x91,
+ 0x02, 0x00, 0x02, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x26, 0x07, 0xf8, 0xb0, 0x40, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x11
+ };
+
+ std::basic_stringbuf<uint8_t> sb;
+ sb.pubsetbuf( raw_packet_stream, sizeof(raw_packet_stream) );
+ std::basic_istream<uint8_t> is( &sb );
+
+ Ipv6Header ip_header;
+ reinterpret_cast<std::istream&>(is) >> ip_header;
+
+ BOOST_CHECK_EQUAL( ip_header.get_version(), 6 );
+ BOOST_CHECK_EQUAL( ip_header.get_differentiated_services(), 0 );
+ BOOST_CHECK_EQUAL( ip_header.get_flow_label(), 0 );
+ BOOST_CHECK_EQUAL( ip_header.get_payload_length(), 20 );
+ BOOST_CHECK_EQUAL( ip_header.get_next_header(), 0x3A ); // ICMPv6
+ BOOST_CHECK_EQUAL( ip_header.get_hop_limit(), 64 );
+ BOOST_CHECK_EQUAL( ip_header.get_source_address(), boost::asio::ip::address_v6::from_string("2001:1291:200:25a::2") );
+ BOOST_CHECK_EQUAL( ip_header.get_destination_address(), boost::asio::ip::address_v6::from_string("2607:f8b0:4008:804::1011") );
+}
+
+BOOST_AUTO_TEST_CASE( tcp_packet )
+{
+ uint8_t raw_packet_stream[] = {
+ 0x60, 0x00, 0x00, 0x00, 0x00, 0x28, 0x06, 0x40, 0x20, 0x01, 0x12, 0x91,
+ 0x02, 0x00, 0x02, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x26, 0x20, 0x00, 0x00, 0x06, 0xb0, 0x00, 0x0a, 0x02, 0x50, 0x56, 0xff,
+ 0xfe, 0x99, 0x78, 0xf7
+ };
+
+ std::basic_stringbuf<uint8_t> sb;
+ sb.pubsetbuf( raw_packet_stream, sizeof(raw_packet_stream) );
+ std::basic_istream<uint8_t> is( &sb );
+
+ Ipv6Header ip_header;
+ reinterpret_cast<std::istream&>(is) >> ip_header;
+
+ BOOST_CHECK_EQUAL( ip_header.get_version(), 6 );
+ BOOST_CHECK_EQUAL( ip_header.get_differentiated_services(), 0 );
+ BOOST_CHECK_EQUAL( ip_header.get_flow_label(), 0 );
+ BOOST_CHECK_EQUAL( ip_header.get_payload_length(), 40 );
+ BOOST_CHECK_EQUAL( ip_header.get_next_header(), 0x06 ); // TCP
+ BOOST_CHECK_EQUAL( ip_header.get_hop_limit(), 64 );
+ BOOST_CHECK_EQUAL( ip_header.get_source_address(), boost::asio::ip::address_v6::from_string("2001:1291:200:25a::2") );
+ BOOST_CHECK_EQUAL( ip_header.get_destination_address(), boost::asio::ip::address_v6::from_string("2620:0:6b0:a:250:56ff:fe99:78f7") );
+}
+
+BOOST_AUTO_TEST_SUITE_END()