From: ssauer Date: Mon, 3 May 2010 10:10:45 +0000 (+0000) Subject: Fix for NDP Options header length representation X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=cad7256a15fbec9b4bf38559e89db7e0fe814db0;hp=9cb871b939efe93e35dd96808d25089399acfc46;p=senf.git Fix for NDP Options header length representation git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1613 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/DefaultBundle/NDPMessage.test.cc b/senf/Packets/DefaultBundle/NDPMessage.test.cc index 7817143..2b5914c 100644 --- a/senf/Packets/DefaultBundle/NDPMessage.test.cc +++ b/senf/Packets/DefaultBundle/NDPMessage.test.cc @@ -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, diff --git a/senf/Packets/DefaultBundle/NDPOptions.cc b/senf/Packets/DefaultBundle/NDPOptions.cc index a76d41e..80d75c6 100644 --- a/senf/Packets/DefaultBundle/NDPOptions.cc +++ b/senf/Packets/DefaultBundle/NDPOptions.cc @@ -27,13 +27,10 @@ #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 { diff --git a/senf/Packets/DefaultBundle/NDPOptions.hh b/senf/Packets/DefaultBundle/NDPOptions.hh index 488e5eb..186343b 100644 --- a/senf/Packets/DefaultBundle/NDPOptions.hh +++ b/senf/Packets/DefaultBundle/NDPOptions.hh @@ -46,7 +46,17 @@ namespace senf { typedef GenericTLVParserRegistry Registry; }; - typedef GenericTLVParserBase NDPGenericOptionParser; + + struct NDPGenericOptionParser : public GenericTLVParserBase + { + typedef GenericTLVParserBase 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; };