1.1 --- a/src/helper/internet-stack-helper.cc Thu Oct 01 21:51:03 2009 -0700
1.2 +++ b/src/helper/internet-stack-helper.cc Thu Oct 01 22:49:25 2009 -0700
1.3 @@ -179,15 +179,17 @@
1.4 bool InternetStackHelper::m_isInitialized = false;
1.5
1.6 InternetStackHelper::InternetStackHelper ()
1.7 - : m_ipv4Enabled (true),
1.8 + : m_routing (0),
1.9 + m_routingv6 (0),
1.10 + m_ipv4Enabled (true),
1.11 m_ipv6Enabled (true)
1.12 {
1.13 SetTcp ("ns3::TcpL4Protocol");
1.14 - static Ipv4StaticRoutingHelper staticRouting;
1.15 - static Ipv4GlobalRoutingHelper globalRouting;
1.16 - static Ipv4ListRoutingHelper listRouting;
1.17 - static Ipv6ListRoutingHelper listRoutingv6;
1.18 - static Ipv6StaticRoutingHelper staticRoutingv6;
1.19 + Ipv4StaticRoutingHelper staticRouting;
1.20 + Ipv4GlobalRoutingHelper globalRouting;
1.21 + Ipv4ListRoutingHelper listRouting;
1.22 + Ipv6ListRoutingHelper listRoutingv6;
1.23 + Ipv6StaticRoutingHelper staticRoutingv6;
1.24 if (m_isInitialized == false)
1.25 {
1.26 // Only add these once
1.27 @@ -203,16 +205,24 @@
1.28 SetRoutingHelper (listRoutingv6);
1.29 }
1.30
1.31 +InternetStackHelper::~InternetStackHelper ()
1.32 +{
1.33 + delete m_routing;
1.34 + delete m_routingv6;
1.35 +}
1.36 +
1.37 void
1.38 InternetStackHelper::SetRoutingHelper (const Ipv4RoutingHelper &routing)
1.39 {
1.40 - m_routing = &routing;
1.41 + delete m_routing;
1.42 + m_routing = routing.Copy ();
1.43 }
1.44
1.45 void
1.46 InternetStackHelper::SetRoutingHelper (const Ipv6RoutingHelper &routing)
1.47 {
1.48 - m_routingv6 = &routing;
1.49 + delete m_routingv6;
1.50 + m_routingv6 = routing.Copy ();
1.51 }
1.52
1.53 void
2.1 --- a/src/helper/internet-stack-helper.h Thu Oct 01 21:51:03 2009 -0700
2.2 +++ b/src/helper/internet-stack-helper.h Thu Oct 01 22:49:25 2009 -0700
2.3 @@ -53,6 +53,7 @@
2.4 * such as ns3::OlsrHelper
2.5 */
2.6 InternetStackHelper(void);
2.7 + virtual ~InternetStackHelper(void);
2.8
2.9 /**
2.10 * \param routing a new routing helper
3.1 --- a/src/helper/ipv4-global-routing-helper.cc Thu Oct 01 21:51:03 2009 -0700
3.2 +++ b/src/helper/ipv4-global-routing-helper.cc Thu Oct 01 22:49:25 2009 -0700
3.3 @@ -29,6 +29,17 @@
3.4
3.5 Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper ()
3.6 {}
3.7 +
3.8 +Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper (const Ipv4GlobalRoutingHelper &o)
3.9 +{
3.10 +}
3.11 +
3.12 +Ipv4GlobalRoutingHelper*
3.13 +Ipv4GlobalRoutingHelper::Copy (void) const
3.14 +{
3.15 + return new Ipv4GlobalRoutingHelper (*this);
3.16 +}
3.17 +
3.18 Ptr<Ipv4RoutingProtocol>
3.19 Ipv4GlobalRoutingHelper::Create (Ptr<Node> node) const
3.20 {
4.1 --- a/src/helper/ipv4-global-routing-helper.h Thu Oct 01 21:51:03 2009 -0700
4.2 +++ b/src/helper/ipv4-global-routing-helper.h Thu Oct 01 22:49:25 2009 -0700
4.3 @@ -32,6 +32,15 @@
4.4 {
4.5 public:
4.6 Ipv4GlobalRoutingHelper ();
4.7 + Ipv4GlobalRoutingHelper (const Ipv4GlobalRoutingHelper &);
4.8 + /**
4.9 + * \returns pointer to clone of this Ipv4GlobalRoutingHelper
4.10 + *
4.11 + * This method is mainly for internal use by the other helpers;
4.12 + * clients are expected to free the dynamic memory allocated by this method
4.13 + */
4.14 + Ipv4GlobalRoutingHelper* Copy (void) const;
4.15 +
4.16 /**
4.17 * \param node the node on which the routing protocol will run
4.18 * \returns a newly-created routing protocol
4.19 @@ -63,6 +72,8 @@
4.20 *
4.21 */
4.22 static void RecomputeRoutingTables (void);
4.23 +private:
4.24 + Ipv4GlobalRoutingHelper &operator = (const Ipv4GlobalRoutingHelper &o);
4.25 };
4.26
4.27 } // namespace ns3
5.1 --- a/src/helper/ipv4-list-routing-helper.cc Thu Oct 01 21:51:03 2009 -0700
5.2 +++ b/src/helper/ipv4-list-routing-helper.cc Thu Oct 01 22:49:25 2009 -0700
5.3 @@ -25,16 +25,42 @@
5.4
5.5 Ipv4ListRoutingHelper::Ipv4ListRoutingHelper()
5.6 {}
5.7 +
5.8 +Ipv4ListRoutingHelper::~Ipv4ListRoutingHelper()
5.9 +{
5.10 + for (std::list<std::pair<const Ipv4RoutingHelper *, int16_t> >::iterator i = m_list.begin ();
5.11 + i != m_list.end (); ++i)
5.12 + {
5.13 + delete i->first;
5.14 + }
5.15 +}
5.16 +
5.17 +Ipv4ListRoutingHelper::Ipv4ListRoutingHelper (const Ipv4ListRoutingHelper &o)
5.18 +{
5.19 + std::list<std::pair<const Ipv4RoutingHelper *, int16_t> >::const_iterator i;
5.20 + for (i = o.m_list.begin (); i != o.m_list.end (); ++i)
5.21 + {
5.22 + m_list.push_back (std::make_pair (const_cast<const Ipv4RoutingHelper *> (i->first->Copy ()), i->second));
5.23 + }
5.24 +}
5.25 +
5.26 +Ipv4ListRoutingHelper*
5.27 +Ipv4ListRoutingHelper::Copy (void) const
5.28 +{
5.29 + return new Ipv4ListRoutingHelper (*this);
5.30 +}
5.31 +
5.32 void
5.33 Ipv4ListRoutingHelper::Add (const Ipv4RoutingHelper &routing, int16_t priority)
5.34 {
5.35 - m_list.push_back (std::make_pair(&routing,priority));
5.36 + m_list.push_back (std::make_pair (const_cast<const Ipv4RoutingHelper *> (routing.Copy ()), priority));
5.37 }
5.38 +
5.39 Ptr<Ipv4RoutingProtocol>
5.40 Ipv4ListRoutingHelper::Create (Ptr<Node> node) const
5.41 {
5.42 Ptr<Ipv4ListRouting> list = CreateObject<Ipv4ListRouting> ();
5.43 - for (std::list<std::pair<const Ipv4RoutingHelper *,int16_t> >::const_iterator i = m_list.begin ();
5.44 + for (std::list<std::pair<const Ipv4RoutingHelper *, int16_t> >::const_iterator i = m_list.begin ();
5.45 i != m_list.end (); ++i)
5.46 {
5.47 Ptr<Ipv4RoutingProtocol> prot = i->first->Create (node);
6.1 --- a/src/helper/ipv4-list-routing-helper.h Thu Oct 01 21:51:03 2009 -0700
6.2 +++ b/src/helper/ipv4-list-routing-helper.h Thu Oct 01 22:49:25 2009 -0700
6.3 @@ -35,7 +35,17 @@
6.4 class Ipv4ListRoutingHelper : public Ipv4RoutingHelper
6.5 {
6.6 public:
6.7 - Ipv4ListRoutingHelper();
6.8 + Ipv4ListRoutingHelper ();
6.9 + virtual ~Ipv4ListRoutingHelper ();
6.10 + Ipv4ListRoutingHelper (const Ipv4ListRoutingHelper &);
6.11 + /**
6.12 + * \returns pointer to clone of this Ipv4ListRoutingHelper
6.13 + *
6.14 + * This method is mainly for internal use by the other helpers;
6.15 + * clients are expected to free the dynamic memory allocated by this method
6.16 + */
6.17 + Ipv4ListRoutingHelper* Copy (void) const;
6.18 +
6.19 /**
6.20 * \param routing a routing helper
6.21 * \param priority the priority of the associated helper
6.22 @@ -55,6 +65,8 @@
6.23 */
6.24 virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const;
6.25 private:
6.26 + Ipv4ListRoutingHelper &operator = (const Ipv4ListRoutingHelper &o);
6.27 +
6.28 std::list<std::pair<const Ipv4RoutingHelper *,int16_t> > m_list;
6.29 };
6.30
7.1 --- a/src/helper/ipv4-nix-vector-helper.cc Thu Oct 01 21:51:03 2009 -0700
7.2 +++ b/src/helper/ipv4-nix-vector-helper.cc Thu Oct 01 22:49:25 2009 -0700
7.3 @@ -28,6 +28,17 @@
7.4 m_agentFactory.SetTypeId ("ns3::Ipv4NixVectorRouting");
7.5 }
7.6
7.7 +Ipv4NixVectorHelper::Ipv4NixVectorHelper (const Ipv4NixVectorHelper &o)
7.8 + : m_agentFactory (o.m_agentFactory)
7.9 +{
7.10 +}
7.11 +
7.12 +Ipv4NixVectorHelper*
7.13 +Ipv4NixVectorHelper::Copy (void) const
7.14 +{
7.15 + return new Ipv4NixVectorHelper (*this);
7.16 +}
7.17 +
7.18 Ptr<Ipv4RoutingProtocol>
7.19 Ipv4NixVectorHelper::Create (Ptr<Node> node) const
7.20 {
8.1 --- a/src/helper/ipv4-nix-vector-helper.h Thu Oct 01 21:51:03 2009 -0700
8.2 +++ b/src/helper/ipv4-nix-vector-helper.h Thu Oct 01 22:49:25 2009 -0700
8.3 @@ -38,6 +38,14 @@
8.4 {
8.5 public:
8.6 Ipv4NixVectorHelper ();
8.7 + Ipv4NixVectorHelper (const Ipv4NixVectorHelper &);
8.8 + /**
8.9 + * \returns pointer to clone of this Ipv4NixVectorHelper
8.10 + *
8.11 + * This method is mainly for internal use by the other helpers;
8.12 + * clients are expected to free the dynamic memory allocated by this method
8.13 + */
8.14 + Ipv4NixVectorHelper* Copy (void) const;
8.15
8.16 /**
8.17 * \param node the node on which the routing protocol will run
8.18 @@ -48,6 +56,8 @@
8.19 virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const;
8.20
8.21 private:
8.22 + Ipv4NixVectorHelper &operator = (const Ipv4NixVectorHelper &o);
8.23 +
8.24 ObjectFactory m_agentFactory;
8.25 };
8.26 } // namespace ns3
9.1 --- a/src/helper/ipv4-routing-helper.h Thu Oct 01 21:51:03 2009 -0700
9.2 +++ b/src/helper/ipv4-routing-helper.h Thu Oct 01 22:49:25 2009 -0700
9.3 @@ -40,6 +40,16 @@
9.4 {
9.5 public:
9.6 virtual ~Ipv4RoutingHelper ();
9.7 +
9.8 + /**
9.9 + * \brief virtual constructor
9.10 + * \returns pointer to clone of this Ipv4RoutingHelper
9.11 + *
9.12 + * This method is mainly for internal use by the other helpers;
9.13 + * clients are expected to free the dynamic memory allocated by this method
9.14 + */
9.15 + virtual Ipv4RoutingHelper* Copy (void) const = 0;
9.16 +
9.17 /**
9.18 * \param node the node within which the new routing protocol will run
9.19 * \returns a newly-created routing protocol
10.1 --- a/src/helper/ipv4-static-routing-helper.cc Thu Oct 01 21:51:03 2009 -0700
10.2 +++ b/src/helper/ipv4-static-routing-helper.cc Thu Oct 01 22:49:25 2009 -0700
10.3 @@ -35,6 +35,17 @@
10.4
10.5 Ipv4StaticRoutingHelper::Ipv4StaticRoutingHelper()
10.6 {}
10.7 +
10.8 +Ipv4StaticRoutingHelper::Ipv4StaticRoutingHelper (const Ipv4StaticRoutingHelper &o)
10.9 +{
10.10 +}
10.11 +
10.12 +Ipv4StaticRoutingHelper*
10.13 +Ipv4StaticRoutingHelper::Copy (void) const
10.14 +{
10.15 + return new Ipv4StaticRoutingHelper (*this);
10.16 +}
10.17 +
10.18 Ptr<Ipv4RoutingProtocol>
10.19 Ipv4StaticRoutingHelper::Create (Ptr<Node> node) const
10.20 {
11.1 --- a/src/helper/ipv4-static-routing-helper.h Thu Oct 01 21:51:03 2009 -0700
11.2 +++ b/src/helper/ipv4-static-routing-helper.h Thu Oct 01 22:49:25 2009 -0700
11.3 @@ -40,7 +40,15 @@
11.4 class Ipv4StaticRoutingHelper : public Ipv4RoutingHelper
11.5 {
11.6 public:
11.7 - Ipv4StaticRoutingHelper();
11.8 + Ipv4StaticRoutingHelper ();
11.9 + Ipv4StaticRoutingHelper (const Ipv4StaticRoutingHelper &);
11.10 + /**
11.11 + * \returns pointer to clone of this Ipv4StaticRoutingHelper
11.12 + *
11.13 + * This method is mainly for internal use by the other helpers;
11.14 + * clients are expected to free the dynamic memory allocated by this method
11.15 + */
11.16 + Ipv4StaticRoutingHelper* Copy (void) const;
11.17
11.18 /**
11.19 * \param node the node on which the routing protocol will run
11.20 @@ -74,6 +82,8 @@
11.21 void SetDefaultMulticastRoute (Ptr<Node> n, std::string ndName);
11.22 void SetDefaultMulticastRoute (std::string nName, Ptr<NetDevice> nd);
11.23 void SetDefaultMulticastRoute (std::string nName, std::string ndName);
11.24 +private:
11.25 + Ipv4StaticRoutingHelper &operator = (const Ipv4StaticRoutingHelper &o);
11.26
11.27 };
11.28
12.1 --- a/src/helper/ipv6-list-routing-helper.cc Thu Oct 01 21:51:03 2009 -0700
12.2 +++ b/src/helper/ipv6-list-routing-helper.cc Thu Oct 01 22:49:25 2009 -0700
12.3 @@ -27,10 +27,34 @@
12.4
12.5 Ipv6ListRoutingHelper::Ipv6ListRoutingHelper ()
12.6 {}
12.7 +
12.8 +Ipv6ListRoutingHelper::~Ipv6ListRoutingHelper()
12.9 +{
12.10 + for (std::list<std::pair<const Ipv6RoutingHelper *, int16_t> >::iterator i = m_list.begin ();
12.11 + i != m_list.end (); ++i)
12.12 + {
12.13 + delete i->first;
12.14 + }
12.15 +}
12.16 +Ipv6ListRoutingHelper::Ipv6ListRoutingHelper (const Ipv6ListRoutingHelper &o)
12.17 +{
12.18 + std::list<std::pair<const Ipv6RoutingHelper *, int16_t> >::const_iterator i;
12.19 + for (i = o.m_list.begin (); i != o.m_list.end (); ++i)
12.20 + {
12.21 + m_list.push_back (std::make_pair (const_cast<const Ipv6RoutingHelper *> (i->first->Copy ()), i->second));
12.22 + }
12.23 +}
12.24 +
12.25 +Ipv6ListRoutingHelper*
12.26 +Ipv6ListRoutingHelper::Copy (void) const
12.27 +{
12.28 + return new Ipv6ListRoutingHelper (*this);
12.29 +}
12.30 +
12.31 void
12.32 Ipv6ListRoutingHelper::Add (const Ipv6RoutingHelper &routing, int16_t priority)
12.33 {
12.34 - m_list.push_back (std::make_pair (&routing,priority));
12.35 + m_list.push_back (std::make_pair (const_cast<const Ipv6RoutingHelper *> (routing.Copy ()), priority));
12.36 }
12.37 Ptr<Ipv6RoutingProtocol>
12.38 Ipv6ListRoutingHelper::Create (Ptr<Node> node) const
13.1 --- a/src/helper/ipv6-list-routing-helper.h Thu Oct 01 21:51:03 2009 -0700
13.2 +++ b/src/helper/ipv6-list-routing-helper.h Thu Oct 01 22:49:25 2009 -0700
13.3 @@ -38,6 +38,16 @@
13.4 {
13.5 public:
13.6 Ipv6ListRoutingHelper ();
13.7 + virtual ~Ipv6ListRoutingHelper ();
13.8 + Ipv6ListRoutingHelper (const Ipv6ListRoutingHelper &);
13.9 + /**
13.10 + * \returns pointer to clone of this Ipv6ListRoutingHelper
13.11 + *
13.12 + * This method is mainly for internal use by the other helpers;
13.13 + * clients are expected to free the dynamic memory allocated by this method
13.14 + */
13.15 + Ipv6ListRoutingHelper* Copy (void) const;
13.16 +
13.17 /**
13.18 * \param routing a routing helper
13.19 * \param priority the priority of the associated helper
13.20 @@ -57,6 +67,8 @@
13.21 */
13.22 virtual Ptr<Ipv6RoutingProtocol> Create (Ptr<Node> node) const;
13.23 private:
13.24 + Ipv6ListRoutingHelper &operator = (const Ipv6ListRoutingHelper &o);
13.25 +
13.26 std::list<std::pair<const Ipv6RoutingHelper *,int16_t> > m_list;
13.27 };
13.28
14.1 --- a/src/helper/ipv6-routing-helper.h Thu Oct 01 21:51:03 2009 -0700
14.2 +++ b/src/helper/ipv6-routing-helper.h Thu Oct 01 22:49:25 2009 -0700
14.3 @@ -41,6 +41,16 @@
14.4 {
14.5 public:
14.6 virtual ~Ipv6RoutingHelper ();
14.7 +
14.8 + /**
14.9 + * \brief virtual constructor
14.10 + * \returns pointer to clone of this Ipv6RoutingHelper
14.11 + *
14.12 + * This method is mainly for internal use by the other helpers;
14.13 + * clients are expected to free the dynamic memory allocated by this method
14.14 + */
14.15 + virtual Ipv6RoutingHelper* Copy (void) const = 0;
14.16 +
14.17 /**
14.18 * \param node the node within which the new routing protocol will run
14.19 * \returns a newly-created routing protocol
15.1 --- a/src/helper/ipv6-static-routing-helper.cc Thu Oct 01 21:51:03 2009 -0700
15.2 +++ b/src/helper/ipv6-static-routing-helper.cc Thu Oct 01 22:49:25 2009 -0700
15.3 @@ -37,6 +37,17 @@
15.4
15.5 Ipv6StaticRoutingHelper::Ipv6StaticRoutingHelper ()
15.6 {}
15.7 +
15.8 +Ipv6StaticRoutingHelper::Ipv6StaticRoutingHelper (const Ipv6StaticRoutingHelper &o)
15.9 +{
15.10 +}
15.11 +
15.12 +Ipv6StaticRoutingHelper*
15.13 +Ipv6StaticRoutingHelper::Copy (void) const
15.14 +{
15.15 + return new Ipv6StaticRoutingHelper (*this);
15.16 +}
15.17 +
15.18 Ptr<Ipv6RoutingProtocol>
15.19 Ipv6StaticRoutingHelper::Create (Ptr<Node> node) const
15.20 {
16.1 --- a/src/helper/ipv6-static-routing-helper.h Thu Oct 01 21:51:03 2009 -0700
16.2 +++ b/src/helper/ipv6-static-routing-helper.h Thu Oct 01 22:49:25 2009 -0700
16.3 @@ -45,6 +45,14 @@
16.4 * \brief Constructor.
16.5 */
16.6 Ipv6StaticRoutingHelper ();
16.7 + Ipv6StaticRoutingHelper (const Ipv6StaticRoutingHelper &);
16.8 + /**
16.9 + * \returns pointer to clone of this Ipv6StaticRoutingHelper
16.10 + *
16.11 + * This method is mainly for internal use by the other helpers;
16.12 + * clients are expected to free the dynamic memory allocated by this method
16.13 + */
16.14 + Ipv6StaticRoutingHelper* Copy (void) const;
16.15
16.16 /**
16.17 * \param node the node on which the routing protocol will run
16.18 @@ -80,6 +88,8 @@
16.19 void SetDefaultMulticastRoute (std::string nName, Ptr<NetDevice> nd);
16.20 void SetDefaultMulticastRoute (std::string nName, std::string ndName);
16.21 #endif
16.22 +private:
16.23 + Ipv6StaticRoutingHelper &operator = (const Ipv6StaticRoutingHelper &o);
16.24 };
16.25
16.26 } // namespace ns3
17.1 --- a/src/helper/olsr-helper.cc Thu Oct 01 21:51:03 2009 -0700
17.2 +++ b/src/helper/olsr-helper.cc Thu Oct 01 22:49:25 2009 -0700
17.3 @@ -30,6 +30,17 @@
17.4 m_agentFactory.SetTypeId ("ns3::olsr::RoutingProtocol");
17.5 }
17.6
17.7 +OlsrHelper::OlsrHelper (const OlsrHelper &o)
17.8 + : m_agentFactory (o.m_agentFactory)
17.9 +{
17.10 +}
17.11 +
17.12 +OlsrHelper*
17.13 +OlsrHelper::Copy (void) const
17.14 +{
17.15 + return new OlsrHelper (*this);
17.16 +}
17.17 +
17.18 Ptr<Ipv4RoutingProtocol>
17.19 OlsrHelper::Create (Ptr<Node> node) const
17.20 {
18.1 --- a/src/helper/olsr-helper.h Thu Oct 01 21:51:03 2009 -0700
18.2 +++ b/src/helper/olsr-helper.h Thu Oct 01 22:49:25 2009 -0700
18.3 @@ -37,6 +37,14 @@
18.4 {
18.5 public:
18.6 OlsrHelper ();
18.7 + OlsrHelper (const OlsrHelper &);
18.8 + /**
18.9 + * \returns pointer to clone of this OlsrHelper
18.10 + *
18.11 + * This method is mainly for internal use by the other helpers;
18.12 + * clients are expected to free the dynamic memory allocated by this method
18.13 + */
18.14 + OlsrHelper* Copy (void) const;
18.15
18.16 /**
18.17 * \param node the node on which the routing protocol will run
18.18 @@ -54,6 +62,7 @@
18.19 */
18.20 void Set (std::string name, const AttributeValue &value);
18.21 private:
18.22 + OlsrHelper &operator = (const OlsrHelper &o);
18.23 ObjectFactory m_agentFactory;
18.24 };
18.25