Fix for NDP Options header length representation
ssauer [Mon, 3 May 2010 10:10:45 +0000 (10:10 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1613 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/DefaultBundle/NDPMessage.test.cc
senf/Packets/DefaultBundle/NDPOptions.cc
senf/Packets/DefaultBundle/NDPOptions.hh

index 7817143..2b5914c 100644 (file)
@@ -34,6 +34,8 @@
 ///////////////////////////////cc.p////////////////////////////////////////
 SENF_AUTO_UNIT_TEST(NDPMessage_create)
 {
+    senf::dumpPacketRegistries(std::cout);
+
     unsigned char data[] = {
             0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3a, 0xff, //IPv6
             0x20, 0x01, 0x08, 0x90, 0x06, 0x00, 0xff, 0xff,
index a76d41e..80d75c6 100644 (file)
 
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
-
-namespace {
-    SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPSourceLLAddressTLVParser );
-    SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPTargetLLAddressTLVParser );
-    SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPPrefixInformationTLVParser );
-    SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPMTUTLVParser );
-}
+SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPSourceLLAddressTLVParser );
+SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPTargetLLAddressTLVParser );
+SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPPrefixInformationTLVParser );
+SENF_PACKET_TLV_REGISTRY_REGISTER( senf::NDPMTUTLVParser );
 
 prefix_ void senf::NDPSourceLLAddressTLVParser::dump(std::ostream & os) const
 {
index 488e5eb..186343b 100644 (file)
@@ -46,7 +46,17 @@ namespace senf {
 
         typedef GenericTLVParserRegistry<NDPOptionParser> Registry;
     };
-    typedef GenericTLVParserBase<NDPOptionParser> NDPGenericOptionParser;
+
+    struct NDPGenericOptionParser : public GenericTLVParserBase<NDPOptionParser>
+    {
+        typedef GenericTLVParserBase<NDPOptionParser> base;
+        NDPGenericOptionParser(data_iterator i, state_type s) : base(i,s) {}
+
+        senf::PacketParserBase::size_type bytes() const
+        {
+            return length()*8;
+        }
+    };
 
     struct NDPSourceLLAddressTLVParser : public NDPOptionParser
     {
@@ -76,7 +86,11 @@ namespace senf {
             type() = typeId;
             length() = 1;
         }
-        static const UInt8Parser::value_type typeId = 0x02;
+
+        senf::PacketParserBase::size_type bytes(NDPTargetLLAddressTLVParser p) {
+                    return length()*8;
+        }
+        static const type_t::value_type typeId = 0x02;
         void dump(std::ostream & os) const;
     };
 
@@ -101,6 +115,9 @@ namespace senf {
             reserved1() = 0;
             reserved2() = 0;
         }
+        senf::PacketParserBase::size_type bytes(NDPPrefixInformationTLVParser p) {
+            return length()*8;
+        }
         static const UInt8Parser::value_type typeId = 0x03;
         void dump(std::ostream & os) const;
     };