Multimap required as each port may be on the optimal path for more than one MOOSE...
authorRichard Whitehouse <github@richardwhiuk.com>
Sun, 20 Feb 2011 04:18:52 +0000 (04:18 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Sun, 20 Feb 2011 04:18:52 +0000 (04:18 +0000)
code/src/devices/bridge/helper/moose-bridge-helper.cc
code/src/devices/bridge/helper/moose-bridge-helper.h

index 7d4b727ba53ef55f738765ed2768ef4d30d41cfb..f74203fc81c73a972df8972c4356805b997e0101 100644 (file)
@@ -43,7 +43,7 @@ MooseBridgeHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1)
 }
 
 NetDeviceContainer
-MooseBridgeHelper::Install (Ptr<Node> node, NetDeviceContainer c, MoosePrefixAddress addr, std::map<Ptr<NetDevice>, MoosePrefixAddress> routes)
+MooseBridgeHelper::Install (Ptr<Node> node, NetDeviceContainer c, MoosePrefixAddress addr, std::multimap<Ptr<NetDevice>, MoosePrefixAddress> routes)
 {
   NS_LOG_FUNCTION_NOARGS ();
   NS_LOG_LOGIC ("**** Install MOOSE bridge device on node " << node->GetId ());
@@ -61,9 +61,8 @@ MooseBridgeHelper::Install (Ptr<Node> node, NetDeviceContainer c, MoosePrefixAdd
     {
       NS_LOG_LOGIC ("**** Add MooseBridgePort "<< *i);
       Ptr<BridgePortNetDevice> port = dev->AddBridgePort (*i);
-      std::map<Ptr<NetDevice>, MoosePrefixAddress>::iterator it = routes.find(*i);
-      if(it != routes.end()){
-           portMap[routes[*i]] = port;
+      for(std::multimap<Ptr<NetDevice>, MoosePrefixAddress>::iterator it = routes.lower_bound(*i); it != routes.upper_bound(*i); ++it){
+           portMap[it->second] = port;
       }
     }
 
index c6fa8d904b7245f45184a4f1325dab5d57c44273..9bd463d93cc12a0442b03f6aaec06fc6a212951d 100644 (file)
@@ -69,7 +69,7 @@ public:
    * This method creates an ns3::MooseBridgeNetDevice with static routing.
    */
 
-  NetDeviceContainer Install (Ptr<Node> node, NetDeviceContainer c, MoosePrefixAddress addr, std::map<Ptr<NetDevice>, MoosePrefixAddress> routes);
+  NetDeviceContainer Install (Ptr<Node> node, NetDeviceContainer c, MoosePrefixAddress addr, std::multimap<Ptr<NetDevice>, MoosePrefixAddress> routes);
 
   /**
    * This method creates an ns3::MooseBridgeNetDevice with the attributes