# HG changeset patch # Parent 09af4a34e9ae03eccbdcba29d9b72abb0ce9c207 # User Tommaso Pecorella # Date 1388932965 -3600 L4Socket BindToNetDevice diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -651,21 +651,34 @@ { NS_LOG_FUNCTION (netdevice); Socket::BindToNetDevice (netdevice); // Includes sanity check - if (m_endPoint == 0 && m_endPoint6 == 0) + if (m_endPoint == 0) { if (Bind () == -1) { - NS_ASSERT ((m_endPoint == 0 && m_endPoint6 == 0)); + NS_ASSERT (m_endPoint == 0); return; } - NS_ASSERT ((m_endPoint != 0 && m_endPoint6 != 0)); + NS_ASSERT (m_endPoint != 0); + } + + if (m_endPoint6 == 0) + { + if (Bind6 () == -1) + { + NS_ASSERT (m_endPoint6 == 0); + return; + } + NS_ASSERT (m_endPoint6 != 0); } if (m_endPoint != 0) { m_endPoint->BindToNetDevice (netdevice); } - // No BindToNetDevice() for Ipv6EndPoint + if (m_endPoint6 != 0) + { + m_endPoint6->BindToNetDevice (netdevice); + } return; } diff --git a/src/internet/model/udp-socket-impl.cc b/src/internet/model/udp-socket-impl.cc --- a/src/internet/model/udp-socket-impl.cc +++ b/src/internet/model/udp-socket-impl.cc @@ -229,6 +229,8 @@ if (InetSocketAddress::IsMatchingType (address)) { + NS_ASSERT_MSG (m_endPoint == 0, "Endpoint already allocated."); + InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); Ipv4Address ipv4 = transport.GetIpv4 (); uint16_t port = transport.GetPort (); @@ -256,6 +258,8 @@ } else if (Inet6SocketAddress::IsMatchingType (address)) { + NS_ASSERT_MSG (m_endPoint == 0, "Endpoint already allocated."); + Inet6SocketAddress transport = Inet6SocketAddress::ConvertFrom (address); Ipv6Address ipv6 = transport.GetIpv6 (); uint16_t port = transport.GetPort (); @@ -894,6 +898,7 @@ UdpSocketImpl::BindToNetDevice (Ptr netdevice) { NS_LOG_FUNCTION (netdevice); + Socket::BindToNetDevice (netdevice); // Includes sanity check if (m_endPoint == 0) { @@ -905,6 +910,17 @@ NS_ASSERT (m_endPoint != 0); } m_endPoint->BindToNetDevice (netdevice); + + if (m_endPoint6 == 0) + { + if (Bind6 () == -1) + { + NS_ASSERT (m_endPoint6 == 0); + return; + } + NS_ASSERT (m_endPoint6 != 0); + } + m_endPoint6->BindToNetDevice (netdevice); return; }