--- a/RELEASE_NOTES Tue Jul 09 13:14:19 2013 -0700
+++ b/RELEASE_NOTES Tue Jul 09 22:49:30 2013 +0200
@@ -26,6 +26,7 @@
Bugs fixed
----------
- Bug 760 - IP address removal can be painful
+- Bug 1296 - Enhancement in Ipv[4,6]RoutingHelper
- Bug 1390 - ICMPv6 Redirect are handled correctly only for /64 networks
- Bug 1643 - NdiscCache creation and existence checks
- Bug 1646 - ICMPv6 Redirect are sent from global address instead of link-local
--- a/src/internet/helper/ipv4-routing-helper.cc Tue Jul 09 13:14:19 2013 -0700
+++ b/src/internet/helper/ipv4-routing-helper.cc Tue Jul 09 22:49:30 2013 +0200
@@ -17,10 +17,12 @@
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
+
#include "ns3/node.h"
#include "ns3/node-list.h"
#include "ns3/simulator.h"
#include "ns3/ipv4-routing-protocol.h"
+#include "ns3/ipv4-list-routing.h"
#include "ipv4-routing-helper.h"
namespace ns3 {
@@ -80,4 +82,27 @@
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, this, printInterval, node, stream);
}
+template<class T>
+Ptr<T> Ipv4RoutingHelper::GetRouting (Ptr<Ipv4RoutingProtocol> protocol)
+{
+ Ptr<T> ret = DynamicCast<T> (protocol);
+ if (ret == 0)
+ {
+ // trying to check if protocol is a list routing
+ Ptr<Ipv4ListRouting> lrp = DynamicCast<Ipv4ListRouting> (protocol);
+ if (lrp != 0)
+ {
+ for (uint32_t i = 0; i < lrp->GetNRoutingProtocols (); i++)
+ {
+ int16_t priority;
+ ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting
+ if (ret != 0)
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
} // namespace ns3
--- a/src/internet/helper/ipv4-routing-helper.h Tue Jul 09 13:14:19 2013 -0700
+++ b/src/internet/helper/ipv4-routing-helper.h Tue Jul 09 22:49:30 2013 +0200
@@ -17,6 +17,7 @@
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
+
#ifndef IPV4_ROUTING_HELPER_H
#define IPV4_ROUTING_HELPER_H
@@ -107,6 +108,18 @@
*/
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
+ /**
+ * \brief Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol
+ *
+ * If protocol is Ipv4ListRouting, then protocol will be searched in the list,
+ * otherwise a simple DynamicCast will be performed
+ *
+ * \param protocol Smart pointer to Ipv4RoutingProtocol object
+ * \return a Smart Pointer to the requested protocol (zero if the protocol can't be found)
+ */
+ template<class T>
+ static Ptr<T> GetRouting (Ptr<Ipv4RoutingProtocol> protocol);
+
private:
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
--- a/src/internet/helper/ipv6-routing-helper.cc Tue Jul 09 13:14:19 2013 -0700
+++ b/src/internet/helper/ipv6-routing-helper.cc Tue Jul 09 22:49:30 2013 +0200
@@ -22,6 +22,7 @@
#include "ns3/node-list.h"
#include "ns3/simulator.h"
#include "ns3/ipv6-routing-protocol.h"
+#include "ns3/ipv6-list-routing.h"
#include "ipv6-routing-helper.h"
namespace ns3 {
@@ -81,4 +82,27 @@
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, this, printInterval, node, stream);
}
+template<class T>
+Ptr<T> Ipv6RoutingHelper::GetRouting (Ptr<Ipv6RoutingProtocol> protocol)
+{
+ Ptr<T> ret = DynamicCast<T> (protocol);
+ if (ret == 0)
+ {
+ // trying to check if protocol is a list routing
+ Ptr<Ipv6ListRouting> lrp = DynamicCast<Ipv6ListRouting> (protocol);
+ if (lrp != 0)
+ {
+ for (uint32_t i = 0; i < lrp->GetNRoutingProtocols (); i++)
+ {
+ int16_t priority;
+ ret = GetRouting<T> (lrp->GetRoutingProtocol (i, priority)); // potential recursion, if inside ListRouting is ListRouting
+ if (ret != 0)
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
} // namespace ns3
--- a/src/internet/helper/ipv6-routing-helper.h Tue Jul 09 13:14:19 2013 -0700
+++ b/src/internet/helper/ipv6-routing-helper.h Tue Jul 09 22:49:30 2013 +0200
@@ -110,6 +110,18 @@
*/
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
+ /**
+ * \brief Request a specified routing protocol <T> from Ipv6RoutingProtocol protocol
+ *
+ * If protocol is Ipv6ListRouting, then protocol will be searched in the list,
+ * otherwise a simple DynamicCast will be performed
+ *
+ * \param protocol Smart pointer to Ipv6RoutingProtocol object
+ * \return a Smart Pointer to the requested protocol (zero if the protocol can't be found)
+ */
+ template<class T>
+ static Ptr<T> GetRouting (Ptr<Ipv6RoutingProtocol> protocol);
+
private:
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;