[Bug 827] promiscuous mode for wifi

This commit is contained in:
Ruben Merz
2011-05-16 22:12:39 +02:00
parent 24a396bee5
commit 8f5bb9a833
6 changed files with 40 additions and 0 deletions

View File

@@ -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> 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));

View File

@@ -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;

View File

@@ -390,6 +390,12 @@ RegularWifiMac::GetBssid (void) const
return m_low->GetBssid ();
}
void
RegularWifiMac::SetPromisc (void)
{
m_low->SetPromisc ();
}
void
RegularWifiMac::Enqueue (Ptr<const Packet> packet,
Mac48Address to, Mac48Address from)

View File

@@ -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.

View File

@@ -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.

View File

@@ -356,6 +356,7 @@ void
WifiNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
{
m_promiscRx = cb;
m_mac->SetPromisc();
}
bool