mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 09:21:57 -05:00
Kernel/Net: Implement SO_SNDBUF and SO_RCVBUF getsockopt for AF_LOCAL
These options are used for QoS and return buffer length as response. We currently don't support setting the buffer size.
This commit is contained in:
parent
62f5bba718
commit
513eb6ed03
1 changed files with 16 additions and 4 deletions
|
@ -403,10 +403,22 @@ ErrorOr<void> LocalSocket::getsockopt(OpenFileDescription& description, int leve
|
|||
TRY(copy_from_user(&size, value_size.unsafe_userspace_ptr()));
|
||||
|
||||
switch (option) {
|
||||
case SO_SNDBUF:
|
||||
return ENOTSUP;
|
||||
case SO_RCVBUF:
|
||||
return ENOTSUP;
|
||||
case SO_SNDBUF: {
|
||||
if (size != sizeof(int))
|
||||
return EINVAL;
|
||||
int snd_buffer_size = static_cast<int>(m_for_server->space_for_writing() + m_for_server->immediately_readable());
|
||||
TRY(copy_to_user(static_ptr_cast<int*>(value), &snd_buffer_size));
|
||||
TRY(copy_to_user(value_size, &size));
|
||||
return {};
|
||||
}
|
||||
case SO_RCVBUF: {
|
||||
if (size != sizeof(int))
|
||||
return EINVAL;
|
||||
int rcv_buffer_size = static_cast<int>(m_for_client->space_for_writing() + m_for_client->immediately_readable());
|
||||
TRY(copy_to_user(static_ptr_cast<int*>(value), &rcv_buffer_size));
|
||||
TRY(copy_to_user(value_size, &size));
|
||||
return {};
|
||||
}
|
||||
case SO_PEERCRED: {
|
||||
if (size < sizeof(ucred))
|
||||
return EINVAL;
|
||||
|
|
Loading…
Reference in a new issue