22 #include "ns3/ipv4-route.h"
24 #include "ns3/ipv4-static-routing.h"
39 .AddConstructor<Ipv4ListRouting> ()
66 (*rprotoIter).second = 0;
78 <<
"Ipv4ListRouting table" << std::endl;
82 *stream->
GetStream () <<
" Priority: " << (*i).first <<
" Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
83 (*i).second->PrintRoutingTable (stream);
96 protocol->Initialize ();
111 NS_LOG_LOGIC (
"Checking protocol " << (*i).second->GetInstanceTypeId () <<
" with priority " << (*i).first);
113 route = (*i).second->RouteOutput (p, header, oif, sockerr);
133 NS_LOG_FUNCTION (
this << p << header << idev << &ucb << &mcb << &lcb << &ecb);
140 uint32_t iif =
m_ipv4->GetInterfaceForDevice (idev);
149 lcb (packetCopy, header, iif);
155 lcb (p, header, iif);
160 if (
m_ipv4->IsForwarding (iif) ==
false)
162 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
172 downstreamLcb = MakeNullCallback<void, Ptr<const Packet>,
const Ipv4Header &, uint32_t > ();
174 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
179 if ((*rprotoIter).second->RouteInput (p, header, idev, ucb, mcb, downstreamLcb, ecb))
181 NS_LOG_LOGIC (
"Route found to forward packet in protocol " << (*rprotoIter).second->GetInstanceTypeId ().GetName ());
193 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
198 (*rprotoIter).second->NotifyInterfaceUp (interface);
205 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
210 (*rprotoIter).second->NotifyInterfaceDown (interface);
217 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
222 (*rprotoIter).second->NotifyAddAddress (interface, address);
229 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
234 (*rprotoIter).second->NotifyRemoveAddress (interface, address);
242 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
247 (*rprotoIter).second->SetIpv4 (ipv4);
255 NS_LOG_FUNCTION (
this << routingProtocol->GetInstanceTypeId () << priority);
260 routingProtocol->SetIpv4 (
m_ipv4);
277 NS_FATAL_ERROR (
"Ipv4ListRouting::GetRoutingProtocol(): index " << index <<
" out of range");
280 for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
m_routingProtocols.begin ();
285 priority = (*rprotoIter).first;
286 return (*rprotoIter).second;
296 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
Return pointer to routing protocol stored at index, with the first protocol (index 0) the highest pri...
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
void DoInitialize(void)
This method is called only once by Object::Initialize.
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)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
bool IsMulticast(void) const
static TypeId GetTypeId(void)
Get the type ID of this class.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
SocketErrno
Enumeration of the possible errors returned by a socket.
#define NS_FATAL_ERROR(msg)
fatal error handling
Ptr< Ipv4 > m_ipv4
Ipv4 this protocol is associated with.
double GetSeconds(void) const
static bool Compare(const Ipv4RoutingProtocolEntry &a, const Ipv4RoutingProtocolEntry &b)
Compare two routing protocols.
virtual ~Ipv4ListRouting()
std::pair< int16_t, Ptr< Ipv4RoutingProtocol > > Ipv4RoutingProtocolEntry
Container identifying an IPv4 Routing Protocol entry in the list.
#define NS_LOG_LOGIC(msg)
Ptr< Packet > Copy(void) const
virtual uint32_t GetNRoutingProtocols(void) const
void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual void NotifyInterfaceUp(uint32_t interface)
static Time Now(void)
Return the "current simulation time".
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
List of routing protocols.
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)
Return a pointer to an ostream previously set in the wrapper.
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
NS_LOG_COMPONENT_DEFINE("Ipv4ListRouting")