1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

Kernel: Implement the SO_ACCEPTCONN SOL_SOCKET-level option

This commit is contained in:
Idan Horowitz 2021-12-02 00:52:12 +02:00 committed by Andreas Kling
parent a0e2fedc20
commit 641498954f
2 changed files with 10 additions and 0 deletions

View file

@ -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;