First draft of patch for bug 827
authorRuben Merz <ruben@net.t-labs.tu-berlin.de>
Tue, 17 May 2011 10:57:18 +0200
changeset 0 d15c3820d389
child 1 7cc57436fc1d
First draft of patch for bug 827
.hgignore
001-promisc-wifi.patch
series
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Tue May 17 10:57:18 2011 +0200
@@ -0,0 +1,5 @@
+^\.hg
+^\.mq
+syntax: glob
+status
+guards
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/001-promisc-wifi.patch	Tue May 17 10:57:18 2011 +0200
@@ -0,0 +1,127 @@
+# HG changeset patch
+# User Ruben Merz <ruben@net.t-labs.tu-berlin.de>
+# Date 1305576759 -7200
+
+[Bug 827] promiscuous mode for wifi
+
+diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc
+--- a/src/wifi/model/mac-low.cc
++++ b/src/wifi/model/mac-low.cc
+@@ -366,6 +366,7 @@
+   NS_LOG_FUNCTION (this);
+   m_lastNavDuration = Seconds (0);
+   m_lastNavStart = Seconds (0);
++  m_promisc = false;
+ }
+ 
+ MacLow::~MacLow ()
+@@ -522,6 +523,11 @@
+ {
+   m_bssid = bssid;
+ }
++void
++MacLow::SetPromisc (void)
++{
++  m_promisc = true;
++}
+ Mac48Address
+ MacLow::GetAddress (void) const
+ {
+@@ -893,6 +899,14 @@
+           // 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
+--- a/src/wifi/model/mac-low.h
++++ b/src/wifi/model/mac-low.h
+@@ -388,6 +388,7 @@
+   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 @@
+   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
+--- a/src/wifi/model/regular-wifi-mac.cc
++++ b/src/wifi/model/regular-wifi-mac.cc
+@@ -391,6 +391,12 @@
+ }
+ 
+ void
++RegularWifiMac::SetPromisc (void)
++{
++  m_low->SetPromisc ();
++}
++
++void
+ RegularWifiMac::Enqueue (Ptr<const Packet> packet,
+                          Mac48Address to, Mac48Address from)
+ {
+diff --git a/src/wifi/model/regular-wifi-mac.h b/src/wifi/model/regular-wifi-mac.h
+--- a/src/wifi/model/regular-wifi-mac.h
++++ b/src/wifi/model/regular-wifi-mac.h
+@@ -130,6 +130,14 @@
+    * \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
+--- a/src/wifi/model/wifi-mac.h
++++ b/src/wifi/model/wifi-mac.h
+@@ -133,6 +133,14 @@
+    * \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
+--- a/src/wifi/model/wifi-net-device.cc
++++ b/src/wifi/model/wifi-net-device.cc
+@@ -356,6 +356,7 @@
+ WifiNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
+ {
+   m_promiscRx = cb;
++  m_mac->SetPromisc();
+ }
+ 
+ bool
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/series	Tue May 17 10:57:18 2011 +0200
@@ -0,0 +1,1 @@
+001-promisc-wifi.patch