From 77fe2e1cbb76173deeef1d4e85e65d9b6f9e8c2c Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Tue, 25 Nov 2008 14:45:46 +0000 Subject: [PATCH] [Bug 398] NqstaWifiMac does not filter received frames by BSSID --- src/devices/wifi/nqsta-wifi-mac.cc | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/devices/wifi/nqsta-wifi-mac.cc b/src/devices/wifi/nqsta-wifi-mac.cc index 2f94f52d8..781aaa303 100644 --- a/src/devices/wifi/nqsta-wifi-mac.cc +++ b/src/devices/wifi/nqsta-wifi-mac.cc @@ -475,10 +475,25 @@ NqstaWifiMac::Receive (Ptr packet, WifiMacHeader const *hdr) if (hdr->GetAddr1 () != GetAddress () && !hdr->GetAddr1 ().IsBroadcast ()) { - // packet is not for us + NS_LOG_LOGIC ("packet is not for us"); } else if (hdr->IsData ()) { + if (!IsAssociated ()) + { + NS_LOG_LOGIC ("Received data frame while not associated: ignore"); + return; + } + if (!(hdr->IsFromDs () && !hdr->IsToDs ())) + { + NS_LOG_LOGIC ("Received data frame not from the DS: ignore"); + return; + } + if (hdr->GetAddr2 () != GetBssid ()) + { + NS_LOG_LOGIC ("Received data frame not from the the BSS we are associated with: ignore"); + return; + } if (hdr->GetAddr3 () != GetAddress ()) { ForwardUp (packet, hdr->GetAddr3 (), hdr->GetAddr1 ()); @@ -499,12 +514,16 @@ NqstaWifiMac::Receive (Ptr packet, WifiMacHeader const *hdr) if (GetSsid ().IsBroadcast () || beacon.GetSsid ().IsEqual (GetSsid ())) { - Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); - RestartBeaconWatchdog (delay); goodBeacon = true; } - if (goodBeacon) + if (IsAssociated () && hdr->GetAddr3 () != GetBssid ()) { + goodBeacon = false; + } + if (goodBeacon) + { + Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); + RestartBeaconWatchdog (delay); SetBssid (hdr->GetAddr3 ()); } if (goodBeacon && m_state == BEACON_MISSED)