Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.

This commit is contained in:
Gustavo J. A. M. Carneiro
2008-07-24 11:41:15 +01:00
parent 732b7994de
commit ca2fef3bd8
13 changed files with 99 additions and 32 deletions

View File

@@ -38,25 +38,4 @@ TypeId NetDevice::GetTypeId (void)
NetDevice::~NetDevice ()
{}
bool
NetDevice::SupportsPromiscuous () const
{
return false;
}
void
NetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
{
// assert that the virtual method was overridden in a subclass if it
// claims to support promiscuous mode.
NS_ASSERT (!SupportsPromiscuous ());
}
bool
NetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
{
NS_FATAL_ERROR ("NetDevice::SendFrom not implemented for " << GetInstanceTypeId ().GetName ());
return false;
}
} // namespace ns3

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);
virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
/**
* \returns the node base class which contains this network
* interface.
@@ -309,12 +309,12 @@ public:
* sensed by the netdevice but which are intended to be received by
* other hosts.
*/
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb) = 0;
/**
* \return true if this interface supports a promiscuous mode, false otherwise.
*/
virtual bool SupportsPromiscuous (void) const;
virtual bool SupportsPromiscuous (void) const = 0;
};

View File

@@ -200,5 +200,16 @@ SimpleNetDevice::DoDispose (void)
}
void
SimpleNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
{
NS_FATAL_ERROR ("Not supported");
}
bool
SimpleNetDevice::SupportsPromiscuous (void) const
{
return false;
}
} // namespace ns3

View File

@@ -68,6 +68,8 @@ public:
virtual void SetNode (Ptr<Node> node);
virtual bool NeedsArp (void) const;
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
virtual bool SupportsPromiscuous (void) const;
protected:
virtual void DoDispose (void);