diff options
author | Anton Kling <anton@kling.gg> | 2023-10-27 00:48:21 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-10-30 21:49:48 +0100 |
commit | 5026f823fa2708404302aa59d03401635a435c0b (patch) | |
tree | 03d8db6da25416fa27b9744ae60df2cfa5fc1d2b /scalls | |
parent | f8e15da04472f5ed6a26e588de4a23cb3e1ba20b (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')
-rw-r--r-- | scalls/recvfrom.c | 15 | ||||
-rw-r--r-- | scalls/recvfrom.h | 4 |
2 files changed, 19 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); +} diff --git a/scalls/recvfrom.h b/scalls/recvfrom.h new file mode 100644 index 0000000..9897899 --- /dev/null +++ b/scalls/recvfrom.h @@ -0,0 +1,4 @@ +#include <socket.h> + +size_t syscall_recvfrom(int socket, void *buffer, size_t length, int flags, + struct sockaddr *address, socklen_t *address_len); |