diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/rustix/src/net | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/net')
-rw-r--r-- | vendor/rustix/src/net/addr.rs | 4 | ||||
-rw-r--r-- | vendor/rustix/src/net/ip.rs | 12 | ||||
-rw-r--r-- | vendor/rustix/src/net/mod.rs | 14 | ||||
-rw-r--r-- | vendor/rustix/src/net/socket.rs | 10 | ||||
-rw-r--r-- | vendor/rustix/src/net/socket_addr_any.rs | 22 | ||||
-rw-r--r-- | vendor/rustix/src/net/sockopt.rs | 68 |
6 files changed, 112 insertions, 18 deletions
diff --git a/vendor/rustix/src/net/addr.rs b/vendor/rustix/src/net/addr.rs index af9e51a8a..ca87298e9 100644 --- a/vendor/rustix/src/net/addr.rs +++ b/vendor/rustix/src/net/addr.rs @@ -1,14 +1,12 @@ //! The following is derived from Rust's //! library/std/src/net/socket_addr.rs at revision -//! f7e8ba28a4785e698a55fb95e4b3e803302de0ff. +//! bd20fc1fd657b32f7aa1d70d8723f04c87f21606. //! //! All code in this file is licensed MIT or Apache 2.0 at your option. //! //! This defines `SocketAddr`, `SocketAddrV4`, and `SocketAddrV6` in a //! platform-independent way. It is not the native representation. -#![allow(unsafe_code)] - use crate::net::ip::{IpAddr, Ipv4Addr, Ipv6Addr}; use core::cmp::Ordering; use core::hash; diff --git a/vendor/rustix/src/net/ip.rs b/vendor/rustix/src/net/ip.rs index 4d921cc10..ffa5302e3 100644 --- a/vendor/rustix/src/net/ip.rs +++ b/vendor/rustix/src/net/ip.rs @@ -1,6 +1,6 @@ //! The following is derived from Rust's //! library/std/src/net/ip_addr.rs at revision -//! 14230a7f8e117aa049d3ae661fa00ded7edefc68. +//! bd20fc1fd657b32f7aa1d70d8723f04c87f21606. //! //! All code in this file is licensed MIT or Apache 2.0 at your option. //! @@ -1200,6 +1200,7 @@ impl Ipv6Addr { rustc_const_stable(feature = "const_ip_32", since = "1.32.0") )] #[cfg_attr(staged_api, stable(feature = "rust1", since = "1.0.0"))] + #[allow(clippy::too_many_arguments)] #[must_use] #[inline] pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr { @@ -1222,6 +1223,9 @@ impl Ipv6Addr { /// An IPv6 address representing localhost: `::1`. /// + /// This corresponds to constant `IN6ADDR_LOOPBACK_INIT` or `in6addr_loopback` in other + /// languages. + /// /// # Examples /// /// ``` @@ -1230,11 +1234,15 @@ impl Ipv6Addr { /// let addr = Ipv6Addr::LOCALHOST; /// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)); /// ``` + #[doc(alias = "IN6ADDR_LOOPBACK_INIT")] + #[doc(alias = "in6addr_loopback")] #[cfg_attr(staged_api, stable(feature = "ip_constructors", since = "1.30.0"))] pub const LOCALHOST: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1); /// An IPv6 address representing the unspecified address: `::` /// + /// This corresponds to constant `IN6ADDR_ANY_INIT` or `in6addr_any` in other languages. + /// /// # Examples /// /// ``` @@ -1243,6 +1251,8 @@ impl Ipv6Addr { /// let addr = Ipv6Addr::UNSPECIFIED; /// assert_eq!(addr, Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)); /// ``` + #[doc(alias = "IN6ADDR_ANY_INIT")] + #[doc(alias = "in6addr_any")] #[cfg_attr(staged_api, stable(feature = "ip_constructors", since = "1.30.0"))] pub const UNSPECIFIED: Self = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0); diff --git a/vendor/rustix/src/net/mod.rs b/vendor/rustix/src/net/mod.rs index 24fe06dc3..4a3419737 100644 --- a/vendor/rustix/src/net/mod.rs +++ b/vendor/rustix/src/net/mod.rs @@ -4,8 +4,8 @@ //! of these APIs. [`wsa_cleanup`] may be used in the process if these APIs are //! no longer needed. //! -//! [`wsa_startup`]: https://docs.rs/rustix/latest/x86_64-pc-windows-msvc/rustix/net/fn.wsa_startup.html -//! [`wsa_cleanup`]: https://docs.rs/rustix/latest/x86_64-pc-windows-msvc/rustix/net/fn.wsa_cleanup.html +//! [`wsa_startup`]: https://docs.rs/rustix/*/x86_64-pc-windows-msvc/rustix/net/fn.wsa_startup.html +//! [`wsa_cleanup`]: https://docs.rs/rustix/*/x86_64-pc-windows-msvc/rustix/net/fn.wsa_cleanup.html #[cfg(not(feature = "std"))] mod addr; @@ -21,14 +21,8 @@ mod wsa; pub mod sockopt; -pub use send_recv::{ - recv, recvfrom, send, sendto, sendto_any, sendto_v4, sendto_v6, RecvFlags, SendFlags, -}; -pub use socket::{ - accept, accept_with, acceptfrom, acceptfrom_with, bind, bind_any, bind_v4, bind_v6, connect, - connect_any, connect_v4, connect_v6, getpeername, getsockname, listen, shutdown, socket, - socket_with, AcceptFlags, AddressFamily, Protocol, Shutdown, SocketFlags, SocketType, -}; +pub use send_recv::*; +pub use socket::*; pub use socket_addr_any::{SocketAddrAny, SocketAddrStorage}; #[cfg(not(any(windows, target_os = "wasi")))] pub use socketpair::socketpair; diff --git a/vendor/rustix/src/net/socket.rs b/vendor/rustix/src/net/socket.rs index 687022afe..5840d39ff 100644 --- a/vendor/rustix/src/net/socket.rs +++ b/vendor/rustix/src/net/socket.rs @@ -19,8 +19,10 @@ impl Default for Protocol { /// `socket(domain, type_, protocol)`—Creates a socket. /// /// POSIX guarantees that `socket` will use the lowest unused file descriptor, -/// however it is not safe in general to rely on this, as file descriptors -/// may be unexpectedly allocated on other threads or in libraries. +/// however it is not safe in general to rely on this, as file descriptors may +/// be unexpectedly allocated on other threads or in libraries. +/// +/// To pass extra flags such as [`SocketFlags::CLOEXEC`], use [`socket_with`]. /// /// # References /// - [POSIX] @@ -41,8 +43,8 @@ pub fn socket(domain: AddressFamily, type_: SocketType, protocol: Protocol) -> i /// flags. /// /// POSIX guarantees that `socket` will use the lowest unused file descriptor, -/// however it is not safe in general to rely on this, as file descriptors -/// may be unexpectedly allocated on other threads or in libraries. +/// however it is not safe in general to rely on this, as file descriptors may +/// be unexpectedly allocated on other threads or in libraries. /// /// `socket_with` is the same as [`socket`] but adds an additional flags /// operand. diff --git a/vendor/rustix/src/net/socket_addr_any.rs b/vendor/rustix/src/net/socket_addr_any.rs index 287c6c1ee..403ad11c2 100644 --- a/vendor/rustix/src/net/socket_addr_any.rs +++ b/vendor/rustix/src/net/socket_addr_any.rs @@ -32,6 +32,28 @@ pub enum SocketAddrAny { Unix(SocketAddrUnix), } +impl From<SocketAddrV4> for SocketAddrAny { + #[inline] + fn from(from: SocketAddrV4) -> Self { + Self::V4(from) + } +} + +impl From<SocketAddrV6> for SocketAddrAny { + #[inline] + fn from(from: SocketAddrV6) -> Self { + Self::V6(from) + } +} + +#[cfg(unix)] +impl From<SocketAddrUnix> for SocketAddrAny { + #[inline] + fn from(from: SocketAddrUnix) -> Self { + Self::Unix(from) + } +} + impl SocketAddrAny { /// Return the address family of this socket address. #[inline] diff --git a/vendor/rustix/src/net/sockopt.rs b/vendor/rustix/src/net/sockopt.rs index 436d5bf86..ffdc67942 100644 --- a/vendor/rustix/src/net/sockopt.rs +++ b/vendor/rustix/src/net/sockopt.rs @@ -226,6 +226,28 @@ pub fn get_socket_timeout<Fd: AsFd>(fd: Fd, id: Timeout) -> io::Result<Option<Du backend::net::syscalls::sockopt::get_socket_timeout(fd.as_fd(), id) } +/// `getsockopt(fd, SOL_SOCKET, SO_ERROR)` +/// +/// # References +/// - [POSIX `getsockopt`] +/// - [POSIX `sys/socket.h`] +/// - [Linux `getsockopt`] +/// - [Linux `socket`] +/// - [Winsock2 `getsockopt`] +/// - [Winsock2 `SOL_SOCKET` options] +/// +/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html +/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html +/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html +/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html +/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt +/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options +#[inline] +#[doc(alias = "SO_ERROR")] +pub fn get_socket_error<Fd: AsFd>(fd: Fd) -> io::Result<Result<(), crate::io::Errno>> { + backend::net::syscalls::sockopt::get_socket_error(fd.as_fd()) +} + /// `setsockopt(fd, IPPROTO_IP, IP_TTL, ttl)` /// /// # References @@ -642,3 +664,49 @@ pub fn set_tcp_nodelay<Fd: AsFd>(fd: Fd, nodelay: bool) -> io::Result<()> { pub fn get_tcp_nodelay<Fd: AsFd>(fd: Fd) -> io::Result<bool> { backend::net::syscalls::sockopt::get_tcp_nodelay(fd.as_fd()) } + +/// `getsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE)` +/// +/// # References +/// - [POSIX `getsockopt`] +/// - [POSIX `netinet/tcp.h`] +/// - [Linux `getsockopt`] +/// - [Linux `tcp`] +/// - [Winsock2 `getsockopt`] +/// - [Winsock2 `IPPROTO_TCP` options] +/// +/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html +/// [POSIX `netinet/tcp.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_tcp.h.html +/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html +/// [Linux `tcp`]: https://man7.org/linux/man-pages/man7/tcp.7.html +/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt +/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options +#[cfg(any(apple, target_os = "freebsd"))] +#[doc(alias = "SO_NOSIGPIPE")] +#[inline] +pub fn getsockopt_nosigpipe<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::syscalls::sockopt::getsockopt_nosigpipe(fd.as_fd()) +} + +/// `setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, val)` +/// +/// # References +/// - [POSIX `getsockopt`] +/// - [POSIX `netinet/tcp.h`] +/// - [Linux `getsockopt`] +/// - [Linux `tcp`] +/// - [Winsock2 `getsockopt`] +/// - [Winsock2 `IPPROTO_TCP` options] +/// +/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html +/// [POSIX `netinet/tcp.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_tcp.h.html +/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html +/// [Linux `tcp`]: https://man7.org/linux/man-pages/man7/tcp.7.html +/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt +/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options +#[cfg(any(apple, target_os = "freebsd"))] +#[doc(alias = "SO_NOSIGPIPE")] +#[inline] +pub fn setsockopt_nosigpipe<Fd: AsFd>(fd: Fd, val: bool) -> io::Result<()> { + backend::net::syscalls::sockopt::setsockopt_nosigpipe(fd.as_fd(), val) +} |