24 #include "ns3/packet.h"
25 #include "ns3/simulator.h"
26 #include "ns3/ipv6-route.h"
27 #include "ns3/net-device.h"
41 .AddConstructor<Ipv6StaticRouting> ()
87 <<
"Ipv6StaticRouting table" << std::endl;
92 *os << route << std::endl;
99 NS_LOG_FUNCTION (
this << dst << nextHop << interface << prefixToUse << metric);
102 NS_LOG_WARN (
"Ipv6StaticRouting::AddHostRouteTo - Next hop should be link-local");
116 NS_LOG_FUNCTION (
this << network << networkPrefix << nextHop << interface << metric);
124 NS_LOG_FUNCTION (
this << network << networkPrefix << nextHop << interface << prefixToUse << metric);
127 NS_LOG_WARN (
"Ipv6StaticRouting::AddNetworkRouteTo - Next hop should be link-local");
253 uint16_t longestMask = 0;
254 uint32_t shortestMetric = 0xffffffff;
260 NS_ASSERT_MSG (interface,
"Try to send on link-local multicast address, and no interface index is given!");
261 rtentry = Create<Ipv6Route> ();
263 rtentry->SetDestination (dst);
265 rtentry->SetOutputDevice (interface);
272 uint32_t metric = it->second;
277 NS_LOG_LOGIC (
"Searching for route to " << dst <<
", mask length " << maskLen <<
", metric " << metric);
281 NS_LOG_LOGIC (
"Found global network route " << j <<
", mask length " << maskLen <<
", metric " << metric);
286 if (maskLen < longestMask)
292 if (maskLen > longestMask)
294 shortestMetric = 0xffffffff;
297 longestMask = maskLen;
298 if (metric > shortestMetric)
300 NS_LOG_LOGIC (
"Equal mask length, but previous metric shorter, skipping");
304 shortestMetric = metric;
307 rtentry = Create<Ipv6Route> ();
322 rtentry->SetDestination (route->
GetDest ());
331 NS_LOG_LOGIC (
"Matching route via " << rtentry->GetDestination () <<
" (throught " << rtentry->GetGateway () <<
") at the end");
378 NS_LOG_LOGIC (
"Find source specific multicast route" << *i);
386 mrtentry = Create<Ipv6MulticastRoute> ();
387 mrtentry->SetGroup (route->
GetGroup ());
388 mrtentry->SetOrigin (route->
GetOrigin ());
414 uint32_t shortestMetric = 0xffffffff;
420 uint32_t metric = it->second;
430 if (metric > shortestMetric)
434 shortestMetric = metric;
568 mcb (idev, mrtentry, p, header);
594 NS_LOG_LOGIC (
"For me (destination " << addr <<
" match)");
600 lcb (p, header, iif);
609 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
619 NS_LOG_LOGIC (
"Found unicast destination- calling unicast callback");
620 ucb (idev, rtentry, p, header);
625 NS_LOG_LOGIC (
"Did not find unicast destination- returning false");
717 NS_LOG_INFO (
this << dst << mask << nextHop << interface << prefixToUse);
747 if (dst == entry && prefix == mask && rtentry->
GetInterface () == interface)