Skip to content

Commit a38d197

Browse files
committed
Suffix Socket::(set_)ttl with v4
To indicate it an option for IPv4 sockets.
1 parent 25337f1 commit a38d197

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/socket.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,8 @@ impl Socket {
11651165
///
11661166
/// [`SOCK_RAW`]: Type::RAW
11671167
/// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html
1168-
/// [`IP_TTL`]: Socket::set_ttl
11691168
/// [`IP_TOS`]: Socket::set_tos
1169+
/// [`IP_TTL`]: Socket::set_ttl_v4
11701170
#[cfg_attr(
11711171
any(target_os = "fuchsia", target_os = "illumos", target_os = "solaris"),
11721172
allow(rustdoc::broken_intra_doc_links)
@@ -1531,10 +1531,10 @@ impl Socket {
15311531

15321532
/// Get the value of the `IP_TTL` option for this socket.
15331533
///
1534-
/// For more information about this option, see [`set_ttl`].
1534+
/// For more information about this option, see [`set_ttl_v4`].
15351535
///
1536-
/// [`set_ttl`]: Socket::set_ttl
1537-
pub fn ttl(&self) -> io::Result<u32> {
1536+
/// [`set_ttl_v4`]: Socket::set_ttl_v4
1537+
pub fn ttl_v4(&self) -> io::Result<u32> {
15381538
unsafe {
15391539
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_TTL).map(|ttl| ttl as u32)
15401540
}
@@ -1544,7 +1544,7 @@ impl Socket {
15441544
///
15451545
/// This value sets the time-to-live field that is used in every packet sent
15461546
/// from this socket.
1547-
pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {
1547+
pub fn set_ttl_v4(&self, ttl: u32) -> io::Result<()> {
15481548
unsafe { setsockopt(self.as_raw(), sys::IPPROTO_IP, sys::IP_TTL, ttl as c_int) }
15491549
}
15501550

tests/socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ test!(freebind, set_freebind(true));
14011401
#[cfg(all(feature = "all", target_os = "linux"))]
14021402
test!(IPv6 freebind_ipv6, set_freebind_ipv6(true));
14031403

1404-
test!(IPv4 ttl, set_ttl(40));
1404+
test!(IPv4 ttl_v4, set_ttl_v4(40));
14051405

14061406
#[cfg(not(any(
14071407
target_os = "fuchsia",

0 commit comments

Comments
 (0)