A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tap-bridge-helper.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#include "ns3/log.h"
20
#include "ns3/node.h"
21
#include "ns3/enum.h"
22
#include "ns3/tap-bridge.h"
23
#include "ns3/names.h"
24
#include "
tap-bridge-helper.h
"
25
26
NS_LOG_COMPONENT_DEFINE
(
"TapBridgeHelper"
);
27
28
namespace
ns3 {
29
30
TapBridgeHelper::TapBridgeHelper
()
31
{
32
NS_LOG_FUNCTION_NOARGS
();
33
m_deviceFactory
.
SetTypeId
(
"ns3::TapBridge"
);
34
}
35
36
TapBridgeHelper::TapBridgeHelper
(
Ipv4Address
gateway)
37
{
38
NS_LOG_FUNCTION_NOARGS
();
39
m_deviceFactory
.
SetTypeId
(
"ns3::TapBridge"
);
40
SetAttribute
(
"Gateway"
,
Ipv4AddressValue
(gateway));
41
SetAttribute
(
"Mode"
,
EnumValue
(
TapBridge::CONFIGURE_LOCAL
));
42
}
43
44
void
45
TapBridgeHelper::SetAttribute
(std::string n1,
const
AttributeValue
&v1)
46
{
47
NS_LOG_FUNCTION
(n1 << &v1);
48
m_deviceFactory
.
Set
(n1, v1);
49
}
50
51
52
Ptr<NetDevice>
53
TapBridgeHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
nd,
const
AttributeValue
&v1)
54
{
55
NS_LOG_FUNCTION
(node << nd << &v1);
56
m_deviceFactory
.
Set
(
"DeviceName"
, v1);
57
return
Install
(node, nd);
58
}
59
60
Ptr<NetDevice>
61
TapBridgeHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
nd)
62
{
63
NS_LOG_FUNCTION
(node << nd);
64
NS_LOG_LOGIC
(
"Install TapBridge on node "
<< node->
GetId
() <<
" bridging net device "
<< nd);
65
66
Ptr<TapBridge>
bridge =
m_deviceFactory
.
Create
<
TapBridge
> ();
67
node->
AddDevice
(bridge);
68
bridge->SetBridgedNetDevice (nd);
69
70
return
bridge;
71
}
72
73
Ptr<NetDevice>
74
TapBridgeHelper::Install
(std::string nodeName,
Ptr<NetDevice>
nd)
75
{
76
Ptr<Node>
node = Names::Find<Node> (nodeName);
77
return
Install
(node, nd);
78
}
79
80
Ptr<NetDevice>
81
TapBridgeHelper::Install
(
Ptr<Node>
node, std::string ndName)
82
{
83
Ptr<NetDevice>
nd = Names::Find<NetDevice> (ndName);
84
return
Install
(node, nd);
85
}
86
87
Ptr<NetDevice>
88
TapBridgeHelper::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
ns3::TapBridgeHelper::SetAttribute
void SetAttribute(std::string n1, const AttributeValue &v1)
Definition:
tap-bridge-helper.cc:45
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:56
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Definition:
object-factory.cc:41
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log.h:309
ns3::EnumValue
hold variables of type 'enum'
Definition:
enum.h:37
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Definition:
object-factory.cc:90
ns3::TapBridge
A bridge to make it appear that a real host process is connected to an ns-3 net device.
Definition:
tap-bridge.h:103
ns3::TapBridgeHelper::TapBridgeHelper
TapBridgeHelper()
Construct a TapBridgeHelper to make life easier for people wanting to have their simulations interact...
Definition:
tap-bridge-helper.cc:30
tap-bridge-helper.h
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("TapBridgeHelper")
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Definition:
log.h:368
ns3::TapBridgeHelper::m_deviceFactory
ObjectFactory m_deviceFactory
Definition:
tap-bridge-helper.h:129
ns3::TapBridge::CONFIGURE_LOCAL
ns-3 creates and configures tap device
Definition:
tap-bridge.h:114
ns3::ObjectFactory::Set
void Set(std::string name, const AttributeValue &value)
Definition:
object-factory.cc:59
ns3::Ipv4AddressValue
hold objects of type ns3::Ipv4Address
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
ns3::Node::AddDevice
uint32_t AddDevice(Ptr< NetDevice > device)
Definition:
node.cc:118
ns3::Node::GetId
uint32_t GetId(void) const
Definition:
node.cc:104
ns3::TapBridgeHelper::Install
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...
Definition:
tap-bridge-helper.cc:61
src
tap-bridge
helper
tap-bridge-helper.cc
Generated on Sat Apr 19 2014 14:07:09 for ns-3 by
1.8.6