diff --git a/src/nix-vector-routing/doc/nix-vector-routing.rst b/src/nix-vector-routing/doc/nix-vector-routing.rst index 79d0b4156..34246371d 100644 --- a/src/nix-vector-routing/doc/nix-vector-routing.rst +++ b/src/nix-vector-routing/doc/nix-vector-routing.rst @@ -74,6 +74,8 @@ When using the IPv6 stack, the link-local address allocation is unique by default over the entire topology. However, if the link-local addresses are assigned manually, the user must ensure uniqueness of link-local addresses. +NixVectorRouting supports routes to IPv4 and IPv6 loopback addresses on localhost. +Although it is not really intended to route to these addresses, it can do so. Usage ***** diff --git a/src/nix-vector-routing/model/nix-vector-routing.cc b/src/nix-vector-routing/model/nix-vector-routing.cc index 3fa360eb9..4e80f8245 100644 --- a/src/nix-vector-routing/model/nix-vector-routing.cc +++ b/src/nix-vector-routing/model/nix-vector-routing.cc @@ -681,6 +681,24 @@ NixVectorRouting::RouteOutput (Ptr p, const IpHeader &header, Ptr (); + rtentry->SetSource (IpAddress::GetLoopback ()); + rtentry->SetDestination (destAddress); + rtentry->SetGateway (IpAddress::GetZero ()); + for (uint32_t i = 0 ; i < m_ip->GetNInterfaces (); i++) + { + Ptr loNetDevice = DynamicCast (m_ip->GetNetDevice (i)); + if (loNetDevice) + { + rtentry->SetOutputDevice (loNetDevice); + break; + } + } + return rtentry; + } + if constexpr (!IsIpv4::value) { /* when sending on link-local multicast, there have to be interface specified */