From 5940300a9828e7e54cf521cd96f80675f49bf23c Mon Sep 17 00:00:00 2001 From: SteveLauC Date: Mon, 22 Jul 2024 13:47:13 +0800 Subject: [PATCH] feat: add socket option IP_TOS/IPV6_TCLASS on Android/FreeBSD (#2464) * feat: add socket option IP_TOS/IPV6_TCLASS on Android/FreeBSD * chore: changelog entry[skip ci] --- changelog/2464.added.md | 1 + src/sys/socket/sockopt.rs | 4 ++-- test/sys/test_sockopt.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 changelog/2464.added.md diff --git a/changelog/2464.added.md b/changelog/2464.added.md new file mode 100644 index 0000000000..6e38ff735f --- /dev/null +++ b/changelog/2464.added.md @@ -0,0 +1 @@ +Add socket option IP_TOS (nix::sys::socket::sockopt::IpTos) IPV6_TCLASS (nix::sys::socket::sockopt::Ipv6TClass) on Android/FreeBSD \ No newline at end of file diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 0b6b07a948..8df71a2778 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -402,7 +402,7 @@ sockopt_impl!( libc::SO_PRIORITY, libc::c_int ); -#[cfg(target_os = "linux")] +#[cfg(any(linux_android, target_os = "freebsd"))] #[cfg(feature = "net")] sockopt_impl!( #[cfg_attr(docsrs, doc(cfg(feature = "net")))] @@ -414,7 +414,7 @@ sockopt_impl!( libc::IP_TOS, libc::c_int ); -#[cfg(target_os = "linux")] +#[cfg(any(linux_android, target_os = "freebsd"))] #[cfg(feature = "net")] sockopt_impl!( #[cfg_attr(docsrs, doc(cfg(feature = "net")))] diff --git a/test/sys/test_sockopt.rs b/test/sys/test_sockopt.rs index 1da3f6af38..427e5854ec 100644 --- a/test/sys/test_sockopt.rs +++ b/test/sys/test_sockopt.rs @@ -469,7 +469,7 @@ fn test_so_priority() { } #[test] -#[cfg(target_os = "linux")] +#[cfg(any(linux_android, target_os = "freebsd"))] fn test_ip_tos() { let fd = socket( AddressFamily::Inet, @@ -484,7 +484,7 @@ fn test_ip_tos() { } #[test] -#[cfg(target_os = "linux")] +#[cfg(any(linux_android, target_os = "freebsd"))] // Disable the test under emulation because it fails in Cirrus-CI. Lack // of QEMU support is suspected. #[cfg_attr(qemu, ignore)]