src/devices/csma/csma-net-device.cc
changeset 3460 99698bc858e8
parent 3448 0bd851bb1225
child 3476 b834a9204124
--- a/src/devices/csma/csma-net-device.cc	Wed Jul 16 14:33:44 2008 +0100
+++ b/src/devices/csma/csma-net-device.cc	Wed Jul 16 16:06:50 2008 +0100
@@ -481,7 +481,11 @@
   if (m_encapMode == RAW)
     {
       m_rxTrace (packet);
-      m_rxCallback (this, packet, 0, GetBroadcast (), GetAddress (), PACKET_HOST);
+      if (!m_promiscRxCallback.IsNull ())
+        {
+          m_promiscRxCallback (this, packet, 0, GetBroadcast (), GetAddress (), PACKET_HOST);
+        }
+      m_rxCallback (this, packet, 0, GetBroadcast ());
       return;
     }
 
@@ -575,7 +579,15 @@
           packetType = PACKET_OTHERHOST;
         }
       
-      m_rxCallback (this, packet, protocol, header.GetSource (), header.GetDestination (), packetType);
+      if (!m_promiscRxCallback.IsNull ())
+        {
+          m_promiscRxCallback (this, packet, protocol, header.GetSource (), header.GetDestination (), packetType);
+        }
+
+      if (packetType != PACKET_OTHERHOST)
+        {
+          m_rxCallback (this, packet, protocol, header.GetSource ());
+        }
     }
 }
 
@@ -847,4 +859,16 @@
   m_rxCallback = cb;
 }
 
+void 
+CsmaNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb)
+{
+  m_promiscRxCallback = cb;
+}
+
+bool 
+CsmaNetDevice::SupportsPromiscuous () const
+{
+  return true;
+}
+
 } // namespace ns3