A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tap-bridge-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include "tap-bridge-helper.h"
19
20#include "ns3/enum.h"
21#include "ns3/log.h"
22#include "ns3/names.h"
23#include "ns3/node.h"
24#include "ns3/tap-bridge.h"
25
26namespace ns3
27{
28
29NS_LOG_COMPONENT_DEFINE("TapBridgeHelper");
30
32{
34 m_deviceFactory.SetTypeId("ns3::TapBridge");
35}
36
38{
40 m_deviceFactory.SetTypeId("ns3::TapBridge");
41 SetAttribute("Gateway", Ipv4AddressValue(gateway));
43}
44
45void
47{
48 NS_LOG_FUNCTION(n1 << &v1);
49 m_deviceFactory.Set(n1, v1);
50}
51
54{
55 NS_LOG_FUNCTION(node << nd << &v1);
56 m_deviceFactory.Set("DeviceName", v1);
57 return Install(node, nd);
58}
59
62{
63 NS_LOG_FUNCTION(node << nd);
64 NS_LOG_LOGIC("Install TapBridge on node " << node->GetId() << " bridging net device " << nd);
65
67 node->AddDevice(bridge);
68 bridge->SetBridgedNetDevice(nd);
69
70 return bridge;
71}
72
75{
76 Ptr<Node> node = Names::Find<Node>(nodeName);
77 return Install(node, nd);
78}
79
81TapBridgeHelper::Install(Ptr<Node> node, std::string ndName)
82{
83 Ptr<NetDevice> nd = Names::Find<NetDevice>(ndName);
84 return Install(node, nd);
85}
86
88TapBridgeHelper::Install(std::string nodeName, std::string ndName)
89{
90 Ptr<Node> node = Names::Find<Node>(nodeName);
91 Ptr<NetDevice> nd = Names::Find<NetDevice>(ndName);
92 return Install(node, nd);
93}
94
95} // namespace ns3
Hold a value for an Attribute.
Definition: attribute.h:70
Hold variables of type enum.
Definition: enum.h:62
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
AttributeValue implementation for Ipv4Address.
Definition: ipv4-address.h:341
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Ptr< NetDevice > Install(Ptr< Node > node, Ptr< NetDevice > nd)
This method installs a TapBridge on the specified Node and forms the bridge with the NetDevice specif...
TapBridgeHelper()
Construct a TapBridgeHelper to make life easier for people wanting to have their simulations interact...
void SetAttribute(std::string n1, const AttributeValue &v1)
Set an attribute in the underlying TapBridge net device when these devices are automatically created.
ObjectFactory m_deviceFactory
Object factory.
A bridge to make it appear that a real host process is connected to an ns-3 net device.
Definition: tap-bridge.h:109
@ CONFIGURE_LOCAL
ns-3 creates and configures tap device
Definition: tap-bridge.h:124
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.