# HG changeset patch # User Natale Patriciello # Date 1436363400 25200 # Node ID 366c7284d4a880d7cc910ffe12210438157a3f9d # Parent e5def623f9e8c04dc01333044e4efd22af2f7686 Thanks to previous commits, now TcpSocketBases uses only public methods on TcpL4Protocol and the friend relation could be removed. diff -r e5def623f9e8 -r 366c7284d4a8 src/internet/model/tcp-socket-base.cc --- a/src/internet/model/tcp-socket-base.cc Wed Jul 08 06:48:40 2015 -0700 +++ b/src/internet/model/tcp-socket-base.cc Wed Jul 08 06:50:00 2015 -0700 @@ -331,10 +331,8 @@ return -1; } - if (std::find(m_tcp->m_sockets.begin(), m_tcp->m_sockets.end(), this) == m_tcp->m_sockets.end()) - { - m_tcp->m_sockets.push_back (this); - } + m_tcp->AddSocket(this); + return SetupCallback (); } @@ -349,10 +347,8 @@ return -1; } - if (std::find(m_tcp->m_sockets.begin(), m_tcp->m_sockets.end(), this) == m_tcp->m_sockets.end()) - { - m_tcp->m_sockets.push_back (this); - } + m_tcp->AddSocket(this); + return SetupCallback (); } @@ -421,10 +417,8 @@ return -1; } - if (std::find(m_tcp->m_sockets.begin(), m_tcp->m_sockets.end(), this) == m_tcp->m_sockets.end()) - { - m_tcp->m_sockets.push_back (this); - } + m_tcp->AddSocket(this); + NS_LOG_LOGIC ("TcpSocketBase " << this << " got an endpoint: " << m_endPoint); return SetupCallback (); @@ -1626,12 +1620,7 @@ m_endPoint = 0; if (m_tcp != 0) { - std::vector >::iterator it - = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this); - if (it != m_tcp->m_sockets.end ()) - { - m_tcp->m_sockets.erase (it); - } + m_tcp->RemoveSocket(this); } NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " << (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ()); @@ -1647,12 +1636,7 @@ m_endPoint6 = 0; if (m_tcp != 0) { - std::vector >::iterator it - = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this); - if (it != m_tcp->m_sockets.end ()) - { - m_tcp->m_sockets.erase (it); - } + m_tcp->RemoveSocket(this); } NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " << (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ()); @@ -1798,12 +1782,7 @@ m_endPoint->SetDestroyCallback (MakeNullCallback ()); m_tcp->DeAllocate (m_endPoint); m_endPoint = 0; - std::vector >::iterator it - = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this); - if (it != m_tcp->m_sockets.end ()) - { - m_tcp->m_sockets.erase (it); - } + m_tcp->RemoveSocket(this); } else if (m_endPoint6 != 0) { @@ -1811,12 +1790,7 @@ m_endPoint6->SetDestroyCallback (MakeNullCallback ()); m_tcp->DeAllocate (m_endPoint6); m_endPoint6 = 0; - std::vector >::iterator it - = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this); - if (it != m_tcp->m_sockets.end ()) - { - m_tcp->m_sockets.erase (it); - } + m_tcp->RemoveSocket(this); } } @@ -1905,7 +1879,7 @@ Inet6SocketAddress::ConvertFrom (fromAddress).GetPort ()); m_endPoint = 0; } - m_tcp->m_sockets.push_back (this); + m_tcp->AddSocket(this); // Change the cloned socket from LISTEN state to SYN_RCVD NS_LOG_INFO ("LISTEN -> SYN_RCVD");