mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 19:45:07 +00:00
TCP: Collect the payload if present in a packet with FIN set.
This commit is contained in:
parent
25e521f510
commit
f9569db1e5
3 changed files with 9 additions and 1 deletions
|
@ -222,9 +222,11 @@ ssize_t IPv4Socket::recvfrom(void* buffer, size_t buffer_length, int flags, sock
|
|||
void IPv4Socket::did_receive(ByteBuffer&& packet)
|
||||
{
|
||||
LOCKER(lock());
|
||||
auto packet_size = packet.size();
|
||||
m_receive_queue.append(move(packet));
|
||||
m_can_read = true;
|
||||
m_bytes_received += packet_size;
|
||||
#ifdef IPV4_SOCKET_DEBUG
|
||||
kprintf("IPv4Socket(%p): did_receive %d bytes, packets in queue: %d\n", this, packet.size(), m_receive_queue.size_slow());
|
||||
kprintf("IPv4Socket(%p): did_receive %d bytes, total_received=%u, packets in queue: %d\n", this, packet_size, m_bytes_received, m_receive_queue.size_slow());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ private:
|
|||
word m_source_port { 0 };
|
||||
word m_destination_port { 0 };
|
||||
|
||||
dword m_bytes_received { 0 };
|
||||
|
||||
bool m_can_read { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -302,6 +302,10 @@ void handle_tcp(const EthernetFrameHeader& eth, int frame_size)
|
|||
|
||||
if (tcp_packet.has_fin()) {
|
||||
kprintf("handle_tcp: Got FIN, payload_size=%u\n", payload_size);
|
||||
|
||||
if (payload_size != 0)
|
||||
socket->did_receive(ByteBuffer::copy((const byte*)&ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size()));
|
||||
|
||||
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
|
||||
socket->send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
|
||||
socket->set_state(TCPSocket::State::Disconnecting);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue