Bug 1163 - Ipv4EndPointDemux::AllocateEphemeralPort forget to increment the port

This commit is contained in:
John Abraham
2011-08-17 12:23:54 -04:00
parent 2c0e7f05ef
commit 8cc5db3c07
3 changed files with 18 additions and 1 deletions

View File

@@ -27,7 +27,7 @@ namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("Ipv4EndPointDemux");
Ipv4EndPointDemux::Ipv4EndPointDemux ()
: m_ephemeral (49152)
: m_ephemeral (49152), m_portLast (65535), m_portFirst (49152)
{
NS_LOG_FUNCTION_NOARGS ();
}

View File

@@ -77,6 +77,8 @@ private:
uint16_t AllocateEphemeralPort (void);
uint16_t m_ephemeral;
uint16_t m_portLast;
uint16_t m_portFirst;
EndPoints m_endPoints;
};

View File

@@ -219,6 +219,11 @@ TcpSocketBase::Bind (void)
{
NS_LOG_FUNCTION_NOARGS ();
m_endPoint = m_tcp->Allocate ();
if (0 == m_endPoint)
{
m_errno = ERROR_ADDRNOTAVAIL;
return -1;
}
return SetupCallback ();
}
@@ -238,6 +243,11 @@ 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)
{
@@ -251,6 +261,11 @@ TcpSocketBase::Bind (const Address &address)
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)
{