1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

Kernel: Send ACK/FIN in response to FIN packets on active connections

This is to work around our lack of a shutdown() implementation.
This commit is contained in:
Conrad Pankoff 2019-09-08 17:42:19 +10:00 committed by Andreas Kling
parent 117d8db2a2
commit 328d52b323

View file

@ -527,8 +527,12 @@ void handle_tcp(const IPv4Packet& ipv4_packet)
socket->did_receive(ipv4_packet.source(), tcp_packet.source_port(), KBuffer::copy(&ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size()));
socket->set_ack_number(tcp_packet.sequence_number() + payload_size + 1);
socket->send_tcp_packet(TCPFlags::ACK);
socket->set_state(TCPSocket::State::CloseWait);
// TODO: We should only send a FIN packet out once we're shutting
// down our side of the socket, so we should change this back to
// just being an ACK and a transition to CloseWait once we have a
// shutdown() implementation.
socket->send_tcp_packet(TCPFlags::FIN | TCPFlags::ACK);
socket->set_state(TCPSocket::State::Closing);
socket->set_connected(false);
return;
}