Skip to content

Commit

Permalink
Suffix Socket::(set_)recv_tos with v4
Browse files Browse the repository at this point in the history
To indicate it an option for IPv4 sockets.
  • Loading branch information
Thomasdezeeuw committed Jan 27, 2025
1 parent 11428df commit 171d1eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ impl Socket {
target_os = "espidf",
target_os = "vita",
)))]
pub fn set_recv_tos(&self, recv_tos: bool) -> io::Result<()> {
pub fn set_recv_tos_v4(&self, recv_tos: bool) -> io::Result<()> {
unsafe {
setsockopt(
self.as_raw(),
Expand All @@ -1620,9 +1620,9 @@ impl Socket {

/// Get the value of the `IP_RECVTOS` option for this socket.
///
/// For more information about this option, see [`set_recv_tos`].
/// For more information about this option, see [`set_recv_tos_v4`].
///
/// [`set_recv_tos`]: Socket::set_recv_tos
/// [`set_recv_tos_v4`]: Socket::set_recv_tos_v4
#[cfg(not(any(
target_os = "aix",
target_os = "dragonfly",
Expand All @@ -1638,7 +1638,7 @@ impl Socket {
target_os = "espidf",
target_os = "vita",
)))]
pub fn recv_tos(&self) -> io::Result<bool> {
pub fn recv_tos_v4(&self) -> io::Result<bool> {
unsafe {
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_RECVTOS)
.map(|recv_tos| recv_tos > 0)
Expand Down
2 changes: 1 addition & 1 deletion tests/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ test!(IPv4 tos_v4, set_tos_v4(96));
target_os = "vita",
target_os = "haiku",
)))]
test!(IPv4 recv_tos, set_recv_tos(true));
test!(IPv4 recv_tos_v4, set_recv_tos_v4(true));

#[cfg(not(windows))] // TODO: returns `WSAENOPROTOOPT` (10042) on Windows.
test!(IPv4 broadcast, set_broadcast(true));
Expand Down

0 comments on commit 171d1eb

Please sign in to comment.