Skip to content

Commit

Permalink
DragonFly doesn't have IP_RECVTOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode committed Sep 27, 2023
1 parent dc6ed1f commit 5756d7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/backend/libc/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,13 @@ pub(crate) fn get_ip_tos(fd: BorrowedFd<'_>) -> io::Result<u8> {
Ok(value as u8)
}

#[cfg(any(apple, freebsdlike, linux_like, target_os = "fuchsia"))]
#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))]
#[inline]
pub(crate) fn set_ip_recvtos(fd: BorrowedFd<'_>, value: bool) -> io::Result<()> {
setsockopt(fd, c::IPPROTO_IP, c::IP_RECVTOS, from_bool(value))
}

#[cfg(any(apple, freebsdlike, linux_like, target_os = "fuchsia"))]
#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))]
#[inline]
pub(crate) fn get_ip_recvtos(fd: BorrowedFd<'_>) -> io::Result<bool> {
getsockopt(fd, c::IPPROTO_IP, c::IP_RECVTOS).map(to_bool)
Expand Down
4 changes: 2 additions & 2 deletions src/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ pub fn get_ip_tos<Fd: AsFd>(fd: Fd) -> io::Result<u8> {
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[cfg(any(apple, freebsdlike, linux_like, target_os = "fuchsia"))]
#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))]
#[inline]
#[doc(alias = "IP_RECVTOS")]
pub fn set_ip_recvtos<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
Expand All @@ -846,7 +846,7 @@ pub fn set_ip_recvtos<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
/// See the [module-level documentation] for more.
///
/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions
#[cfg(any(apple, freebsdlike, linux_like, target_os = "fuchsia"))]
#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))]
#[inline]
#[doc(alias = "IP_RECVTOS")]
pub fn get_ip_recvtos<Fd: AsFd>(fd: Fd) -> io::Result<bool> {
Expand Down
2 changes: 1 addition & 1 deletion tests/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ fn test_sockopts_ipv4() {
}

// Check the initial value of IP RECVTOS, set it, and check it.
#[cfg(any(apple, freebsdlike, linux_like, target_os = "fuchsia"))]
#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))]
{
assert!(!sockopt::get_ip_recvtos(&s).unwrap());
sockopt::set_ip_recvtos(&s, true).unwrap();
Expand Down

0 comments on commit 5756d7f

Please sign in to comment.