Instead of directly manage the m_socketList member from TcpSocketBase, interact with it through public methods of TcpL4Protocol.
authorNatale Patriciello <natale.patriciello@gmail.com>
Wed, 08 Jul 2015 06:48:40 -0700
changeset 11499 e5def623f9e8
parent 11498 97a672449c14
child 11500 366c7284d4a8
Instead of directly manage the m_socketList member from TcpSocketBase, interact with it through public methods of TcpL4Protocol.
src/internet/model/tcp-l4-protocol.cc
src/internet/model/tcp-l4-protocol.h
--- a/src/internet/model/tcp-l4-protocol.cc	Wed Jul 08 06:46:54 2015 -0700
+++ b/src/internet/model/tcp-l4-protocol.cc	Wed Jul 08 06:48:40 2015 -0700
@@ -611,6 +611,43 @@
 }
 
 void
+TcpL4Protocol::AddSocket(Ptr<TcpSocketBase> socket)
+{
+  std::vector<Ptr<TcpSocketBase> >::iterator it = m_sockets.begin ();
+
+  while (it != m_sockets.end())
+    {
+      if (*it == socket)
+        {
+          return;
+        }
+
+      ++it;
+    }
+
+   m_sockets.push_back (socket);
+}
+
+bool
+TcpL4Protocol::RemoveSocket(Ptr<TcpSocketBase> socket)
+{
+  std::vector<Ptr<TcpSocketBase> >::iterator it = m_sockets.begin ();
+
+  while (it != m_sockets.end())
+    {
+      if (*it == socket)
+        {
+          m_sockets.erase(it);
+          return true;
+        }
+
+      ++it;
+    }
+
+  return false;
+}
+
+void
 TcpL4Protocol::SetDownTarget (IpL4Protocol::DownTargetCallback callback)
 {
   m_downTarget = callback;
--- a/src/internet/model/tcp-l4-protocol.h	Wed Jul 08 06:46:54 2015 -0700
+++ b/src/internet/model/tcp-l4-protocol.h	Wed Jul 08 06:48:40 2015 -0700
@@ -182,6 +182,23 @@
                    Ipv6Address saddr, Ipv6Address daddr, Ptr<NetDevice> oif = 0);
 
   /**
+   * \brief Make a socket capable to being demultiplexed
+   *
+   * Called after a socket has been bound, it is inserted in an internal vector.
+   *
+   * \param socket Socket to be added
+   */
+  void AddSocket (Ptr<TcpSocketBase> socket);
+
+  /**
+   * \brief Remove a socket from the internal list
+   *
+   * \param socket socket to Remove
+   * \return true if the socket has been removed
+   */
+  bool RemoveSocket(Ptr<TcpSocketBase> socket);
+
+  /**
    * \brief Remove an IPv4 Endpoint.
    * \param endPoint the end point to remove
    */