Try to preserve API compatibility, after SendFrom / promiscuous mode changes.

This commit is contained in:
Gustavo J. A. M. Carneiro committed 2008-07-04 19:15:00 +01:00
1 parent bf13c98467
commit fd8f87cd26
5 files changed
+43 -3

No files matched your search

+21
View File
@@ -21,6 +21,7 @@
#include "ns3/object.h"
#include "ns3/log.h"
#include "net-device.h"
#include "ns3/packet.h"
NS_LOG_COMPONENT_DEFINE ("NetDevice");
@@ -38,4 +39,24 @@ TypeId NetDevice::GetTypeId (void)
NetDevice::~NetDevice ()
{}
bool
NetDevice::SupportsPromiscuousReceiveCallback (void) const
{
return false;
}
void
NetDevice::SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb)
{
NS_FATAL_ERROR ("promiscuous receive callback not supported for this device");
}
bool
NetDevice::SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
{
NS_FATAL_ERROR ("NetDevice " << GetInstanceTypeId ().GetName () << " does not support SendFrom.");
return false;
}
} // namespace ns3
+7 -2
View File
@@ -228,7 +228,7 @@ public:
*
* \return whether the Send operation succeeded
*/
virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
/**
* \returns the node base class which contains this network
* interface.
@@ -297,7 +297,12 @@ public:
* it. In that sense, it receives a superset of packets
* received by the normal ReceivedCallback.
*/
virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb) = 0;
virtual void SetPromiscuousReceiveCallback (PromiscuousReceiveCallback cb);
/**
* \returns true if device supports promiscuous receive callback
*/
virtual bool SupportsPromiscuousReceiveCallback (void) const;
};
+8 -1
View File
@@ -96,7 +96,10 @@ Node::AddDevice (Ptr<NetDevice> device)
device->SetNode (this);
device->SetIfIndex(index);
device->SetReceiveCallback (MakeCallback (&Node::ReceiveFromDevice, this));
device->SetPromiscuousReceiveCallback (MakeCallback (&Node::PromiscuousReceiveFromDevice, this));
if (device->SupportsPromiscuousReceiveCallback ())
{
device->SetPromiscuousReceiveCallback (MakeCallback (&Node::PromiscuousReceiveFromDevice, this));
}
NotifyDeviceAdded (device);
return index;
}
@@ -191,6 +194,10 @@ Node::RegisterPromiscuousProtocolHandler (PromiscuousProtocolHandler handler,
entry.handler = handler;
entry.protocol = protocolType;
entry.device = device;
if (device)
{
NS_ASSERT (device->SupportsPromiscuousReceiveCallback ());
}
m_promiscuousHandlers.push_back (entry);
}