internet: Align RIPng and RIP implementations
This commit is contained in:
@@ -205,7 +205,7 @@ Ptr<Ipv4Route> Rip::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<Ne
|
||||
NS_LOG_LOGIC ("RouteOutput (): Multicast destination");
|
||||
}
|
||||
|
||||
rtentry = Lookup (destination, oif);
|
||||
rtentry = Lookup (destination, true, oif);
|
||||
if (rtentry)
|
||||
{
|
||||
sockerr = Socket::ERROR_NOTERROR;
|
||||
@@ -276,7 +276,7 @@ bool Rip::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const N
|
||||
}
|
||||
// Next, try to find a route
|
||||
NS_LOG_LOGIC ("Unicast destination");
|
||||
Ptr<Ipv4Route> rtentry = Lookup (header.GetDestination ());
|
||||
Ptr<Ipv4Route> rtentry = Lookup (header.GetDestination (), false);
|
||||
|
||||
if (rtentry != 0)
|
||||
{
|
||||
@@ -582,8 +582,7 @@ void Rip::DoDispose ()
|
||||
Ipv4RoutingProtocol::DoDispose ();
|
||||
}
|
||||
|
||||
|
||||
Ptr<Ipv4Route> Rip::Lookup (Ipv4Address dst, Ptr<NetDevice> interface)
|
||||
Ptr<Ipv4Route> Rip::Lookup (Ipv4Address dst, bool setSource, Ptr<NetDevice> interface)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << dst << interface);
|
||||
|
||||
@@ -633,13 +632,16 @@ Ptr<Ipv4Route> Rip::Lookup (Ipv4Address dst, Ptr<NetDevice> interface)
|
||||
uint32_t interfaceIdx = route->GetInterface ();
|
||||
rtentry = Create<Ipv4Route> ();
|
||||
|
||||
if (route->GetDest ().IsAny ()) /* default route */
|
||||
if (setSource)
|
||||
{
|
||||
rtentry->SetSource (m_ipv4->SourceAddressSelection (interfaceIdx, route->GetGateway ()));
|
||||
}
|
||||
else
|
||||
{
|
||||
rtentry->SetSource (m_ipv4->SourceAddressSelection (interfaceIdx, route->GetDest ()));
|
||||
if (route->GetDest ().IsAny ()) /* default route */
|
||||
{
|
||||
rtentry->SetSource (m_ipv4->SourceAddressSelection (interfaceIdx, route->GetGateway ()));
|
||||
}
|
||||
else
|
||||
{
|
||||
rtentry->SetSource (m_ipv4->SourceAddressSelection (interfaceIdx, route->GetDest ()));
|
||||
}
|
||||
}
|
||||
|
||||
rtentry->SetDestination (route->GetDest ());
|
||||
|
||||
@@ -305,10 +305,11 @@ private:
|
||||
/**
|
||||
* \brief Lookup in the forwarding table for destination.
|
||||
* \param dest destination address
|
||||
* \param setSource set source address in the route
|
||||
* \param interface output interface if any (put 0 otherwise)
|
||||
* \return Ipv4Route to route the packet to reach dest address
|
||||
*/
|
||||
Ptr<Ipv4Route> Lookup (Ipv4Address dest, Ptr<NetDevice> = 0);
|
||||
Ptr<Ipv4Route> Lookup (Ipv4Address dest, bool setSource, Ptr<NetDevice> = 0);
|
||||
|
||||
/**
|
||||
* Receive and process unicast packet
|
||||
|
||||
Reference in New Issue
Block a user