equal
deleted
inserted
replaced
301 } |
301 } |
302 int |
302 int |
303 TcpSocketImpl::ShutdownRecv (void) |
303 TcpSocketImpl::ShutdownRecv (void) |
304 { |
304 { |
305 NS_LOG_FUNCTION_NOARGS (); |
305 NS_LOG_FUNCTION_NOARGS (); |
306 m_shutdownRecv = false; |
306 m_shutdownRecv = true; |
307 return 0; |
307 return 0; |
308 } |
308 } |
309 |
309 |
310 int |
310 int |
311 TcpSocketImpl::Close (void) |
311 TcpSocketImpl::Close (void) |
561 = i->second->CreateFragment(avail,i->second->GetSize()-avail); |
561 = i->second->CreateFragment(avail,i->second->GetSize()-avail); |
562 m_rxAvailable += i->second->GetSize()-avail; |
562 m_rxAvailable += i->second->GetSize()-avail; |
563 m_rxBufSize += i->second->GetSize()-avail; |
563 m_rxBufSize += i->second->GetSize()-avail; |
564 } |
564 } |
565 } |
565 } |
|
566 SocketAddressTag tag; |
|
567 tag.SetAddress (InetSocketAddress (m_remoteAddress, m_remotePort)); |
|
568 outPacket->AddPacketTag (tag); |
566 return outPacket; |
569 return outPacket; |
567 } |
570 } |
568 |
571 |
569 uint32_t |
572 uint32_t |
570 TcpSocketImpl::GetRxAvailable (void) const |
573 TcpSocketImpl::GetRxAvailable (void) const |
575 return m_rxAvailable; |
578 return m_rxAvailable; |
576 } |
579 } |
577 |
580 |
578 Ptr<Packet> |
581 Ptr<Packet> |
579 TcpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, |
582 TcpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, |
580 Address &fromAddress) |
583 Address &fromAddress) |
581 { |
584 { |
582 NS_LOG_FUNCTION (this << maxSize << flags); |
585 NS_LOG_FUNCTION (this << maxSize << flags); |
583 Ptr<Packet> packet = Recv (maxSize, flags); |
586 Ptr<Packet> packet = Recv (maxSize, flags); |
584 //Null packet means no data to read, and an empty packet indicates EOF |
587 //Null packet means no data to read, and an empty packet indicates EOF |
585 if (packet != 0 && packet->GetSize() != 0) |
588 if (packet != 0 && packet->GetSize() != 0) |
586 { |
589 { |
587 SocketAddressTag tag; |
590 SocketAddressTag tag; |
588 bool found; |
591 bool found; |
589 found = packet->FindFirstMatchingByteTag (tag); |
592 found = packet->PeekPacketTag (tag); |
590 NS_ASSERT (found); |
593 NS_ASSERT (found); |
591 fromAddress = tag.GetAddress (); |
594 fromAddress = tag.GetAddress (); |
592 } |
595 } |
593 return packet; |
596 return packet; |
594 } |
597 } |
1194 } |
1197 } |
1195 } |
1198 } |
1196 p = p->CreateFragment (0,s); |
1199 p = p->CreateFragment (0,s); |
1197 m_nextRxSequence += s; // Advance next expected sequence |
1200 m_nextRxSequence += s; // Advance next expected sequence |
1198 NS_LOG_LOGIC("Case 1, advanced nrxs to " << m_nextRxSequence ); |
1201 NS_LOG_LOGIC("Case 1, advanced nrxs to " << m_nextRxSequence ); |
1199 SocketAddressTag tag; |
|
1200 tag.SetAddress (fromAddress); |
|
1201 p->AddByteTag (tag); |
|
1202 //buffer this, it'll be read by call to Recv |
1202 //buffer this, it'll be read by call to Recv |
1203 UnAckData_t::iterator i = |
1203 UnAckData_t::iterator i = |
1204 m_bufferedData.find (tcpHeader.GetSequenceNumber () ); |
1204 m_bufferedData.find (tcpHeader.GetSequenceNumber () ); |
1205 NS_ASSERT(i == m_bufferedData.end ()); //no way it should have been found |
1205 NS_ASSERT(i == m_bufferedData.end ()); //no way it should have been found |
1206 // Save for later delivery if there is room |
1206 // Save for later delivery if there is room |
1264 { |
1264 { |
1265 p = i->second; |
1265 p = i->second; |
1266 } |
1266 } |
1267 } |
1267 } |
1268 // Save for later delivery |
1268 // Save for later delivery |
1269 SocketAddressTag tag; |
|
1270 tag.SetAddress (fromAddress); |
|
1271 p->AddByteTag (tag); |
|
1272 m_bufferedData[startSeq] = p; |
1269 m_bufferedData[startSeq] = p; |
1273 i = m_bufferedData.find (startSeq); |
1270 i = m_bufferedData.find (startSeq); |
1274 next = i; |
1271 next = i; |
1275 ++next; |
1272 ++next; |
1276 if(next != m_bufferedData.end()) |
1273 if(next != m_bufferedData.end()) |
1293 } |
1290 } |
1294 } |
1291 } |
1295 p = p->CreateFragment (m_nextRxSequence - tcpHeader.GetSequenceNumber (),s); |
1292 p = p->CreateFragment (m_nextRxSequence - tcpHeader.GetSequenceNumber (),s); |
1296 SequenceNumber start = m_nextRxSequence; |
1293 SequenceNumber start = m_nextRxSequence; |
1297 m_nextRxSequence += s; // Advance next expected sequence |
1294 m_nextRxSequence += s; // Advance next expected sequence |
1298 SocketAddressTag tag; |
|
1299 tag.SetAddress (fromAddress); |
|
1300 p->AddByteTag (tag); |
|
1301 //buffer the new fragment, it'll be read by call to Recv |
1295 //buffer the new fragment, it'll be read by call to Recv |
1302 UnAckData_t::iterator i = m_bufferedData.find (start); |
1296 UnAckData_t::iterator i = m_bufferedData.find (start); |
1303 if (i != m_bufferedData.end () ) //we found it already in the buffer |
1297 if (i != m_bufferedData.end () ) //we found it already in the buffer |
1304 { |
1298 { |
1305 i->second = 0; // relase reference to already buffered |
1299 i->second = 0; // relase reference to already buffered |