Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
--- a/RELEASE_NOTES Thu Jul 24 11:37:56 2008 +0100
+++ b/RELEASE_NOTES Thu Jul 24 11:41:15 2008 +0100
@@ -36,7 +36,9 @@
- remove references to Parameter in helper APIs (changeset 3cdd9d60f7c7,
bug 232); old variants are currently deprecated API and will be removed
in a future release
-- New NetDevice APIs: SendFrom and SetPromiscRxCallback;
+- New NetDevice APIs: SendFrom, SetPromiscRxCallback,
+ SupportsPromiscuous. These are pure virtual methods, so they need
+ to be implemented by NetDevice subclasses;
In order to support the learning bridge, some API changes in Node and
NetDevice were made.
--- a/bindings/python/ns3_module_node.py Thu Jul 24 11:37:56 2008 +0100
+++ b/bindings/python/ns3_module_node.py Thu Jul 24 11:41:15 2008 +0100
@@ -1538,7 +1538,7 @@
cls.add_method('SendFrom',
'bool',
[param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address&', 'source', is_const=True), param('ns3::Address&', 'dest', is_const=True), param('uint16_t', 'protocolNumber')],
- is_virtual=True)
+ is_pure_virtual=True, is_virtual=True)
## net-device.h: ns3::Ptr<ns3::Node> ns3::NetDevice::GetNode() const [member function]
cls.add_method('GetNode',
'ns3::Ptr< ns3::Node >',
@@ -1563,12 +1563,12 @@
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
- is_virtual=True)
+ is_pure_virtual=True, is_virtual=True)
## net-device.h: bool ns3::NetDevice::SupportsPromiscuous() const [member function]
cls.add_method('SupportsPromiscuous',
'bool',
[],
- is_const=True, is_virtual=True)
+ is_pure_virtual=True, is_const=True, is_virtual=True)
cls.add_constructor([])
return
@@ -2444,6 +2444,16 @@
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
+ ## simple-net-device.h: void ns3::SimpleNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
+ cls.add_method('SetPromiscReceiveCallback',
+ 'void',
+ [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
+ is_virtual=True)
+ ## simple-net-device.h: bool ns3::SimpleNetDevice::SupportsPromiscuous() const [member function]
+ cls.add_method('SupportsPromiscuous',
+ 'bool',
+ [],
+ is_const=True, is_virtual=True)
## simple-net-device.h: void ns3::SimpleNetDevice::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
--- a/bindings/python/ns3_module_point_to_point.py Thu Jul 24 11:37:56 2008 +0100
+++ b/bindings/python/ns3_module_point_to_point.py Thu Jul 24 11:41:15 2008 +0100
@@ -232,6 +232,16 @@
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
+ ## point-to-point-net-device.h: void ns3::PointToPointNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
+ cls.add_method('SetPromiscReceiveCallback',
+ 'void',
+ [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
+ is_virtual=True)
+ ## point-to-point-net-device.h: bool ns3::PointToPointNetDevice::SupportsPromiscuous() const [member function]
+ cls.add_method('SupportsPromiscuous',
+ 'bool',
+ [],
+ is_const=True, is_virtual=True)
## point-to-point-net-device.h: void ns3::PointToPointNetDevice::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
--- a/bindings/python/ns3_module_simulator.py Thu Jul 24 11:37:56 2008 +0100
+++ b/bindings/python/ns3_module_simulator.py Thu Jul 24 11:41:15 2008 +0100
@@ -333,10 +333,10 @@
def register_Ns3Simulator_methods(root_module, cls):
## simulator.h: static void ns3::Simulator::SetImplementation(ns3::Ptr<ns3::SimulatorImpl> impl) [member function]
- #cls.add_method('SetImplementation',
- # 'void',
- # [param('ns3::Ptr< ns3::SimulatorImpl >', 'impl')],
- # is_static=True)
+ cls.add_method('SetImplementation',
+ 'void',
+ [param('ns3::Ptr< ns3::SimulatorImpl >', 'impl')],
+ is_static=True)
## simulator.h: static void ns3::Simulator::SetScheduler(ns3::Ptr<ns3::Scheduler> scheduler) [member function]
cls.add_method('SetScheduler',
'void',
--- a/bindings/python/ns3_module_wifi.py Thu Jul 24 11:37:56 2008 +0100
+++ b/bindings/python/ns3_module_wifi.py Thu Jul 24 11:41:15 2008 +0100
@@ -2155,6 +2155,21 @@
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
+ ## wifi-net-device.h: bool ns3::WifiNetDevice::SendFrom(ns3::Ptr<ns3::Packet> packet, ns3::Address const & source, ns3::Address const & dest, uint16_t protocolNumber) [member function]
+ cls.add_method('SendFrom',
+ 'bool',
+ [param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Address&', 'source', is_const=True), param('ns3::Address&', 'dest', is_const=True), param('uint16_t', 'protocolNumber')],
+ is_virtual=True)
+ ## wifi-net-device.h: void ns3::WifiNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
+ cls.add_method('SetPromiscReceiveCallback',
+ 'void',
+ [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
+ is_virtual=True)
+ ## wifi-net-device.h: bool ns3::WifiNetDevice::SupportsPromiscuous() const [member function]
+ cls.add_method('SupportsPromiscuous',
+ 'bool',
+ [],
+ is_const=True, is_virtual=True)
## wifi-net-device.h: void ns3::WifiNetDevice::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
--- a/src/devices/point-to-point/point-to-point-net-device.cc Thu Jul 24 11:37:56 2008 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.cc Thu Jul 24 11:41:15 2008 +0100
@@ -467,4 +467,16 @@
m_rxCallback = cb;
}
+ void
+PointToPointNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
+{
+ NS_FATAL_ERROR ("not implemented");
+}
+
+ bool
+PointToPointNetDevice::SupportsPromiscuous (void) const
+{
+ return false;
+}
+
} // namespace ns3
--- a/src/devices/point-to-point/point-to-point-net-device.h Thu Jul 24 11:37:56 2008 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.h Thu Jul 24 11:41:15 2008 +0100
@@ -177,6 +177,9 @@
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
+ virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
+ virtual bool SupportsPromiscuous (void) const;
+
private:
virtual void DoDispose (void);
--- a/src/devices/wifi/wifi-net-device.cc Thu Jul 24 11:37:56 2008 +0100
+++ b/src/devices/wifi/wifi-net-device.cc Thu Jul 24 11:41:15 2008 +0100
@@ -332,5 +332,24 @@
}
}
+bool
+WifiNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
+{
+ NS_FATAL_ERROR ("TODO");
+ return false;
+}
+
+void
+WifiNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
+{
+ NS_FATAL_ERROR ("TODO");
+}
+
+bool
+WifiNetDevice::SupportsPromiscuous (void) const
+{
+ return false; // TODO
+}
+
} // namespace ns3
--- a/src/devices/wifi/wifi-net-device.h Thu Jul 24 11:37:56 2008 +0100
+++ b/src/devices/wifi/wifi-net-device.h Thu Jul 24 11:41:15 2008 +0100
@@ -101,6 +101,10 @@
virtual bool NeedsArp (void) const;
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
+ virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
+ virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
+ virtual bool SupportsPromiscuous (void) const;
+
private:
virtual void DoDispose (void);
void ForwardUp (Ptr<Packet> packet, const Mac48Address &from);
--- a/src/node/net-device.cc Thu Jul 24 11:37:56 2008 +0100
+++ b/src/node/net-device.cc Thu Jul 24 11:41:15 2008 +0100
@@ -38,25 +38,4 @@
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
--- a/src/node/net-device.h Thu Jul 24 11:37:56 2008 +0100
+++ b/src/node/net-device.h Thu Jul 24 11:41:15 2008 +0100
@@ -228,7 +228,7 @@
*
* \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 @@
* 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;
};
--- a/src/node/simple-net-device.cc Thu Jul 24 11:37:56 2008 +0100
+++ b/src/node/simple-net-device.cc Thu Jul 24 11:41:15 2008 +0100
@@ -200,5 +200,16 @@
}
+void
+SimpleNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
+{
+ NS_FATAL_ERROR ("Not supported");
+}
+
+bool
+SimpleNetDevice::SupportsPromiscuous (void) const
+{
+ return false;
+}
} // namespace ns3
--- a/src/node/simple-net-device.h Thu Jul 24 11:37:56 2008 +0100
+++ b/src/node/simple-net-device.h Thu Jul 24 11:41:15 2008 +0100
@@ -68,6 +68,8 @@
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);