From 92f2ed110aebb00d076253e225e692286c8fc238 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 4 Jun 2008 09:19:16 -0700 Subject: [PATCH] bug 203: Listen must be implemented for Udp and Packet sockets. --- src/internet-node/udp-socket-impl.cc | 7 +++++++ src/internet-node/udp-socket-impl.h | 1 + src/node/packet-socket.cc | 6 ++++++ src/node/packet-socket.h | 3 +++ src/node/socket.cc | 6 ------ src/node/socket.h | 4 ++-- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/internet-node/udp-socket-impl.cc b/src/internet-node/udp-socket-impl.cc index 378ff10f6..03b0da18f 100644 --- a/src/internet-node/udp-socket-impl.cc +++ b/src/internet-node/udp-socket-impl.cc @@ -216,6 +216,13 @@ UdpSocketImpl::Connect(const Address & address) return 0; } +int +UdpSocketImpl::Listen (uint32_t queueLimit) +{ + m_errno = Socket::ERROR_OPNOTSUPP; + return -1; +} + int UdpSocketImpl::Send (Ptr p) { diff --git a/src/internet-node/udp-socket-impl.h b/src/internet-node/udp-socket-impl.h index 42047a5d0..f7b185215 100644 --- a/src/internet-node/udp-socket-impl.h +++ b/src/internet-node/udp-socket-impl.h @@ -57,6 +57,7 @@ public: virtual int ShutdownSend (void); virtual int ShutdownRecv (void); virtual int Connect(const Address &address); + virtual int Listen (uint32_t queueLimit); virtual int Send (Ptr p); virtual int SendTo (Ptr p, const Address &address); virtual uint32_t GetTxAvailable (void) const; diff --git a/src/node/packet-socket.cc b/src/node/packet-socket.cc index 58949a331..c4b60bb69 100644 --- a/src/node/packet-socket.cc +++ b/src/node/packet-socket.cc @@ -220,6 +220,12 @@ PacketSocket::Connect(const Address &ad) NotifyConnectionFailed (); return -1; } +int +PacketSocket::Listen(uint32_t queueLimit) +{ + m_errno = Socket::ERROR_OPNOTSUPP; + return -1; +} int PacketSocket::Send (Ptr p) diff --git a/src/node/packet-socket.h b/src/node/packet-socket.h index 31f8cd3fc..dfd0dcc09 100644 --- a/src/node/packet-socket.h +++ b/src/node/packet-socket.h @@ -71,6 +71,8 @@ class PacketSocketAddress; * The fields "physical address", device, and protocol are filled. * * - Accept: not allowed + * + * - Listen: returns -1 (OPNOTSUPP) */ class PacketSocket : public Socket { @@ -90,6 +92,7 @@ public: virtual int ShutdownSend (void); virtual int ShutdownRecv (void); virtual int Connect(const Address &address); + virtual int Listen(uint32_t queueLimit); virtual int Send (Ptr p); virtual uint32_t GetTxAvailable (void) const; diff --git a/src/node/socket.cc b/src/node/socket.cc index 4f427c9f9..5b5c79f02 100644 --- a/src/node/socket.cc +++ b/src/node/socket.cc @@ -103,12 +103,6 @@ Socket::SetRecvCallback (Callback > receivedData) m_receivedData = receivedData; } -int Socket::Listen (uint32_t queueLimit) -{ - return 0; //XXX the base class version does nothing -} - - int Socket::Send (const uint8_t* buf, uint32_t size) { NS_LOG_FUNCTION_NOARGS (); diff --git a/src/node/socket.h b/src/node/socket.h index 0db7c0568..325698a3f 100644 --- a/src/node/socket.h +++ b/src/node/socket.h @@ -231,9 +231,9 @@ public: /** * \brief Listen for incoming connections. * \param queueLimit maximum number of incoming request to queue - * \returns XXX an error code + * \returns 0 on success, -1 on error (in which case errno is set). */ - virtual int Listen (uint32_t queueLimit); + virtual int Listen (uint32_t queueLimit) = 0; /** * \brief Send data (or dummy data) to the remote host