--- a/CHANGES.html Wed Dec 15 10:24:31 2010 +0100
+++ b/CHANGES.html Thu Dec 16 20:17:50 2010 -0500
@@ -82,6 +82,11 @@
in Mbps (6, 9, 12, 18, 24, 36, 48, 54), are available for 802.11g.
More details are in the RELEASE_NOTES for details. </p> </li>
+<li><b>Socket::GetSocketType ()</b>
+<p>This is analogous to getsockopt(SO_TYPE). ipv4-raw-socket, ipv6-raw-socket,
+ and packet-socket return SOCK_RAW. tcp-socket and nsc-tcp-socket return
+ SOCK_STREAM. udp-socket returns SOCK_DGRAM.</p></li>
+
</ul>
<h2>Changes to existing API:</h2>
--- a/src/internet-stack/ipv4-raw-socket-impl.cc Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/ipv4-raw-socket-impl.cc Thu Dec 16 20:17:50 2010 -0500
@@ -80,6 +80,13 @@
NS_LOG_FUNCTION (this);
return m_err;
}
+
+enum Socket::SocketType
+Ipv4RawSocketImpl::GetSocketType (void) const
+{
+ return SOCK_RAW;
+}
+
Ptr<Node>
Ipv4RawSocketImpl::GetNode (void) const
{
--- a/src/internet-stack/ipv4-raw-socket-impl.h Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/ipv4-raw-socket-impl.h Thu Dec 16 20:17:50 2010 -0500
@@ -23,6 +23,7 @@
void SetNode (Ptr<Node> node);
virtual enum Socket::SocketErrno GetErrno (void) const;
+ virtual enum Socket::SocketType GetSocketType (void) const;
virtual Ptr<Node> GetNode (void) const;
virtual int Bind (const Address &address);
virtual int Bind ();
--- a/src/internet-stack/ipv6-raw-socket-impl.cc Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/ipv6-raw-socket-impl.cc Thu Dec 16 20:17:50 2010 -0500
@@ -97,6 +97,11 @@
return m_err;
}
+enum Socket::SocketType Ipv6RawSocketImpl::GetSocketType () const
+{
+ return SOCK_RAW;
+}
+
int Ipv6RawSocketImpl::Bind (const Address& address)
{
NS_LOG_FUNCTION (this << address);
--- a/src/internet-stack/ipv6-raw-socket-impl.h Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/ipv6-raw-socket-impl.h Thu Dec 16 20:17:50 2010 -0500
@@ -69,6 +69,12 @@
virtual enum Socket::SocketErrno GetErrno () const;
/**
+ * \brief Get socket type (SOCK_RAW)
+ * \return socket type
+ */
+ virtual enum Socket::SocketType GetSocketType () const;
+
+ /**
* \brief Get node.
* \return node associated with this raw socket.
*/
--- a/src/internet-stack/nsc-tcp-socket-impl.cc Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/nsc-tcp-socket-impl.cc Thu Dec 16 20:17:50 2010 -0500
@@ -171,6 +171,12 @@
return m_errno;
}
+enum Socket::SocketType
+NscTcpSocketImpl::GetSocketType (void) const
+{
+ return SOCK_STREAM;
+}
+
Ptr<Node>
NscTcpSocketImpl::GetNode (void) const
{
--- a/src/internet-stack/nsc-tcp-socket-impl.h Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/nsc-tcp-socket-impl.h Thu Dec 16 20:17:50 2010 -0500
@@ -66,6 +66,7 @@
void SetTcp (Ptr<NscTcpL4Protocol> tcp);
virtual enum SocketErrno GetErrno (void) const;
+ virtual enum SocketType GetSocketType (void) const;
virtual Ptr<Node> GetNode (void) const;
virtual int Bind (void);
virtual int Bind (const Address &address);
--- a/src/internet-stack/tcp-socket-impl.cc Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/tcp-socket-impl.cc Thu Dec 16 20:17:50 2010 -0500
@@ -230,6 +230,12 @@
return m_errno;
}
+enum Socket::SocketType
+TcpSocketImpl::GetSocketType (void) const
+{
+ return SOCK_STREAM;
+}
+
Ptr<Node>
TcpSocketImpl::GetNode (void) const
{
--- a/src/internet-stack/tcp-socket-impl.h Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/tcp-socket-impl.h Thu Dec 16 20:17:50 2010 -0500
@@ -81,6 +81,7 @@
void SetRtt (Ptr<RttEstimator> rtt);
virtual enum SocketErrno GetErrno (void) const;
+ virtual enum SocketType GetSocketType (void) const;
virtual Ptr<Node> GetNode (void) const;
virtual int Bind (void);
virtual int Bind (const Address &address);
--- a/src/internet-stack/udp-socket-impl.cc Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/udp-socket-impl.cc Thu Dec 16 20:17:50 2010 -0500
@@ -116,6 +116,12 @@
return m_errno;
}
+enum Socket::SocketType
+UdpSocketImpl::GetSocketType (void) const
+{
+ return SOCK_DGRAM;
+}
+
Ptr<Node>
UdpSocketImpl::GetNode (void) const
{
--- a/src/internet-stack/udp-socket-impl.h Wed Dec 15 10:24:31 2010 +0100
+++ b/src/internet-stack/udp-socket-impl.h Thu Dec 16 20:17:50 2010 -0500
@@ -60,6 +60,7 @@
void SetUdp (Ptr<UdpL4Protocol> udp);
virtual enum SocketErrno GetErrno (void) const;
+ virtual enum SocketType GetSocketType (void) const;
virtual Ptr<Node> GetNode (void) const;
virtual int Bind (void);
virtual int Bind (const Address &address);
--- a/src/node/packet-socket.cc Wed Dec 15 10:24:31 2010 +0100
+++ b/src/node/packet-socket.cc Thu Dec 16 20:17:50 2010 -0500
@@ -89,6 +89,12 @@
return m_errno;
}
+enum Socket::SocketType
+PacketSocket::GetSocketType (void) const
+{
+ return SOCK_RAW;
+}
+
Ptr<Node>
PacketSocket::GetNode (void) const
{
--- a/src/node/packet-socket.h Wed Dec 15 10:24:31 2010 +0100
+++ b/src/node/packet-socket.h Thu Dec 16 20:17:50 2010 -0500
@@ -86,6 +86,7 @@
void SetNode (Ptr<Node> node);
virtual enum SocketErrno GetErrno (void) const;
+ virtual enum SocketType GetSocketType (void) const;
virtual Ptr<Node> GetNode (void) const;
virtual int Bind (void);
virtual int Bind (const Address & address);
--- a/src/node/socket.h Wed Dec 15 10:24:31 2010 +0100
+++ b/src/node/socket.h Thu Dec 16 20:17:50 2010 -0500
@@ -85,6 +85,13 @@
SOCKET_ERRNO_LAST
};
+ enum SocketType {
+ SOCK_STREAM,
+ SOCK_SEQPACKET,
+ SOCK_DGRAM,
+ SOCK_RAW
+ };
+
/**
* This method wraps the creation of sockets that is performed
* by a socket factory on a given node based on a TypeId.
@@ -102,6 +109,10 @@
*/
virtual enum Socket::SocketErrno GetErrno (void) const = 0;
/**
+ * \return the socket type, analogous to getsockopt (SO_TYPE)
+ */
+ virtual enum Socket::SocketType GetSocketType (void) const = 0;
+ /**
* \returns the node this socket is associated with.
*/
virtual Ptr<Node> GetNode (void) const = 0;