fixed ...
[senf.git] / senf / Packets / DefaultBundle / IPv6ExtOptionType.ct
index cc5f9f2..6c5a841 100644 (file)
 template <class ForwardReadableRange>
 prefix_ void senf::GenericOptTypeTLVPacketParser::value(ForwardReadableRange const &range)
 {
-    safe_data_iterator si( data(), boost::next(data().begin()+2) );
     unsigned int rangeSize = boost::size(range);
-//    std::cout << "tmpl. method - optLength =" << (unsigned) optionLength()
-//      << ", rangeSize: " << rangeSize
-//      << ", optionType: " << (unsigned) optionType() << std::endl;
-    if ( rangeSize > optionLength() ){
+    safe_data_iterator si( data(),  boost::next(i(), 2 + optionLength() ) );
+//    if ( rangeSize > optionLength() ){
 //        std::cout << "rangeSize > optionLength()" << std::endl;
-        data().insert(si, rangeSize - optionLength(),0 );
-    }
-    if (rangeSize < optionLength() ){
+//        data().insert(si, rangeSize - optionLength(),0 );
+//    }
+//    if (rangeSize < optionLength() ){
 //        std::cout << "rangeSize < optionLength()" << std::endl;
-        data().erase(si, si + (optionLength() - rangeSize));
-    }
-    std::copy(( boost::begin(range)), boost::end(range), si);
-    optionLength() = 2u;
-//    std::cout << "optLength AFTER =" << (unsigned) optionLength() << ", rangeSize: " << rangeSize << std::endl;
+//        data().erase(si, si + (optionLength() - rangeSize));
+//    }
+    if ( (rangeSize-2) != optionLength() )
+        resize(optionLength()+2, rangeSize);
+
+    std::copy(boost::next(boost::begin(range), 2), boost::next(boost::end(range)), si);
+    optionType() = *(boost::begin(range));
+    optionLength() = *(boost::next( boost::begin(range), 1));
 }
 
 ///////////////////////////////ct.e////////////////////////////////////////