added additional flags in optionType Parser and unittests
pug [Fri, 11 Sep 2009 14:41:13 +0000 (14:41 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1413 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/DefaultBundle/IPv6ExtOptionType.ct
senf/Packets/DefaultBundle/IPv6ExtOptionType.hh
senf/Packets/DefaultBundle/IPv6Extensions.test.cc
senf/Packets/ListOptionTypeParser.test.cc

index 6c5a841..f498f28 100644 (file)
@@ -44,7 +44,13 @@ prefix_ void senf::GenericOptTypeTLVPacketParser::value(ForwardReadableRange con
         resize(optionLength()+2, rangeSize);
 
     std::copy(boost::next(boost::begin(range), 2), boost::next(boost::end(range)), si);
-    optionType() = *(boost::begin(range));
+    unsigned int val = *(boost::begin(range));
+    unsigned int mask = 192u;
+    altAction() = (val & mask) >> 6;
+    mask = 32u;
+    changeFlag() = (val & mask) >> 5;
+    mask = 31u;
+    optionType() = (val & mask);
     optionLength() = *(boost::next( boost::begin(range), 1));
 }
 
index 5feed04..48c8e73 100644 (file)
@@ -33,10 +33,10 @@ namespace senf {
 class OptTypeTLVPacketParser: public PacketParserBase {
 public:
 #       include SENF_PARSER()
-//    SENF_PARSER_BITFIELD (altAction, 2, unsigned);
-//    SENF_PARSER_BITFIELD (changeFlag, 1, unsigned);
-//    SENF_PARSER_BITFIELD (optionType, 5, unsigned);
-    SENF_PARSER_FIELD (optionType, UInt8Parser);
+    SENF_PARSER_BITFIELD (altAction, 2, unsigned);
+    SENF_PARSER_BITFIELD (changeFlag, 1, unsigned);
+    SENF_PARSER_BITFIELD (optionType, 5, unsigned);
+//    SENF_PARSER_FIELD (optionType, UInt8Parser);
     SENF_PARSER_FIELD (optionLength, UInt8Parser);
     SENF_PARSER_FINALIZE (OptTypeTLVPacketParser);
 
index 0b3d740..8be4f32 100644 (file)
@@ -149,7 +149,7 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions)
 }
     //==============================================================================================
     
-BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop)
+BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_parse)
 {
     unsigned char HopByHop_packetData[] = {
         0x60, 0x00, 0x00, 0x00, //IP version, class, flow label
@@ -200,9 +200,14 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop)
     pHop_extension.dump(oss);
     senf::IPv6Extension_HopByHop::Parser::options_t::container optC(pHop_extension->options() );
     senf::IPv6Extension_HopByHop::Parser::options_t::container::iterator listIter (optC.begin());
+
+    BOOST_CHECK_EQUAL( listIter->altAction(), 0u);
+    BOOST_CHECK_EQUAL( listIter->changeFlag(), 0u);
     BOOST_CHECK_EQUAL( listIter->optionType(), 5u);
     BOOST_CHECK_EQUAL( listIter->optionLength(), 2u);
     ++listIter;
+    BOOST_CHECK_EQUAL( listIter->altAction(), 0u);
+    BOOST_CHECK_EQUAL( listIter->changeFlag(), 0u);
     BOOST_CHECK_EQUAL( listIter->optionType(), 2u);
     BOOST_CHECK_EQUAL( listIter->optionLength(), 0);
     pHop_extension.dump(oss);
@@ -214,6 +219,7 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop)
     BOOST_CHECK_EQUAL( pICMPv6->checksum(), 0x50cc);
 }
 
+
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
index 2c00ff6..b3105ab 100644 (file)
@@ -89,7 +89,7 @@ BOOST_AUTO_UNIT_TEST(ListOptionTypeParser_container)
         BOOST_CHECK_EQUAL( c.bytes(), 0u ); // padding bytes wont be in here, added/removed automatically in destructor
         BOOST_CHECK( c.begin() == c.end() );
 
-        unsigned char d[]  = {0x05, 0x02, 0x40, 0x34};
+        unsigned char d[]  = {0x65, 0x02, 0x40, 0x34};
         unsigned char d1[] = {0x03, 0x01, 0x77};
         unsigned char d2[] = {0x07, 0x01, 0x13};
 
@@ -106,7 +106,8 @@ BOOST_AUTO_UNIT_TEST(ListOptionTypeParser_container)
         BOOST_CHECK_EQUAL( c.size(), 3u );
 
         OptionParser::list_t::container::iterator cIter (c.begin());
-
+        BOOST_CHECK_EQUAL( cIter->altAction(), 1u);
+        BOOST_CHECK_EQUAL( cIter->changeFlag(), 1u);
         BOOST_CHECK_EQUAL( cIter->optionType(), 5u);
         BOOST_CHECK_EQUAL( cIter->optionLength(), 2u);
         BOOST_CHECK_EQUAL( *(boost::begin(cIter->value()) ), 0x40);