diff --git a/src/internet/model/nsc-tcp-l4-protocol.cc b/src/internet/model/nsc-tcp-l4-protocol.cc index 345d66f9d..005b885bb 100644 --- a/src/internet/model/nsc-tcp-l4-protocol.cc +++ b/src/internet/model/nsc-tcp-l4-protocol.cc @@ -309,25 +309,27 @@ NscTcpL4Protocol::Allocate (Ipv4Address address) } Ipv4EndPoint * -NscTcpL4Protocol::Allocate (uint16_t port) +NscTcpL4Protocol::Allocate (Ptr boundNetDevice, uint16_t port) { - NS_LOG_FUNCTION (this << port); - return m_endPoints->Allocate (port); + NS_LOG_FUNCTION (this << boundNetDevice << port); + return m_endPoints->Allocate (boundNetDevice, port); } Ipv4EndPoint * -NscTcpL4Protocol::Allocate (Ipv4Address address, uint16_t port) +NscTcpL4Protocol::Allocate (Ptr boundNetDevice, Ipv4Address address, uint16_t port) { - NS_LOG_FUNCTION (this << address << port); - return m_endPoints->Allocate (address, port); + NS_LOG_FUNCTION (this << boundNetDevice << address << port); + return m_endPoints->Allocate (boundNetDevice, address, port); } Ipv4EndPoint * -NscTcpL4Protocol::Allocate (Ipv4Address localAddress, uint16_t localPort, +NscTcpL4Protocol::Allocate (Ptr boundNetDevice, + Ipv4Address localAddress, uint16_t localPort, Ipv4Address peerAddress, uint16_t peerPort) { - NS_LOG_FUNCTION (this << localAddress << localPort << peerAddress << peerPort); - return m_endPoints->Allocate (localAddress, localPort, + NS_LOG_FUNCTION (this << boundNetDevice << localAddress << localPort << peerAddress << peerPort); + return m_endPoints->Allocate (boundNetDevice, + localAddress, localPort, peerAddress, peerPort); } diff --git a/src/internet/model/nsc-tcp-l4-protocol.h b/src/internet/model/nsc-tcp-l4-protocol.h index a33ac45ba..5e073812f 100644 --- a/src/internet/model/nsc-tcp-l4-protocol.h +++ b/src/internet/model/nsc-tcp-l4-protocol.h @@ -37,6 +37,7 @@ class Ipv4Interface; class NscTcpSocketImpl; class Ipv4EndPoint; class NscInterfaceImpl; +class NetDevice; /** * \ingroup nsctcp @@ -99,26 +100,30 @@ public: Ipv4EndPoint *Allocate (Ipv4Address address); /** * \brief Allocate an IPv4 Endpoint + * \param boundNetDevice Bound NetDevice (if any) * \param port port to use * \return the Endpoint */ - Ipv4EndPoint *Allocate (uint16_t port); + Ipv4EndPoint *Allocate (Ptr boundNetDevice, uint16_t port); /** * \brief Allocate an IPv4 Endpoint + * \param boundNetDevice Bound NetDevice (if any) * \param address address to use * \param port port to use * \return the Endpoint */ - Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port); + Ipv4EndPoint *Allocate (Ptr boundNetDevice, Ipv4Address address, uint16_t port); /** * \brief Allocate an IPv4 Endpoint + * \param boundNetDevice Bound NetDevice (if any) * \param localAddress local address to use * \param localPort local port to use * \param peerAddress remote address to use * \param peerPort remote port to use * \return the Endpoint */ - Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort, + Ipv4EndPoint *Allocate (Ptr boundNetDevice, + Ipv4Address localAddress, uint16_t localPort, Ipv4Address peerAddress, uint16_t peerPort); diff --git a/src/internet/model/nsc-tcp-socket-impl.cc b/src/internet/model/nsc-tcp-socket-impl.cc index 3438c3199..208fdeacc 100644 --- a/src/internet/model/nsc-tcp-socket-impl.cc +++ b/src/internet/model/nsc-tcp-socket-impl.cc @@ -250,7 +250,7 @@ NscTcpSocketImpl::Bind (const Address &address) } else if (ipv4 == Ipv4Address::GetAny () && port != 0) { - m_endPoint = m_tcp->Allocate (port); + m_endPoint = m_tcp->Allocate (GetBoundNetDevice (), port); NS_LOG_LOGIC ("NscTcpSocketImpl "<Allocate (ipv4, port); + m_endPoint = m_tcp->Allocate (GetBoundNetDevice (), ipv4, port); NS_LOG_LOGIC ("NscTcpSocketImpl "< netdevice) +{ + NS_LOG_FUNCTION (this << netdevice); + Socket::BindToNetDevice (netdevice); // Includes sanity check + if (m_endPoint != 0) + { + m_endPoint->BindToNetDevice (netdevice); + } + return; +} + int NscTcpSocketImpl::ShutdownSend (void) { diff --git a/src/internet/model/nsc-tcp-socket-impl.h b/src/internet/model/nsc-tcp-socket-impl.h index 8d8fcc2a2..bfc1dbd71 100644 --- a/src/internet/model/nsc-tcp-socket-impl.h +++ b/src/internet/model/nsc-tcp-socket-impl.h @@ -105,6 +105,7 @@ public: virtual int GetSockName (Address &address) const; virtual bool SetAllowBroadcast (bool allowBroadcast); virtual bool GetAllowBroadcast () const; + virtual void BindToNetDevice (Ptr netdevice); // NetDevice with my m_endPoint private: /**