summaryrefslogtreecommitdiff
path: root/scalls/recvfrom.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2023-10-27 00:48:21 +0200
committerAnton Kling <anton@kling.gg>2023-10-30 21:49:48 +0100
commit5026f823fa2708404302aa59d03401635a435c0b (patch)
tree03d8db6da25416fa27b9744ae60df2cfa5fc1d2b /scalls/recvfrom.c
parentf8e15da04472f5ed6a26e588de4a23cb3e1ba20b (diff)
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.
Diffstat (limited to 'scalls/recvfrom.c')
-rw-r--r--scalls/recvfrom.c15
1 files changed, 15 insertions, 0 deletions
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 <fs/vfs.h>
+#include <poll.h>
+#include <scalls/recvfrom.h>
+
+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);
+}