//#include "IPv6ExtOptionType.ih"
// Custom includes
-#include <senf/Utils/hexdump.hh>
#define prefix_
///////////////////////////////ct.p////////////////////////////////////////
if ( (rangeSize-2) != optionLength() )
resize(optionLength()+2, rangeSize);
- std::copy(boost::next(boost::begin(range), 2), boost::next(boost::end(range)), boost::next(i(), 2 + optionLength() ));
+ std::copy(boost::next(boost::begin(range), 2), boost::next(boost::end(range)),
+ boost::next(i(), 2 + optionLength() ));
unsigned int val = *(boost::begin(range));
unsigned int mask = 192u;
altAction() = (val & mask) >> 6;
optionLength() = rangeSize;
}
-
template <class Parser>
prefix_ Parser senf::IPv6GenericOptionTLVParser::init()
{
return concreteParser;
}
-
-// template <class Parser>
-// prefix_ Parser& senf::GenericOptTypeTLVParser::get()
-// {
-// SENF_ASSERT (optionType() == typeCode);
-// return *(this);
-// }
+template <class Parser>
+prefix_ Parser senf::IPv6GenericOptionTLVParser::as()
+{
+ return Parser(i(), state() );
+}
///////////////////////////////ct.e////////////////////////////////////////
BOOST_CHECK_EQUAL( pICMPv6->checksum(), 0x50cc);
}
+
BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create)
{
std::ostringstream oss (std::ostringstream::out);
eth.data().begin(), eth.data().end() );
}
+
namespace {
struct IPv6ChecksumOptionTLVParser : public senf::IPv6OptionTLVParser
{
};
}
-BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create_SN) {
- unsigned char data[] = {
- 0x3a, 0x01, // Hop-By-Hop Header (nextHeader, length)
- 0x0d, 0x05, // option type, length
- // option value: slfNetType, checksum
- 0x01, 0x01, 0x23, 0x45, 0x67,
- // padding (PadN option: type, length, 0-padding)
- 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00
- };
-
+BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create_SN)
+{
senf::IPv6HopByHopOptionsPacket p ( senf::IPv6HopByHopOptionsPacket::create() );
p->nextHeader() = 0x3a;
{
- senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optC(p->options() );
+ senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optC (p->options() );
{
IPv6ChecksumOptionTLVParser opt (
optC.push_back_space().init<IPv6ChecksumOptionTLVParser>());
}
}
+ unsigned char data[] = {
+ 0x3a, 0x01, // Hop-By-Hop Header (nextHeader, length)
+ 0x0d, 0x05, // option type, length
+ // option value: slfNetType, checksum
+ 0x01, 0x01, 0x23, 0x45, 0x67,
+ // padding (PadN option: type, length, 0-padding)
+ 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
SENF_CHECK_EQUAL_COLLECTIONS( data, data+sizeof(data),
p.data().begin(), p.data().end() );
}
+
+BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_parse_SN)
+{
+ unsigned char data[] = {
+ 0x3a, 0x01, // Hop-By-Hop Header (nextHeader, length)
+ 0x0d, 0x05, // option type, length
+ // option value: slfNetType, checksum
+ 0x01, 0x01, 0x23, 0x45, 0x67,
+ // padding (PadN option: type, length, 0-padding)
+ 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+
+ senf::IPv6HopByHopOptionsPacket p ( senf::IPv6HopByHopOptionsPacket::create(data) );
+ BOOST_CHECK_EQUAL( p->nextHeader(), 0x3a);
+
+ typedef senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optContainer_t;
+ optContainer_t optC (p->options() );
+ optContainer_t::iterator listIter (optC.begin());
+
+ BOOST_CHECK_EQUAL( listIter->optionType(), 0x0d);
+ IPv6ChecksumOptionTLVParser opt ( listIter->as<IPv6ChecksumOptionTLVParser>());
+ BOOST_CHECK_EQUAL( opt.slfNetType(), 0x01);
+ BOOST_CHECK_EQUAL( opt.checksum(), 0x01234567);
+}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_