author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sat, 04 Jul 2009 08:15:48 +0200 | |
changeset 4654 | 2eaebe77d66b |
parent 4289 | 2f5b0ec50102 |
permissions | -rw-r--r-- |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 University of Washington |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
*/ |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
|
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
#include "ns3/log.h" |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
#include "ns3/node.h" |
4289
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
21 |
#include "ns3/enum.h" |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
#include "ns3/tap-bridge.h" |
4194
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
23 |
#include "ns3/names.h" |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
#include "tap-bridge-helper.h" |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
|
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
NS_LOG_COMPONENT_DEFINE ("TapBridgeHelper"); |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
|
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
namespace ns3 { |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
|
4289
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
30 |
TapBridgeHelper::TapBridgeHelper () |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
31 |
{ |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
32 |
NS_LOG_FUNCTION_NOARGS (); |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
33 |
m_deviceFactory.SetTypeId ("ns3::TapBridge"); |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
34 |
} |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
35 |
|
4167
7e444dc749ee
wire needed values into tap-bridge Attribute system, but figure out as many as possible in the default case
Craig Dowell <craigdo@ee.washington.edu>
parents:
4163
diff
changeset
|
36 |
TapBridgeHelper::TapBridgeHelper (Ipv4Address gateway) |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
{ |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
NS_LOG_FUNCTION_NOARGS (); |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
m_deviceFactory.SetTypeId ("ns3::TapBridge"); |
4167
7e444dc749ee
wire needed values into tap-bridge Attribute system, but figure out as many as possible in the default case
Craig Dowell <craigdo@ee.washington.edu>
parents:
4163
diff
changeset
|
40 |
SetAttribute ("Gateway", Ipv4AddressValue (gateway)); |
4289
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
41 |
SetAttribute ("Mode", EnumValue(TapBridge::CONFIGURE_LOCAL)); |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
} |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
|
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
void |
4167
7e444dc749ee
wire needed values into tap-bridge Attribute system, but figure out as many as possible in the default case
Craig Dowell <craigdo@ee.washington.edu>
parents:
4163
diff
changeset
|
45 |
TapBridgeHelper::SetAttribute (std::string n1, const AttributeValue &v1) |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
{ |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
NS_LOG_FUNCTION (n1 << &v1); |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
m_deviceFactory.Set (n1, v1); |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
} |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
|
4194
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
51 |
|
4289
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
52 |
Ptr<NetDevice> |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
53 |
TapBridgeHelper::Install (Ptr<Node> node, Ptr<NetDevice> nd, const AttributeValue &v1) |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
54 |
{ |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
55 |
NS_LOG_FUNCTION (node << nd << &v1); |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
56 |
m_deviceFactory.Set ("DeviceName", v1); |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
57 |
return Install (node, nd); |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
58 |
} |
2f5b0ec50102
initial modifications to tap-bridge
core@samcore1.nettech.boeing.com
parents:
4194
diff
changeset
|
59 |
|
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
Ptr<NetDevice> |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
TapBridgeHelper::Install (Ptr<Node> node, Ptr<NetDevice> nd) |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
{ |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
NS_LOG_FUNCTION (node << nd); |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
NS_LOG_LOGIC ("Install TapBridge on node " << node->GetId () << " bridging net device " << nd); |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
|
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
Ptr<TapBridge> bridge = m_deviceFactory.Create<TapBridge> (); |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
node->AddDevice (bridge); |
4167
7e444dc749ee
wire needed values into tap-bridge Attribute system, but figure out as many as possible in the default case
Craig Dowell <craigdo@ee.washington.edu>
parents:
4163
diff
changeset
|
68 |
bridge->SetBridgedNetDevice (nd); |
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
|
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
return bridge; |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
} |
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
|
4194
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
73 |
Ptr<NetDevice> |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
74 |
TapBridgeHelper::Install (std::string nodeName, Ptr<NetDevice> nd) |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
75 |
{ |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
76 |
Ptr<Node> node = Names::Find<Node> (nodeName); |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
77 |
return Install (node, nd); |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
78 |
} |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
79 |
|
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
80 |
Ptr<NetDevice> |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
81 |
TapBridgeHelper::Install (Ptr<Node> node, std::string ndName) |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
82 |
{ |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
83 |
Ptr<NetDevice> nd = Names::Find<NetDevice> (ndName); |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
84 |
return Install (node, nd); |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
85 |
} |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
86 |
|
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
87 |
Ptr<NetDevice> |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
88 |
TapBridgeHelper::Install (std::string nodeName, std::string ndName) |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
89 |
{ |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
90 |
Ptr<Node> node = Names::Find<Node> (nodeName); |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
91 |
Ptr<NetDevice> nd = Names::Find<NetDevice> (ndName); |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
92 |
return Install (node, nd); |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
93 |
} |
819e09dac21a
add names support to tap bridge helper
Craig Dowell <craigdo@ee.washington.edu>
parents:
4167
diff
changeset
|
94 |
|
4163
8c48682b3d42
checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
} // namespace ns3 |