diff options
author | Ian Moffett <ian@osmora.org> | 2025-08-04 20:09:38 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-08-04 20:10:50 -0400 |
commit | ff68e8679d7d2487126ff355ed2b34a6f84058bb (patch) | |
tree | 510cec60308d737f386bc9019c1389cf5dcd885d /sys/include | |
parent | 8c9ef7128ff90522949b453087367b6b60e9587d (diff) |
kernel: socket: Add POSIX setsockopt()
This commit introduces the kernel-side implementation of setsockopt()
for setting options on a socket file descriptor. See POSIX
setsockopt() for more information.
https://pubs.opengroup.org/onlinepubs/9690949499/functions/setsockopt.html
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/sys/socket.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/include/sys/socket.h b/sys/include/sys/socket.h index c82ae4e..9224542 100644 --- a/sys/include/sys/socket.h +++ b/sys/include/sys/socket.h @@ -69,6 +69,10 @@ typedef uint32_t socklen_t; /* Socket types */ #define SOCK_STREAM 1 +/* Socket option names */ +#define SO_RCVTIMEO 0 /* Max time recv(2) waits */ +#define _SO_MAX 1 /* Max socket options */ + struct sockaddr_un { sa_family_t sun_family; char sun_path[108]; @@ -149,12 +153,22 @@ struct cmsg_list { uint8_t is_init : 1; }; +/* + * Socket option that may be applied to + * sockets on the system. + */ +struct sockopt { + socklen_t len; + char data[]; +}; + struct ksocket { int sockfd; union { struct sockaddr sockaddr; struct sockaddr_un un; }; + struct sockopt *opt[_SO_MAX]; struct proc *owner; struct cmsg_list cmsg_list; struct sockbuf buf; @@ -174,6 +188,8 @@ scret_t sys_sendmsg(struct syscall_args *scargs); int socket(int domain, int type, int protocol); int bind(int sockfd, const struct sockaddr *addr, socklen_t len); + +int setsockopt(int sockfd, int level, int name, const void *v, socklen_t len); int connect(int sockfd, const struct sockaddr *addr, socklen_t len); ssize_t send(int sockfd, const void *buf, size_t size, int flags); |