mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Kernel: Implement the SO_ACCEPTCONN SOL_SOCKET-level option
This commit is contained in:
parent
a0e2fedc20
commit
641498954f
Notes:
sideshowbarker
2024-07-17 23:10:35 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/641498954fd Pull-request: https://github.com/SerenityOS/serenity/pull/11152 Reviewed-by: https://github.com/awesomekling
2 changed files with 10 additions and 0 deletions
|
@ -108,6 +108,7 @@ enum {
|
|||
SO_TIMESTAMP,
|
||||
SO_BROADCAST,
|
||||
SO_LINGER,
|
||||
SO_ACCEPTCONN,
|
||||
};
|
||||
#define SO_RCVTIMEO SO_RCVTIMEO
|
||||
#define SO_SNDTIMEO SO_SNDTIMEO
|
||||
|
@ -123,6 +124,7 @@ enum {
|
|||
#define SO_SNDBUF SO_SNDBUF
|
||||
#define SO_RCVBUF SO_RCVBUF
|
||||
#define SO_LINGER SO_LINGER
|
||||
#define SO_ACCEPTCONN SO_ACCEPTCONN
|
||||
|
||||
enum {
|
||||
SCM_TIMESTAMP,
|
||||
|
|
|
@ -208,6 +208,14 @@ ErrorOr<void> Socket::getsockopt(OpenFileDescription&, int level, int option, Us
|
|||
TRY(memset_user(value.unsafe_userspace_ptr(), 0, sizeof(int)));
|
||||
size = sizeof(int);
|
||||
return copy_to_user(value_size, &size);
|
||||
case SO_ACCEPTCONN: {
|
||||
int accepting_connections = (m_role == Role::Listener) ? 1 : 0;
|
||||
if (size < sizeof(accepting_connections))
|
||||
return EINVAL;
|
||||
TRY(copy_to_user(static_ptr_cast<int*>(value), &accepting_connections));
|
||||
size = sizeof(accepting_connections);
|
||||
return copy_to_user(value_size, &size);
|
||||
}
|
||||
default:
|
||||
dbgln("setsockopt({}) at SOL_SOCKET not implemented.", option);
|
||||
return ENOPROTOOPT;
|
||||
|
|
Loading…
Reference in a new issue