Skip to content

Commit c93cdcc

Browse files
pd0wmThomasdezeeuw
authored andcommitted
Add MSG_CONFIRM and MSG_DONTROUTE to RecvFlags
1 parent faa59e9 commit c93cdcc

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/sys/unix.rs

+35
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,37 @@ impl RecvFlags {
573573
pub const fn is_out_of_band(self) -> bool {
574574
self.0 & libc::MSG_OOB != 0
575575
}
576+
577+
/// Check if the confirm flag is set.
578+
///
579+
/// This is used by SocketCAN to indicate a frame was sent via the
580+
/// socket it is received on. This flag can be interpreted as a
581+
/// 'transmission confirmation'.
582+
///
583+
/// On Unix this corresponds to the `MSG_CONFIRM` flag.
584+
#[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))]
585+
#[cfg_attr(
586+
docsrs,
587+
doc(cfg(all(feature = "all", any(target_os = "android", target_os = "linux"))))
588+
)]
589+
pub const fn is_confirm(self) -> bool {
590+
self.0 & libc::MSG_CONFIRM != 0
591+
}
592+
593+
/// Check if the don't route flag is set.
594+
///
595+
/// This is used by SocketCAN to indicate a frame was created
596+
/// on the local host.
597+
///
598+
/// On Unix this corresponds to the `MSG_DONTROUTE` flag.
599+
#[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))]
600+
#[cfg_attr(
601+
docsrs,
602+
doc(cfg(all(feature = "all", any(target_os = "android", target_os = "linux"))))
603+
)]
604+
pub const fn is_dontroute(self) -> bool {
605+
self.0 & libc::MSG_DONTROUTE != 0
606+
}
576607
}
577608

578609
#[cfg(not(target_os = "redox"))]
@@ -584,6 +615,10 @@ impl std::fmt::Debug for RecvFlags {
584615
s.field("is_out_of_band", &self.is_out_of_band());
585616
#[cfg(not(target_os = "espidf"))]
586617
s.field("is_truncated", &self.is_truncated());
618+
#[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))]
619+
s.field("is_confirm", &self.is_confirm());
620+
#[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))]
621+
s.field("is_dontroute", &self.is_dontroute());
587622
s.finish()
588623
}
589624
}

tests/socket.rs

+4
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,10 @@ fn send_from_recv_to_vectored() {
731731
#[cfg(all(unix, not(target_os = "redox")))]
732732
assert_eq!(flags.is_out_of_band(), false);
733733
assert_eq!(flags.is_truncated(), false);
734+
#[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))]
735+
assert_eq!(flags.is_confirm(), false);
736+
#[cfg(all(feature = "all", any(target_os = "android", target_os = "linux")))]
737+
assert_eq!(flags.is_dontroute(), false);
734738
assert_eq!(
735739
addr.as_socket_ipv6().unwrap(),
736740
addr_a.as_socket_ipv6().unwrap()

0 commit comments

Comments
 (0)