View | Details | Raw Unified | Return to bug 902
Collapse All | Expand All

(-)a/src/internet-stack/tcp-socket-impl.cc (-9 / +23 lines)
 Lines 82-87    Link Here 
82
    m_highestRxAck (0),
82
    m_highestRxAck (0),
83
    m_lastRxAck (0),
83
    m_lastRxAck (0),
84
    m_nextRxSequence (0),
84
    m_nextRxSequence (0),
85
    m_finSequence (0),
85
    m_rxAvailable (0),
86
    m_rxAvailable (0),
86
    m_rxBufSize (0),
87
    m_rxBufSize (0),
87
    m_pendingData (0),
88
    m_pendingData (0),
 Lines 119-124    Link Here 
119
    m_highestRxAck (sock.m_highestRxAck),
120
    m_highestRxAck (sock.m_highestRxAck),
120
    m_lastRxAck (sock.m_lastRxAck),
121
    m_lastRxAck (sock.m_lastRxAck),
121
    m_nextRxSequence (sock.m_nextRxSequence),
122
    m_nextRxSequence (sock.m_nextRxSequence),
123
    m_finSequence (sock.m_finSequence),
122
    m_rxAvailable (0),
124
    m_rxAvailable (0),
123
    m_rxBufSize (0),
125
    m_rxBufSize (0),
124
    m_pendingData (0),
126
    m_pendingData (0),
 Lines 345-350    Link Here 
345
                   " deferring close, state " << m_state);
347
                   " deferring close, state " << m_state);
346
      return 0;
348
      return 0;
347
    }
349
    }
350
  m_finSequence = m_nextTxSequence + SequenceNumber (1);
348
  Actions_t action  = ProcessEvent (APP_CLOSE);
351
  Actions_t action  = ProcessEvent (APP_CLOSE);
349
  ProcessAction (action);
352
  ProcessAction (action);
350
  return 0;
353
  return 0;
 Lines 943-948    Link Here 
943
      if(tcpHeader.GetFlags() & TcpHeader::FIN)
946
      if(tcpHeader.GetFlags() & TcpHeader::FIN)
944
      {
947
      {
945
        ++m_nextRxSequence; //bump this to account for the FIN
948
        ++m_nextRxSequence; //bump this to account for the FIN
949
        m_nextTxSequence = m_finSequence;
946
      }
950
      }
947
      SendEmptyPacket (TcpHeader::ACK);
951
      SendEmptyPacket (TcpHeader::ACK);
948
      break;
952
      break;
 Lines 1037-1055    Link Here 
1037
      // out of sequence.  If so, note pending close and process
1041
      // out of sequence.  If so, note pending close and process
1038
      // new sequence rx
1042
      // new sequence rx
1039
      if (tcpHeader.GetSequenceNumber () != m_nextRxSequence)
1043
      if (tcpHeader.GetSequenceNumber () != m_nextRxSequence)
1040
        { // process close later
1044
        {
1041
          m_pendingClose = true;
1045
          if (m_finSequence != m_nextRxSequence)
1042
          NS_LOG_LOGIC ("TcpSocketImpl " << this << " setting pendingClose" 
1046
            {
1043
            << " rxseq " << tcpHeader.GetSequenceNumber () 
1047
              // process close later
1044
            << " nextRxSeq " << m_nextRxSequence);
1048
              m_finSequence = tcpHeader.GetSequenceNumber () + SequenceNumber (p->GetSize ());
1045
          NewRx (p, tcpHeader, fromAddress, toAddress);
1049
              m_pendingClose = true;
1046
          return true;
1050
              NS_LOG_LOGIC ("TcpSocketImpl " << this << " setting pendingClose" 
1051
                << " rxseq " << tcpHeader.GetSequenceNumber () 
1052
                << " nextRxSeq " << m_nextRxSequence);
1053
              NewRx (p, tcpHeader, fromAddress, toAddress);
1054
              return true;
1055
            }
1047
        }
1056
        }
1048
      // Now we need to see if any data came with the FIN
1057
      // Now we need to see if any data came with the FIN
1049
      // if so, call NewRx
1058
      // if so, call NewRx, unless NewRx was already called
1050
      if (p->GetSize () != 0)
1059
      if (p->GetSize () != 0)
1051
        {
1060
        {
1052
          NewRx (p, tcpHeader, fromAddress, toAddress);
1061
          if (m_finSequence != m_nextRxSequence)
1062
            {
1063
              NewRx (p, tcpHeader, fromAddress, toAddress);
1064
            }
1053
        }
1065
        }
1054
      ++m_nextRxSequence; //bump this to account for the FIN
1066
      ++m_nextRxSequence; //bump this to account for the FIN
1055
      States_t saveState = m_state; // Used to see if app responds
1067
      States_t saveState = m_state; // Used to see if app responds
 Lines 1159-1164    Link Here 
1159
          m_nextTxSequence + SequenceNumber (sz));
1171
          m_nextTxSequence + SequenceNumber (sz));
1160
      if (m_closeOnEmpty && (remainingData == 0))
1172
      if (m_closeOnEmpty && (remainingData == 0))
1161
        {
1173
        {
1174
          m_finSequence = m_nextTxSequence + SequenceNumber (1 + sz);
1162
          flags = TcpHeader::FIN;
1175
          flags = TcpHeader::FIN;
1163
          m_state = FIN_WAIT_1;
1176
          m_state = FIN_WAIT_1;
1164
        }
1177
        }
 Lines 1322-1327    Link Here 
1322
          if (m_bufferedData.empty())
1335
          if (m_bufferedData.empty())
1323
            {
1336
            {
1324
              ProcessPacketAction (PEER_CLOSE, p, tcpHeader, fromAddress, toAddress);
1337
              ProcessPacketAction (PEER_CLOSE, p, tcpHeader, fromAddress, toAddress);
1338
              return;
1325
            }
1339
            }
1326
        }
1340
        }
1327
    }
1341
    }
(-)a/src/internet-stack/tcp-socket-impl.h (+3 lines)
 Lines 202-207    Link Here 
202
  //sequence info, receiver side
202
  //sequence info, receiver side
203
  SequenceNumber m_nextRxSequence; //next expected sequence
203
  SequenceNumber m_nextRxSequence; //next expected sequence
204
204
205
  //sequence number where fin was sent or received
206
  SequenceNumber m_finSequence;
207
205
  //Rx buffer
208
  //Rx buffer
206
  UnAckData_t m_bufferedData; //buffer which sorts out of sequence data
209
  UnAckData_t m_bufferedData; //buffer which sorts out of sequence data
207
  //Rx buffer state
210
  //Rx buffer state
208
211

Return to bug 902