A Discrete-Event Network Simulator
API
ipv4-list-routing.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 University of Washington
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17 
18 #ifndef IPV4_LIST_ROUTING_H
19 #define IPV4_LIST_ROUTING_H
20 
21 #include "ipv4-routing-protocol.h"
22 
23 #include "ns3/nstime.h"
24 #include "ns3/simulator.h"
25 
26 #include <list>
27 
28 namespace ns3
29 {
30 
47 {
48  public:
53  static TypeId GetTypeId();
54 
56  ~Ipv4ListRouting() override;
57 
65  virtual void AddRoutingProtocol(Ptr<Ipv4RoutingProtocol> routingProtocol, int16_t priority);
69  virtual uint32_t GetNRoutingProtocols() const;
81  virtual Ptr<Ipv4RoutingProtocol> GetRoutingProtocol(uint32_t index, int16_t& priority) const;
82 
83  // Below are from Ipv4RoutingProtocol
85  const Ipv4Header& header,
86  Ptr<NetDevice> oif,
87  Socket::SocketErrno& sockerr) override;
88 
90  const Ipv4Header& header,
92  const UnicastForwardCallback& ucb,
93  const MulticastForwardCallback& mcb,
94  const LocalDeliverCallback& lcb,
95  const ErrorCallback& ecb) override;
96  void NotifyInterfaceUp(uint32_t interface) override;
97  void NotifyInterfaceDown(uint32_t interface) override;
98  void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override;
99  void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) override;
100  void SetIpv4(Ptr<Ipv4> ipv4) override;
102  Time::Unit unit = Time::S) const override;
103 
104  protected:
105  void DoDispose() override;
106  void DoInitialize() override;
107 
108  private:
112  typedef std::pair<int16_t, Ptr<Ipv4RoutingProtocol>> Ipv4RoutingProtocolEntry;
116  typedef std::list<Ipv4RoutingProtocolEntry> Ipv4RoutingProtocolList;
118 
125  static bool Compare(const Ipv4RoutingProtocolEntry& a, const Ipv4RoutingProtocolEntry& b);
127 };
128 
129 } // namespace ns3
130 
131 #endif /* IPV4_LIST_ROUTING_H */
Packet header for IPv4.
Definition: ipv4-header.h:34
a class to store IPv4 address information on an interface
IPv4 list routing.
std::pair< int16_t, Ptr< Ipv4RoutingProtocol > > Ipv4RoutingProtocolEntry
Container identifying an IPv4 Routing Protocol entry in the list.
static TypeId GetTypeId()
Get the type ID of this class.
void DoDispose() override
Destructor implementation.
Ipv4RoutingProtocolList m_routingProtocols
List of routing protocols.
void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) override
Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr) override
Query routing cache for an existing route, for an outbound packet.
void SetIpv4(Ptr< Ipv4 > ipv4) override
virtual uint32_t GetNRoutingProtocols() const
std::list< Ipv4RoutingProtocolEntry > Ipv4RoutingProtocolList
Container of the IPv4 Routing Protocols.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const override
Print the Routing Table entries.
bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, const UnicastForwardCallback &ucb, const MulticastForwardCallback &mcb, const LocalDeliverCallback &lcb, const ErrorCallback &ecb) override
Route an input packet (to be forwarded or locally delivered)
virtual void AddRoutingProtocol(Ptr< Ipv4RoutingProtocol > routingProtocol, int16_t priority)
Register a new routing protocol to be used in this IPv4 stack.
Ptr< Ipv4 > m_ipv4
Ipv4 this protocol is associated with.
static bool Compare(const Ipv4RoutingProtocolEntry &a, const Ipv4RoutingProtocolEntry &b)
Compare two routing protocols.
void NotifyInterfaceDown(uint32_t interface) override
void DoInitialize() override
Initialize() implementation.
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...
void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override
void NotifyInterfaceUp(uint32_t interface) override
Abstract base class for IPv4 routing protocols.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:84
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:111
@ S
second
Definition: nstime.h:116
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.