From ac288b4a207da74337e6da9c88b6806c015ab69a Mon Sep 17 00:00:00 2001 From: Fausto Date: Sat, 5 Mar 2022 13:55:27 -0500 Subject: [PATCH 1/7] add setters and getters for ipv6 socket hop limit --- library/std/src/lib.rs | 1 + library/std/src/net/udp.rs | 76 +++++++++++++++++++++++++++++++ library/std/src/sys_common/net.rs | 18 ++++++++ 3 files changed, 95 insertions(+) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 36e6032b5e4e5..a1d18087ceb90 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -277,6 +277,7 @@ #![feature(hashmap_internals)] #![feature(int_error_internals)] #![feature(intra_doc_pointers)] +#![feature(ipv6_hop_limit)] #![feature(lang_items)] #![feature(linkage)] #![feature(log_syntax)] diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 11a696e92c825..ec206b215add6 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -554,6 +554,82 @@ impl UdpSocket { self.0.ttl() } + /// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket. + /// + /// This value sets the unicast hop limit field that is used in every packet + /// sent from this socket. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::UdpSocket; + /// + /// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address"); + /// socket.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed"); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn set_hop_limit_v6(&self, limit: i32) -> io::Result<()> { + self.0.set_hop_limit_v6(limit) + } + + /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket. + /// + /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::UdpSocket; + /// + /// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address"); + /// socket.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed"); + /// assert_eq!(socket.hop_limit_v6().unwrap(), 88); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn hop_limit_v6(&self) -> io::Result { + self.0.hop_limit_v6() + } + + /// Sets the value for the `IPV6_MULTICAST_HOPS` option on this socket. + /// + /// This value sets the hop limit field for outgoing multicast packets + /// sent from this socket. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::UdpSocket; + /// + /// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address"); + /// socket.set_multicast_hlim_v6(88).expect("set_multicast_hlim_v6 call failed"); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn set_multicast_hlim_v6(&self, limit: i32) -> io::Result<()> { + self.0.set_multicast_hlim_v6(limit) + } + + /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. + /// + /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::UdpSocket; + /// + /// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address"); + /// socket.set_multicast_hlim_v6(88).expect("set_multicast_hlim_v6 call failed"); + /// assert_eq!(socket.multicast_hlim_v6().unwrap(), 88); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn multicast_hlim_v6(&self) -> io::Result { + self.0.multicast_hlim_v6() + } + /// Executes an operation of the `IP_ADD_MEMBERSHIP` type. /// /// This function specifies a new multicast group for this socket to join. diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index 3b7cdd55a081c..cde66dccef48a 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -641,6 +641,24 @@ impl UdpSocket { Ok(raw as u32) } + pub fn set_hop_limit_v6(&self, limit: i32) -> io::Result<()> { + setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_UNICAST_HOPS, limit as c_int) + } + + pub fn hop_limit_v6(&self) -> io::Result { + let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_UNICAST_HOPS)?; + Ok(raw as u32) + } + + pub fn set_multicast_hlim_v6(&self, limit: i32) -> io::Result<()> { + setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS, limit as c_int) + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS)?; + Ok(raw as u32) + } + pub fn take_error(&self) -> io::Result> { self.inner.take_error() } From 44c2226513a96edae3f496b16489e07ed1aeb3e8 Mon Sep 17 00:00:00 2001 From: Fausto Date: Sat, 5 Mar 2022 15:39:08 -0500 Subject: [PATCH 2/7] add setters for hop limit to tcp listener and stream and update tests --- library/std/src/net/tcp.rs | 156 ++++++++++++++++++++++++++++++ library/std/src/net/tcp/tests.rs | 17 ++++ library/std/src/net/udp.rs | 4 +- library/std/src/net/udp/tests.rs | 12 +++ library/std/src/sys_common/net.rs | 40 +++++++- 5 files changed, 225 insertions(+), 4 deletions(-) diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index cc4e4fd4fdc77..e58ac3a747832 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -540,6 +540,86 @@ impl TcpStream { self.0.ttl() } + /// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket. + /// + /// This value sets the unicast hop limit field that is used in every packet + /// sent from this socket. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpStream; + /// + /// let stream = TcpStream::connect("127.0.0.1:54321") + /// .expect("Couldn't connect to the server..."); + /// stream.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed"); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + self.0.set_hop_limit_v6(limit) + } + + /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket. + /// + /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpStream; + /// + /// let stream = TcpStream::connect("127.0.0.1:54321") + /// .expect("Couldn't connect to the server..."); + /// stream.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed"); + /// assert_eq!(stream.hop_limit_v6().unwrap(), 88); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn hop_limit_v6(&self) -> io::Result { + self.0.hop_limit_v6() + } + + /// Sets the value for the `IPV6_MULTICAST_HOPS` option on this socket. + /// + /// This value sets the hop limit field for outgoing multicast packets + /// sent from this socket. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpStream; + /// + /// let stream = TcpStream::connect("127.0.0.1:54321") + /// .expect("Couldn't connect to the server..."); + /// stream.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + self.0.set_multicast_hlim_v6(limit) + } + + /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. + /// + /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpStream; + /// + /// let stream = TcpStream::connect("127.0.0.1:54321") + /// .expect("Couldn't connect to the server..."); + /// stream.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); + /// assert_eq!(stream.multicast_hlim_v6().unwrap(), 88); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn multicast_hlim_v6(&self) -> io::Result { + self.0.multicast_hlim_v6() + } + /// Gets the value of the `SO_ERROR` option on this socket. /// /// This will retrieve the stored error in the underlying socket, clearing @@ -914,6 +994,82 @@ impl TcpListener { self.0.ttl() } + /// Sets the value for the `IPV6_UNICAST_HOPS` option on this socket. + /// + /// This value sets the unicast hop limit field that is used in every packet + /// sent from this socket. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpListener; + /// + /// let listener = TcpListener::bind("127.0.0.1:54321").unwrap(); + /// listener.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed"); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + self.0.set_hop_limit_v6(limit) + } + + /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket. + /// + /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpListener; + /// + /// let listener = TcpListener::bind("127.0.0.1:80").unwrap(); + /// listener.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed"); + /// assert_eq!(listener.hop_limit_v6().unwrap(), 88); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn hop_limit_v6(&self) -> io::Result { + self.0.hop_limit_v6() + } + + /// Sets the value for the `IPV6_MULTICAST_HOPS` option on this socket. + /// + /// This value sets the hop limit field for outgoing multicast packets + /// sent from this socket. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpListener; + /// + /// let listener = TcpListener::bind("127.0.0.1:54321").unwrap(); + /// listener.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + self.0.set_multicast_hlim_v6(limit) + } + + /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. + /// + /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// + /// # Examples + /// + /// ```no_run + /// #![feature(ipv6_hop_limit)] + /// use std::net::TcpListener; + /// + /// let listener = TcpListener::bind("127.0.0.1:54321").unwrap(); + /// listener.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); + /// assert_eq!(listener.multicast_hlim_v6().unwrap(), 88); + /// ``` + #[unstable(feature = "ipv6_hop_limit", issue = "47727")] + pub fn multicast_hlim_v6(&self) -> io::Result { + self.0.multicast_hlim_v6() + } + #[stable(feature = "net2_mutators", since = "1.9.0")] #[rustc_deprecated( since = "1.16.0", diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs index c2061c1351262..8d38e1d16ec17 100644 --- a/library/std/src/net/tcp/tests.rs +++ b/library/std/src/net/tcp/tests.rs @@ -814,6 +814,23 @@ fn ttl() { assert_eq!(ttl, t!(stream.ttl())); } +#[test] +#[cfg_attr(target_env = "sgx", ignore)] +fn hop_limit() { + let hlim: u32 = 100; + + let addr = next_test_ip6(); + let listener = t!(TcpListener::bind(&addr)); + + t!(listener.set_hop_limit_v6(hlim)); + assert_eq!(hlim, t!(listener.hop_limit_v6())); + + let stream = t!(TcpStream::connect(&addr)); + + t!(stream.set_hop_limit_v6(hlim)); + assert_eq!(hlim, t!(stream.hop_limit_v6())); +} + #[test] #[cfg_attr(target_env = "sgx", ignore)] fn set_nonblocking() { diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index ec206b215add6..2ff09457af515 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -569,7 +569,7 @@ impl UdpSocket { /// socket.set_hop_limit_v6(88).expect("set_hop_limit_v6 call failed"); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn set_hop_limit_v6(&self, limit: i32) -> io::Result<()> { + pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> { self.0.set_hop_limit_v6(limit) } @@ -607,7 +607,7 @@ impl UdpSocket { /// socket.set_multicast_hlim_v6(88).expect("set_multicast_hlim_v6 call failed"); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn set_multicast_hlim_v6(&self, limit: i32) -> io::Result<()> { + pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { self.0.set_multicast_hlim_v6(limit) } diff --git a/library/std/src/net/udp/tests.rs b/library/std/src/net/udp/tests.rs index a51113dd9e749..1fd66c4976c41 100644 --- a/library/std/src/net/udp/tests.rs +++ b/library/std/src/net/udp/tests.rs @@ -342,6 +342,18 @@ fn ttl() { assert_eq!(ttl, t!(stream.ttl())); } +#[test] +fn hop_limit() { + let hlim = 100; + + let addr = next_test_ip6(); + + let stream = t!(UdpSocket::bind(&addr)); + + t!(stream.set_hop_limit_v6(hlim)); + assert_eq!(hlim, t!(stream.hop_limit_v6())); +} + #[test] fn set_nonblocking() { each_ip(&mut |addr, _| { diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index cde66dccef48a..513f3fbe20b2c 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -337,6 +337,24 @@ impl TcpStream { Ok(raw as u32) } + pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_UNICAST_HOPS, limit as c_int) + } + + pub fn hop_limit_v6(&self) -> io::Result { + let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_UNICAST_HOPS)?; + Ok(raw as u32) + } + + pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS, limit as c_int) + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS)?; + Ok(raw as u32) + } + pub fn take_error(&self) -> io::Result> { self.inner.take_error() } @@ -437,6 +455,24 @@ impl TcpListener { Ok(raw as u32) } + pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_UNICAST_HOPS, limit as c_int) + } + + pub fn hop_limit_v6(&self) -> io::Result { + let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_UNICAST_HOPS)?; + Ok(raw as u32) + } + + pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS, limit as c_int) + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS)?; + Ok(raw as u32) + } + pub fn set_only_v6(&self, only_v6: bool) -> io::Result<()> { setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_V6ONLY, only_v6 as c_int) } @@ -641,7 +677,7 @@ impl UdpSocket { Ok(raw as u32) } - pub fn set_hop_limit_v6(&self, limit: i32) -> io::Result<()> { + pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> { setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_UNICAST_HOPS, limit as c_int) } @@ -650,7 +686,7 @@ impl UdpSocket { Ok(raw as u32) } - pub fn set_multicast_hlim_v6(&self, limit: i32) -> io::Result<()> { + pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS, limit as c_int) } From c60ab7bf60851e1942ced51e57015b8eadc5ff75 Mon Sep 17 00:00:00 2001 From: Fausto Date: Sat, 5 Mar 2022 16:09:03 -0500 Subject: [PATCH 3/7] add noop methods for other sys --- library/std/src/sys/hermit/net.rs | 48 +++++++++++++++++++++++++ library/std/src/sys/sgx/net.rs | 50 ++++++++++++++++++++++++++ library/std/src/sys/unix/l4re.rs | 48 +++++++++++++++++++++++++ library/std/src/sys/unsupported/net.rs | 48 +++++++++++++++++++++++++ library/std/src/sys/wasi/net.rs | 48 +++++++++++++++++++++++++ 5 files changed, 242 insertions(+) diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index f65fd8e53bdc9..b34963dc749fb 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -209,6 +209,22 @@ impl TcpStream { .map_err(|_| io::const_io_error!(ErrorKind::Uncategorized, "unable to get TTL")) } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unsupported() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unsupported() + } + pub fn take_error(&self) -> io::Result> { unsupported() } @@ -266,6 +282,22 @@ impl TcpListener { unsupported() } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unsupported() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unsupported() + } + pub fn set_only_v6(&self, _: bool) -> io::Result<()> { unsupported() } @@ -392,6 +424,22 @@ impl UdpSocket { unsupported() } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unsupported() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unsupported() + } + pub fn take_error(&self) -> io::Result> { unsupported() } diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index d14990c6877af..f92a5f48952a8 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -11,6 +11,8 @@ use crate::time::Duration; use super::abi::usercalls; const DEFAULT_FAKE_TTL: u32 = 64; +const DEFAULT_FAKE_HLIM: u32 = 64; + #[derive(Debug, Clone)] pub struct Socket { @@ -207,6 +209,22 @@ impl TcpStream { sgx_ineffective(DEFAULT_FAKE_TTL) } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + sgx_ineffective(()) + } + + pub fn hop_limit_v6(&self) -> io::Result { + sgx_ineffective(DEFAULT_FAKE_HLIM) + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + sgx_ineffective(()) + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + sgx_ineffective(DEFAULT_FAKE_HLIM) + } + pub fn take_error(&self) -> io::Result> { Ok(None) } @@ -283,6 +301,22 @@ impl TcpListener { sgx_ineffective(DEFAULT_FAKE_TTL) } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + sgx_ineffective(()) + } + + pub fn hop_limit_v6(&self) -> io::Result { + sgx_ineffective(DEFAULT_FAKE_HLIM) + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + sgx_ineffective(()) + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + sgx_ineffective(DEFAULT_FAKE_HLIM) + } + pub fn set_only_v6(&self, _: bool) -> io::Result<()> { sgx_ineffective(()) } @@ -421,6 +455,22 @@ impl UdpSocket { self.0 } + pub fn set_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + self.0 + } + + pub fn hop_limit_v6(&self) -> io::Result { + self.0 + } + + pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + self.0 + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + self.0 + } + pub fn take_error(&self) -> io::Result> { self.0 } diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs index d13e1ecbbfed4..665f589344bdd 100644 --- a/library/std/src/sys/unix/l4re.rs +++ b/library/std/src/sys/unix/l4re.rs @@ -242,6 +242,22 @@ pub mod net { unimpl!(); } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unimpl!() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unimpl!() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unimpl!() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unimpl!() + } + pub fn ttl(&self) -> io::Result { unimpl!(); } @@ -304,6 +320,22 @@ pub mod net { unimpl!(); } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unimpl!() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unimpl!() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unimpl!() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unimpl!() + } + pub fn set_only_v6(&self, _: bool) -> io::Result<()> { unimpl!(); } @@ -446,6 +478,22 @@ pub mod net { unimpl!(); } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unimpl!() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unimpl!() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unimpl!() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unimpl!() + } + pub fn take_error(&self) -> io::Result> { unimpl!(); } diff --git a/library/std/src/sys/unsupported/net.rs b/library/std/src/sys/unsupported/net.rs index dbb6ce22c22de..9e969a00369b3 100644 --- a/library/std/src/sys/unsupported/net.rs +++ b/library/std/src/sys/unsupported/net.rs @@ -100,6 +100,22 @@ impl TcpStream { self.0 } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + self.0 + } + + pub fn hop_limit_v6(&self) -> io::Result { + self.0 + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + self.0 + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + self.0 + } + pub fn take_error(&self) -> io::Result> { self.0 } @@ -142,6 +158,22 @@ impl TcpListener { self.0 } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + self.0 + } + + pub fn hop_limit_v6(&self) -> io::Result { + self.0 + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + self.0 + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + self.0 + } + pub fn set_only_v6(&self, _: bool) -> io::Result<()> { self.0 } @@ -268,6 +300,22 @@ impl UdpSocket { self.0 } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + self.0 + } + + pub fn hop_limit_v6(&self) -> io::Result { + self.0 + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + self.0 + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + self.0 + } + pub fn take_error(&self) -> io::Result> { self.0 } diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index c66e0e4d328ad..c320e0b9eec63 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -152,6 +152,22 @@ impl TcpStream { unsupported() } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unsupported() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unsupported() + } + pub fn take_error(&self) -> io::Result> { unsupported() } @@ -234,6 +250,22 @@ impl TcpListener { unsupported() } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unsupported() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unsupported() + } + pub fn set_only_v6(&self, _: bool) -> io::Result<()> { unsupported() } @@ -403,6 +435,22 @@ impl UdpSocket { unsupported() } + pub fn set_hop_limit_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn hop_limit_v6(&self) -> io::Result { + unsupported() + } + + pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + unsupported() + } + + pub fn multicast_hlim_v6(&self) -> io::Result { + unsupported() + } + pub fn take_error(&self) -> io::Result> { unsupported() } From 090c1c93ba4c895f6c8bb08b8ffeeaa60cf761dc Mon Sep 17 00:00:00 2001 From: Fausto Date: Sat, 5 Mar 2022 16:15:19 -0500 Subject: [PATCH 4/7] add unicast and multicast hop limit option for windows --- library/std/src/sys/windows/c.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index 9b61b2476d5bb..d30dfbc7d7165 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -215,6 +215,8 @@ pub const IPPROTO_TCP: c_int = 6; pub const IPPROTO_IPV6: c_int = 41; pub const TCP_NODELAY: c_int = 0x0001; pub const IP_TTL: c_int = 4; +pub const IPV6_UNICAST_HOPS: c_int = 4; +pub const IPV6_MULTICAST_HOPS: c_int = 10; pub const IPV6_V6ONLY: c_int = 27; pub const SO_ERROR: c_int = 0x1007; pub const SO_BROADCAST: c_int = 0x0020; From 6d0d29e17ceee90c056121dd9b85a7aafef135fb Mon Sep 17 00:00:00 2001 From: Fausto Date: Sun, 6 Mar 2022 13:19:06 -0500 Subject: [PATCH 5/7] cleanup - remove whitespace --- library/std/src/sys/sgx/net.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index f92a5f48952a8..e2e67292faa77 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -13,7 +13,6 @@ use super::abi::usercalls; const DEFAULT_FAKE_TTL: u32 = 64; const DEFAULT_FAKE_HLIM: u32 = 64; - #[derive(Debug, Clone)] pub struct Socket { inner: Arc, From 36096cfd2bc61a2e5b50d0a8b76df728f314b469 Mon Sep 17 00:00:00 2001 From: Fausto Date: Sun, 6 Mar 2022 13:49:35 -0500 Subject: [PATCH 6/7] fix broken intra doc links --- library/std/src/net/tcp.rs | 8 ++++---- library/std/src/net/udp.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index e58ac3a747832..c0fc4a38a5d8b 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -562,7 +562,7 @@ impl TcpStream { /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// For more information about this option, see [`TcpStream::set_hop_limit_v6`]. /// /// # Examples /// @@ -602,7 +602,7 @@ impl TcpStream { /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// For more information about this option, see [`TcpStream::set_multicast_hlim_v6`]. /// /// # Examples /// @@ -1015,7 +1015,7 @@ impl TcpListener { /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// For more information about this option, see [`TcpListener::set_hop_limit_v6`]. /// /// # Examples /// @@ -1053,7 +1053,7 @@ impl TcpListener { /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// For more information about this option, see [`TcpListener::set_multicast_hlim_v6`]. /// /// # Examples /// diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 2ff09457af515..11f8a97fd6368 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -575,7 +575,7 @@ impl UdpSocket { /// Gets the value of the `IPV6_UNICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// For more information about this option, see [`UdpSocket::set_hop_limit_v6`]. /// /// # Examples /// @@ -613,7 +613,7 @@ impl UdpSocket { /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`UdpSocket::set_hop_limit_ipv6`]. + /// For more information about this option, see [`UdpSocket::set_multicast_hlim_v6`]. /// /// # Examples /// From b3e9e948846331dd1dd757acbe0d8dccfb34ca20 Mon Sep 17 00:00:00 2001 From: Fausto Date: Tue, 8 Mar 2022 12:20:17 -0500 Subject: [PATCH 7/7] rename multicast methods --- library/std/src/net/tcp.rs | 32 +++++++++++++------------- library/std/src/net/udp.rs | 16 ++++++------- library/std/src/sys/hermit/net.rs | 12 +++++----- library/std/src/sys/sgx/net.rs | 12 +++++----- library/std/src/sys/unix/l4re.rs | 12 +++++----- library/std/src/sys/unsupported/net.rs | 12 +++++----- library/std/src/sys/wasi/net.rs | 12 +++++----- library/std/src/sys_common/net.rs | 12 +++++----- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index c0fc4a38a5d8b..ac84c95cfa4c2 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -593,16 +593,16 @@ impl TcpStream { /// /// let stream = TcpStream::connect("127.0.0.1:54321") /// .expect("Couldn't connect to the server..."); - /// stream.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); + /// stream.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed"); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { - self.0.set_multicast_hlim_v6(limit) + pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + self.0.set_multicast_hop_limit_v6(limit) } /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`TcpStream::set_multicast_hlim_v6`]. + /// For more information about this option, see [`TcpStream::set_multicast_hop_limit_v6`]. /// /// # Examples /// @@ -612,12 +612,12 @@ impl TcpStream { /// /// let stream = TcpStream::connect("127.0.0.1:54321") /// .expect("Couldn't connect to the server..."); - /// stream.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); - /// assert_eq!(stream.multicast_hlim_v6().unwrap(), 88); + /// stream.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed"); + /// assert_eq!(stream.multicast_hop_limit_v6().unwrap(), 88); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn multicast_hlim_v6(&self) -> io::Result { - self.0.multicast_hlim_v6() + pub fn multicast_hop_limit_v6(&self) -> io::Result { + self.0.multicast_hop_limit_v6() } /// Gets the value of the `SO_ERROR` option on this socket. @@ -1044,16 +1044,16 @@ impl TcpListener { /// use std::net::TcpListener; /// /// let listener = TcpListener::bind("127.0.0.1:54321").unwrap(); - /// listener.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); + /// listener.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed"); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { - self.0.set_multicast_hlim_v6(limit) + pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + self.0.set_multicast_hop_limit_v6(limit) } /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`TcpListener::set_multicast_hlim_v6`]. + /// For more information about this option, see [`TcpListener::set_multicast_hop_limit_v6`]. /// /// # Examples /// @@ -1062,12 +1062,12 @@ impl TcpListener { /// use std::net::TcpListener; /// /// let listener = TcpListener::bind("127.0.0.1:54321").unwrap(); - /// listener.set_multicast_hlim_v6(88).expect("set_hop_limit_v6 call failed"); - /// assert_eq!(listener.multicast_hlim_v6().unwrap(), 88); + /// listener.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed"); + /// assert_eq!(listener.multicast_hop_limit_v6().unwrap(), 88); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn multicast_hlim_v6(&self) -> io::Result { - self.0.multicast_hlim_v6() + pub fn multicast_hop_limit_v6(&self) -> io::Result { + self.0.multicast_hop_limit_v6() } #[stable(feature = "net2_mutators", since = "1.9.0")] diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 11f8a97fd6368..52335ce7ed30a 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -604,16 +604,16 @@ impl UdpSocket { /// use std::net::UdpSocket; /// /// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address"); - /// socket.set_multicast_hlim_v6(88).expect("set_multicast_hlim_v6 call failed"); + /// socket.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed"); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { - self.0.set_multicast_hlim_v6(limit) + pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> { + self.0.set_multicast_hop_limit_v6(limit) } /// Gets the value of the `IPV6_MULTICAST_HOPS` option on this socket. /// - /// For more information about this option, see [`UdpSocket::set_multicast_hlim_v6`]. + /// For more information about this option, see [`UdpSocket::set_multicast_hop_limit_v6`]. /// /// # Examples /// @@ -622,12 +622,12 @@ impl UdpSocket { /// use std::net::UdpSocket; /// /// let socket = UdpSocket::bind("127.0.0.1:54321").expect("couldn't bind to address"); - /// socket.set_multicast_hlim_v6(88).expect("set_multicast_hlim_v6 call failed"); - /// assert_eq!(socket.multicast_hlim_v6().unwrap(), 88); + /// socket.set_multicast_hop_limit_v6(88).expect("set_multicast_hop_limit_v6 call failed"); + /// assert_eq!(socket.multicast_hop_limit_v6().unwrap(), 88); /// ``` #[unstable(feature = "ipv6_hop_limit", issue = "47727")] - pub fn multicast_hlim_v6(&self) -> io::Result { - self.0.multicast_hlim_v6() + pub fn multicast_hop_limit_v6(&self) -> io::Result { + self.0.multicast_hop_limit_v6() } /// Executes an operation of the `IP_ADD_MEMBERSHIP` type. diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs index b34963dc749fb..f53841aa14a0a 100644 --- a/library/std/src/sys/hermit/net.rs +++ b/library/std/src/sys/hermit/net.rs @@ -217,11 +217,11 @@ impl TcpStream { unsupported() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unsupported() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unsupported() } @@ -290,11 +290,11 @@ impl TcpListener { unsupported() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unsupported() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unsupported() } @@ -432,11 +432,11 @@ impl UdpSocket { unsupported() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unsupported() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unsupported() } diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs index e2e67292faa77..5622a7fc874de 100644 --- a/library/std/src/sys/sgx/net.rs +++ b/library/std/src/sys/sgx/net.rs @@ -216,11 +216,11 @@ impl TcpStream { sgx_ineffective(DEFAULT_FAKE_HLIM) } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { sgx_ineffective(()) } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { sgx_ineffective(DEFAULT_FAKE_HLIM) } @@ -308,11 +308,11 @@ impl TcpListener { sgx_ineffective(DEFAULT_FAKE_HLIM) } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { sgx_ineffective(()) } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { sgx_ineffective(DEFAULT_FAKE_HLIM) } @@ -462,11 +462,11 @@ impl UdpSocket { self.0 } - pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> { self.0 } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { self.0 } diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs index 665f589344bdd..cd9292d5a7039 100644 --- a/library/std/src/sys/unix/l4re.rs +++ b/library/std/src/sys/unix/l4re.rs @@ -250,11 +250,11 @@ pub mod net { unimpl!() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unimpl!() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unimpl!() } @@ -328,11 +328,11 @@ pub mod net { unimpl!() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unimpl!() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unimpl!() } @@ -486,11 +486,11 @@ pub mod net { unimpl!() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unimpl!() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unimpl!() } diff --git a/library/std/src/sys/unsupported/net.rs b/library/std/src/sys/unsupported/net.rs index 9e969a00369b3..d79f506bbd496 100644 --- a/library/std/src/sys/unsupported/net.rs +++ b/library/std/src/sys/unsupported/net.rs @@ -108,11 +108,11 @@ impl TcpStream { self.0 } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { self.0 } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { self.0 } @@ -166,11 +166,11 @@ impl TcpListener { self.0 } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { self.0 } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { self.0 } @@ -308,11 +308,11 @@ impl UdpSocket { self.0 } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { self.0 } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { self.0 } diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index c320e0b9eec63..2c15d84926833 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -160,11 +160,11 @@ impl TcpStream { unsupported() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unsupported() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unsupported() } @@ -258,11 +258,11 @@ impl TcpListener { unsupported() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unsupported() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unsupported() } @@ -443,11 +443,11 @@ impl UdpSocket { unsupported() } - pub fn set_multicast_hlim_v6(&self, _: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, _: u32) -> io::Result<()> { unsupported() } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { unsupported() } diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs index 513f3fbe20b2c..a14b2ab2366cd 100644 --- a/library/std/src/sys_common/net.rs +++ b/library/std/src/sys_common/net.rs @@ -346,11 +346,11 @@ impl TcpStream { Ok(raw as u32) } - pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> { setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS, limit as c_int) } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS)?; Ok(raw as u32) } @@ -464,11 +464,11 @@ impl TcpListener { Ok(raw as u32) } - pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> { setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS, limit as c_int) } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS)?; Ok(raw as u32) } @@ -686,11 +686,11 @@ impl UdpSocket { Ok(raw as u32) } - pub fn set_multicast_hlim_v6(&self, limit: u32) -> io::Result<()> { + pub fn set_multicast_hop_limit_v6(&self, limit: u32) -> io::Result<()> { setsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS, limit as c_int) } - pub fn multicast_hlim_v6(&self) -> io::Result { + pub fn multicast_hop_limit_v6(&self) -> io::Result { let raw: c_int = getsockopt(&self.inner, c::IPPROTO_IPV6, c::IPV6_MULTICAST_HOPS)?; Ok(raw as u32) }