Bug 1163 - Ipv4EndPointDemux::AllocateEphemeralPort forget to increment the port
This commit is contained in:
@@ -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 ();
|
||||
}
|
||||
|
||||
@@ -77,6 +77,8 @@ private:
|
||||
uint16_t AllocateEphemeralPort (void);
|
||||
|
||||
uint16_t m_ephemeral;
|
||||
uint16_t m_portLast;
|
||||
uint16_t m_portFirst;
|
||||
EndPoints m_endPoints;
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user