src/devices/csma/csma-net-device.cc
changeset 3442 8eef02250bc9
parent 3438 86e262420fbf
child 3445 ae9f7d5e2d56
--- a/src/devices/csma/csma-net-device.cc	Fri Jul 04 17:58:31 2008 +0100
+++ b/src/devices/csma/csma-net-device.cc	Fri Jul 04 18:03:26 2008 +0100
@@ -173,6 +173,7 @@
   void 
 CsmaNetDevice::AddHeader (
   Ptr<Packet> p, 
+  Mac48Address source,
   Mac48Address dest,
   uint16_t protocolNumber)
 {
@@ -183,7 +184,6 @@
       return;
     }
 
-  Mac48Address source = Mac48Address::ConvertFrom (GetAddress ());
   EthernetHeader header (false);
   header.SetSource (source);
   header.SetDestination (dest);
@@ -492,17 +492,6 @@
   NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
 
 //
-// We never forward up packets that we sent.  Real devices don't do this since
-// their receivers are disabled during send, so we don't.  Drop the packet 
-// silently (no tracing) since it would really never get here in a real device.
-//
-  if (header.GetSource () == GetAddress ())
-    {
-      NS_LOG_LOGIC ("Ignoring packet sourced by this device");
-      return;
-    }
-
-//
 // An IP host group address is mapped to an Ethernet multicast address
 // by placing the low-order 23-bits of the IP address into the low-order
 // 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex).
@@ -730,11 +719,19 @@
   return false;
 }
 
-  bool 
-CsmaNetDevice::Send(
-  Ptr<Packet> packet, 
-  const Address& dest, 
-  uint16_t protocolNumber)
+bool
+CsmaNetDevice::Send (Ptr<Packet> packet, 
+                     const Address& dest, 
+                     uint16_t protocolNumber)
+{
+  return SendFrom (packet, m_address, dest, protocolNumber);
+}
+
+bool
+CsmaNetDevice::SendFrom (Ptr<Packet> packet,
+                         const Address& src,
+                         const Address& dest,
+                         uint16_t protocolNumber)
 {
   NS_LOG_FUNCTION_NOARGS ();
   NS_LOG_LOGIC ("p=" << packet);
@@ -751,7 +748,8 @@
     }
 
   Mac48Address destination = Mac48Address::ConvertFrom (dest);
-  AddHeader (packet, destination, protocolNumber);
+  Mac48Address source = Mac48Address::ConvertFrom (src);
+  AddHeader (packet, source, destination, protocolNumber);
 
 //
 // Place the packet to be sent on the send queue