Packets/80211Bundle: completed information elements handling in WLAN BeaconPacket
tho [Fri, 9 Oct 2009 14:16:35 +0000 (14:16 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1491 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/80211Bundle/InformationElements.hh
senf/Packets/80211Bundle/WLANBeaconPacket.hh
senf/Packets/80211Bundle/WLANBeaconPacket.test.cc

index 21911d5..a40691c 100644 (file)
@@ -60,6 +60,37 @@ namespace senf {
         }        
         static const type_t::value_type TYPEID = 0x00u;
     };
+        
+    struct WLANSupportedRatesInfoElementParser
+        : public WLANInfoElementParser
+    {
+    #   include SENF_PARSER()
+        SENF_PARSER_INHERIT  ( WLANInfoElementParser               );
+        // we just skip the value here. If somebody needs the information he has to implement 
+        // this strange information element hisself. 
+        SENF_PARSER_SKIP     ( length(), 0                         );
+        SENF_PARSER_FINALIZE ( WLANSupportedRatesInfoElementParser );
+     
+        SENF_PARSER_INIT() {
+            type() = TYPEID;
+        }        
+        static const type_t::value_type TYPEID = 0x01u;
+    };
+        
+    struct WLANPowerConstraintInfoElementParser
+        : public WLANInfoElementParser
+    {
+    #   include SENF_PARSER()
+        SENF_PARSER_INHERIT  ( WLANInfoElementParser                );
+        SENF_PARSER_FIELD    ( value,   UInt8Parser                 );
+        SENF_PARSER_FINALIZE ( WLANPowerConstraintInfoElementParser );
+     
+        SENF_PARSER_INIT() {
+            type() = TYPEID;
+            length() = 1;
+        }        
+        static const type_t::value_type TYPEID = 0x20u;
+    };
 }
 
 ///////////////////////////////hh.e////////////////////////////////////////
index 3451770..8443d3d 100644 (file)
@@ -28,7 +28,6 @@
 #define HH_SENF_Packets_80211Bundle_WLANBeaconPacket_ 1
 
 // Custom includes
-#include <senf/Packets/Packets.hh>
 #include "InformationElements.hh"
 
 ///////////////////////////////hh.p////////////////////////////////////////
@@ -45,8 +44,11 @@ namespace senf {
         SENF_PARSER_FIELD( ssidIE, WLANSSIDInfoElementParser );
         WLANSSIDInfoElementParser::value_t ssid() const { return ssidIE().value(); }
         
-        SENF_PARSER_FINALIZE( WLANBeaconPacketParser );
+        SENF_PARSER_FIELD( supportedRatesIE, WLANSupportedRatesInfoElementParser );
+        
+        SENF_PARSER_LIST ( ieList, packetSize(), WLANGenericInfoElementParser );
         
+        SENF_PARSER_FINALIZE( WLANBeaconPacketParser );
     };
 
  
index 41eb81d..e36846f 100644 (file)
@@ -46,7 +46,7 @@ BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_parse)
         0x2c, 0x01, 0x11, 0x30, 0x01, 0x11, 0x34, 0x01, 0x17, 0x38, 0x01,
         0x17, 0x3c, 0x01, 0x17, 0x40, 0x01, 0x17, 0x95, 0x01, 0x1e, 0x99,
         0x01, 0x1e, 0x9d, 0x01, 0x1e, 0xa1, 0x01, 0x1e, 0xa5, 0x01, 0x1e, //Country information
-        0x20, 0x01, 0x00, //power constraint
+        0x20, 0x01, 0x42, //power constraint
         0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01, 0x88, 0x00, 0x02,
         0xa3, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00,
         0x62, 0x32, 0x2f, 0x00,  //vendor specific
@@ -58,6 +58,34 @@ BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_parse)
     BOOST_CHECK_EQUAL( p->ssidIE().length(), 5);
     BOOST_CHECK_EQUAL( p->ssidIE().value().value(), "boxC1");
     BOOST_CHECK_EQUAL( p->ssid().value(), "boxC1");
+    
+    typedef senf::WLANBeaconPacket::Parser::ieList_t::container ieListContainer_t;
+    ieListContainer_t ieListContainer (p->ieList());
+    BOOST_CHECK_EQUAL( ieListContainer.size(), 5);
+    
+    ieListContainer_t::iterator i ( ieListContainer.begin());
+    BOOST_CHECK_EQUAL( i->type(), 0x03); //DS parameter set
+    ++i;
+    BOOST_CHECK_EQUAL( i->type(), 0x05); //TIM
+    ++i;
+    BOOST_CHECK_EQUAL( i->type(), 0x07); //Country information
+    ++i;
+    //power constraint
+    BOOST_CHECK_EQUAL( i->type(), senf::WLANPowerConstraintInfoElementParser::TYPEID+0);
+    BOOST_CHECK( i->is<senf::WLANPowerConstraintInfoElementParser>());
+    senf::WLANPowerConstraintInfoElementParser ie ( i->as<senf::WLANPowerConstraintInfoElementParser>());
+    BOOST_CHECK_EQUAL( ie.value(), 0x42);
+    ++i;
+    BOOST_CHECK_EQUAL( i->type(), 0xdd); //vendor specific
+    BOOST_CHECK_EQUAL( i->length(), 0x18);
+    BOOST_CHECK_EQUAL( boost::size(i->value()), 0x18);    
+    unsigned char value[] = {
+            0x00, 0x50, 0xf2, 0x02, 0x01, 0x01, 0x88, 0x00,
+            0x02, 0xa3, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00,
+            0x42, 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00
+    };
+    SENF_CHECK_EQUAL_COLLECTIONS( value, value+sizeof(value),
+            boost::begin(i->value()), boost::end(i->value()) );
 }
 
 BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_create)
@@ -66,13 +94,22 @@ BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_create)
     p->timestamp() << 0x0000009C4CAA303AuLL;
     p->beaconInterval() << 100u;
     p->ssidIE().value() << "boxC1";
+    
+    typedef senf::WLANBeaconPacket::Parser::ieList_t::container ieListContainer_t;
+    ieListContainer_t ieListContainer (p->ieList());
+    senf::WLANPowerConstraintInfoElementParser ie (
+            ieListContainer.push_back_space().init<senf::WLANPowerConstraintInfoElementParser>() );
+    ie.value() << 0x42;    
+    
     p.finalizeThis();
     
     unsigned char data[] = {
         0x3a, 0x30, 0xaa, 0x4c, 0x9c, 0x00, 0x00, 0x00, //timestamp
         0x64, 0x00, //beacon interval
         0x00, 0x00, //capability information
-        0x00, 0x05, 0x62, 0x6f, 0x78, 0x43, 0x31 //SSID
+        0x00, 0x05, 0x62, 0x6f, 0x78, 0x43, 0x31, //SSID
+        0x01, 0x00, //supported rates
+        0x20, 0x01, 0x42, //power constraint
     };
     SENF_CHECK_EQUAL_COLLECTIONS( p.data().begin(), p.data().end(),
             data, data+sizeof(data) );