summaryrefslogtreecommitdiff
path: root/kernel/network/tcp.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-04-28 21:39:53 +0200
committerAnton Kling <anton@kling.gg>2024-04-28 21:40:39 +0200
commit507062d51b3e018fdfac838e7982ffe62ff423c5 (patch)
tree9ed18a03fd2c35329525872f2aabe2455a7a6236 /kernel/network/tcp.c
parent7695cb9ca77a32aae75cf0d2bcea9769cd938615 (diff)
Kernel: Use ringbuffer for handling incoming socket data
Diffstat (limited to 'kernel/network/tcp.c')
-rw-r--r--kernel/network/tcp.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/kernel/network/tcp.c b/kernel/network/tcp.c
index 997b699..8740a63 100644
--- a/kernel/network/tcp.c
+++ b/kernel/network/tcp.c
@@ -186,7 +186,6 @@ void handle_tcp(ipv4_t src_ip, const u8 *payload, u32 payload_length) {
}
struct TcpConnection *incoming_connection = tcp_find_connection(dst_port);
- kprintf("dst_port: %d\n", dst_port);
if (!incoming_connection) {
kprintf("unable to find open port for incoming connection\n");
}
@@ -214,10 +213,9 @@ void handle_tcp(ipv4_t src_ip, const u8 *payload, u32 payload_length) {
}
u16 tcp_payload_length = payload_length - header->data_offset * sizeof(u32);
if (tcp_payload_length > 0) {
- int len = fifo_object_write(
- (u8 *)(payload + header->data_offset * sizeof(u32)), 0,
- tcp_payload_length, incoming_connection->data_file);
- assert(len >= 0);
+ const u8 *tcp_payload = payload + header->data_offset * sizeof(u32);
+ u32 len = ringbuffer_write(&incoming_connection->buffer, tcp_payload,
+ tcp_payload_length);
assert(len == tcp_payload_length);
incoming_connection->ack += len;
tcp_send_ack(incoming_connection);