From 2eb560a9f77774bf15cd8b7faee5ce53b17a5748 Mon Sep 17 00:00:00 2001 From: Hajime Tazaki Date: Thu, 8 Apr 2010 11:26:46 +0900 Subject: [PATCH] bug 859 - Output interface estimation for the source address bound socket in IPv4 Raw socket --- src/internet-stack/ipv4-raw-socket-impl.cc | 8 ++++++++ src/internet-stack/wscript | 1 + 2 files changed, 9 insertions(+) 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',