Liu's GetSockName patch

This commit is contained in:
Craig Dowell
2008-10-23 15:59:48 -07:00
parent 922d5a4de9
commit b4947df5d0
9 changed files with 68 additions and 0 deletions

View File

@@ -64,6 +64,8 @@ NscTcpSocketImpl::GetTypeId ()
: m_endPoint (0),
m_node (0),
m_tcp (0),
m_localAddress (Ipv4Address::GetZero ()),
m_localPort (0),
m_peerAddress ("0.0.0.0", 0),
m_errno (ERROR_NOTERROR),
m_shutdownSend (false),
@@ -466,6 +468,14 @@ NscTcpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags,
return packet;
}
int
NscTcpSocketImpl::GetSockName (Address &address) const
{
NS_LOG_FUNCTION_NOARGS ();
address = InetSocketAddress(m_localAddress, m_localPort);
return 0;
}
uint32_t
NscTcpSocketImpl::GetRxAvailable (void) const
{

View File

@@ -81,6 +81,7 @@ public:
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
Address &fromAddress);
virtual int GetSockName (Address &address) const;
private:
void NSCWakeup(void);

View File

@@ -62,6 +62,8 @@ TcpSocketImpl::GetTypeId ()
m_endPoint (0),
m_node (0),
m_tcp (0),
m_localAddress (Ipv4Address::GetZero ()),
m_localPort (0),
m_errno (ERROR_NOTERROR),
m_shutdownSend (false),
m_shutdownRecv (false),
@@ -553,6 +555,14 @@ TcpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags,
return packet;
}
int
TcpSocketImpl::GetSockName (Address &address) const
{
NS_LOG_FUNCTION_NOARGS ();
address = InetSocketAddress(m_localAddress, m_localPort);
return 0;
}
void
TcpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Address ipv4, uint16_t port)
{

View File

@@ -94,6 +94,7 @@ public:
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
Address &fromAddress);
virtual int GetSockName (Address &address) const;
private:
friend class Tcp;

View File

@@ -437,6 +437,21 @@ UdpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags,
return packet;
}
int
UdpSocketImpl::GetSockName (Address &address) const
{
NS_LOG_FUNCTION_NOARGS ();
if (m_endPoint != 0)
{
address = InetSocketAddress (m_endPoint->GetLocalAddress (), m_endPoint->GetLocalPort());
}
else
{
address = InetSocketAddress(Ipv4Address::GetZero(), 0);
}
return 0;
}
void
UdpSocketImpl::ForwardUp (Ptr<Packet> packet, Ipv4Address ipv4, uint16_t port)
{

View File

@@ -73,6 +73,7 @@ public:
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
Address &fromAddress);
virtual int GetSockName (Address &address) const;
private:
// Attributes set through UdpSocket base class