diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index b934895ed..2f8e9c115 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -366,6 +366,7 @@ MacLow::MacLow () NS_LOG_FUNCTION (this); m_lastNavDuration = Seconds (0); m_lastNavStart = Seconds (0); + m_promisc = false; } MacLow::~MacLow () @@ -522,6 +523,11 @@ MacLow::SetBssid (Mac48Address bssid) { m_bssid = bssid; } +void +MacLow::SetPromisc (void) +{ + m_promisc = true; +} Mac48Address MacLow::GetAddress (void) const { @@ -893,6 +899,14 @@ MacLow::ReceiveOk (Ptr packet, double rxSnr, WifiMode txMode, WifiPreamb // DROP } } + else if (m_promisc) + { + NS_ASSERT (hdr.GetAddr1 () != m_self); + if (hdr.IsData ()) + { + goto rxPacket; + } + } else { //NS_LOG_DEBUG_VERBOSE ("rx not-for-me from %d", GetSource (packet)); diff --git a/src/wifi/model/mac-low.h b/src/wifi/model/mac-low.h index 9aaf9682b..75103761b 100644 --- a/src/wifi/model/mac-low.h +++ b/src/wifi/model/mac-low.h @@ -388,6 +388,7 @@ public: void SetSlotTime (Time slotTime); void SetPifs (Time pifs); void SetBssid (Mac48Address ad); + void SetPromisc (void); Mac48Address GetAddress (void) const; Time GetAckTimeout (void) const; Time GetBasicBlockAckTimeout () const; @@ -632,6 +633,8 @@ private: Time m_lastNavStart; Time m_lastNavDuration; + bool m_promisc; + // Listerner needed to monitor when a channel switching occurs. class PhyMacLowListener * m_phyMacLowListener; diff --git a/src/wifi/model/regular-wifi-mac.cc b/src/wifi/model/regular-wifi-mac.cc index 2ae2bf0b4..4ef8e463f 100644 --- a/src/wifi/model/regular-wifi-mac.cc +++ b/src/wifi/model/regular-wifi-mac.cc @@ -390,6 +390,12 @@ RegularWifiMac::GetBssid (void) const return m_low->GetBssid (); } +void +RegularWifiMac::SetPromisc (void) +{ + m_low->SetPromisc (); +} + void RegularWifiMac::Enqueue (Ptr packet, Mac48Address to, Mac48Address from) diff --git a/src/wifi/model/regular-wifi-mac.h b/src/wifi/model/regular-wifi-mac.h index 81b4323eb..93e50a564 100644 --- a/src/wifi/model/regular-wifi-mac.h +++ b/src/wifi/model/regular-wifi-mac.h @@ -130,6 +130,14 @@ public: * \returns the bssid of the network this device belongs to. */ virtual Mac48Address GetBssid (void) const; + /** + * \brief Sets the interface in promiscuous mode. + * + * Enables promiscuous mode on the interface. Note that any further + * filtering on the incoming frame path may affect the overall + * behavior. + */ + virtual void SetPromisc (void); /** * \param packet the packet to send. diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index 2a1b91ac0..a208abb4a 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -133,6 +133,14 @@ public: * \returns the bssid of the network this device belongs to. */ virtual Mac48Address GetBssid (void) const = 0; + /** + * \brief Sets the interface in promiscuous mode. + * + * Enables promiscuous mode on the interface. Note that any further + * filtering on the incoming frame path may affect the overall + * behavior. + */ + virtual void SetPromisc (void) = 0; /** * \param packet the packet to send. diff --git a/src/wifi/model/wifi-net-device.cc b/src/wifi/model/wifi-net-device.cc index 8accbbb09..6b654b14e 100644 --- a/src/wifi/model/wifi-net-device.cc +++ b/src/wifi/model/wifi-net-device.cc @@ -356,6 +356,7 @@ void WifiNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb) { m_promiscRx = cb; + m_mac->SetPromisc(); } bool