author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Wed, 16 Jul 2008 16:06:50 +0100 | |
changeset 3460 | 99698bc858e8 |
parent 3450 | 73e90de6eb47 |
child 3513 | fe3945d67a88 |
permissions | -rw-r--r-- |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
2 |
/* |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
3 |
* Copyright (c) 2006 Georgia Tech Research Corporation, INRIA |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
4 |
* |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
7 |
* published by the Free Software Foundation; |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
8 |
* |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
12 |
* GNU General Public License for more details. |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
13 |
* |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
17 |
* |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
18 |
* Authors: George F. Riley<riley@ece.gatech.edu> |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
19 |
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
20 |
*/ |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
21 |
#include "node.h" |
358
cefde4f0d6b2
Add nodes to NodeList in static Create method; cut over simple-serial.cc to use this node factory
Tom Henderson <tomh@tomh.org>
parents:
355
diff
changeset
|
22 |
#include "node-list.h" |
467
319ffa6c5e0a
dispose properly from Node::Dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
465
diff
changeset
|
23 |
#include "net-device.h" |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
24 |
#include "application.h" |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1412
diff
changeset
|
25 |
#include "ns3/packet.h" |
475
aeadea0cdc82
destroy the Node vector upon Simulator::Destroy rather than wait until the global static destructor of Node::g_nodes is invoked. This fixes a bad assert caught with valgrind.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
474
diff
changeset
|
26 |
#include "ns3/simulator.h" |
2478
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
27 |
#include "ns3/object-vector.h" |
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
28 |
#include "ns3/uinteger.h" |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
29 |
#include "ns3/log.h" |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
30 |
|
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
31 |
NS_LOG_COMPONENT_DEFINE ("Node"); |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
namespace ns3{ |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
|
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
35 |
NS_OBJECT_ENSURE_REGISTERED (Node); |
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
36 |
|
2250
18f432098389
InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2249
diff
changeset
|
37 |
TypeId |
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
38 |
Node::GetTypeId (void) |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
39 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
40 |
static TypeId tid = TypeId ("ns3::Node") |
2478
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
41 |
.SetParent<Object> () |
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
42 |
.AddAttribute ("DeviceList", "The list of devices associated to this Node.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
43 |
ObjectVectorValue (), |
2478
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
44 |
MakeObjectVectorAccessor (&Node::m_devices), |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2735
diff
changeset
|
45 |
MakeObjectVectorChecker<NetDevice> ()) |
2478
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
46 |
.AddAttribute ("ApplicationList", "The list of applications associated to this Node.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
47 |
ObjectVectorValue (), |
2478
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
48 |
MakeObjectVectorAccessor (&Node::m_applications), |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2735
diff
changeset
|
49 |
MakeObjectVectorChecker<Application> ()) |
2478
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
50 |
.AddAttribute ("Id", "The id (unique integer) of this Node.", |
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
51 |
TypeId::ATTR_GET, // allow only getting it. |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
52 |
UintegerValue (0), |
2478
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
53 |
MakeUintegerAccessor (&Node::m_id), |
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
54 |
MakeUintegerChecker<uint32_t> ()) |
8ace2f58506e
application and netdevice lists are attributes now.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
55 |
; |
2252
80595448707a
iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
56 |
return tid; |
2232
9abd038ee588
replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
57 |
} |
512
5404e1e41f82
make Node derive from NsUnknown rather than Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
484
diff
changeset
|
58 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
59 |
Node::Node() |
710
2a9c061219a7
port code from Interface to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
60 |
: m_id(0), |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
61 |
m_sid(0) |
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
62 |
{ |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
63 |
Construct (); |
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
244
diff
changeset
|
64 |
} |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
244
diff
changeset
|
65 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
66 |
Node::Node(uint32_t sid) |
710
2a9c061219a7
port code from Interface to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
67 |
: m_id(0), |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
68 |
m_sid(sid) |
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
244
diff
changeset
|
69 |
{ |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
70 |
Construct (); |
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
71 |
} |
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
72 |
|
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
73 |
void |
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
74 |
Node::Construct (void) |
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
75 |
{ |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
76 |
m_id = NodeList::Add (this); |
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
77 |
} |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
79 |
Node::~Node () |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
{} |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
|
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
82 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
83 |
Node::GetId (void) const |
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
84 |
{ |
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
85 |
return m_id; |
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
86 |
} |
359
91b7ad7fa784
OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents:
358
diff
changeset
|
87 |
|
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
88 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
89 |
Node::GetSystemId (void) const |
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
90 |
{ |
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
91 |
return m_sid; |
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
92 |
} |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
|
447
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
94 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
95 |
Node::AddDevice (Ptr<NetDevice> device) |
447
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
96 |
{ |
1195
53f1175dbe94
fix tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
97 |
uint32_t index = m_devices.size (); |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
98 |
m_devices.push_back (device); |
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
99 |
device->SetNode (this); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
525
diff
changeset
|
100 |
device->SetIfIndex(index); |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
101 |
device->SetReceiveCallback (MakeCallback (&Node::NonPromiscReceiveFromDevice, this)); |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
102 |
NotifyDeviceAdded (device); |
447
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
103 |
return index; |
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
104 |
} |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
535
diff
changeset
|
105 |
Ptr<NetDevice> |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
106 |
Node::GetDevice (uint32_t index) const |
447
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
107 |
{ |
1195
53f1175dbe94
fix tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1194
diff
changeset
|
108 |
return m_devices[index]; |
447
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
109 |
} |
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
110 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
111 |
Node::GetNDevices (void) const |
447
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
112 |
{ |
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
113 |
return m_devices.size (); |
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
114 |
} |
180117abfb04
add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
381
diff
changeset
|
115 |
|
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
116 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
117 |
Node::AddApplication (Ptr<Application> application) |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
118 |
{ |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
119 |
uint32_t index = m_applications.size (); |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
120 |
m_applications.push_back (application); |
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
121 |
application->SetNode (this); |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
122 |
return index; |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
123 |
} |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
124 |
Ptr<Application> |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
125 |
Node::GetApplication (uint32_t index) const |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
126 |
{ |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
127 |
return m_applications[index]; |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
128 |
} |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
129 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
710
diff
changeset
|
130 |
Node::GetNApplications (void) const |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
131 |
{ |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
132 |
return m_applications.size (); |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
133 |
} |
3380 | 134 |
Ptr<Application> |
135 |
Node::GetFirstApplication(TypeId tid) |
|
136 |
{ |
|
137 |
for (std::vector<Ptr<Application> >::iterator i = m_applications.begin (); |
|
138 |
i != m_applications.end (); i++) { |
|
139 |
Ptr<Application> app = *i; |
|
140 |
if (app->GetInstanceTypeId() == tid) |
|
141 |
return app; |
|
142 |
} |
|
143 |
||
144 |
return 0; |
|
145 |
} |
|
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
146 |
|
1194
b8e957eb0a94
replace Node::DoCreateTraceResolver with Node::DoFillTraceResolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
147 |
void |
b8e957eb0a94
replace Node::DoCreateTraceResolver with Node::DoFillTraceResolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1186
diff
changeset
|
148 |
Node::DoDispose() |
465
7f620ea278f4
merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
448
diff
changeset
|
149 |
{ |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
535
diff
changeset
|
150 |
for (std::vector<Ptr<NetDevice> >::iterator i = m_devices.begin (); |
467
319ffa6c5e0a
dispose properly from Node::Dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
465
diff
changeset
|
151 |
i != m_devices.end (); i++) |
319ffa6c5e0a
dispose properly from Node::Dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
465
diff
changeset
|
152 |
{ |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
535
diff
changeset
|
153 |
Ptr<NetDevice> device = *i; |
467
319ffa6c5e0a
dispose properly from Node::Dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
465
diff
changeset
|
154 |
device->Dispose (); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
535
diff
changeset
|
155 |
*i = 0; |
467
319ffa6c5e0a
dispose properly from Node::Dispose
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
465
diff
changeset
|
156 |
} |
515
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
514
diff
changeset
|
157 |
m_devices.clear (); |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
158 |
for (std::vector<Ptr<Application> >::iterator i = m_applications.begin (); |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
159 |
i != m_applications.end (); i++) |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
160 |
{ |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
161 |
Ptr<Application> application = *i; |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
162 |
application->Dispose (); |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
163 |
*i = 0; |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
164 |
} |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
580
diff
changeset
|
165 |
m_applications.clear (); |
710
2a9c061219a7
port code from Interface to Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
166 |
Object::DoDispose (); |
465
7f620ea278f4
merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
448
diff
changeset
|
167 |
} |
7f620ea278f4
merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
448
diff
changeset
|
168 |
|
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
169 |
void |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
170 |
Node::NotifyDeviceAdded (Ptr<NetDevice> device) |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
171 |
{} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
172 |
|
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
173 |
void |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
174 |
Node::RegisterProtocolHandler (ProtocolHandler handler, |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
175 |
uint16_t protocolType, |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
176 |
Ptr<NetDevice> device, |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
177 |
bool promiscuous) |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
178 |
{ |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
179 |
struct Node::ProtocolHandlerEntry entry; |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
180 |
entry.handler = handler; |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
181 |
entry.protocol = protocolType; |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
182 |
entry.device = device; |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
183 |
entry.promiscuous = promiscuous; |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
184 |
|
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
185 |
// On demand enable promiscuous mode in netdevices |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
186 |
if (promiscuous) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
187 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
188 |
if (device == 0) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
189 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
190 |
for (std::vector<Ptr<NetDevice> >::iterator i = m_devices.begin (); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
191 |
i != m_devices.end (); i++) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
192 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
193 |
Ptr<NetDevice> dev = *i; |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
194 |
if (dev->SupportsPromiscuous ()) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
195 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
196 |
dev->SetPromiscReceiveCallback (MakeCallback (&Node::PromiscReceiveFromDevice, this)); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
197 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
198 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
199 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
200 |
else |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
201 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
202 |
if (device->SupportsPromiscuous ()) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
203 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
204 |
device->SetPromiscReceiveCallback (MakeCallback (&Node::PromiscReceiveFromDevice, this)); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
205 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
206 |
else |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
207 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
208 |
NS_LOG_WARN ("Protocol handler request promiscuous mode for a specific netdevice," |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
209 |
" but netdevice does not support promiscuous mode."); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
210 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
211 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
212 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
213 |
|
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
214 |
m_handlers.push_back (entry); |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
215 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
216 |
|
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
217 |
void |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
218 |
Node::UnregisterProtocolHandler (ProtocolHandler handler) |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
219 |
{ |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
220 |
for (ProtocolHandlerList::iterator i = m_handlers.begin (); |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
221 |
i != m_handlers.end (); i++) |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
222 |
{ |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
223 |
if (i->handler.IsEqual (handler)) |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
224 |
{ |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
225 |
m_handlers.erase (i); |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
226 |
break; |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
227 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
228 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
229 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
230 |
|
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
231 |
bool |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
232 |
Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
233 |
const Address &from, const Address &to, NetDevice::PacketType packetType) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
234 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
235 |
NS_LOG_FUNCTION(device->GetName ()); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
236 |
return ReceiveFromDevice (device, packet, protocol, from, to, packetType, true); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
237 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
238 |
|
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
239 |
bool |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
240 |
Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
241 |
const Address &from) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
242 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
243 |
NS_LOG_FUNCTION(device->GetName ()); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
244 |
return ReceiveFromDevice (device, packet, protocol, from, from, NetDevice::PacketType (0), false); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
245 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
246 |
|
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
247 |
bool |
3448
0bd851bb1225
Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3446
diff
changeset
|
248 |
Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
249 |
const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous) |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
250 |
{ |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
251 |
NS_LOG_FUNCTION(device->GetName ()); |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
252 |
bool found = false; |
3016
f77acbb9f7b4
Missing Packet::Copy in Node::ReceiveFromDevice for the multiple protocol handlers scenario.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2965
diff
changeset
|
253 |
// if there are (potentially) multiple handlers, we need to copy the |
f77acbb9f7b4
Missing Packet::Copy in Node::ReceiveFromDevice for the multiple protocol handlers scenario.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2965
diff
changeset
|
254 |
// packet before passing it to each handler, because handlers may |
f77acbb9f7b4
Missing Packet::Copy in Node::ReceiveFromDevice for the multiple protocol handlers scenario.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2965
diff
changeset
|
255 |
// modify it. |
f77acbb9f7b4
Missing Packet::Copy in Node::ReceiveFromDevice for the multiple protocol handlers scenario.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2965
diff
changeset
|
256 |
bool copyNeeded = (m_handlers.size () > 1); |
f77acbb9f7b4
Missing Packet::Copy in Node::ReceiveFromDevice for the multiple protocol handlers scenario.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2965
diff
changeset
|
257 |
|
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
258 |
for (ProtocolHandlerList::iterator i = m_handlers.begin (); |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
259 |
i != m_handlers.end (); i++) |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
260 |
{ |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
261 |
if (i->device == 0 || |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
262 |
(i->device != 0 && i->device == device)) |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
263 |
{ |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
264 |
if (i->protocol == 0 || |
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1176
diff
changeset
|
265 |
i->protocol == protocol) |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
266 |
{ |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
267 |
if (promiscuous == i->promiscuous) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
268 |
{ |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
269 |
i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, packetType); |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
270 |
found = true; |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3450
diff
changeset
|
271 |
} |
1176
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
272 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
273 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
274 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
275 |
return found; |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
276 |
} |
4894ea885c0f
implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
729
diff
changeset
|
277 |
|
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
278 |
}//namespace ns3 |