equal
deleted
inserted
replaced
338 } |
338 } |
339 InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
339 InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); |
340 m_remoteAddress = transport.GetIpv4 (); |
340 m_remoteAddress = transport.GetIpv4 (); |
341 m_remotePort = transport.GetPort (); |
341 m_remotePort = transport.GetPort (); |
342 |
342 |
343 uint32_t localIfIndex; |
343 uint32_t localInterface; |
344 Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
344 Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
345 |
345 |
346 if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) |
346 if (ipv4->GetInterfaceForDestination (m_remoteAddress, localInterface)) |
347 { |
347 { |
348 m_endPoint->SetLocalAddress (ipv4->GetAddress (localIfIndex)); |
348 m_endPoint->SetLocalAddress (ipv4->GetAddress (localInterface)); |
349 } |
349 } |
350 else |
350 else |
351 { |
351 { |
352 m_errno = ERROR_NOROUTETOHOST; |
352 m_errno = ERROR_NOROUTETOHOST; |
353 return -1; |
353 return -1; |
792 bool TcpSocketImpl::ProcessPacketAction (Actions_t a, Ptr<Packet> p, |
792 bool TcpSocketImpl::ProcessPacketAction (Actions_t a, Ptr<Packet> p, |
793 const TcpHeader& tcpHeader, |
793 const TcpHeader& tcpHeader, |
794 const Address& fromAddress) |
794 const Address& fromAddress) |
795 { |
795 { |
796 NS_LOG_FUNCTION (this << a << p << fromAddress); |
796 NS_LOG_FUNCTION (this << a << p << fromAddress); |
797 uint32_t localIfIndex; |
797 uint32_t localInterface; |
798 Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
798 Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
799 switch (a) |
799 switch (a) |
800 { |
800 { |
801 case ACK_TX: |
801 case ACK_TX: |
802 if(tcpHeader.GetFlags() & TcpHeader::FIN) |
802 if(tcpHeader.GetFlags() & TcpHeader::FIN) |
807 break; |
807 break; |
808 case SYN_ACK_TX: |
808 case SYN_ACK_TX: |
809 NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_ACK_TX"); |
809 NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_ACK_TX"); |
810 // m_remotePort = InetSocketAddress::ConvertFrom (fromAddress).GetPort (); |
810 // m_remotePort = InetSocketAddress::ConvertFrom (fromAddress).GetPort (); |
811 // m_remoteAddress = InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (); |
811 // m_remoteAddress = InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (); |
812 // if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) |
812 // if (ipv4->GetInterfaceForDestination (m_remoteAddress, localInterface)) |
813 // { |
813 // { |
814 // m_localAddress = ipv4->GetAddress (localIfIndex); |
814 // m_localAddress = ipv4->GetAddress (localInterface); |
815 // } |
815 // } |
816 if (m_state == LISTEN) //this means we should fork a new TcpSocketImpl |
816 if (m_state == LISTEN) //this means we should fork a new TcpSocketImpl |
817 { |
817 { |
818 NS_LOG_DEBUG("In SYN_ACK_TX, m_state is LISTEN, this " << this); |
818 NS_LOG_DEBUG("In SYN_ACK_TX, m_state is LISTEN, this " << this); |
819 //notify the server that we got a SYN |
819 //notify the server that we got a SYN |
828 return true; |
828 return true; |
829 } |
829 } |
830 // This is the cloned endpoint |
830 // This is the cloned endpoint |
831 NS_ASSERT (m_state == SYN_RCVD); |
831 NS_ASSERT (m_state == SYN_RCVD); |
832 m_endPoint->SetPeer (m_remoteAddress, m_remotePort); |
832 m_endPoint->SetPeer (m_remoteAddress, m_remotePort); |
833 if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) |
833 if (ipv4->GetInterfaceForDestination (m_remoteAddress, localInterface)) |
834 { |
834 { |
835 m_localAddress = ipv4->GetAddress (localIfIndex); |
835 m_localAddress = ipv4->GetAddress (localInterface); |
836 m_endPoint->SetLocalAddress (m_localAddress); |
836 m_endPoint->SetLocalAddress (m_localAddress); |
837 // Leave local addr in the portmap to any, as the path from |
837 // Leave local addr in the portmap to any, as the path from |
838 // remote can change and packets can arrive on different interfaces |
838 // remote can change and packets can arrive on different interfaces |
839 //m_endPoint->SetLocalAddress (Ipv4Address::GetAny()); |
839 //m_endPoint->SetLocalAddress (Ipv4Address::GetAny()); |
840 } |
840 } |