From: Richard Whitehouse Date: Sun, 20 Feb 2011 07:06:31 +0000 (+0000) Subject: Add function to take enabled ports and disable as required X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=dfc3e55308095e66e8421e86a422c7ac22dcfbe1;p=ns-moose.git Add function to take enabled ports and disable as required --- diff --git a/code/src/devices/bridge/helper/bridge-helper.cc b/code/src/devices/bridge/helper/bridge-helper.cc index 01f12c0..b74ca8b 100644 --- a/code/src/devices/bridge/helper/bridge-helper.cc +++ b/code/src/devices/bridge/helper/bridge-helper.cc @@ -39,6 +39,29 @@ BridgeHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1) m_deviceFactory.Set (n1, v1); } +NetDeviceContainer +BridgeHelper::Install (Ptr node, NetDeviceContainer c, std::map, bool> portsEnabled) +{ + NS_LOG_FUNCTION_NOARGS (); + NS_LOG_LOGIC ("**** Install bridge device on node " << node->GetId ()); + + NetDeviceContainer devs; + Ptr dev = m_deviceFactory.Create (); + devs.Add (dev); + node->AddDevice (dev); + + for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i) + { + NS_LOG_LOGIC ("**** Add BridgePort "<< *i); + Ptr port = dev->AddBridgePort (*i); + if(portsEnabled.find(*i) != portsEnabled.end()){ + port->SetEnabled(portsEnabled[*i]); + } + } + return devs; +} + + NetDeviceContainer BridgeHelper::Install (Ptr node, NetDeviceContainer c) { diff --git a/code/src/devices/bridge/helper/bridge-helper.h b/code/src/devices/bridge/helper/bridge-helper.h index 49af329..bd00d4e 100644 --- a/code/src/devices/bridge/helper/bridge-helper.h +++ b/code/src/devices/bridge/helper/bridge-helper.h @@ -24,6 +24,7 @@ #include "ns3/net-device-container.h" #include "ns3/object-factory.h" #include +#include namespace ns3 { @@ -48,6 +49,21 @@ public: * \param v1 the value of the attribute to set */ void SetDeviceAttribute (std::string n1, const AttributeValue &v1); + + /** + * This method creates an ns3::BridgeNetDevice with the attributes + * configured by BridgeHelper::SetDeviceAttribute, adds the device + * to the node, and attaches the given NetDevices as ports of the + * bridge. + * + * This version uses static spanning tree to disable loops. + * + * \param node The node to install the device in + * \param c Container of NetDevices to add as bridge ports + * \returns A container holding the added net device. + */ + NetDeviceContainer Install (Ptr node, NetDeviceContainer c, std::map, bool> portsEnabled); + /** * This method creates an ns3::BridgeNetDevice with the attributes * configured by BridgeHelper::SetDeviceAttribute, adds the device