diff options
author | Lu, Wangshan <wisagan@gmail.com> | 2021-03-20 22:36:36 +0800 |
---|---|---|
committer | Lu, Wangshan <wisagan@gmail.com> | 2021-04-08 10:41:38 +0800 |
commit | 830bab64a8615642ea7de69952b5ae122a124285 (patch) | |
tree | b4d07b07e0abb496bbbe94852b1ad02f0bb2f64e /src/sys/socket/mod.rs | |
parent | 3f8a66dc69ba3ae4df6a0f3eb879dc30020965bc (diff) | |
download | nix-830bab64a8615642ea7de69952b5ae122a124285.zip |
Support TIMESTAMPNS for linux
Diffstat (limited to 'src/sys/socket/mod.rs')
-rw-r--r-- | src/sys/socket/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 2725e57c..6e22274c 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -7,6 +7,8 @@ use libc::{self, c_void, c_int, iovec, socklen_t, size_t, CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN}; use std::{mem, ptr, slice}; use std::os::unix::io::RawFd; +#[cfg(all(target_os = "linux"))] +use crate::sys::time::TimeSpec; use crate::sys::time::TimeVal; use crate::sys::uio::IoVec; @@ -554,6 +556,11 @@ pub enum ControlMessageOwned { /// # } /// ``` ScmTimestamp(TimeVal), + /// Nanoseconds resolution timestamp + /// + /// [Further reading](https://www.kernel.org/doc/html/latest/networking/timestamping.html) + #[cfg(all(target_os = "linux"))] + ScmTimestampns(TimeSpec), #[cfg(any( target_os = "android", target_os = "ios", @@ -645,6 +652,11 @@ impl ControlMessageOwned { let tv: libc::timeval = ptr::read_unaligned(p as *const _); ControlMessageOwned::ScmTimestamp(TimeVal::from(tv)) }, + #[cfg(all(target_os = "linux"))] + (libc::SOL_SOCKET, libc::SCM_TIMESTAMPNS) => { + let ts: libc::timespec = ptr::read_unaligned(p as *const _); + ControlMessageOwned::ScmTimestampns(TimeSpec::from(ts)) + } #[cfg(any( target_os = "android", target_os = "freebsd", |