22 #include "ns3/ipv4-route.h"
24 #include "ns3/ipv4-static-routing.h"
38 .AddConstructor<Ipv4ListRouting> ()
65 (*rprotoIter).second = 0;
77 <<
"Ipv4ListRouting table" << std::endl;
81 *stream->
GetStream () <<
" Priority: " << (*i).first <<
" Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
82 (*i).second->PrintRoutingTable (stream);
95 protocol->Initialize ();
110 NS_LOG_LOGIC (
"Checking protocol " << (*i).second->GetInstanceTypeId () <<
" with priority " << (*i).first);
112 route = (*i).second->RouteOutput (p, header, oif, sockerr);
132 NS_LOG_FUNCTION (
this << p << header << idev << &ucb << &mcb << &lcb << &ecb);
139 uint32_t iif =
m_ipv4->GetInterfaceForDevice (idev);
148 lcb (packetCopy, header, iif);
154 lcb (p, header, iif);
159 if (
m_ipv4->IsForwarding (iif) ==
false)
161 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
171 downstreamLcb = MakeNullCallback<void, Ptr<const Packet>,
const Ipv4Header &, uint32_t > ();
173 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
178 if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, downstreamLcb, ecb))
180 NS_LOG_LOGIC (
"Route found to forward packet in protocol " << (*rprotoIter).second->GetInstanceTypeId ().GetName ());
192 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
197 (*rprotoIter).second->NotifyInterfaceUp (interface);
204 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
209 (*rprotoIter).second->NotifyInterfaceDown (interface);
216 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
221 (*rprotoIter).second->NotifyAddAddress (interface, address);
228 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
233 (*rprotoIter).second->NotifyRemoveAddress (interface, address);
241 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
246 (*rprotoIter).second->SetIpv4 (ipv4);
254 NS_LOG_FUNCTION (
this << routingProtocol->GetInstanceTypeId () << priority);
259 routingProtocol->SetIpv4 (
m_ipv4);
276 NS_FATAL_ERROR (
"Ipv4ListRouting::GetRoutingProtocol(): index " << index <<
" out of range");
279 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
284 priority = (*rprotoIter).first;
285 return (*rprotoIter).second;
295 return a.first > b.first;
#define NS_LOG_FUNCTION(parameters)
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the Routing Table entries.
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(uint32_t index, int16_t &priority) const
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
virtual void AddRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol, int16_t priority)
Register a new routing protocol to be used in this IPv4 stack.
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
bool IsMulticast(void) const
static TypeId GetTypeId(void)
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
#define NS_LOG_FUNCTION_NOARGS()
#define NS_FATAL_ERROR(msg)
fatal error handling
double GetSeconds(void) const
static bool Compare(const Ipv4RoutingProtocolEntry &a, const Ipv4RoutingProtocolEntry &b)
virtual ~Ipv4ListRouting()
std::pair< int16_t, Ptr< Ipv4RoutingProtocol > > Ipv4RoutingProtocolEntry
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
#define NS_LOG_LOGIC(msg)
Ptr< Packet > Copy(void) const
virtual uint32_t GetNRoutingProtocols(void) const
virtual void NotifyInterfaceUp(uint32_t interface)
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
uint32_t GetId(void) const
a class to store IPv4 address information on an interface
Ipv4RoutingProtocolList m_routingProtocols
virtual void NotifyInterfaceDown(uint32_t interface)
Abstract base class for IPv4 routing protocols.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
std::ostream * GetStream(void)
virtual void DoInitialize(void)
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)