Thanks to previous commits, now TcpSocketBases uses only public methods on TcpL4Protocol and the friend relation could be removed.
authorNatale Patriciello <natale.patriciello@gmail.com>
Wed, 08 Jul 2015 06:50:00 -0700
changeset 11500 366c7284d4a8
parent 11499 e5def623f9e8
child 11501 37a230604f8e
Thanks to previous commits, now TcpSocketBases uses only public methods on TcpL4Protocol and the friend relation could be removed.
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<Ptr<TcpSocketBase> >::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<Ptr<TcpSocketBase> >::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<void> ());
       m_tcp->DeAllocate (m_endPoint);
       m_endPoint = 0;
-      std::vector<Ptr<TcpSocketBase> >::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<void> ());
       m_tcp->DeAllocate (m_endPoint6);
       m_endPoint6 = 0;
-      std::vector<Ptr<TcpSocketBase> >::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");