Improve code readability in TCP module.

This commit is contained in:
Adrian S Tam
2011-12-11 23:57:15 -05:00
parent 24eee8459b
commit be7f2d54bc
2 changed files with 6 additions and 21 deletions

View File

@@ -102,7 +102,7 @@ TcpRxBuffer::IncNextRxSequence ()
m_nextRxSeq++;
}
// Return the highest sequence number that this TcpRxBuffer can accept
// Return the lowest sequence number that this TcpRxBuffer cannot accept
SequenceNumber32
TcpRxBuffer::MaxRxSequence (void) const
{

View File

@@ -258,38 +258,23 @@ TcpSocketBase::Bind (const Address &address)
if (ipv4 == Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_tcp->Allocate ();
if (0 == m_endPoint)
{
m_errno = ERROR_ADDRNOTAVAIL;
return -1;
}
}
else if (ipv4 == Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (port);
if (0 == m_endPoint)
{
m_errno = ERROR_ADDRINUSE;
return -1;
}
}
else if (ipv4 != Ipv4Address::GetAny () && port == 0)
{
m_endPoint = m_tcp->Allocate (ipv4);
if (0 == m_endPoint)
{
m_errno = ERROR_ADDRNOTAVAIL;
return -1;
}
}
else if (ipv4 != Ipv4Address::GetAny () && port != 0)
{
m_endPoint = m_tcp->Allocate (ipv4, port);
if (0 == m_endPoint)
{
m_errno = ERROR_ADDRINUSE;
return -1;
}
}
if (0 == m_endPoint)
{
m_errno = port ? ERROR_ADDRINUSE : ERROR_ADDRNOTAVAIL;
return -1;
}
m_tcp->m_sockets.push_back (this);
NS_LOG_LOGIC ("TcpSocketBase " << this << " got an endpoint: " << m_endPoint);