API for SocketOptions class

This commit is contained in:
Tom Henderson committed 2008-05-10 21:27:32 -07:00
1 parent ddda864b77
commit 0f55fefaba
8 files changed
+111 -50

No files matched your search

+6 -4
View File
@@ -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
+3 -2
View File
@@ -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,
+50
View File
@@ -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 ();
+39 -30
View File
@@ -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;
};
/**