mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
Kernel: Implement the SO_DONTROUTE SOL_SOCKET-level option
This commit is contained in:
parent
641498954f
commit
613ade9dec
4 changed files with 20 additions and 2 deletions
|
@ -123,6 +123,14 @@ ErrorOr<void> Socket::setsockopt(int level, int option, Userspace<const void*> u
|
|||
return ENOTSUP;
|
||||
}
|
||||
return {};
|
||||
case SO_DONTROUTE: {
|
||||
int routing_disabled;
|
||||
if (user_value_size != sizeof(routing_disabled))
|
||||
return EINVAL;
|
||||
TRY(copy_from_user(&routing_disabled, static_ptr_cast<const int*>(user_value)));
|
||||
m_routing_disabled = routing_disabled != 0;
|
||||
return {};
|
||||
}
|
||||
default:
|
||||
dbgln("setsockopt({}) at SOL_SOCKET not implemented.", option);
|
||||
return ENOPROTOOPT;
|
||||
|
@ -216,6 +224,14 @@ ErrorOr<void> Socket::getsockopt(OpenFileDescription&, int level, int option, Us
|
|||
size = sizeof(accepting_connections);
|
||||
return copy_to_user(value_size, &size);
|
||||
}
|
||||
case SO_DONTROUTE: {
|
||||
int routing_disabled = m_routing_disabled ? 1 : 0;
|
||||
if (size < sizeof(routing_disabled))
|
||||
return EINVAL;
|
||||
TRY(copy_to_user(static_ptr_cast<int*>(value), &routing_disabled));
|
||||
size = sizeof(routing_disabled);
|
||||
return copy_to_user(value_size, &size);
|
||||
}
|
||||
default:
|
||||
dbgln("setsockopt({}) at SOL_SOCKET not implemented.", option);
|
||||
return ENOPROTOOPT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue