mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-29 15:58:47 +00:00
TCP: Start working on auto-closing connections when we get FIN.
This commit is contained in:
parent
4629272135
commit
25e521f510
Notes:
sideshowbarker
2024-07-19 15:03:22 +09:00
Author: https://github.com/awesomekling
Commit: 25e521f510
6 changed files with 35 additions and 6 deletions
|
@ -287,7 +287,7 @@ void handle_tcp(const EthernetFrameHeader& eth, int frame_size)
|
|||
ASSERT(socket->source_port() == tcp_packet.destination_port());
|
||||
|
||||
if (tcp_packet.ack_number() != socket->sequence_number()) {
|
||||
kprintf("handle_tcp: ack/seq mismatch: got %u, wanted %u\n",tcp_packet.ack_number(), socket->sequence_number());
|
||||
kprintf("handle_tcp: ack/seq mismatch: got %u, wanted %u\n", tcp_packet.ack_number(), socket->sequence_number());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -300,6 +300,14 @@ void handle_tcp(const EthernetFrameHeader& eth, int frame_size)
|
|||
return;
|
||||
}
|
||||
|
||||
if (tcp_packet.has_fin()) {
|
||||
kprintf("handle_tcp: Got FIN, payload_size=%u\n", 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);
|
||||
return;
|
||||
}
|
||||
|
||||
socket->set_ack_number(tcp_packet.sequence_number() + payload_size);
|
||||
kprintf("Got packet with ack_no=%u, seq_no=%u, payload_size=%u, acking it with new ack_no=%u, seq_no=%u\n",
|
||||
tcp_packet.ack_number(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue