Kernel+LibC+UserspaceEmulator: Add SO_TIMESTAMP, and cmsg definitions

When SO_TIMESTAMP is set as an option on a SOCK_DGRAM socket, then
recvmsg() will return a SCM_TIMESTAMP control message that
contains a struct timeval with the system time that was current
when the socket was received.
This commit is contained in:
Nico Weber 2020-09-16 12:32:45 -04:00 committed by Andreas Kling
parent ae5ba4074d
commit 47b3e98af8
Notes: sideshowbarker 2024-07-19 02:21:45 +09:00
6 changed files with 94 additions and 2 deletions

View file

@ -490,10 +490,10 @@ int Emulator::virt$setsockopt(FlatPtr params_addr)
Syscall::SC_setsockopt_params params;
mmu().copy_from_vm(&params, params_addr, sizeof(params));
if (params.option == SO_RCVTIMEO) {
if (params.option == SO_RCVTIMEO || params.option == SO_TIMESTAMP) {
auto host_value_buffer = ByteBuffer::create_zeroed(params.value_size);
mmu().copy_from_vm(host_value_buffer.data(), (FlatPtr)params.value, params.value_size);
int rc = setsockopt(params.sockfd, params.level, SO_RCVTIMEO, host_value_buffer.data(), host_value_buffer.size());
int rc = setsockopt(params.sockfd, params.level, params.option, host_value_buffer.data(), host_value_buffer.size());
if (rc < 0)
return -errno;
return rc;