summaryrefslogtreecommitdiff
path: root/src/sys/socket
diff options
context:
space:
mode:
authorAlessandro Ghedini <alessandro@cloudflare.com>2021-08-25 14:31:57 +0100
committerAlessandro Ghedini <alessandro@cloudflare.com>2021-12-29 14:15:54 +0000
commita9829853df9192048be39cb9593206b8492748f6 (patch)
tree35d76ceca21b7e8511edf0bb2e40eb39ec6b9993 /src/sys/socket
parentc77a8728b558dc75a9a023c669543bf23dd13a9f (diff)
downloadnix-a9829853df9192048be39cb9593206b8492748f6.zip
Add support for the SO_TXTIME sockopt and SCM_TXTIME control message
Diffstat (limited to 'src/sys/socket')
-rw-r--r--src/sys/socket/mod.rs22
-rw-r--r--src/sys/socket/sockopt.rs5
2 files changed, 27 insertions, 0 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 9df5ed4a..f6d37c99 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -1056,6 +1056,14 @@ pub enum ControlMessage<'a> {
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
#[cfg_attr(docsrs, doc(cfg(all())))]
RxqOvfl(&'a u32),
+
+ /// Configure the transmission time of packets.
+ ///
+ /// For further information, please refer to the
+ /// [`tc-etf(8)`](https://man7.org/linux/man-pages/man8/tc-etf.8.html) man
+ /// page.
+ #[cfg(target_os = "linux")]
+ TxTime(&'a u64),
}
// An opaque structure used to prevent cmsghdr from being a public type
@@ -1153,6 +1161,10 @@ impl<'a> ControlMessage<'a> {
ControlMessage::RxqOvfl(drop_count) => {
drop_count as *const _ as *const u8
},
+ #[cfg(target_os = "linux")]
+ ControlMessage::TxTime(tx_time) => {
+ tx_time as *const _ as *const u8
+ },
};
unsafe {
ptr::copy_nonoverlapping(
@@ -1208,6 +1220,10 @@ impl<'a> ControlMessage<'a> {
ControlMessage::RxqOvfl(drop_count) => {
mem::size_of_val(drop_count)
},
+ #[cfg(target_os = "linux")]
+ ControlMessage::TxTime(tx_time) => {
+ mem::size_of_val(tx_time)
+ },
}
}
@@ -1237,6 +1253,8 @@ impl<'a> ControlMessage<'a> {
ControlMessage::Ipv6PacketInfo(_) => libc::IPPROTO_IPV6,
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
ControlMessage::RxqOvfl(_) => libc::SOL_SOCKET,
+ #[cfg(target_os = "linux")]
+ ControlMessage::TxTime(_) => libc::SOL_SOCKET,
}
}
@@ -1279,6 +1297,10 @@ impl<'a> ControlMessage<'a> {
ControlMessage::RxqOvfl(_) => {
libc::SO_RXQ_OVFL
},
+ #[cfg(target_os = "linux")]
+ ControlMessage::TxTime(_) => {
+ libc::SCM_TXTIME
+ },
}
}
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index 056ded42..c600391c 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -582,6 +582,11 @@ sockopt_impl!(
#[allow(missing_docs)]
// Not documented by Linux!
UdpGroSegment, Both, libc::IPPROTO_UDP, libc::UDP_GRO, bool);
+#[cfg(target_os = "linux")]
+sockopt_impl!(
+ /// Configures the behavior of time-based transmission of packets, for use
+ /// with the `TxTime` control message.
+ TxTime, Both, libc::SOL_SOCKET, libc::SO_TXTIME, libc::sock_txtime);
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
sockopt_impl!(
/// Indicates that an unsigned 32-bit value ancillary message (cmsg) should