API for SocketOptions class
This commit is contained in:
@@ -489,7 +489,7 @@ TcpSocket::SetSndBuf (uint32_t size)
|
||||
|
||||
// XXX Raj to finish
|
||||
uint32_t
|
||||
TcpSocket::GetSndBuf (void)
|
||||
TcpSocket::GetSndBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -502,7 +502,7 @@ TcpSocket::SetRcvBuf (uint32_t size)
|
||||
|
||||
// XXX Raj to finish
|
||||
uint32_t
|
||||
TcpSocket::GetRcvBuf (void)
|
||||
TcpSocket::GetRcvBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -74,10 +74,11 @@ public:
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
|
||||
virtual uint32_t GetRxAvailable (void) const;
|
||||
|
||||
protected:
|
||||
virtual void SetSndBuf (uint32_t size);
|
||||
virtual uint32_t GetSndBuf (void);
|
||||
virtual uint32_t GetSndBuf (void) const;
|
||||
virtual void SetRcvBuf (uint32_t size);
|
||||
virtual uint32_t GetRcvBuf (void);
|
||||
virtual uint32_t GetRcvBuf (void) const;
|
||||
|
||||
private:
|
||||
friend class Tcp;
|
||||
|
||||
@@ -338,7 +338,7 @@ uint32_t
|
||||
UdpSocket::GetTxAvailable (void) const
|
||||
{
|
||||
// No finite send buffer is modelled
|
||||
return 0xffffffff;
|
||||
return std::numeric_limits<uint32_t>::max ();
|
||||
}
|
||||
|
||||
int
|
||||
@@ -416,27 +416,24 @@ UdpSocket::SetSndBuf (uint32_t size)
|
||||
// return EINVAL since we are not modelling a finite send buffer
|
||||
// Enforcing buffer size should be added if we ever start to model
|
||||
// non-zero processing delay in the UDP/IP stack
|
||||
m_errno = ERROR_INVAL;
|
||||
NS_LOG_WARN ("UdpSocket has infinite send buffer");
|
||||
}
|
||||
|
||||
uint32_t
|
||||
UdpSocket::GetSndBuf (void)
|
||||
UdpSocket::GetSndBuf (void) const
|
||||
{
|
||||
m_errno = ERROR_NOTERROR;
|
||||
return 0xffffffff;
|
||||
return std::numeric_limits<uint32_t>::max ();
|
||||
}
|
||||
|
||||
void
|
||||
UdpSocket::SetRcvBuf (uint32_t size)
|
||||
{
|
||||
m_errno = ERROR_NOTERROR;
|
||||
m_udp_rmem = size;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
UdpSocket::GetRcvBuf (void)
|
||||
UdpSocket::GetRcvBuf (void) const
|
||||
{
|
||||
m_errno = ERROR_NOTERROR;
|
||||
return m_udp_rmem;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,10 +63,11 @@ public:
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
|
||||
virtual uint32_t GetRxAvailable (void) const;
|
||||
|
||||
protected:
|
||||
virtual void SetSndBuf (uint32_t size);
|
||||
virtual uint32_t GetSndBuf (void);
|
||||
virtual uint32_t GetSndBuf (void) const;
|
||||
virtual void SetRcvBuf (uint32_t size);
|
||||
virtual uint32_t GetRcvBuf (void);
|
||||
virtual uint32_t GetRcvBuf (void) const;
|
||||
|
||||
private:
|
||||
friend class Udp;
|
||||
|
||||
@@ -349,19 +349,21 @@ void
|
||||
PacketSocket::SetSndBuf (uint32_t size)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t
|
||||
PacketSocket::GetSndBuf (void)
|
||||
PacketSocket::GetSndBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
void
|
||||
PacketSocket::SetRcvBuf (uint32_t size)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t
|
||||
PacketSocket::GetRcvBuf (void)
|
||||
PacketSocket::GetRcvBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -93,10 +93,11 @@ public:
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
|
||||
virtual uint32_t GetRxAvailable (void) const;
|
||||
|
||||
protected:
|
||||
virtual void SetSndBuf (uint32_t size);
|
||||
virtual uint32_t GetSndBuf (void);
|
||||
virtual uint32_t GetSndBuf (void) const;
|
||||
virtual void SetRcvBuf (uint32_t size);
|
||||
virtual uint32_t GetRcvBuf (void);
|
||||
virtual uint32_t GetRcvBuf (void) const;
|
||||
|
||||
private:
|
||||
void ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet,
|
||||
|
||||
@@ -28,6 +28,56 @@ NS_LOG_COMPONENT_DEFINE ("Socket");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
TypeId
|
||||
SocketOptions::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::SocketOptions")
|
||||
.SetParent<Object> ()
|
||||
.AddConstructor<SocketOptions> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
SocketOptions::SocketOptions (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
SocketOptions::~SocketOptions (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SocketOptions::SetSndBuf (uint32_t size)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SocketOptions::GetSndBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SocketOptions::SetRcvBuf (uint32_t size)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SocketOptions::GetRcvBuf (void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Socket::Socket (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<SocketOptions> s = CreateObject<SocketOptions> ();
|
||||
AggregateObject (s);
|
||||
}
|
||||
|
||||
Socket::~Socket ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
@@ -36,6 +36,36 @@ namespace ns3 {
|
||||
class Node;
|
||||
class Packet;
|
||||
|
||||
/**
|
||||
* \brief Support for socket options at the socket level.
|
||||
*
|
||||
* A SocketOptions object is aggregated to each Socket. This object
|
||||
* can be fetched using GetObject() by any user of a Socket. An
|
||||
* instance of SocketOptions is aggregated to each Socket when the
|
||||
* Socket is constructed.
|
||||
*
|
||||
* This implements the equivalent of getsockopt() and setsockopt()
|
||||
* function calls to manipulate the options associated with the
|
||||
* socket at the uppermost ``socket'' level. Socket options that
|
||||
* exist at a lower level (such as TCP socket options) are manipulated
|
||||
* using a different aggregated class (TcpSocketOptions).
|
||||
*/
|
||||
class SocketOptions : public Object
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
SocketOptions (void);
|
||||
virtual ~SocketOptions (void);
|
||||
|
||||
virtual void SetSndBuf (uint32_t size);
|
||||
virtual uint32_t GetSndBuf (void) const;
|
||||
virtual void SetRcvBuf (uint32_t size);
|
||||
virtual uint32_t GetRcvBuf (void) const;
|
||||
|
||||
// all others
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Define a Socket API based on the BSD Socket API.
|
||||
*
|
||||
@@ -48,8 +78,10 @@ class Packet;
|
||||
*/
|
||||
class Socket : public Object
|
||||
{
|
||||
friend class SocketOptions;
|
||||
public:
|
||||
virtual ~Socket();
|
||||
Socket (void);
|
||||
virtual ~Socket (void);
|
||||
|
||||
enum SocketErrno {
|
||||
ERROR_NOTERROR,
|
||||
@@ -286,35 +318,6 @@ public:
|
||||
*/
|
||||
virtual uint32_t GetRxAvailable (void) const = 0;
|
||||
|
||||
/**
|
||||
* \brief ns-3 version of setsockopt (SO_SNDBUF)
|
||||
*
|
||||
* The error code value can be checked by calling GetErrno ()
|
||||
*/
|
||||
virtual void SetSndBuf (uint32_t size) = 0;
|
||||
/**
|
||||
* \brief ns-3 version of getsockopt (SO_SNDBUF)
|
||||
*
|
||||
* The error code value can be checked by calling GetErrno ()
|
||||
*
|
||||
* \returns The size in bytes of the send buffer
|
||||
*/
|
||||
virtual uint32_t GetSndBuf (void) = 0;
|
||||
/**
|
||||
* \brief ns-3 version of setsockopt (SO_RCVBUF)
|
||||
*
|
||||
* The error code value can be checked by calling GetErrno ()
|
||||
*/
|
||||
virtual void SetRcvBuf (uint32_t size) = 0;
|
||||
/**
|
||||
* \brief ns-3 version of getsockopt (SO_RCVBUF)
|
||||
*
|
||||
* The error code value can be checked by calling GetErrno ()
|
||||
*
|
||||
* \returns The size in bytes of the receive buffer
|
||||
*/
|
||||
virtual uint32_t GetRcvBuf (void) = 0;
|
||||
|
||||
protected:
|
||||
void NotifyCloseCompleted (void);
|
||||
void NotifyConnectionSucceeded (void);
|
||||
@@ -337,6 +340,12 @@ protected:
|
||||
Callback<void, Ptr<Socket>, uint32_t> m_dataSent;
|
||||
Callback<void, Ptr<Socket>, uint32_t > m_sendCb;
|
||||
Callback<void, Ptr<Socket> > m_receivedData;
|
||||
|
||||
// Socket options at level socket
|
||||
virtual void SetSndBuf (uint32_t size) = 0;
|
||||
virtual uint32_t GetSndBuf (void) const = 0;
|
||||
virtual void SetRcvBuf (uint32_t size) = 0;
|
||||
virtual uint32_t GetRcvBuf (void) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user