--- /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 "icmp/icmptype.h"
+#include "icmp/icmpv6header.h"
+
+BOOST_AUTO_TEST_SUITE( TestIcmpv6Header )
+
+BOOST_AUTO_TEST_CASE( echo_reply )
+{
+ uint8_t raw_packet_stream[] = {
+ 0x81, 0x00, 0xbf, 0x50, 0x0e, 0xbe, 0x00, 0x1a, 0x9c, 0xbb, 0x10, 0x4f,
+ 0x15, 0x4d, 0x03, 0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
+ 0x34, 0x35, 0x36, 0x37
+ };
+
+ std::basic_stringbuf<uint8_t> sb;
+ sb.pubsetbuf( raw_packet_stream, sizeof(raw_packet_stream) );
+ std::basic_istream<uint8_t> is( &sb );
+
+ Icmpv6Header icmp_header;
+ reinterpret_cast<std::istream&>(is) >> icmp_header;
+
+ BOOST_CHECK_EQUAL( icmp_header.get_type(), Icmpv6Type_EchoReply );
+ BOOST_CHECK_EQUAL( icmp_header.get_code(), 0 );
+ BOOST_CHECK_EQUAL( icmp_header.get_checksum(), 0xBF50 );
+ BOOST_CHECK_EQUAL( icmp_header.get_identifier(), 0x0EBE );
+ BOOST_CHECK_EQUAL( icmp_header.get_sequence_number(), 26 );
+}
+
+BOOST_AUTO_TEST_CASE( echo_request )
+{
+ uint8_t raw_packet_stream[] = {
+ 0x80, 0x00, 0xed, 0xa4, 0x11, 0xfd, 0x00, 0x06, 0x37, 0x03, 0x0c, 0x4f,
+ 0x98, 0xc1, 0x0b, 0x00, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
+ 0x34, 0x35, 0x36, 0x37
+ };
+
+ std::basic_stringbuf<uint8_t> sb;
+ sb.pubsetbuf( raw_packet_stream, sizeof(raw_packet_stream) );
+ std::basic_istream<uint8_t> is( &sb );
+
+ Icmpv6Header icmp_header;
+ reinterpret_cast<std::istream&>(is) >> icmp_header;
+
+ BOOST_CHECK_EQUAL( icmp_header.get_type(), Icmpv6Type_EchoRequest );
+ BOOST_CHECK_EQUAL( icmp_header.get_code(), 0 );
+ BOOST_CHECK_EQUAL( icmp_header.get_checksum(), 0xEDA4 );
+ BOOST_CHECK_EQUAL( icmp_header.get_identifier(), 0x11FD );
+ BOOST_CHECK_EQUAL( icmp_header.get_sequence_number(), 6 );
+}
+
+BOOST_AUTO_TEST_SUITE_END()