senf/Packets/80211Bundle/WLANPacket: added set method for sequence number in WLAN...
cni [Fri, 5 Feb 2010 15:10:43 +0000 (15:10 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1571 270642c3-0616-0410-b53a-bc976706d245

senf/Packets/80211Bundle/WLANPacket.cc
senf/Packets/80211Bundle/WLANPacket.hh
senf/Packets/80211Bundle/WLANPacket.test.cc

index 47011b2..c4e9c67 100644 (file)
@@ -55,6 +55,12 @@ namespace {
     }
 }
 
+prefix_ void senf::WLANPacket_MgtFrameParser::sequenceNumber(boost::uint16_t sn)
+{
+    seqNumber_2() = seqNumber_2() | (sn >> 4 ) ;
+    seqNumber_1() = seqNumber_1() | sn;
+}
+
 prefix_ void senf::WLANPacket_MgtFrameType::dump(packet p, std::ostream &os)
 {
     boost::io::ios_all_saver ias(os);
@@ -77,6 +83,13 @@ prefix_ void senf::WLANPacket_CtrlFrameType::dump(packet p, std::ostream &os)
         os << senf::fieldName("source")                << p->sourceAddress() << "\n";
 }
 
+prefix_ void senf::WLANPacket_DataFrameParser::sequenceNumber(boost::uint16_t sn)
+{
+    seqNumber_2() = seqNumber_2() | (sn >> 4 ) ;
+    seqNumber_1() = seqNumber_1() | sn;
+}
+
+
 prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::destinationAddress()
     const
 {
index c323afc..b5c2de9 100644 (file)
@@ -93,6 +93,8 @@ namespace senf
         boost::uint16_t sequenceNumber() const {
             return (uint16_t)(seqNumber_2()) << 4 | seqNumber_1();
         };
+        
+        void sequenceNumber(boost::uint16_t sn);
     };
 
     /** \brief WLAN Management frame packet
@@ -213,6 +215,8 @@ namespace senf
         boost::uint16_t sequenceNumber() const {
             return (uint16_t)(seqNumber_2()) << 4 | seqNumber_1();
         };
+        
+        void sequenceNumber(boost::uint16_t sn);
 
         // TODO fourth address field in case of WDS
         // SENF_PARSER_PRIVATE_VARIANT (wds_, dsBits,
index 9a99389..a47a1a9 100644 (file)
@@ -86,7 +86,10 @@ SENF_AUTO_UNIT_TEST(WLANPacket_dataFrame_create)
     senf::WLANPacket_DataFrame p (senf::WLANPacket_DataFrame::create());
 
     SENF_CHECK_NO_THROW( p->bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") );
+    SENF_CHECK_NO_THROW(p->sequenceNumber(4095u));
+    
     BOOST_CHECK_EQUAL( p->type(), 2u );
+    BOOST_CHECK_EQUAL( p->sequenceNumber(), 4095u );
 }
 
 
@@ -156,8 +159,14 @@ SENF_AUTO_UNIT_TEST(WLANPacket_mgtFrame_create)
     SENF_CHECK_NO_THROW(
             p->bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c")
     );
+    SENF_CHECK_NO_THROW(
+            p->sequenceNumber(555u);
+    );
+    
 
+    std::cout << p->sequenceNumber() << "\n";
     BOOST_CHECK_EQUAL( p->type(), 0u );
+    BOOST_CHECK_EQUAL( p->sequenceNumber(), 555u );
 }
 
 
@@ -196,6 +205,7 @@ SENF_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_create)
     senf::WLANPacket_CtrlFrame p (senf::WLANPacket_CtrlFrame::create()) ;
     p->receiverAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c");
     p->set_ack();
+    
     BOOST_CHECK_EQUAL( p->type(), 1u);
     BOOST_CHECK_EQUAL( p->subtype(), 13u);
 }