--- a/src/node/socket.h Sat May 10 20:22:27 2008 -0700
+++ b/src/node/socket.h Sat May 10 21:27:32 2008 -0700
@@ -37,6 +37,36 @@
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.
*
* Contrary to the original BSD socket API, this API is asynchronous:
@@ -48,8 +78,10 @@
*/
class Socket : public Object
{
+ friend class SocketOptions;
public:
- virtual ~Socket();
+ Socket (void);
+ virtual ~Socket (void);
enum SocketErrno {
ERROR_NOTERROR,
@@ -286,35 +318,6 @@
*/
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 @@
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;
};
/**