diff --git a/src/internet-stack/ipv4-raw-socket-impl.cc b/src/internet-stack/ipv4-raw-socket-impl.cc index 946728848..5b8ba4280 100644 --- a/src/internet-stack/ipv4-raw-socket-impl.cc +++ b/src/internet-stack/ipv4-raw-socket-impl.cc @@ -178,6 +178,14 @@ Ipv4RawSocketImpl::SendTo (Ptr p, uint32_t flags, SocketErrno errno_ = ERROR_NOTERROR;//do not use errno as it is the standard C last error number Ptr route; Ptr oif = m_boundnetdevice; //specify non-zero if bound to a source address + if (!oif && m_src != Ipv4Address::GetAny ()) + { + int32_t index = ipv4->GetInterfaceForAddress (m_src); + NS_ASSERT (index >= 0); + oif = ipv4->GetNetDevice (index); + NS_LOG_LOGIC ("Set index " << oif << "from source " << m_src); + } + // TBD-- we could cache the route and just check its validity route = ipv4->GetRoutingProtocol ()->RouteOutput (p, header, oif, errno_); if (route != 0) diff --git a/src/internet-stack/wscript b/src/internet-stack/wscript index 8410a47ad..09f15eaa8 100644 --- a/src/internet-stack/wscript +++ b/src/internet-stack/wscript @@ -75,6 +75,7 @@ def build(bld): 'tcp-test.cc', 'udp-test.cc', 'ipv4-test.cc', + 'ipv4-raw-test.cc', 'ipv4-l4-protocol.cc', 'udp-header.cc', 'tcp-header.cc',