Bug 1527 - Ipv4RawSocket's BindToNetDevice not doing anything
authorTommaso Pecorella <tommaso.pecorella@unifi.it>
Sun, 11 Nov 2012 16:29:57 +0100
changeset 9147 e9af93287335
parent 9146 1bc2026bc8b4
child 9148 9c37ec6053bd
Bug 1527 - Ipv4RawSocket's BindToNetDevice not doing anything
src/internet/model/ipv4-raw-socket-impl.cc
--- a/src/internet/model/ipv4-raw-socket-impl.cc	Thu Nov 22 07:15:19 2012 -0800
+++ b/src/internet/model/ipv4-raw-socket-impl.cc	Sun Nov 11 16:29:57 2012 +0100
@@ -311,6 +311,16 @@
     {
       return false;
     }
+
+  Ptr<NetDevice> boundNetDevice = Socket::GetBoundNetDevice();
+  if (boundNetDevice)
+    {
+      if (boundNetDevice != incomingInterface->GetDevice())
+        {
+          return false;
+        }
+    }
+
   NS_LOG_LOGIC ("src = " << m_src << " dst = " << m_dst);
   if ((m_src == Ipv4Address::GetAny () || ipHeader.GetDestination () == m_src) &&
       (m_dst == Ipv4Address::GetAny () || ipHeader.GetSource () == m_dst) &&