|
|
| 23 |
#include "ns3/ptr.h" |
23 |
#include "ns3/ptr.h" |
| 24 |
#include "ns3/nstime.h" |
24 |
#include "ns3/nstime.h" |
| 25 |
#include "ns3/output-stream-wrapper.h" |
25 |
#include "ns3/output-stream-wrapper.h" |
|
|
26 |
#include "ns3/ipv4-list-routing.h" |
| 26 |
|
27 |
|
| 27 |
namespace ns3 { |
28 |
namespace ns3 { |
| 28 |
|
29 |
|
|
|
| 60 |
* \returns a newly-created routing protocol |
61 |
* \returns a newly-created routing protocol |
| 61 |
*/ |
62 |
*/ |
| 62 |
virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const = 0; |
63 |
virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const = 0; |
| 63 |
|
64 |
|
| 64 |
/** |
65 |
/** |
| 65 |
* \brief prints the routing tables of all nodes at a particular time. |
66 |
* \brief prints the routing tables of all nodes at a particular time. |
| 66 |
* \param printTime the time at which the routing table is supposed to be printed. |
67 |
* \param printTime the time at which the routing table is supposed to be printed. |
|
|
| 107 |
*/ |
108 |
*/ |
| 108 |
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const; |
109 |
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const; |
| 109 |
|
110 |
|
|
|
111 |
/** |
| 112 |
* @brief Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol |
| 113 |
* |
| 114 |
* If protocol is Ipv4ListRouting, then protocol will be searched in the list, |
| 115 |
* otherwise a simple DynamicCast will be performed |
| 116 |
* |
| 117 |
* @param protocol Smart pointer to Ipv4RoutingProtocol object |
| 118 |
*/ |
| 119 |
template<class T> |
| 120 |
static Ptr<T> GetRouting (Ptr<Ipv4RoutingProtocol> protocol); |
| 121 |
|
| 110 |
private: |
122 |
private: |
| 111 |
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const; |
123 |
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const; |
| 112 |
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const; |
124 |
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const; |
| 113 |
}; |
125 |
}; |
| 114 |
|
126 |
|
|
|
127 |
// This function does a recursive search for a requested routing protocol. |
| 128 |
// Strictly speaking this recursion is not necessary, but why not? |
| 129 |
template<class T> |
| 130 |
Ptr<T> Ipv4RoutingHelper::GetRouting (Ptr<Ipv4RoutingProtocol> protocol) |
| 131 |
{ |
| 132 |
Ptr<T> ret = DynamicCast<T> (protocol); |
| 133 |
if (ret == 0) |
| 134 |
{ |
| 135 |
// trying to check if protocol is a list routing |
| 136 |
Ptr<Ipv4ListRouting> lrp = DynamicCast<Ipv4ListRouting> (protocol); |
| 137 |
if (lrp != 0) |
| 138 |
{ |
| 139 |
for (uint32_t i = 0; i < lrp->GetNRoutingProtocols (); i++) |
| 140 |
{ |
| 141 |
int16_t priority; |
| 142 |
ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting |
| 143 |
if (ret != 0) |
| 144 |
break; |
| 145 |
} |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
return ret; |
| 150 |
} |
| 151 |
|
| 115 |
} // namespace ns3 |
152 |
} // namespace ns3 |
| 116 |
|
153 |
|
| 117 |
|
154 |
|