22 #include "ns3/ipv6-route.h"
24 #include "ns3/ipv6-static-routing.h"
26 #include "ns3/simulator.h"
40 .AddConstructor<Ipv6ListRouting> ()
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);
111 uint32_t iif =
m_ipv6->GetInterfaceForDevice (idev);
119 if (
m_ipv6->MulticastCheckGroup (iif, dst))
123 NS_LOG_LOGIC (
"Multicast packet for me-- local deliver");
127 lcb (packetCopy, header, iif);
138 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
142 NS_LOG_LOGIC (
"Multicast packet for me-- trying to forward");
143 if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
157 for (uint32_t j = 0; j <
m_ipv6->GetNInterfaces (); j++)
159 for (uint32_t i = 0; i <
m_ipv6->GetNAddresses (j); i++)
167 NS_LOG_LOGIC (
"For me (destination " << addr <<
" match)");
173 lcb (p, header, iif);
180 if (
m_ipv6->IsForwarding (iif) ==
false)
182 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
187 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
192 if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
205 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
210 (*rprotoIter).second->NotifyInterfaceUp (interface);
217 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
222 (*rprotoIter).second->NotifyInterfaceDown (interface);
229 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
234 (*rprotoIter).second->NotifyAddAddress (interface, address);
241 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
246 (*rprotoIter).second->NotifyRemoveAddress (interface, address);
253 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
258 (*rprotoIter).second->NotifyAddRoute (dst, mask, nextHop, interface, prefixToUse);
265 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
270 (*rprotoIter).second->NotifyRemoveRoute (dst, mask, nextHop, interface, prefixToUse);
281 <<
"Ipv6ListRouting table" << std::endl;
285 *stream->
GetStream () <<
" Priority: " << (*i).first <<
" Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
286 (*i).second->PrintRoutingTable (stream);
296 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
301 (*rprotoIter).second->SetIpv6 (ipv6);
309 NS_LOG_FUNCTION (
this << routingProtocol->GetInstanceTypeId () << priority);
314 routingProtocol->SetIpv6 (
m_ipv6);
331 NS_FATAL_ERROR (
"Ipv6ListRouting::GetRoutingProtocol (): index " << index <<
" out of range");
334 for (Ipv6RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
339 priority = (*rprotoIter).first;
340 return (*rprotoIter).second;
349 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)
virtual uint32_t GetNRoutingProtocols(void) const
Get the number of routing protocols.
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)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
IPv6 address associated with an interface.
bool IsEqual(const Ipv6Address &other) const
Comparison operation between two Ipv6Addresses.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
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.
#define NS_FATAL_ERROR(msg)
fatal error handling
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.
double GetSeconds(void) const
Ipv6Address GetAddress() const
Get the IPv6 address.
virtual void NotifyInterfaceUp(uint32_t interface)
Notify when specified interface goes UP.
#define NS_LOG_LOGIC(msg)
virtual void SetIpv6(Ptr< Ipv6 > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
static Ipv6Address GetAllHostsMulticast()
Get the "all hosts multicast" address.
Ptr< Packet > Copy(void) const
Ipv6ListRouting()
Constructor.
bool IsMulticast() const
If the IPv6 address is multicast (ff00::/8).
std::pair< int16_t, Ptr< Ipv6RoutingProtocol > > Ipv6RoutingProtocolEntry
Container identifying an IPv6 Routing Protocol entry in the list.
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the Routing Table entries.
virtual ~Ipv6ListRouting()
Destructor.
static Time Now(void)
Return the "current simulation time".
Describes an IPv6 address.
static TypeId GetTypeId(void)
Get the type ID of this class.
uint32_t GetId(void) const
virtual void NotifyInterfaceDown(uint32_t interface)
Notify when specified interface goes DOWN.
Describes an IPv6 prefix.
virtual void DoDispose(void)
Dispose this object.
Abstract base class for Ipv6 routing protocols.
a unique identifier for an interface.
virtual Ptr< Ipv6RoutingProtocol > GetRoutingProtocol(uint32_t index, int16_t &priority) const
Get pointer to routing protocol stored at index,.
TypeId SetParent(TypeId tid)
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
Ipv6RoutingProtocolList m_routingProtocols
List of routing protocols.
NS_LOG_COMPONENT_DEFINE("Ipv6ListRouting")
static Ipv6Address GetAllRoutersMulticast()
Get the "all routers multicast" address.
virtual void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address.