Rescan API; fix and enable the socket unit test, as it now works.

This commit is contained in:
Gustavo J. A. M. Carneiro
2008-07-09 18:50:28 +01:00
parent 1f1ffe7372
commit ee19e57741
3 changed files with 21 additions and 69 deletions

View File

@@ -800,32 +800,6 @@ def register_Ns3UdpSocket_methods(root_module, cls):
cls.add_method('GetTypeId', 'ns3::TypeId', [], is_static=True)
## udp-socket.h: ns3::UdpSocket::UdpSocket() [constructor]
cls.add_constructor([], visibility='public')
## udp-socket.h: ns3::Socket::SocketErrno ns3::UdpSocket::GetErrno() const [member function]
cls.add_method('GetErrno', 'ns3::Socket::SocketErrno', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## udp-socket.h: ns3::Ptr<ns3::Node> ns3::UdpSocket::GetNode() const [member function]
cls.add_method('GetNode', 'ns3::Ptr< ns3::Node >', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## udp-socket.h: int ns3::UdpSocket::Bind() [member function]
cls.add_method('Bind', 'int', [], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: int ns3::UdpSocket::Close() [member function]
cls.add_method('Close', 'int', [], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: int ns3::UdpSocket::ShutdownSend() [member function]
cls.add_method('ShutdownSend', 'int', [], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: int ns3::UdpSocket::ShutdownRecv() [member function]
cls.add_method('ShutdownRecv', 'int', [], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: int ns3::UdpSocket::Connect(ns3::Address const & address) [member function]
cls.add_method('Connect', 'int', [param('ns3::Address&', 'address', is_const=True)], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: uint32_t ns3::UdpSocket::GetTxAvailable() const [member function]
cls.add_method('GetTxAvailable', 'uint32_t', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## udp-socket.h: int ns3::UdpSocket::Send(ns3::Ptr<ns3::Packet> p, uint32_t flags) [member function]
cls.add_method('Send', 'int', [param('ns3::Ptr< ns3::Packet >', 'p'), param('uint32_t', 'flags')], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: int ns3::UdpSocket::SendTo(ns3::Ptr<ns3::Packet> p, uint32_t flags, ns3::Address const & toAddress) [member function]
cls.add_method('SendTo', 'int', [param('ns3::Ptr< ns3::Packet >', 'p'), param('uint32_t', 'flags'), param('ns3::Address&', 'toAddress', is_const=True)], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: uint32_t ns3::UdpSocket::GetRxAvailable() const [member function]
cls.add_method('GetRxAvailable', 'uint32_t', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## udp-socket.h: ns3::Ptr<ns3::Packet> ns3::UdpSocket::Recv(uint32_t maxSize, uint32_t flags) [member function]
cls.add_method('Recv', 'ns3::Ptr< ns3::Packet >', [param('uint32_t', 'maxSize'), param('uint32_t', 'flags')], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: ns3::Ptr<ns3::Packet> ns3::UdpSocket::RecvFrom(uint32_t maxSize, uint32_t flags, ns3::Address & fromAddress) [member function]
cls.add_method('RecvFrom', 'ns3::Ptr< ns3::Packet >', [param('uint32_t', 'maxSize'), param('uint32_t', 'flags'), param('ns3::Address&', 'fromAddress')], is_pure_virtual=True, is_virtual=True)
## udp-socket.h: void ns3::UdpSocket::SetRcvBufSize(uint32_t size) [member function]
cls.add_method('SetRcvBufSize', 'void', [param('uint32_t', 'size')], is_pure_virtual=True, visibility='private', is_virtual=True)
## udp-socket.h: uint32_t ns3::UdpSocket::GetRcvBufSize() const [member function]
@@ -977,32 +951,6 @@ def register_Ns3TcpSocket_methods(root_module, cls):
cls.add_method('GetTypeId', 'ns3::TypeId', [], is_static=True)
## tcp-socket.h: ns3::TcpSocket::TcpSocket() [constructor]
cls.add_constructor([], visibility='public')
## tcp-socket.h: ns3::Socket::SocketErrno ns3::TcpSocket::GetErrno() const [member function]
cls.add_method('GetErrno', 'ns3::Socket::SocketErrno', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## tcp-socket.h: ns3::Ptr<ns3::Node> ns3::TcpSocket::GetNode() const [member function]
cls.add_method('GetNode', 'ns3::Ptr< ns3::Node >', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## tcp-socket.h: int ns3::TcpSocket::Bind() [member function]
cls.add_method('Bind', 'int', [], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: int ns3::TcpSocket::Close() [member function]
cls.add_method('Close', 'int', [], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: int ns3::TcpSocket::ShutdownSend() [member function]
cls.add_method('ShutdownSend', 'int', [], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: int ns3::TcpSocket::ShutdownRecv() [member function]
cls.add_method('ShutdownRecv', 'int', [], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: int ns3::TcpSocket::Connect(ns3::Address const & address) [member function]
cls.add_method('Connect', 'int', [param('ns3::Address&', 'address', is_const=True)], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: uint32_t ns3::TcpSocket::GetTxAvailable() const [member function]
cls.add_method('GetTxAvailable', 'uint32_t', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## tcp-socket.h: int ns3::TcpSocket::Send(ns3::Ptr<ns3::Packet> p, uint32_t flags) [member function]
cls.add_method('Send', 'int', [param('ns3::Ptr< ns3::Packet >', 'p'), param('uint32_t', 'flags')], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: int ns3::TcpSocket::SendTo(ns3::Ptr<ns3::Packet> p, uint32_t flags, ns3::Address const & toAddress) [member function]
cls.add_method('SendTo', 'int', [param('ns3::Ptr< ns3::Packet >', 'p'), param('uint32_t', 'flags'), param('ns3::Address&', 'toAddress', is_const=True)], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: uint32_t ns3::TcpSocket::GetRxAvailable() const [member function]
cls.add_method('GetRxAvailable', 'uint32_t', [], is_pure_virtual=True, is_const=True, is_virtual=True)
## tcp-socket.h: ns3::Ptr<ns3::Packet> ns3::TcpSocket::Recv(uint32_t maxSize, uint32_t flags) [member function]
cls.add_method('Recv', 'ns3::Ptr< ns3::Packet >', [param('uint32_t', 'maxSize'), param('uint32_t', 'flags')], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: ns3::Ptr<ns3::Packet> ns3::TcpSocket::RecvFrom(uint32_t maxSize, uint32_t flags, ns3::Address & fromAddress) [member function]
cls.add_method('RecvFrom', 'ns3::Ptr< ns3::Packet >', [param('uint32_t', 'maxSize'), param('uint32_t', 'flags'), param('ns3::Address&', 'fromAddress')], is_pure_virtual=True, is_virtual=True)
## tcp-socket.h: void ns3::TcpSocket::SetSndBufSize(uint32_t size) [member function]
cls.add_method('SetSndBufSize', 'void', [param('uint32_t', 'size')], is_pure_virtual=True, visibility='private', is_virtual=True)
## tcp-socket.h: uint32_t ns3::TcpSocket::GetSndBufSize() const [member function]

View File

@@ -658,6 +658,8 @@ def register_Ns3NqapWifiMac_methods(root_module, cls):
cls.add_method('SetSsid', 'void', [param('ns3::Ssid', 'ssid')], is_virtual=True)
## nqap-wifi-mac.h: void ns3::NqapWifiMac::SetBeaconInterval(ns3::Time interval) [member function]
cls.add_method('SetBeaconInterval', 'void', [param('ns3::Time', 'interval')])
## nqap-wifi-mac.h: ns3::Time ns3::NqapWifiMac::GetBeaconInterval() const [member function]
cls.add_method('GetBeaconInterval', 'ns3::Time', [], is_const=True)
## nqap-wifi-mac.h: void ns3::NqapWifiMac::StartBeaconing() [member function]
cls.add_method('StartBeaconing', 'void', [])
## nqap-wifi-mac.h: void ns3::NqapWifiMac::DoDispose() [member function]
@@ -713,6 +715,10 @@ def register_Ns3FriisPropagationLossModel_methods(root_module, cls):
cls.add_method('SetLambda', 'void', [param('double', 'lambda')])
## propagation-loss-model.h: void ns3::FriisPropagationLossModel::SetSystemLoss(double systemLoss) [member function]
cls.add_method('SetSystemLoss', 'void', [param('double', 'systemLoss')])
## propagation-loss-model.h: void ns3::FriisPropagationLossModel::SetMinDistance(double minDistance) [member function]
cls.add_method('SetMinDistance', 'void', [param('double', 'minDistance')])
## propagation-loss-model.h: double ns3::FriisPropagationLossModel::GetMinDistance() const [member function]
cls.add_method('GetMinDistance', 'double', [], is_const=True)
## propagation-loss-model.h: double ns3::FriisPropagationLossModel::GetLambda() const [member function]
cls.add_method('GetLambda', 'double', [], is_const=True)
## propagation-loss-model.h: double ns3::FriisPropagationLossModel::GetSystemLoss() const [member function]

View File

@@ -59,27 +59,25 @@ class TestSimulator(unittest.TestCase):
ns3.Config.SetDefault("ns3::OnOffApplication::PacketSize", ns3.UintegerValue(123))
# hm.. no Config.Get?
if 0:
# not yet: https://bugs.launchpad.net/pybindgen/+bug/246069
def testSocket(self):
node = ns3.Node()
ns3.AddInternetStack(node)
self._received_packet = None
def testSocket(self):
node = ns3.Node()
ns3.AddInternetStack(node)
self._received_packet = None
def rx_callback(socket):
assert self._received_packet is None
self._received_packet = socket.Recv()
def rx_callback(socket):
assert self._received_packet is None
self._received_packet = socket.Recv()
sink = ns3.Socket.CreateSocket(node, ns3.TypeId.LookupByName("ns3::UdpSocketFactory"))
sink.Bind(ns3.InetSocketAddress(ns3.Ipv4Address.GetAny(), 80))
sink.SetRecvCallback(rx_callback)
sink = ns3.Socket.CreateSocket(node, ns3.TypeId.LookupByName("ns3::UdpSocketFactory"))
sink.Bind(ns3.InetSocketAddress(ns3.Ipv4Address.GetAny(), 80))
sink.SetRecvCallback(rx_callback)
source = ns3.Socket.CreateSocket(node, ns3.TypeId.LookupByName("ns3::UdpSocketFactory"))
source.SendTo(ns3.InetSocketAddress(ns3.Ipv4Address.GetAny(), 80), ns3.Packet(19))
source = ns3.Socket.CreateSocket(node, ns3.TypeId.LookupByName("ns3::UdpSocketFactory"))
source.SendTo(ns3.Packet(19), 0, ns3.InetSocketAddress(ns3.Ipv4Address("127.0.0.1"), 80))
ns3.Simulator.Run()
self.assert_(self._received_packet is not None)
self.assertEqual(self._received_packet.GetSize(), 19)
ns3.Simulator.Run()
self.assert_(self._received_packet is not None)
self.assertEqual(self._received_packet.GetSize(), 19)
if __name__ == '__main__':