Packets: some minor GenericTLV clean ups
tho [Fri, 16 Oct 2009 12:31:12 +0000 (12:31 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1500 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/80211Bundle/InformationElements.cc
senf/Packets/80211Bundle/InformationElements.hh
senf/Packets/80211Bundle/WLANBeaconPacket.test.cc
senf/Packets/DefaultBundle/IPv6ExtOptions.hh [moved from senf/Packets/DefaultBundle/IPv6ExtOptionType.hh with 72% similarity]
senf/Packets/DefaultBundle/IPv6Extensions.hh
senf/Packets/DefaultBundle/IPv6Extensions.test.cc
senf/Packets/DefaultBundle/ListOptionTypeParser.test.cc
senf/Packets/GenericTLV.hh

index e4530df..c356509 100644 (file)
@@ -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) 
index af497b2..31e506f 100644 (file)
@@ -41,6 +41,8 @@ namespace senf {
         SENF_PARSER_FIELD    ( type,   UInt8Parser   );
         SENF_PARSER_FIELD    ( length, UInt8Parser   );
         SENF_PARSER_FINALIZE ( WLANInfoElementParser );
+        
+        typedef GenericTLVParserRegistry<WLANInfoElementParser> Registry;
     };
 
     typedef GenericTLVParserBase<WLANInfoElementParser> WLANGenericInfoElementParser;
index 7e7e727..a49709f 100644 (file)
@@ -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)
 /** \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 <senf/Packets/Packets.hh>
 
-//#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<IPv6OptionParser> Registry;
     };
 
-    typedef GenericTLVParserBase<IPv6OptionTLVParser> IPv6GenericOptionTLVParser;
+    typedef GenericTLVParserBase<IPv6OptionParser> IPv6GenericOptionParser;
 
 }
 
 
 ///////////////////////////////hh.e////////////////////////////////////////
-//#include "IPv6ExtOptionType.cci"
-//#include "IPv6ExtOptionType.ct"
-//#include "IPv6ExtOptionType.cti"
+//#include "IPv6ExtOptions.cci"
+//#include "IPv6ExtOptions.ct"
+//#include "IPv6ExtOptions.cti"
 #endif
 
 \f
index c8749f7..a7294e0 100644 (file)
@@ -28,8 +28,7 @@
 #define HH_SENF_Packets_DefaultBundle_IPv6Extensions_ 1
 
 // Custom includes
-#include <senf/Packets/Packets.hh>
-#include "IPv6ExtOptionType.hh"
+#include "IPv6ExtOptions.hh"
 #include "ListOptionTypeParser.hh"
 #include "IPv6Packet.hh"
 
@@ -235,7 +234,7 @@ namespace senf {
 
         typedef detail::FixedAuxParserPolicy<UInt8Parser, 1u> ListOptionTypeAuxPolicy;
         typedef detail::ListOptionTypeParser_Policy<
-            IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
+            IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
         typedef ListParser<ListOptionTypePolicy> ListOptionTypeParser;
 
         SENF_PARSER_FIELD  ( options, ListOptionTypeParser);
index a473d85..d92a354 100644 (file)
@@ -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::IPv6GenericOptionTLVParser>());
+            senf::IPv6GenericOptionParser opt ( 
+                    optC.push_back_space().init<senf::IPv6GenericOptionParser>());
             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<IPv6ChecksumOptionTLVParser>::value -senf::init_bytes<IPv6OptionTLVParser>::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<IPv6ChecksumOptionTLVParser>());
-            SENF_CHECK_NO_THROW( opt.slfNetType() = 1u) ;
+            IPv6ChecksumOptionParser opt ( 
+                    optC.push_back_space().init<IPv6ChecksumOptionParser>());
             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<IPv6ChecksumOptionTLVParser>());
-    BOOST_CHECK_EQUAL( opt.slfNetType(), 0x01);
+    BOOST_CHECK( listIter->is<IPv6ChecksumOptionParser>());
+    IPv6ChecksumOptionParser opt ( listIter->as<IPv6ChecksumOptionParser>());
+    BOOST_CHECK_EQUAL( opt.extendedType(), 0x4d);
     BOOST_CHECK_EQUAL( opt.checksum(), 0x01234567);
 }
 
index 75977f8..4989c31 100644 (file)
@@ -22,7 +22,7 @@
 
 // Custom includes
 #include <senf/Packets/Packets.hh>
-#include "IPv6ExtOptionType.hh"
+#include "IPv6ExtOptions.hh"
 #include "ListOptionTypeParser.hh"
 
 #include <senf/Utils/auto_unit_test.hh>
@@ -42,7 +42,7 @@ namespace {
         SENF_PARSER_FIELD( size, senf::UInt8Parser );
         typedef senf::detail::FixedAuxParserPolicy<senf::UInt8Parser, 1u> ListOptionTypeAuxPolicy;
         typedef senf::detail::ListOptionTypeParser_Policy<
-            senf::IPv6GenericOptionTLVParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
+            senf::IPv6GenericOptionParser, ListOptionTypeAuxPolicy> ListOptionTypePolicy;
         typedef senf::ListParser<ListOptionTypePolicy> ListOptionTypeParser;
         SENF_PARSER_FIELD ( list, ListOptionTypeParser);
 
index b0dab34..e14f5c6 100644 (file)
@@ -219,11 +219,10 @@ namespace senf {
         void dump(GenericTLVParserBase<BaseParser> const & parser, std::ostream & os);
     };
         
-#   define SENF_PACKET_TLV_REGISTRY_REGISTER( BaseTLVParser, ConreteTLVParser )     \
-        namespace {                                                                 \
-            senf::GenericTLVParserRegistry<BaseTLVParser>                           \
-                ::RegistrationProxy<ConreteTLVParser>                               \
-                    BOOST_PP_CAT(tlvparserRegistration_, __LINE__);                 \
+#   define SENF_PACKET_TLV_REGISTRY_REGISTER( ConreteTLVParser )                \
+        namespace {                                                             \
+            ConreteTLVParser::Registry::RegistrationProxy<ConreteTLVParser>     \
+                    BOOST_PP_CAT(tlvparserRegistration_, __LINE__);             \
         }
         
 }