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
openflow-switch-helper.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Blake Hurd
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
* Author: Blake Hurd <naimorai@gmail.com>
19
*/
20
#ifdef NS3_OPENFLOW
21
22
#include "
openflow-switch-helper.h
"
23
#include "ns3/log.h"
24
#include "ns3/openflow-switch-net-device.h"
25
#include "ns3/openflow-interface.h"
26
#include "ns3/node.h"
27
#include "ns3/names.h"
28
29
NS_LOG_COMPONENT_DEFINE
(
"OpenFlowSwitchHelper"
);
30
31
namespace
ns3 {
32
33
OpenFlowSwitchHelper::OpenFlowSwitchHelper
()
34
{
35
NS_LOG_FUNCTION_NOARGS
();
36
m_deviceFactory
.
SetTypeId
(
"ns3::OpenFlowSwitchNetDevice"
);
37
}
38
39
void
40
OpenFlowSwitchHelper::SetDeviceAttribute
(std::string n1,
const
AttributeValue &v1)
41
{
42
NS_LOG_FUNCTION_NOARGS
();
43
m_deviceFactory
.
Set
(n1, v1);
44
}
45
46
NetDeviceContainer
47
OpenFlowSwitchHelper::Install
(Ptr<Node> node, NetDeviceContainer c, Ptr<ns3::ofi::Controller> controller)
48
{
49
NS_LOG_FUNCTION_NOARGS
();
50
NS_LOG_INFO
(
"**** Install switch device on node "
<< node->GetId ());
51
52
NetDeviceContainer devs;
53
Ptr<OpenFlowSwitchNetDevice> dev =
m_deviceFactory
.
Create
<OpenFlowSwitchNetDevice> ();
54
devs.Add (dev);
55
node->AddDevice (dev);
56
57
NS_LOG_INFO
(
"**** Set up Controller"
);
58
dev->SetController (controller);
59
60
for
(
NetDeviceContainer::Iterator
i = c.Begin (); i != c.End (); ++i)
61
{
62
NS_LOG_INFO
(
"**** Add SwitchPort "
<< *i);
63
dev->AddSwitchPort (*i);
64
}
65
return
devs;
66
}
67
68
NetDeviceContainer
69
OpenFlowSwitchHelper::Install
(Ptr<Node> node, NetDeviceContainer c)
70
{
71
NS_LOG_FUNCTION_NOARGS
();
72
NS_LOG_INFO
(
"**** Install switch device on node "
<< node->GetId ());
73
74
NetDeviceContainer devs;
75
Ptr<OpenFlowSwitchNetDevice> dev =
m_deviceFactory
.
Create
<OpenFlowSwitchNetDevice> ();
76
devs.Add (dev);
77
node->AddDevice (dev);
78
79
for
(
NetDeviceContainer::Iterator
i = c.Begin (); i != c.End (); ++i)
80
{
81
NS_LOG_INFO
(
"**** Add SwitchPort "
<< *i);
82
dev->AddSwitchPort (*i);
83
}
84
return
devs;
85
}
86
87
NetDeviceContainer
88
OpenFlowSwitchHelper::Install
(std::string nodeName, NetDeviceContainer c)
89
{
90
NS_LOG_FUNCTION_NOARGS
();
91
Ptr<Node> node = Names::Find<Node> (nodeName);
92
return
Install
(node, c);
93
}
94
95
}
// namespace ns3
96
97
#endif // NS3_OPENFLOW
src
openflow
helper
openflow-switch-helper.cc
Generated on Tue Nov 13 2012 10:32:21 for ns-3 by
1.8.1.2