From 5026f823fa2708404302aa59d03401635a435c0b Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Fri, 27 Oct 2023 00:48:21 +0200 Subject: Kernel/Networking/LibC: Add syscalls and libc functions for UDP This allows a UDP server to be created in userland and read data. Currently it can't send data and is very very simplistic. Code is horrible and probably needs some fixing until it can be further built upon. --- scalls/recvfrom.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scalls/recvfrom.c (limited to 'scalls/recvfrom.c') diff --git a/scalls/recvfrom.c b/scalls/recvfrom.c new file mode 100644 index 0000000..0e37153 --- /dev/null +++ b/scalls/recvfrom.c @@ -0,0 +1,15 @@ +#include +#include +#include + +size_t syscall_recvfrom(int socket, void *buffer, size_t length, int flags, + struct sockaddr *address, socklen_t *address_len) { + if (flags & MSG_WAITALL) { + struct pollfd fds[1]; + fds[0].fd = socket; + fds[0].events = POLLIN; + poll(fds, 1, 0); + } + kprintf("got event\n"); + return vfs_pread(socket, buffer, length, 0); +} -- cgit v1.2.3