View | Details | Raw Unified | Return to bug 1068
Collapse All | Expand All

(-)a/src/node/node.cc (-4 / +36 lines)
 Lines 153-158    Link Here 
153
void 
153
void 
154
Node::DoDispose()
154
Node::DoDispose()
155
{
155
{
156
  m_deviceAdditionListeners.clear ();
156
  m_handlers.clear ();
157
  m_handlers.clear ();
157
  for (std::vector<Ptr<NetDevice> >::iterator i = m_devices.begin ();
158
  for (std::vector<Ptr<NetDevice> >::iterator i = m_devices.begin ();
158
       i != m_devices.end (); i++)
159
       i != m_devices.end (); i++)
 Lines 191-200    Link Here 
191
  Object::DoStart ();
192
  Object::DoStart ();
192
}
193
}
193
194
194
void 
195
Node::NotifyDeviceAdded (Ptr<NetDevice> device)
196
{}
197
198
void
195
void
199
Node::RegisterProtocolHandler (ProtocolHandler handler, 
196
Node::RegisterProtocolHandler (ProtocolHandler handler, 
200
                               uint16_t protocolType,
197
                               uint16_t protocolType,
 Lines 298-301    Link Here 
298
  return found;
295
  return found;
299
}
296
}
300
297
298
void 
299
Node::RegisterDeviceAdditionListener (DeviceAdditionListener listener)
300
{
301
  m_deviceAdditionListeners.push_back (listener);
302
  // and, then, notify the new listener about all existing devices.
303
  for (std::vector<Ptr<NetDevice> >::const_iterator i = m_devices.begin ();
304
       i != m_devices.end (); ++i)
305
    {
306
      listener (*i);
307
    }
308
}
309
void 
310
Node::UnregisterDeviceAdditionListener (DeviceAdditionListener listener)
311
{
312
  for (DeviceAdditionListenerList::iterator i = m_deviceAdditionListeners.begin ();
313
       i != m_deviceAdditionListeners.end (); i++)
314
    {
315
      if ((*i).IsEqual (listener))
316
        {
317
          m_deviceAdditionListeners.erase (i);
318
          break;
319
        }
320
    }
321
}
322
323
void 
324
Node::NotifyDeviceAdded (Ptr<NetDevice> device)
325
{
326
  for (DeviceAdditionListenerList::iterator i = m_deviceAdditionListeners.begin ();
327
       i != m_deviceAdditionListeners.end (); i++)
328
    {
329
      (*i) (device);
330
    }  
331
}
332
301
}//namespace ns3
333
}//namespace ns3
(-)a/src/node/node.h (-8 / +7 lines)
 Lines 172-177    Link Here 
172
   */
172
   */
173
  void UnregisterProtocolHandler (ProtocolHandler handler);
173
  void UnregisterProtocolHandler (ProtocolHandler handler);
174
174
175
  typedef Callback<void,Ptr<NetDevice> > DeviceAdditionListener;
176
  void RegisterDeviceAdditionListener (DeviceAdditionListener listener);
177
  void UnregisterDeviceAdditionListener (DeviceAdditionListener listener);
175
  
178
  
176
  /**
179
  /**
177
   * \returns true if checksums are enabled, false otherwise.
180
   * \returns true if checksums are enabled, false otherwise.
 Lines 188-200    Link Here 
188
  virtual void DoDispose (void);
191
  virtual void DoDispose (void);
189
  virtual void DoStart (void);
192
  virtual void DoStart (void);
190
private:
193
private:
191
194
  void NotifyDeviceAdded (Ptr<NetDevice> device);
192
  /**
193
   * \param device the device added to this Node.
194
   *
195
   * This method is invoked whenever a user calls Node::AddDevice.
196
   */
197
  virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
198
195
199
  bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol, const Address &from);
196
  bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol, const Address &from);
200
  bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
197
  bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
 Lines 211-222    Link Here 
211
    bool promiscuous;
208
    bool promiscuous;
212
  };
209
  };
213
  typedef std::vector<struct Node::ProtocolHandlerEntry> ProtocolHandlerList;
210
  typedef std::vector<struct Node::ProtocolHandlerEntry> ProtocolHandlerList;
211
  typedef std::vector<DeviceAdditionListener> DeviceAdditionListenerList;
212
214
  uint32_t    m_id;         // Node id for this node
213
  uint32_t    m_id;         // Node id for this node
215
  uint32_t    m_sid;        // System id for this node
214
  uint32_t    m_sid;        // System id for this node
216
  std::vector<Ptr<NetDevice> > m_devices;
215
  std::vector<Ptr<NetDevice> > m_devices;
217
  std::vector<Ptr<Application> > m_applications;
216
  std::vector<Ptr<Application> > m_applications;
218
  ProtocolHandlerList m_handlers;
217
  ProtocolHandlerList m_handlers;
219
218
  DeviceAdditionListenerList m_deviceAdditionListeners;
220
};
219
};
221
220
222
} //namespace ns3
221
} //namespace ns3

Return to bug 1068