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 /userland/libc/include/socket.h | |
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 'userland/libc/include/socket.h')
-rw-r--r-- | userland/libc/include/socket.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/userland/libc/include/socket.h b/userland/libc/include/socket.h index 5e86b45..c4a3e73 100644 --- a/userland/libc/include/socket.h +++ b/userland/libc/include/socket.h @@ -1,9 +1,14 @@ +#ifndef SOCKET_H +#define SOCKET_H #include <stddef.h> #include <stdint.h> #define AF_UNIX 0 +#define AF_INET 1 #define AF_LOCAL AF_UNIX +#define SOCK_DGRAM 0 + #define INADDR_ANY 0 typedef struct { @@ -24,13 +29,21 @@ typedef struct { typedef uint32_t in_addr_t; typedef uint16_t in_port_t; typedef unsigned int sa_family_t; -typedef uint32_t socklen_t; +typedef int socklen_t; struct sockaddr { sa_family_t sa_family; /* Address family */ char *sa_data; /* Socket address */ }; +struct sockaddr_in { + sa_family_t sin_family; + union { + uint32_t s_addr; + } sin_addr; + uint16_t sin_port; +}; + struct sockaddr_un { sa_family_t sun_family; /* Address family */ char *sun_path; /* Socket pathname */ @@ -39,3 +52,4 @@ struct sockaddr_un { int socket(int domain, int type, int protocol); int accept(int socket, struct sockaddr *address, socklen_t *address_len); int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); +#endif // SOCKET_H |