From: tho Date: Fri, 16 Oct 2009 12:31:12 +0000 (+0000) Subject: Packets: some minor GenericTLV clean ups X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=6c0332484574ed1cb571bbc0dc9f0a37d6653282;p=senf.git Packets: some minor GenericTLV clean ups git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1500 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/80211Bundle/InformationElements.cc b/senf/Packets/80211Bundle/InformationElements.cc index e4530df..c356509 100644 --- a/senf/Packets/80211Bundle/InformationElements.cc +++ b/senf/Packets/80211Bundle/InformationElements.cc @@ -32,9 +32,9 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANInfoElementParser, senf::WLANSSIDInfoElementParser); -SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANInfoElementParser, senf::WLANPowerConstraintInfoElementParser); -SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANInfoElementParser, senf::WLANSupportedRatesInfoElementParser); +SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANSSIDInfoElementParser ); +SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANPowerConstraintInfoElementParser ); +SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANSupportedRatesInfoElementParser ); prefix_ void senf::WLANPowerConstraintInfoElementParser::dump(std::ostream & os) diff --git a/senf/Packets/80211Bundle/InformationElements.hh b/senf/Packets/80211Bundle/InformationElements.hh index af497b2..31e506f 100644 --- a/senf/Packets/80211Bundle/InformationElements.hh +++ b/senf/Packets/80211Bundle/InformationElements.hh @@ -41,6 +41,8 @@ namespace senf { SENF_PARSER_FIELD ( type, UInt8Parser ); SENF_PARSER_FIELD ( length, UInt8Parser ); SENF_PARSER_FINALIZE ( WLANInfoElementParser ); + + typedef GenericTLVParserRegistry Registry; }; typedef GenericTLVParserBase WLANGenericInfoElementParser; diff --git a/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc b/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc index 7e7e727..a49709f 100644 --- a/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc +++ b/senf/Packets/80211Bundle/WLANBeaconPacket.test.cc @@ -88,7 +88,8 @@ BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_parse) SENF_CHECK_EQUAL_COLLECTIONS( value, value+sizeof(value), boost::begin(i->value()), boost::end(i->value()) ); - p.dump(std::cout); + std::ostringstream oss (std::ostringstream::out); + SENF_CHECK_NO_THROW( p.dump( oss )); } BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_create) diff --git a/senf/Packets/DefaultBundle/IPv6ExtOptionType.hh b/senf/Packets/DefaultBundle/IPv6ExtOptions.hh similarity index 72% rename from senf/Packets/DefaultBundle/IPv6ExtOptionType.hh rename to senf/Packets/DefaultBundle/IPv6ExtOptions.hh index db7468a..66ecce7 100644 --- a/senf/Packets/DefaultBundle/IPv6ExtOptionType.hh +++ b/senf/Packets/DefaultBundle/IPv6ExtOptions.hh @@ -23,38 +23,40 @@ /** \file \brief IPv6Extension-Options public header */ -#ifndef HH_SENF_Packets_DefaultBundle_IPv6ExtOptionType_HH_ -#define HH_SENF_Packets_DefaultBundle_IPv6ExtOptionType_HH_ 1 +#ifndef HH_SENF_Packets_DefaultBundle_IPv6ExtOptions_HH_ +#define HH_SENF_Packets_DefaultBundle_IPv6ExtOptions_HH_ 1 // Custom includes #include -//#include "IPv6ExtOptionType.mpp" +//#include "IPv6ExtOptions.mpp" ///////////////////////////////hh.p//////////////////////////////////////// namespace senf { - class IPv6OptionTLVParser : public PacketParserBase + class IPv6OptionParser : public PacketParserBase { public: # include SENF_PARSER() - SENF_PARSER_FIELD ( type, UInt8Parser ); - SENF_PARSER_GOTO ( type ); + SENF_PARSER_FIELD ( type, UInt8Parser ); + SENF_PARSER_GOTO ( type ); SENF_PARSER_BITFIELD ( altAction, 2, unsigned ); SENF_PARSER_BITFIELD ( changeFlag, 1, unsigned ); SENF_PARSER_BITFIELD ( optionType, 5, unsigned ); - SENF_PARSER_FIELD (length, UInt8Parser ); - SENF_PARSER_FINALIZE (IPv6OptionTLVParser ); + SENF_PARSER_FIELD ( length, UInt8Parser ); + SENF_PARSER_FINALIZE ( IPv6OptionParser ); + + typedef GenericTLVParserRegistry Registry; }; - typedef GenericTLVParserBase IPv6GenericOptionTLVParser; + typedef GenericTLVParserBase IPv6GenericOptionParser; } ///////////////////////////////hh.e//////////////////////////////////////// -//#include "IPv6ExtOptionType.cci" -//#include "IPv6ExtOptionType.ct" -//#include "IPv6ExtOptionType.cti" +//#include "IPv6ExtOptions.cci" +//#include "IPv6ExtOptions.ct" +//#include "IPv6ExtOptions.cti" #endif diff --git a/senf/Packets/DefaultBundle/IPv6Extensions.hh b/senf/Packets/DefaultBundle/IPv6Extensions.hh index c8749f7..a7294e0 100644 --- a/senf/Packets/DefaultBundle/IPv6Extensions.hh +++ b/senf/Packets/DefaultBundle/IPv6Extensions.hh @@ -28,8 +28,7 @@ #define HH_SENF_Packets_DefaultBundle_IPv6Extensions_ 1 // Custom includes -#include -#include "IPv6ExtOptionType.hh" +#include "IPv6ExtOptions.hh" #include "ListOptionTypeParser.hh" #include "IPv6Packet.hh" @@ -235,7 +234,7 @@ namespace senf { typedef detail::FixedAuxParserPolicy ListOptionTypeAuxPolicy; typedef detail::ListOptionTypeParser_Policy< - IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy; + IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy; typedef ListParser ListOptionTypeParser; SENF_PARSER_FIELD ( options, ListOptionTypeParser); diff --git a/senf/Packets/DefaultBundle/IPv6Extensions.test.cc b/senf/Packets/DefaultBundle/IPv6Extensions.test.cc index a473d85..d92a354 100644 --- a/senf/Packets/DefaultBundle/IPv6Extensions.test.cc +++ b/senf/Packets/DefaultBundle/IPv6Extensions.test.cc @@ -281,7 +281,8 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create) { senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optC(pext->options() ); { - senf::IPv6GenericOptionTLVParser opt ( optC.push_back_space().init()); + senf::IPv6GenericOptionParser opt ( + optC.push_back_space().init()); opt.altAction() = 0u; opt.changeFlag() = 0u; opt.optionType() = 5u; @@ -309,21 +310,22 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create) namespace { - struct IPv6ChecksumOptionTLVParser : public senf::IPv6OptionTLVParser + struct IPv6ChecksumOptionParser : public senf::IPv6OptionParser { # include SENF_PARSER() - SENF_PARSER_INHERIT ( IPv6OptionTLVParser ); - SENF_PARSER_FIELD ( slfNetType, senf::UInt8Parser ); - SENF_PARSER_FIELD ( checksum, senf::UInt32Parser ); + SENF_PARSER_INHERIT ( IPv6OptionParser ); + SENF_PARSER_FIELD ( extendedType, senf::UInt8Parser ); + SENF_PARSER_FIELD ( checksum, senf::UInt32Parser ); + SENF_PARSER_FINALIZE ( IPv6ChecksumOptionParser ); SENF_PARSER_INIT() { - optionType() = typeCode; - length() = senf::init_bytes::value -senf::init_bytes::value; - slfNetType() = SN_typeCode; + optionType() = typeId; + length() = 5u; + extendedType() = extendedTypeId; } - SENF_PARSER_FINALIZE ( IPv6ChecksumOptionTLVParser ); - static const boost::uint8_t typeCode = 0x0d; - static const boost::uint8_t SN_typeCode = 0x4d; + + static const boost::uint8_t typeId = 0x0d; + static const boost::uint8_t extendedTypeId = 0x4d; }; } @@ -334,9 +336,8 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create_SN) { senf::IPv6HopByHopOptionsPacket::Parser::options_t::container optC (p->options() ); { - IPv6ChecksumOptionTLVParser opt ( - optC.push_back_space().init()); - SENF_CHECK_NO_THROW( opt.slfNetType() = 1u) ; + IPv6ChecksumOptionParser opt ( + optC.push_back_space().init()); opt.checksum() = 0x01234567u; } } @@ -344,8 +345,8 @@ 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, + // option value: extendedType, checksum + 0x4d, 0x01, 0x23, 0x45, 0x67, // padding (PadN option: type, length, 0-padding) 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -360,7 +361,7 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_parse_SN) 0x3a, 0x01, // Hop-By-Hop Header (nextHeader, length) 0x0d, 0x05, // option type, length // option value: slfNetType, checksum - 0x01, 0x01, 0x23, 0x45, 0x67, + 0x4d, 0x01, 0x23, 0x45, 0x67, // padding (PadN option: type, length, 0-padding) 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 }; @@ -373,8 +374,9 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_parse_SN) optContainer_t::iterator listIter (optC.begin()); BOOST_CHECK_EQUAL( listIter->optionType(), 0x0d); - IPv6ChecksumOptionTLVParser opt ( listIter->as()); - BOOST_CHECK_EQUAL( opt.slfNetType(), 0x01); + BOOST_CHECK( listIter->is()); + IPv6ChecksumOptionParser opt ( listIter->as()); + BOOST_CHECK_EQUAL( opt.extendedType(), 0x4d); BOOST_CHECK_EQUAL( opt.checksum(), 0x01234567); } diff --git a/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc b/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc index 75977f8..4989c31 100644 --- a/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc +++ b/senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc @@ -22,7 +22,7 @@ // Custom includes #include -#include "IPv6ExtOptionType.hh" +#include "IPv6ExtOptions.hh" #include "ListOptionTypeParser.hh" #include @@ -42,7 +42,7 @@ namespace { SENF_PARSER_FIELD( size, senf::UInt8Parser ); typedef senf::detail::FixedAuxParserPolicy ListOptionTypeAuxPolicy; typedef senf::detail::ListOptionTypeParser_Policy< - senf::IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy; + senf::IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy; typedef senf::ListParser ListOptionTypeParser; SENF_PARSER_FIELD ( list, ListOptionTypeParser); diff --git a/senf/Packets/GenericTLV.hh b/senf/Packets/GenericTLV.hh index b0dab34..e14f5c6 100644 --- a/senf/Packets/GenericTLV.hh +++ b/senf/Packets/GenericTLV.hh @@ -219,11 +219,10 @@ namespace senf { void dump(GenericTLVParserBase const & parser, std::ostream & os); }; -# define SENF_PACKET_TLV_REGISTRY_REGISTER( BaseTLVParser, ConreteTLVParser ) \ - namespace { \ - senf::GenericTLVParserRegistry \ - ::RegistrationProxy \ - BOOST_PP_CAT(tlvparserRegistration_, __LINE__); \ +# define SENF_PACKET_TLV_REGISTRY_REGISTER( ConreteTLVParser ) \ + namespace { \ + ConreteTLVParser::Registry::RegistrationProxy \ + BOOST_PP_CAT(tlvparserRegistration_, __LINE__); \ } }