A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-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 IPV6_LIST_ROUTING_H
19#define IPV6_LIST_ROUTING_H
20
22
23#include <list>
24
25namespace ns3
26{
27
28/**
29 * \ingroup ipv6Routing
30 *
31 * \brief Hold list of Ipv6RoutingProtocol objects.
32 *
33 * This class is a specialization of Ipv6RoutingProtocol that allows
34 * other instances of Ipv6RoutingProtocol to be inserted in a
35 * prioritized list. Routing protocols in the list are consulted one
36 * by one, from highest to lowest priority, until a routing protocol
37 * is found that will take the packet (this corresponds to a non-zero
38 * return value to RouteOutput, or a return value of true to RouteInput).
39 * The order by which routing protocols with the same priority value
40 * are consulted is undefined.
41 *
42 */
44{
45 public:
46 /**
47 * \brief Get the type ID of this class.
48 * \return type ID
49 */
50 static TypeId GetTypeId();
51
52 /**
53 * \brief Constructor.
54 */
56
57 /**
58 * \brief Destructor.
59 */
60 ~Ipv6ListRouting() override;
61
62 /**
63 * \brief Register a new routing protocol to be used in this IPv4 stack
64 * \param routingProtocol new routing protocol implementation object
65 * \param priority priority to give to this routing protocol.
66 * Values may range between -32768 and +32767.
67 */
68 virtual void AddRoutingProtocol(Ptr<Ipv6RoutingProtocol> routingProtocol, int16_t priority);
69
70 /**
71 * \brief Get the number of routing protocols.
72 * \return number of routing protocols in the list
73 */
74 virtual uint32_t GetNRoutingProtocols() const;
75
76 /**
77 * \brief Get pointer to routing protocol stored at index,
78 *
79 * The first protocol (index 0) the highest priority, the next one (index 1)
80 * the second highest priority, and so on. The priority parameter is an
81 * output parameter and it returns the integer priority of the protocol.
82 * \param index index of protocol to return
83 * \param priority output parameter, set to the priority of the protocol
84 * being returned
85 * \return pointer to routing protocol indexed by
86 */
87 virtual Ptr<Ipv6RoutingProtocol> GetRoutingProtocol(uint32_t index, int16_t& priority) const;
88
89 // Below are from Ipv6RoutingProtocol
91 const Ipv6Header& header,
93 Socket::SocketErrno& sockerr) override;
94
96 const Ipv6Header& header,
98 const UnicastForwardCallback& ucb,
99 const MulticastForwardCallback& mcb,
100 const LocalDeliverCallback& lcb,
101 const ErrorCallback& ecb) override;
102 void NotifyInterfaceUp(uint32_t interface) override;
103 void NotifyInterfaceDown(uint32_t interface) override;
104 void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
105 void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
107 Ipv6Prefix mask,
108 Ipv6Address nextHop,
109 uint32_t interface,
110 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
112 Ipv6Prefix mask,
113 Ipv6Address nextHop,
114 uint32_t interface,
115 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
116 void SetIpv6(Ptr<Ipv6> ipv6) override;
118 Time::Unit unit = Time::S) const override;
119
120 protected:
121 /**
122 * \brief Dispose this object.
123 */
124 void DoDispose() override;
125
126 private:
127 /**
128 * \brief Container identifying an IPv6 Routing Protocol entry in the list.
129 */
130 typedef std::pair<int16_t, Ptr<Ipv6RoutingProtocol>> Ipv6RoutingProtocolEntry;
131
132 /**
133 * \brief Container of the IPv6 Routing Protocols.
134 */
135 typedef std::list<Ipv6RoutingProtocolEntry> Ipv6RoutingProtocolList;
136
137 /**
138 * \brief Compare two routing protocols.
139 * \param a first object to compare
140 * \param b second object to compare
141 * \return true if they are the same, false otherwise
142 */
143 static bool Compare(const Ipv6RoutingProtocolEntry& a, const Ipv6RoutingProtocolEntry& b);
144
145 Ipv6RoutingProtocolList m_routingProtocols; //!< List of routing protocols.
146 Ptr<Ipv6> m_ipv6; //!< Ipv6 this protocol is associated with.
147};
148
149} // namespace ns3
150
151#endif /* IPV6_LIST_ROUTING_H */
Describes an IPv6 address.
Definition: ipv6-address.h:49
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Packet header for IPv6.
Definition: ipv6-header.h:35
IPv6 address associated with an interface.
Hold list of Ipv6RoutingProtocol objects.
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const override
Print the Routing Table entries.
static TypeId GetTypeId()
Get the type ID of this class.
std::pair< int16_t, Ptr< Ipv6RoutingProtocol > > Ipv6RoutingProtocolEntry
Container identifying an IPv6 Routing Protocol entry in the list.
static bool Compare(const Ipv6RoutingProtocolEntry &a, const Ipv6RoutingProtocolEntry &b)
Compare two routing protocols.
void DoDispose() override
Dispose this object.
Ptr< Ipv6Route > RouteOutput(Ptr< Packet > p, const Ipv6Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr) override
Query routing cache for an existing route, for an outbound packet.
bool RouteInput(Ptr< const Packet > p, const Ipv6Header &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 uint32_t GetNRoutingProtocols() const
Get the number of routing protocols.
void SetIpv6(Ptr< Ipv6 > ipv6) override
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
virtual Ptr< Ipv6RoutingProtocol > GetRoutingProtocol(uint32_t index, int16_t &priority) const
Get pointer to routing protocol stored at index,.
void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override
Notify when specified interface add an address.
Ipv6ListRouting()
Constructor.
void NotifyInterfaceDown(uint32_t interface) override
Notify when specified interface goes DOWN.
std::list< Ipv6RoutingProtocolEntry > Ipv6RoutingProtocolList
Container of the IPv6 Routing Protocols.
void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) override
Notify when specified interface add an address.
void NotifyInterfaceUp(uint32_t interface) override
Notify when specified interface goes UP.
void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()) override
Notify a new route.
~Ipv6ListRouting() override
Destructor.
Ipv6RoutingProtocolList m_routingProtocols
List of routing protocols.
virtual void AddRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol, int16_t priority)
Register a new routing protocol to be used in this IPv4 stack.
Ptr< Ipv6 > m_ipv6
Ipv6 this protocol is associated with.
void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()) override
Notify route removing.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
Abstract base class for IPv6 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
Every class exported by the ns3 library is enclosed in the ns3 namespace.