From: cni Date: Fri, 5 Feb 2010 15:10:43 +0000 (+0000) Subject: senf/Packets/80211Bundle/WLANPacket: added set method for sequence number in WLAN... X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=0476b2133cab2df2c483b8c43d09d6116173e414;p=senf.git senf/Packets/80211Bundle/WLANPacket: added set method for sequence number in WLAN (Data and Mgt) Header git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1571 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/80211Bundle/WLANPacket.cc b/senf/Packets/80211Bundle/WLANPacket.cc index 47011b2..c4e9c67 100644 --- a/senf/Packets/80211Bundle/WLANPacket.cc +++ b/senf/Packets/80211Bundle/WLANPacket.cc @@ -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 { diff --git a/senf/Packets/80211Bundle/WLANPacket.hh b/senf/Packets/80211Bundle/WLANPacket.hh index c323afc..b5c2de9 100644 --- a/senf/Packets/80211Bundle/WLANPacket.hh +++ b/senf/Packets/80211Bundle/WLANPacket.hh @@ -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, diff --git a/senf/Packets/80211Bundle/WLANPacket.test.cc b/senf/Packets/80211Bundle/WLANPacket.test.cc index 9a99389..a47a1a9 100644 --- a/senf/Packets/80211Bundle/WLANPacket.test.cc +++ b/senf/Packets/80211Bundle/WLANPacket.test.cc @@ -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); }