diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-08 03:53:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-08 03:53:56 +0000 |
commit | 68d01f0426a82b485b22c31425c0e53b5c372a7d (patch) | |
tree | 9417e3a215db1f947ec15363e935dbd4f487056f /src/sys/socket/mod.rs | |
parent | 2cef18bcf1dffe1662c62424543a348ddbd839ea (diff) | |
parent | 830bab64a8615642ea7de69952b5ae122a124285 (diff) | |
download | nix-68d01f0426a82b485b22c31425c0e53b5c372a7d.zip |
Merge #1402
1402: Support TIMESTAMPNS r=asomers a=WiSaGaN
This adds support of linux TIMESTAMPNS.
The code is mostly copied paste from https://github.com/nix-rust/nix/pull/663
Co-authored-by: Lu, Wangshan <wisagan@gmail.com>
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 726ff8e1..c04af50f 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -8,6 +8,8 @@ use libc::{self, c_void, c_int, iovec, socklen_t, size_t, use memoffset::offset_of; 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; @@ -555,6 +557,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", @@ -646,6 +653,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", |