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 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#ifndef IPV6_LIST_ROUTING_H
8#define IPV6_LIST_ROUTING_H
9
11
12#include <list>
13
14namespace ns3
15{
16
17/**
18 * \ingroup ipv6Routing
19 *
20 * \brief Hold list of Ipv6RoutingProtocol objects.
21 *
22 * This class is a specialization of Ipv6RoutingProtocol that allows
23 * other instances of Ipv6RoutingProtocol to be inserted in a
24 * prioritized list. Routing protocols in the list are consulted one
25 * by one, from highest to lowest priority, until a routing protocol
26 * is found that will take the packet (this corresponds to a non-zero
27 * return value to RouteOutput, or a return value of true to RouteInput).
28 * The order by which routing protocols with the same priority value
29 * are consulted is undefined.
30 *
31 */
33{
34 public:
35 /**
36 * \brief Get the type ID of this class.
37 * \return type ID
38 */
39 static TypeId GetTypeId();
40
41 /**
42 * \brief Constructor.
43 */
45
46 /**
47 * \brief Destructor.
48 */
49 ~Ipv6ListRouting() override;
50
51 /**
52 * \brief Register a new routing protocol to be used in this IPv4 stack
53 * \param routingProtocol new routing protocol implementation object
54 * \param priority priority to give to this routing protocol.
55 * Values may range between -32768 and +32767.
56 */
57 virtual void AddRoutingProtocol(Ptr<Ipv6RoutingProtocol> routingProtocol, int16_t priority);
58
59 /**
60 * \brief Get the number of routing protocols.
61 * \return number of routing protocols in the list
62 */
63 virtual uint32_t GetNRoutingProtocols() const;
64
65 /**
66 * \brief Get pointer to routing protocol stored at index,
67 *
68 * The first protocol (index 0) the highest priority, the next one (index 1)
69 * the second highest priority, and so on. The priority parameter is an
70 * output parameter and it returns the integer priority of the protocol.
71 * \param index index of protocol to return
72 * \param priority output parameter, set to the priority of the protocol
73 * being returned
74 * \return pointer to routing protocol indexed by
75 */
76 virtual Ptr<Ipv6RoutingProtocol> GetRoutingProtocol(uint32_t index, int16_t& priority) const;
77
78 // Below are from Ipv6RoutingProtocol
80 const Ipv6Header& header,
82 Socket::SocketErrno& sockerr) override;
83
85 const Ipv6Header& header,
87 const UnicastForwardCallback& ucb,
88 const MulticastForwardCallback& mcb,
89 const LocalDeliverCallback& lcb,
90 const ErrorCallback& ecb) override;
91 void NotifyInterfaceUp(uint32_t interface) override;
92 void NotifyInterfaceDown(uint32_t interface) override;
93 void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
94 void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
96 Ipv6Prefix mask,
97 Ipv6Address nextHop,
98 uint32_t interface,
99 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
101 Ipv6Prefix mask,
102 Ipv6Address nextHop,
103 uint32_t interface,
104 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
105 void SetIpv6(Ptr<Ipv6> ipv6) override;
107 Time::Unit unit = Time::S) const override;
108
109 protected:
110 /**
111 * \brief Dispose this object.
112 */
113 void DoDispose() override;
114
115 private:
116 /**
117 * \brief Container identifying an IPv6 Routing Protocol entry in the list.
118 */
119 typedef std::pair<int16_t, Ptr<Ipv6RoutingProtocol>> Ipv6RoutingProtocolEntry;
120
121 /**
122 * \brief Container of the IPv6 Routing Protocols.
123 */
124 typedef std::list<Ipv6RoutingProtocolEntry> Ipv6RoutingProtocolList;
125
126 /**
127 * \brief Compare two routing protocols.
128 * \param a first object to compare
129 * \param b second object to compare
130 * \return true if they are the same, false otherwise
131 */
132 static bool Compare(const Ipv6RoutingProtocolEntry& a, const Ipv6RoutingProtocolEntry& b);
133
134 Ipv6RoutingProtocolList m_routingProtocols; //!< List of routing protocols.
135 Ptr<Ipv6> m_ipv6; //!< Ipv6 this protocol is associated with.
136};
137
138} // namespace ns3
139
140#endif /* IPV6_LIST_ROUTING_H */
Describes an IPv6 address.
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Packet header for IPv6.
Definition ipv6-header.h:24
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.
Abstract base class for IPv6 routing protocols.
Smart pointer class similar to boost::intrusive_ptr.
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition socket.h:73
Unit
The unit to use to interpret a number representing time.
Definition nstime.h:100
@ S
second
Definition nstime.h:105
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.