bug 642: allow multiple InternetStackHelpers to be instantiated
authorTom Henderson <tomh@tomh.org>
Mon Jul 27 23:04:19 2009 -0700 (6 months ago)
changeset 4715637b9cacd0b5
parent 4714 6cd5056a8fe0
child 4716 a1b6bd8eb43a
bug 642: allow multiple InternetStackHelpers to be instantiated
src/helper/internet-stack-helper.cc
src/helper/internet-stack-helper.h
     1.1 --- a/src/helper/internet-stack-helper.cc	Sun Jul 26 07:25:19 2009 -0700
     1.2 +++ b/src/helper/internet-stack-helper.cc	Mon Jul 27 23:04:19 2009 -0700
     1.3 @@ -171,6 +171,7 @@
     1.4  
     1.5  std::vector<InternetStackHelper::Trace> InternetStackHelper::m_traces;
     1.6  std::string InternetStackHelper::m_pcapBaseFilename;
     1.7 +bool InternetStackHelper::m_isInitialized = false;
     1.8  
     1.9  InternetStackHelper::InternetStackHelper ()
    1.10  {
    1.11 @@ -178,8 +179,13 @@
    1.12    static Ipv4StaticRoutingHelper staticRouting;
    1.13    static Ipv4GlobalRoutingHelper globalRouting;
    1.14    static Ipv4ListRoutingHelper listRouting;
    1.15 -  listRouting.Add (staticRouting, 0);
    1.16 -  listRouting.Add (globalRouting, -10);
    1.17 +  if (m_isInitialized == false)
    1.18 +    {
    1.19 +      // Only add these once
    1.20 +      listRouting.Add (staticRouting, 0);
    1.21 +      listRouting.Add (globalRouting, -10);
    1.22 +      m_isInitialized = true;
    1.23 +    }
    1.24    SetRoutingHelper (listRouting);
    1.25  }
    1.26  
     2.1 --- a/src/helper/internet-stack-helper.h	Sun Jul 26 07:25:19 2009 -0700
     2.2 +++ b/src/helper/internet-stack-helper.h	Mon Jul 27 23:04:19 2009 -0700
     2.3 @@ -173,6 +173,7 @@
     2.4    static std::string m_pcapBaseFilename;
     2.5    static uint32_t GetNodeIndex (std::string context);
     2.6    static std::vector<Trace> m_traces;
     2.7 +  static bool m_isInitialized;
     2.8  };
     2.9  
    2.10  } // namespace ns3