Plumb in socket receive pull model, in parallel to existing Receive framework

This commit is contained in:
Tom Henderson committed 2008-04-24 08:18:01 -07:00
1 parent 776f7dc5ac
commit 1c73dd0dd8
10 files changed
+89 -2

No files matched your search

+8
View File
@@ -305,4 +305,12 @@ PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet,
NotifyDataReceived (packet, address);
}
Ptr<Packet>
PacketSocket::Recv (uint32_t maxSize, uint32_t flags)
{
Ptr<Packet> p = m_deliveryQueue.front ();
m_deliveryQueue.pop ();
return p;
}
}//namespace ns3
+5
View File
@@ -22,6 +22,7 @@
#define PACKET_SOCKET_H
#include <stdint.h>
#include <queue>
#include "ns3/callback.h"
#include "ns3/ptr.h"
#include "ns3/socket.h"
@@ -87,6 +88,8 @@ public:
virtual int Send (Ptr<Packet> p);
virtual int SendTo(const Address &address,Ptr<Packet> p);
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
private:
void ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet,
@@ -109,6 +112,8 @@ private:
bool m_isSingleDevice;
uint32_t m_device;
Address m_destAddr; /// Default destination address
std::queue<Ptr<Packet> > m_deliveryQueue;
};
}//namespace ns3
+16
View File
@@ -86,6 +86,13 @@ Socket::SetRecvCallback (Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&>
m_receivedData = receivedData;
}
void
Socket::SetRecv_Callback (Callback<void, Ptr<Socket> > receivedData)
{
NS_LOG_FUNCTION_NOARGS ();
m_receivedData_ = receivedData;
}
int Socket::Listen (uint32_t queueLimit)
{
return 0; //XXX the base class version does nothing
@@ -230,4 +237,13 @@ Socket::NotifyDataReceived (Ptr<Packet> p, const Address &from)
}
}
void
Socket::NotifyDataRecv (void)
{
NS_LOG_FUNCTION_NOARGS ();
if (!m_receivedData_.IsNull ())
{
m_receivedData_ (this);
}
}
}//namespace ns3
+10 -1
View File
@@ -157,7 +157,12 @@ public:
*/
void SetRecvCallback (Callback<void, Ptr<Socket>, Ptr<Packet>,
const Address&> receivedData);
/**
* \brief Receive data
* \param receivedData Invoked whenever new data is received.
*
*/
void SetRecv_Callback (Callback<void, Ptr<Socket> >);
/**
* \param address the address to try to allocate
* \returns 0 on success, -1 on failure.
@@ -252,6 +257,8 @@ public:
*/
int SendTo (const Address &address, const uint8_t* buf, uint32_t size);
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
protected:
void NotifyCloseCompleted (void);
void NotifyConnectionSucceeded (void);
@@ -263,6 +270,7 @@ protected:
void NotifyDataSent (uint32_t size);
void NotifySend (uint32_t spaceAvailable);
void NotifyDataReceived (Ptr<Packet> p, const Address &from);
void NotifyDataRecv (void);
Callback<void,Ptr<Socket> > m_closeCompleted;
Callback<void, Ptr<Socket> > m_connectionSucceeded;
@@ -274,6 +282,7 @@ protected:
Callback<void, Ptr<Socket>, uint32_t> m_dataSent;
Callback<void, Ptr<Socket>, uint32_t > m_sendCb;
Callback<void, Ptr<Socket>, Ptr<Packet>,const Address&> m_receivedData;
Callback<void, Ptr<Socket> > m_receivedData_;
};
} //namespace ns3