View | Details | Raw Unified | Return to bug 276
Collapse All | Expand All

(-)a/examples/csma-bridge.cc (-8 / +2 lines)
 Lines 94-107   main (int argc, char *argv[]) Link Here 
94
94
95
  // Create the bridge netdevice, which will do the packet switching
95
  // Create the bridge netdevice, which will do the packet switching
96
  Ptr<Node> switchNode = csmaSwitch.Get (0);
96
  Ptr<Node> switchNode = csmaSwitch.Get (0);
97
  Ptr<BridgeNetDevice> bridgeDevice = CreateObject<BridgeNetDevice> ();
97
  BridgeHelper bridge;
98
  switchNode->AddDevice (bridgeDevice);
98
  bridge.Install (switchNode, switchDevices);
99
100
  for (NetDeviceContainer::Iterator portIter = switchDevices.Begin ();
101
       portIter != switchDevices.End (); portIter++)
102
    {
103
      bridgeDevice->AddBridgePort (*portIter);
104
    }
105
99
106
  // Add internet stack to the terminals
100
  // Add internet stack to the terminals
107
  InternetStackHelper internet;
101
  InternetStackHelper internet;
(-)a6113320f46a (+34 lines)
Added Link Here 
1
#include "bridge-helper.h"
2
3
#include "ns3/bridge-net-device.h"
4
#include "ns3/node.h"
5
6
namespace ns3 {
7
8
BridgeHelper::BridgeHelper ()
9
{
10
  m_deviceFactory.SetTypeId ("ns3::BridgeNetDevice");
11
}
12
13
void 
14
BridgeHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1)
15
{
16
  m_deviceFactory.Set (n1, v1);
17
}
18
19
NetDeviceContainer
20
BridgeHelper::Install (Ptr<Node> node, NetDeviceContainer c)
21
{
22
  NetDeviceContainer devs;
23
  Ptr<BridgeNetDevice> dev = m_deviceFactory.Create<BridgeNetDevice> ();
24
  devs.Add (dev);
25
  node->AddDevice (dev);
26
27
  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
28
    {
29
      dev->AddBridgePort (*i);
30
    }
31
  return devs;
32
}
33
34
} // namespace ns3
(-)a6113320f46a (+26 lines)
Added Link Here 
1
#ifndef BRIDGE_HELPER_H
2
#define BRIDGE_HELPER_H
3
4
#include "net-device-container.h"
5
#include "ns3/object-factory.h"
6
#include <string>
7
8
namespace ns3 {
9
10
class Node;
11
class AttributeValue;
12
13
class BridgeHelper
14
{
15
public:
16
  BridgeHelper ();
17
  void SetDeviceAttribute (std::string n1, const AttributeValue &v1);
18
  NetDeviceContainer Install (Ptr<Node> node, NetDeviceContainer c);
19
private:
20
  ObjectFactory m_deviceFactory;
21
};
22
23
} // namespace ns3
24
25
26
#endif /* BRIDGE_HELPER_H */
(-)a/src/helper/wscript (+2 lines)
 Lines 20-25   def build(bld): Link Here 
20
        'packet-socket-helper.cc',
20
        'packet-socket-helper.cc',
21
        'ipv4-interface-container.cc',
21
        'ipv4-interface-container.cc',
22
        'udp-echo-helper.cc',
22
        'udp-echo-helper.cc',
23
        'bridge-helper.cc',
23
        ]
24
        ]
24
25
25
    headers = bld.create_obj('ns3header')
26
    headers = bld.create_obj('ns3header')
 Lines 42-45   def build(bld): Link Here 
42
        'packet-socket-helper.h',
43
        'packet-socket-helper.h',
43
        'ipv4-interface-container.h',
44
        'ipv4-interface-container.h',
44
        'udp-echo-helper.h',
45
        'udp-echo-helper.h',
46
        'bridge-helper.h',
45
        ]
47
        ]

Return to bug 276