# HG changeset patch # User Tom Henderson # Date 1263364191 28800 # Node ID ed8415d216e102c9758a8deab397e2ba4e50532c # Parent be7ee94b8f7984da077a480a472c92ea38b92e2f [bug 778] make OLSR test outgoing interface in RouteOutput() diff -r be7ee94b8f79 -r ed8415d216e1 src/routing/olsr/olsr-routing-protocol.cc --- a/src/routing/olsr/olsr-routing-protocol.cc Tue Jan 12 18:52:34 2010 +0100 +++ b/src/routing/olsr/olsr-routing-protocol.cc Tue Jan 12 22:29:51 2010 -0800 @@ -2610,8 +2610,6 @@ RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject ()->GetId() << " " << header.GetDestination () << " " << oif); - // TBD: oif is unused; can be used to restrict the outgoing interface - // of the found route if application bound to a source interface Ptr rtentry; RoutingTableEntry entry1, entry2; if (Lookup (header.GetDestination (), entry1) != 0) @@ -2621,9 +2619,22 @@ { NS_FATAL_ERROR ("FindSendEntry failure"); } + uint32_t interfaceIdx = entry2.interface; + if (oif && m_ipv4->GetInterfaceForDevice (oif) != static_cast (interfaceIdx)) + { + // We do not attempt to perform a constrained routing search + // if the caller specifies the oif; we just enforce that + // that the found route matches the requested outbound interface + NS_LOG_DEBUG ("Olsr node " << m_mainAddress + << ": RouteOutput for dest=" << header.GetDestination () + << " Route interface " << interfaceIdx + << " does not match requested output interface " + << m_ipv4->GetInterfaceForDevice (oif)); + sockerr = Socket::ERROR_NOROUTETOHOST; + return rtentry; + } rtentry = Create (); rtentry->SetDestination (header.GetDestination ()); - uint32_t interfaceIdx = entry2.interface; // the source address is the interface address that matches // the destination address (when multiple are present on the // outgoing interface, one is selected via scoping rules)