Browse Source

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

ndnSIM-v1
Gustavo J. A. M. Carneiro 17 years ago
parent
commit
ca2fef3bd8
  1. 4
      RELEASE_NOTES
  2. 16
      bindings/python/ns3_module_node.py
  3. 10
      bindings/python/ns3_module_point_to_point.py
  4. 8
      bindings/python/ns3_module_simulator.py
  5. 15
      bindings/python/ns3_module_wifi.py
  6. 12
      src/devices/point-to-point/point-to-point-net-device.cc
  7. 3
      src/devices/point-to-point/point-to-point-net-device.h
  8. 19
      src/devices/wifi/wifi-net-device.cc
  9. 4
      src/devices/wifi/wifi-net-device.h
  10. 21
      src/node/net-device.cc
  11. 6
      src/node/net-device.h
  12. 11
      src/node/simple-net-device.cc
  13. 2
      src/node/simple-net-device.h

4
RELEASE_NOTES

@ -36,7 +36,9 @@ API changes from 3.1 to 3.2
- 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.

16
bindings/python/ns3_module_node.py

@ -1538,7 +1538,7 @@ def register_Ns3NetDevice_methods(root_module, cls):
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 @@ def register_Ns3NetDevice_methods(root_module, cls):
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 @@ def register_Ns3SimpleNetDevice_methods(root_module, cls):
'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',

10
bindings/python/ns3_module_point_to_point.py

@ -232,6 +232,16 @@ def register_Ns3PointToPointNetDevice_methods(root_module, cls):
'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',

8
bindings/python/ns3_module_simulator.py

@ -333,10 +333,10 @@ def register_Ns3Watchdog_methods(root_module, cls):
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',

15
bindings/python/ns3_module_wifi.py

@ -2155,6 +2155,21 @@ def register_Ns3WifiNetDevice_methods(root_module, cls):
'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',

12
src/devices/point-to-point/point-to-point-net-device.cc

@ -467,4 +467,16 @@ PointToPointNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
m_rxCallback = cb;
}
void
PointToPointNetDevice::SetPromiscReceiveCallback (PromiscReceiveCallback cb)
{
NS_FATAL_ERROR ("not implemented");
}
bool
PointToPointNetDevice::SupportsPromiscuous (void) const
{
return false;
}
} // namespace ns3

3
src/devices/point-to-point/point-to-point-net-device.h

@ -177,6 +177,9 @@ public:
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
virtual bool SupportsPromiscuous (void) const;
private:
virtual void DoDispose (void);

19
src/devices/wifi/wifi-net-device.cc

@ -332,5 +332,24 @@ WifiNetDevice::LinkDown (void)
}
}
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

4
src/devices/wifi/wifi-net-device.h

@ -101,6 +101,10 @@ public:
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);

21
src/node/net-device.cc

@ -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

6
src/node/net-device.h

@ -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;
};

11
src/node/simple-net-device.cc

@ -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

2
src/node/simple-net-device.h

@ -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);

Loading…
Cancel
Save