633 m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this))); |
633 m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this))); |
634 } |
634 } |
635 if (m_endPoint6 != 0) |
635 if (m_endPoint6 != 0) |
636 { |
636 { |
637 m_endPoint6->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp6, Ptr<TcpSocketBase> (this))); |
637 m_endPoint6->SetRxCallback (MakeCallback (&TcpSocketBase::ForwardUp6, Ptr<TcpSocketBase> (this))); |
638 m_endPoint6->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy, Ptr<TcpSocketBase> (this))); |
638 m_endPoint6->SetDestroyCallback (MakeCallback (&TcpSocketBase::Destroy6, Ptr<TcpSocketBase> (this))); |
639 } |
639 } |
640 |
640 |
641 return 0; |
641 return 0; |
642 } |
642 } |
643 |
643 |
1420 SetupCallback(), invoked when the endpoint is destroyed. */ |
1420 SetupCallback(), invoked when the endpoint is destroyed. */ |
1421 void |
1421 void |
1422 TcpSocketBase::Destroy (void) |
1422 TcpSocketBase::Destroy (void) |
1423 { |
1423 { |
1424 NS_LOG_FUNCTION (this); |
1424 NS_LOG_FUNCTION (this); |
1425 m_node = 0; |
|
1426 m_endPoint = 0; |
1425 m_endPoint = 0; |
1427 m_endPoint6 = 0; |
|
1428 if (m_tcp != 0) |
1426 if (m_tcp != 0) |
1429 { |
1427 { |
1430 std::vector<Ptr<TcpSocketBase> >::iterator it |
1428 std::vector<Ptr<TcpSocketBase> >::iterator it |
1431 = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this); |
1429 = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this); |
1432 if (it != m_tcp->m_sockets.end ()) |
1430 if (it != m_tcp->m_sockets.end ()) |
1433 { |
1431 { |
1434 m_tcp->m_sockets.erase (it); |
1432 m_tcp->m_sockets.erase (it); |
1435 } |
1433 } |
1436 m_tcp = 0; |
1434 } |
|
1435 NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " << |
|
1436 (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ()); |
|
1437 CancelAllTimers (); |
|
1438 } |
|
1439 |
|
1440 /** Kill this socket. This is a callback function configured to m_endpoint in |
|
1441 SetupCallback(), invoked when the endpoint is destroyed. */ |
|
1442 void |
|
1443 TcpSocketBase::Destroy6 (void) |
|
1444 { |
|
1445 NS_LOG_FUNCTION (this); |
|
1446 m_endPoint6 = 0; |
|
1447 if (m_tcp != 0) |
|
1448 { |
|
1449 std::vector<Ptr<TcpSocketBase> >::iterator it |
|
1450 = std::find (m_tcp->m_sockets.begin (), m_tcp->m_sockets.end (), this); |
|
1451 if (it != m_tcp->m_sockets.end ()) |
|
1452 { |
|
1453 m_tcp->m_sockets.erase (it); |
|
1454 } |
1437 } |
1455 } |
1438 NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " << |
1456 NS_LOG_LOGIC (this << " Cancelled ReTxTimeout event which was set to expire at " << |
1439 (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ()); |
1457 (Simulator::Now () + Simulator::GetDelayLeft (m_retxEvent)).GetSeconds ()); |
1440 CancelAllTimers (); |
1458 CancelAllTimers (); |
1441 } |
1459 } |