[Bug 398] NqstaWifiMac does not filter received frames by BSSID
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Tue, 25 Nov 2008 14:45:46 +0000
changeset 3921 ee1f01c019f4
parent 3920 736b807ae8c0
child 3922 d549fa894719
child 3927 a2a992900b0b
[Bug 398] NqstaWifiMac does not filter received frames by BSSID
src/devices/wifi/nqsta-wifi-mac.cc
--- a/src/devices/wifi/nqsta-wifi-mac.cc	Tue Nov 25 15:37:43 2008 +0100
+++ b/src/devices/wifi/nqsta-wifi-mac.cc	Tue Nov 25 14:45:46 2008 +0000
@@ -475,10 +475,25 @@
   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 @@
       if (GetSsid ().IsBroadcast () ||
           beacon.GetSsid ().IsEqual (GetSsid ()))
         {
+          goodBeacon = true;
+        }
+      if (IsAssociated () && hdr->GetAddr3 () != GetBssid ())
+        {
+          goodBeacon = false;
+        }
+      if (goodBeacon)
+        {
           Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons);
           RestartBeaconWatchdog (delay);
-          goodBeacon = true;
-        }
-      if (goodBeacon) 
-        {
           SetBssid (hdr->GetAddr3 ());
         }
       if (goodBeacon && m_state == BEACON_MISSED)