22 #include "ns3/ipv6-route.h" 24 #include "ns3/ipv6-static-routing.h" 26 #include "ns3/simulator.h" 39 .SetGroupName (
"Internet")
67 (*rprotoIter).second = 0;
82 NS_LOG_LOGIC (
"Checking protocol " << (*i).second->GetInstanceTypeId () <<
" with priority " << (*i).first);
84 route = (*i).second->RouteOutput (p, header, oif, sockerr);
113 uint32_t iif =
m_ipv6->GetInterfaceForDevice (idev);
114 if (
m_ipv6->IsForwarding (iif) ==
false)
116 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
124 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
128 if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, lcb, nullEcb))
143 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
148 (*rprotoIter).second->NotifyInterfaceUp (interface);
155 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
160 (*rprotoIter).second->NotifyInterfaceDown (interface);
167 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
172 (*rprotoIter).second->NotifyAddAddress (interface,
address);
179 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
184 (*rprotoIter).second->NotifyRemoveAddress (interface,
address);
191 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
196 (*rprotoIter).second->NotifyAddRoute (dst, mask, nextHop, interface, prefixToUse);
203 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
208 (*rprotoIter).second->NotifyRemoveRoute (dst, mask, nextHop, interface, prefixToUse);
218 <<
", Time: " <<
Now().
As (unit)
219 <<
", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
220 <<
", Ipv6ListRouting table" << std::endl;
224 *stream->
GetStream () <<
" Priority: " << (*i).first <<
" Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
225 (*i).second->PrintRoutingTable (stream, unit);
234 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
239 (*rprotoIter).second->SetIpv6 (ipv6);
247 NS_LOG_FUNCTION (
this << routingProtocol->GetInstanceTypeId () << priority);
252 routingProtocol->SetIpv6 (
m_ipv6);
269 NS_FATAL_ERROR (
"Ipv6ListRouting::GetRoutingProtocol (): index " << index <<
" out of range");
272 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
277 priority = (*rprotoIter).first;
278 return (*rprotoIter).second;
287 return a.first > b.first;
virtual void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint32_t GetId(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual Ptr< Ipv6RoutingProtocol > GetRoutingProtocol(uint32_t index, int16_t &priority) const
Get pointer to routing protocol stored at index,.
virtual Ptr< Ipv6Route > RouteOutput(Ptr< Packet > p, const Ipv6Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
IPv6 address associated with an interface.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
SocketErrno
Enumeration of the possible errors returned by a socket.
virtual void AddRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol, int16_t priority)
Register a new routing protocol to be used in this IPv4 stack.
virtual void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify a new route.
Ptr< Ipv6 > m_ipv6
Ipv6 this protocol is associated with.
virtual bool RouteInput(Ptr< const Packet > p, const Ipv6Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
static bool Compare(const Ipv6RoutingProtocolEntry &a, const Ipv6RoutingProtocolEntry &b)
Compare two routing protocols.
virtual void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify route removing.
virtual void NotifyInterfaceUp(uint32_t interface)
Notify when specified interface goes UP.
Unit
The unit to use to interpret a number representing time.
virtual void SetIpv6(Ptr< Ipv6 > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
Ipv6ListRouting()
Constructor.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::pair< int16_t, Ptr< Ipv6RoutingProtocol > > Ipv6RoutingProtocolEntry
Container identifying an IPv6 Routing Protocol entry in the list.
virtual ~Ipv6ListRouting()
Destructor.
virtual uint32_t GetNRoutingProtocols(void) const
Get the number of routing protocols.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
Describes an IPv6 address.
static TypeId GetTypeId(void)
Get the type ID of this class.
virtual void NotifyInterfaceDown(uint32_t interface)
Notify when specified interface goes DOWN.
Describes an IPv6 prefix.
Hold list of Ipv6RoutingProtocol objects.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
virtual void DoDispose(void)
Dispose this object.
Abstract base class for IPv6 routing protocols.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
Ipv6RoutingProtocolList m_routingProtocols
List of routing protocols.
virtual void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address.