Skip to content

Commit a2be960

Browse files
committed
Move original_dst(_v6) out of TCP block
Neither use IPPROTO_TCP, so they don't belong in the block.
1 parent 4c864f3 commit a2be960

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

src/socket.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ const fn into_linger(duration: Option<Duration>) -> sys::linger {
11671167
}
11681168
}
11691169

1170-
/// Socket options for IPv4 sockets, get/set using `IPPROTO_IP`.
1170+
/// Socket options for IPv4 sockets, get/set using `IPPROTO_IP` or `SOL_IP`.
11711171
///
11721172
/// Additional documentation can be found in documentation of the OS.
11731173
/// * Linux: <https://man7.org/linux/man-pages/man7/ip.7.html>
@@ -1670,9 +1670,23 @@ impl Socket {
16701670
.map(|recv_tos| recv_tos > 0)
16711671
}
16721672
}
1673+
1674+
/// Get the value for the `SO_ORIGINAL_DST` option on this socket.
1675+
#[cfg(all(
1676+
feature = "all",
1677+
any(
1678+
target_os = "android",
1679+
target_os = "fuchsia",
1680+
target_os = "linux",
1681+
target_os = "windows",
1682+
)
1683+
))]
1684+
pub fn original_dst(&self) -> io::Result<SockAddr> {
1685+
sys::original_dst(self.as_raw())
1686+
}
16731687
}
16741688

1675-
/// Socket options for IPv6 sockets, get/set using `IPPROTO_IPV6`.
1689+
/// Socket options for IPv6 sockets, get/set using `IPPROTO_IPV6` or `SOL_IPV6`.
16761690
///
16771691
/// Additional documentation can be found in documentation of the OS.
16781692
/// * Linux: <https://man7.org/linux/man-pages/man7/ipv6.7.html>
@@ -2075,6 +2089,15 @@ impl Socket {
20752089
)
20762090
}
20772091
}
2092+
2093+
/// Get the value for the `IP6T_SO_ORIGINAL_DST` option on this socket.
2094+
#[cfg(all(
2095+
feature = "all",
2096+
any(target_os = "android", target_os = "linux", target_os = "windows")
2097+
))]
2098+
pub fn original_dst_ipv6(&self) -> io::Result<SockAddr> {
2099+
sys::original_dst_ipv6(self.as_raw())
2100+
}
20782101
}
20792102

20802103
/// Socket options for TCP sockets, get/set using `IPPROTO_TCP`.
@@ -2233,29 +2256,6 @@ impl Socket {
22332256
)
22342257
}
22352258
}
2236-
2237-
/// Get the value for the `SO_ORIGINAL_DST` option on this socket.
2238-
#[cfg(all(
2239-
feature = "all",
2240-
any(
2241-
target_os = "android",
2242-
target_os = "fuchsia",
2243-
target_os = "linux",
2244-
target_os = "windows",
2245-
)
2246-
))]
2247-
pub fn original_dst(&self) -> io::Result<SockAddr> {
2248-
sys::original_dst(self.as_raw())
2249-
}
2250-
2251-
/// Get the value for the `IP6T_SO_ORIGINAL_DST` option on this socket.
2252-
#[cfg(all(
2253-
feature = "all",
2254-
any(target_os = "android", target_os = "linux", target_os = "windows")
2255-
))]
2256-
pub fn original_dst_ipv6(&self) -> io::Result<SockAddr> {
2257-
sys::original_dst_ipv6(self.as_raw())
2258-
}
22592259
}
22602260

22612261
impl Read for Socket {

src/sys/unix.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ fn into_timeval(duration: Option<Duration>) -> libc::timeval {
11871187
feature = "all",
11881188
not(any(target_os = "haiku", target_os = "openbsd", target_os = "vita"))
11891189
))]
1190-
pub(crate) fn keepalive_time(fd: Socket) -> io::Result<Duration> {
1190+
pub(crate) fn tcp_keepalive_time(fd: Socket) -> io::Result<Duration> {
11911191
unsafe {
11921192
getsockopt::<c_int>(fd, IPPROTO_TCP, KEEPALIVE_TIME)
11931193
.map(|secs| Duration::from_secs(secs as u64))
@@ -1569,7 +1569,7 @@ impl crate::Socket {
15691569
///
15701570
/// [`set_mss`]: crate::Socket::set_mss
15711571
#[cfg(all(feature = "all", not(target_os = "redox")))]
1572-
pub fn mss(&self) -> io::Result<u32> {
1572+
pub fn tcp_mss(&self) -> io::Result<u32> {
15731573
unsafe {
15741574
getsockopt::<c_int>(self.as_raw(), libc::IPPROTO_TCP, libc::TCP_MAXSEG)
15751575
.map(|mss| mss as u32)
@@ -1581,7 +1581,7 @@ impl crate::Socket {
15811581
/// The `TCP_MAXSEG` option denotes the TCP Maximum Segment Size and is only
15821582
/// available on TCP sockets.
15831583
#[cfg(all(feature = "all", not(target_os = "redox")))]
1584-
pub fn set_mss(&self, mss: u32) -> io::Result<()> {
1584+
pub fn set_tcp_mss(&self, mss: u32) -> io::Result<()> {
15851585
unsafe {
15861586
setsockopt(
15871587
self.as_raw(),
@@ -1697,7 +1697,7 @@ impl crate::Socket {
16971697
feature = "all",
16981698
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
16991699
))]
1700-
pub fn cork(&self) -> io::Result<bool> {
1700+
pub fn tcp_cork(&self) -> io::Result<bool> {
17011701
unsafe {
17021702
getsockopt::<Bool>(self.as_raw(), libc::IPPROTO_TCP, libc::TCP_CORK)
17031703
.map(|cork| cork != 0)
@@ -1714,7 +1714,7 @@ impl crate::Socket {
17141714
feature = "all",
17151715
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
17161716
))]
1717-
pub fn set_cork(&self, cork: bool) -> io::Result<()> {
1717+
pub fn set_tcp_cork(&self, cork: bool) -> io::Result<()> {
17181718
unsafe {
17191719
setsockopt(
17201720
self.as_raw(),
@@ -1739,7 +1739,7 @@ impl crate::Socket {
17391739
target_os = "cygwin",
17401740
)
17411741
))]
1742-
pub fn quickack(&self) -> io::Result<bool> {
1742+
pub fn tcp_quickack(&self) -> io::Result<bool> {
17431743
unsafe {
17441744
getsockopt::<Bool>(self.as_raw(), libc::IPPROTO_TCP, libc::TCP_QUICKACK)
17451745
.map(|quickack| quickack != 0)
@@ -1761,7 +1761,7 @@ impl crate::Socket {
17611761
target_os = "cygwin",
17621762
)
17631763
))]
1764-
pub fn set_quickack(&self, quickack: bool) -> io::Result<()> {
1764+
pub fn set_tcp_quickack(&self, quickack: bool) -> io::Result<()> {
17651765
unsafe {
17661766
setsockopt(
17671767
self.as_raw(),
@@ -1781,7 +1781,7 @@ impl crate::Socket {
17811781
feature = "all",
17821782
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
17831783
))]
1784-
pub fn thin_linear_timeouts(&self) -> io::Result<bool> {
1784+
pub fn tcp_thin_linear_timeouts(&self) -> io::Result<bool> {
17851785
unsafe {
17861786
getsockopt::<Bool>(
17871787
self.as_raw(),
@@ -1801,7 +1801,7 @@ impl crate::Socket {
18011801
feature = "all",
18021802
any(target_os = "android", target_os = "fuchsia", target_os = "linux")
18031803
))]
1804-
pub fn set_thin_linear_timeouts(&self, timeouts: bool) -> io::Result<()> {
1804+
pub fn set_tcp_thin_linear_timeouts(&self, timeouts: bool) -> io::Result<()> {
18051805
unsafe {
18061806
setsockopt(
18071807
self.as_raw(),

0 commit comments

Comments
 (0)