|
|
| 450 |
// Bug number 426 claims we should send reset in this case. |
450 |
// Bug number 426 claims we should send reset in this case. |
| 451 |
if (m_rxBuffer.Size () != 0) |
451 |
if (m_rxBuffer.Size () != 0) |
| 452 |
{ |
452 |
{ |
|
|
453 |
NS_LOG_INFO ("Socket " << this << " << unread rx data during close. Sending reset"); |
| 453 |
SendRST (); |
454 |
SendRST (); |
| 454 |
return 0; |
455 |
return 0; |
| 455 |
} |
456 |
} |
|
|
457 |
|
| 456 |
if (m_txBuffer.SizeFromSequence (m_nextTxSequence) > 0) |
458 |
if (m_txBuffer.SizeFromSequence (m_nextTxSequence) > 0) |
| 457 |
{ // App close with pending data must wait until all data transmitted |
459 |
{ // App close with pending data must wait until all data transmitted |
| 458 |
if (m_closeOnEmpty == false) |
460 |
if (m_closeOnEmpty == false) |
|
|
| 470 |
TcpSocketBase::ShutdownSend (void) |
472 |
TcpSocketBase::ShutdownSend (void) |
| 471 |
{ |
473 |
{ |
| 472 |
NS_LOG_FUNCTION (this); |
474 |
NS_LOG_FUNCTION (this); |
|
|
475 |
|
| 476 |
//this prevents data from being added to the buffer |
| 473 |
m_shutdownSend = true; |
477 |
m_shutdownSend = true; |
|
|
478 |
|
| 479 |
m_closeOnEmpty = true; |
| 480 |
//if buffer is already empty, send a fin now |
| 481 |
//otherwise fin will go when buffer empties. |
| 482 |
if (m_txBuffer.Size () == 0) |
| 483 |
{ |
| 484 |
NS_LOG_INFO("Emtpy tx buffer, send fin"); |
| 485 |
SendEmptyPacket (TcpHeader::FIN); |
| 486 |
if (m_state == ESTABLISHED) |
| 487 |
{ // On active close: I am the first one to send FIN |
| 488 |
NS_LOG_INFO ("ESTABLISHED -> FIN_WAIT_1"); |
| 489 |
m_state = FIN_WAIT_1; |
| 490 |
} |
| 491 |
else if (m_state == CLOSE_WAIT) |
| 492 |
{ // On passive close: Peer sent me FIN already |
| 493 |
NS_LOG_INFO ("CLOSE_WAIT -> LAST_ACK"); |
| 494 |
m_state = LAST_ACK; |
| 495 |
} |
| 496 |
} |
| 497 |
|
| 474 |
return 0; |
498 |
return 0; |
| 475 |
} |
499 |
} |
| 476 |
|
500 |
|
|
|
| 498 |
m_errno = ERROR_MSGSIZE; |
522 |
m_errno = ERROR_MSGSIZE; |
| 499 |
return -1; |
523 |
return -1; |
| 500 |
} |
524 |
} |
|
|
525 |
if (m_shutdownSend) |
| 526 |
{ |
| 527 |
m_errno = ERROR_SHUTDOWN; |
| 528 |
return -1; |
| 529 |
} |
| 501 |
// Submit the data to lower layers |
530 |
// Submit the data to lower layers |
| 502 |
NS_LOG_LOGIC ("txBufSize=" << m_txBuffer.Size () << " state " << TcpStateName[m_state]); |
531 |
NS_LOG_LOGIC ("txBufSize=" << m_txBuffer.Size () << " state " << TcpStateName[m_state]); |
| 503 |
if (m_state == ESTABLISHED || m_state == CLOSE_WAIT) |
532 |
if (m_state == ESTABLISHED || m_state == CLOSE_WAIT) |
|
|
| 1922 |
" highestRxAck " << m_txBuffer.HeadSequence () << |
1951 |
" highestRxAck " << m_txBuffer.HeadSequence () << |
| 1923 |
" pd->Size " << m_txBuffer.Size () << |
1952 |
" pd->Size " << m_txBuffer.Size () << |
| 1924 |
" pd->SFS " << m_txBuffer.SizeFromSequence (m_nextTxSequence)); |
1953 |
" pd->SFS " << m_txBuffer.SizeFromSequence (m_nextTxSequence)); |
| 1925 |
// Quit if send disallowed |
|
|
| 1926 |
if (m_shutdownSend) |
| 1927 |
{ |
| 1928 |
m_errno = ERROR_SHUTDOWN; |
| 1929 |
return false; |
| 1930 |
} |
| 1931 |
// Stop sending if we need to wait for a larger Tx window (prevent silly window syndrome) |
1954 |
// Stop sending if we need to wait for a larger Tx window (prevent silly window syndrome) |
| 1932 |
if (w < m_segmentSize && m_txBuffer.SizeFromSequence (m_nextTxSequence) > w) |
1955 |
if (w < m_segmentSize && m_txBuffer.SizeFromSequence (m_nextTxSequence) > w) |
| 1933 |
{ |
1956 |
{ |