diff options
Diffstat (limited to 'vendor/rustix/src/net')
-rw-r--r-- | vendor/rustix/src/net/send_recv/mod.rs | 16 | ||||
-rw-r--r-- | vendor/rustix/src/net/send_recv/msg.rs | 110 | ||||
-rw-r--r-- | vendor/rustix/src/net/socket.rs | 38 | ||||
-rw-r--r-- | vendor/rustix/src/net/socket_addr_any.rs | 12 | ||||
-rw-r--r-- | vendor/rustix/src/net/sockopt.rs | 2653 | ||||
-rw-r--r-- | vendor/rustix/src/net/types.rs | 173 |
6 files changed, 1295 insertions, 1707 deletions
diff --git a/vendor/rustix/src/net/send_recv/mod.rs b/vendor/rustix/src/net/send_recv/mod.rs index 1dedd99cb..a377f65ad 100644 --- a/vendor/rustix/src/net/send_recv/mod.rs +++ b/vendor/rustix/src/net/send_recv/mod.rs @@ -8,10 +8,22 @@ use backend::fd::{AsFd, BorrowedFd}; pub use backend::net::send_recv::{RecvFlags, SendFlags}; -#[cfg(not(any(windows, target_os = "espidf", target_os = "redox", target_os = "wasi")))] +#[cfg(not(any( + windows, + target_os = "espidf", + target_os = "redox", + target_os = "vita", + target_os = "wasi" +)))] mod msg; -#[cfg(not(any(windows, target_os = "espidf", target_os = "redox", target_os = "wasi")))] +#[cfg(not(any( + windows, + target_os = "espidf", + target_os = "redox", + target_os = "vita", + target_os = "wasi" +)))] pub use msg::*; /// `recv(fd, buf, flags)`—Reads data from a socket. diff --git a/vendor/rustix/src/net/send_recv/msg.rs b/vendor/rustix/src/net/send_recv/msg.rs index 431aefa03..ea91cbfec 100644 --- a/vendor/rustix/src/net/send_recv/msg.rs +++ b/vendor/rustix/src/net/send_recv/msg.rs @@ -5,10 +5,14 @@ use crate::backend::{self, c}; use crate::fd::{AsFd, BorrowedFd, OwnedFd}; use crate::io::{self, IoSlice, IoSliceMut}; +#[cfg(linux_kernel)] +use crate::net::UCred; use core::iter::FusedIterator; use core::marker::PhantomData; -use core::mem::{size_of, size_of_val, take}; +use core::mem::{align_of, size_of, size_of_val, take}; +#[cfg(linux_kernel)] +use core::ptr::addr_of; use core::{ptr, slice}; use super::{RecvFlags, SendFlags, SocketAddrAny, SocketAddrV4, SocketAddrV6}; @@ -22,6 +26,11 @@ macro_rules! cmsg_space { $len * ::core::mem::size_of::<$crate::fd::BorrowedFd<'static>>(), ) }; + (ScmCredentials($len:expr)) => { + $crate::net::__cmsg_space( + $len * ::core::mem::size_of::<$crate::net::UCred>(), + ) + }; // Combo Rules (($($($x:tt)*),+)) => { @@ -33,8 +42,19 @@ macro_rules! cmsg_space { } #[doc(hidden)] -pub fn __cmsg_space(len: usize) -> usize { - unsafe { c::CMSG_SPACE(len.try_into().expect("CMSG_SPACE size overflow")) as usize } +pub const fn __cmsg_space(len: usize) -> usize { + // Add `align_of::<c::cmsghdr>()` so that we can align the user-provided + // `&[u8]` to the required alignment boundary. + let len = len + align_of::<c::cmsghdr>(); + + // Convert `len` to `u32` for `CMSG_SPACE`. This would be `try_into()` if + // we could call that in a `const fn`. + let converted_len = len as u32; + if converted_len as usize != len { + unreachable!(); // `CMSG_SPACE` size overflow + } + + unsafe { c::CMSG_SPACE(converted_len) as usize } } /// Ancillary message for [`sendmsg`], [`sendmsg_v4`], [`sendmsg_v6`], @@ -42,24 +62,23 @@ pub fn __cmsg_space(len: usize) -> usize { #[non_exhaustive] pub enum SendAncillaryMessage<'slice, 'fd> { /// Send file descriptors. + #[doc(alias = "SCM_RIGHTS")] ScmRights(&'slice [BorrowedFd<'fd>]), + /// Send process credentials. + #[cfg(linux_kernel)] + #[doc(alias = "SCM_CREDENTIAL")] + ScmCredentials(UCred), } impl SendAncillaryMessage<'_, '_> { /// Get the maximum size of an ancillary message. /// /// This can be helpful in determining the size of the buffer you allocate. - pub fn size(&self) -> usize { - let total_bytes = match self { - Self::ScmRights(slice) => size_of_val(*slice), - }; - - unsafe { - c::CMSG_SPACE( - total_bytes - .try_into() - .expect("size too large for CMSG_SPACE"), - ) as usize + pub const fn size(&self) -> usize { + match self { + Self::ScmRights(slice) => cmsg_space!(ScmRights(slice.len())), + #[cfg(linux_kernel)] + Self::ScmCredentials(_) => cmsg_space!(ScmCredentials(1)), } } } @@ -68,10 +87,16 @@ impl SendAncillaryMessage<'_, '_> { #[non_exhaustive] pub enum RecvAncillaryMessage<'a> { /// Received file descriptors. + #[doc(alias = "SCM_RIGHTS")] ScmRights(AncillaryIter<'a, OwnedFd>), + /// Received process credentials. + #[cfg(linux_kernel)] + #[doc(alias = "SCM_CREDENTIALS")] + ScmCredentials(UCred), } -/// Buffer for sending ancillary messages. +/// Buffer for sending ancillary messages with [`sendmsg`], [`sendmsg_v4`], +/// [`sendmsg_v6`], [`sendmsg_unix`], and [`sendmsg_any`]. pub struct SendAncillaryBuffer<'buf, 'slice, 'fd> { /// Raw byte buffer for messages. buffer: &'buf mut [u8], @@ -91,15 +116,20 @@ impl<'buf> From<&'buf mut [u8]> for SendAncillaryBuffer<'buf, '_, '_> { impl Default for SendAncillaryBuffer<'_, '_, '_> { fn default() -> Self { - Self::new(&mut []) + Self { + buffer: &mut [], + length: 0, + _phantom: PhantomData, + } } } impl<'buf, 'slice, 'fd> SendAncillaryBuffer<'buf, 'slice, 'fd> { /// Create a new, empty `SendAncillaryBuffer` from a raw byte buffer. + #[inline] pub fn new(buffer: &'buf mut [u8]) -> Self { Self { - buffer, + buffer: align_for_cmsghdr(buffer), length: 0, _phantom: PhantomData, } @@ -138,6 +168,13 @@ impl<'buf, 'slice, 'fd> SendAncillaryBuffer<'buf, 'slice, 'fd> { unsafe { slice::from_raw_parts(fds.as_ptr().cast::<u8>(), size_of_val(fds)) }; self.push_ancillary(fds_bytes, c::SOL_SOCKET as _, c::SCM_RIGHTS as _) } + #[cfg(linux_kernel)] + SendAncillaryMessage::ScmCredentials(ucred) => { + let ucred_bytes = unsafe { + slice::from_raw_parts(addr_of!(ucred).cast::<u8>(), size_of_val(&ucred)) + }; + self.push_ancillary(ucred_bytes, c::SOL_SOCKET as _, c::SCM_CREDENTIALS as _) + } } } @@ -191,7 +228,8 @@ impl<'slice, 'fd> Extend<SendAncillaryMessage<'slice, 'fd>> } } -/// Buffer for receiving ancillary messages. +/// Buffer for receiving ancillary messages with [`recvmsg`]. +#[derive(Default)] pub struct RecvAncillaryBuffer<'buf> { /// Raw byte buffer for messages. buffer: &'buf mut [u8], @@ -209,17 +247,12 @@ impl<'buf> From<&'buf mut [u8]> for RecvAncillaryBuffer<'buf> { } } -impl Default for RecvAncillaryBuffer<'_> { - fn default() -> Self { - Self::new(&mut []) - } -} - impl<'buf> RecvAncillaryBuffer<'buf> { /// Create a new, empty `RecvAncillaryBuffer` from a raw byte buffer. + #[inline] pub fn new(buffer: &'buf mut [u8]) -> Self { Self { - buffer, + buffer: align_for_cmsghdr(buffer), read: 0, length: 0, } @@ -274,7 +307,17 @@ impl Drop for RecvAncillaryBuffer<'_> { } } -/// An iterator that drains messages from a `RecvAncillaryBuffer`. +/// Return a slice of `buffer` starting at the first `cmsghdr` alignment +/// boundary. +#[inline] +fn align_for_cmsghdr(buffer: &mut [u8]) -> &mut [u8] { + let align = align_of::<c::cmsghdr>(); + let addr = buffer.as_ptr() as usize; + let adjusted = (addr + (align - 1)) & align.wrapping_neg(); + &mut buffer[adjusted - addr..] +} + +/// An iterator that drains messages from a [`RecvAncillaryBuffer`]. pub struct AncillaryDrain<'buf> { /// Inner iterator over messages. messages: messages::Messages<'buf>, @@ -287,14 +330,14 @@ pub struct AncillaryDrain<'buf> { } impl<'buf> AncillaryDrain<'buf> { - /// A closure that converts a message into a `RecvAncillaryMessage`. + /// A closure that converts a message into a [`RecvAncillaryMessage`]. fn cvt_msg( read: &mut usize, length: &mut usize, msg: &c::cmsghdr, ) -> Option<RecvAncillaryMessage<'buf>> { unsafe { - // Advance the "read" pointer. + // Advance the `read` pointer. let msg_len = msg.cmsg_len as usize; *read += msg_len; *length -= msg_len; @@ -315,6 +358,15 @@ impl<'buf> AncillaryDrain<'buf> { Some(RecvAncillaryMessage::ScmRights(fds)) } + #[cfg(linux_kernel)] + (c::SOL_SOCKET, c::SCM_CREDENTIALS) => { + if payload_len >= size_of::<UCred>() { + let ucred = payload.as_ptr().cast::<UCred>().read_unaligned(); + Some(RecvAncillaryMessage::ScmCredentials(ucred)) + } else { + None + } + } _ => None, } } @@ -693,7 +745,7 @@ mod messages { /// An iterator over the messages in an ancillary buffer. pub(super) struct Messages<'buf> { - /// The message header we're using to iterator over the messages. + /// The message header we're using to iterate over the messages. msghdr: c::msghdr, /// The current pointer to the next message header to return. diff --git a/vendor/rustix/src/net/socket.rs b/vendor/rustix/src/net/socket.rs index 8727ca53b..fe7439562 100644 --- a/vendor/rustix/src/net/socket.rs +++ b/vendor/rustix/src/net/socket.rs @@ -453,6 +453,44 @@ pub fn connect_unix<Fd: AsFd>(sockfd: Fd, addr: &SocketAddrUnix) -> io::Result<( backend::net::syscalls::connect_unix(sockfd.as_fd(), addr) } +/// `connect(sockfd, {.sa_family = AF_UNSPEC}, sizeof(struct sockaddr))` +/// — Dissolve the socket's association. +/// +/// On UDP sockets, BSD platforms report [`Errno::AFNOSUPPORT`] or +/// [`Errno::INVAL`] even if the disconnect was successful. +/// +/// # References +/// - [Beej's Guide to Network Programming] +/// - [POSIX] +/// - [Linux] +/// - [Apple] +/// - [Winsock2] +/// - [FreeBSD] +/// - [NetBSD] +/// - [OpenBSD] +/// - [DragonFly BSD] +/// - [illumos] +/// - [glibc] +/// +/// [Beej's Guide to Network Programming]: https://beej.us/guide/bgnet/html/split/system-calls-or-bust.html#connect +/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html +/// [Linux]: https://man7.org/linux/man-pages/man2/connect.2.html +/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/connect.2.html +/// [Winsock2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect +/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=connect&sektion=2 +/// [NetBSD]: https://man.netbsd.org/connect.2 +/// [OpenBSD]: https://man.openbsd.org/connect.2 +/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=connect§ion=2 +/// [illumos]: https://illumos.org/man/3SOCKET/connect +/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Connecting.html +/// [`Errno::AFNOSUPPORT`]: io::Errno::AFNOSUPPORT +/// [`Errno::INVAL`]: io::Errno::INVAL +#[inline] +#[doc(alias = "connect")] +pub fn connect_unspec<Fd: AsFd>(sockfd: Fd) -> io::Result<()> { + backend::net::syscalls::connect_unspec(sockfd.as_fd()) +} + /// `listen(fd, backlog)`—Enables listening for incoming connections. /// /// # References diff --git a/vendor/rustix/src/net/socket_addr_any.rs b/vendor/rustix/src/net/socket_addr_any.rs index 7cb124e4c..a649015f4 100644 --- a/vendor/rustix/src/net/socket_addr_any.rs +++ b/vendor/rustix/src/net/socket_addr_any.rs @@ -11,7 +11,7 @@ #[cfg(unix)] use crate::net::SocketAddrUnix; -use crate::net::{AddressFamily, SocketAddrV4, SocketAddrV6}; +use crate::net::{AddressFamily, SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::{backend, io}; #[cfg(feature = "std")] use core::fmt; @@ -32,6 +32,16 @@ pub enum SocketAddrAny { Unix(SocketAddrUnix), } +impl From<SocketAddr> for SocketAddrAny { + #[inline] + fn from(from: SocketAddr) -> Self { + match from { + SocketAddr::V4(v4) => Self::V4(v4), + SocketAddr::V6(v6) => Self::V6(v6), + } + } +} + impl From<SocketAddrV4> for SocketAddrAny { #[inline] fn from(from: SocketAddrV4) -> Self { diff --git a/vendor/rustix/src/net/sockopt.rs b/vendor/rustix/src/net/sockopt.rs index 1939155d9..afeaf0b33 100644 --- a/vendor/rustix/src/net/sockopt.rs +++ b/vendor/rustix/src/net/sockopt.rs @@ -1,7 +1,144 @@ //! `getsockopt` and `setsockopt` functions. //! -//! In the rustix API, there is a separate function for each option, so that -//! it can be given an option-specific type signature. +//! In the rustix API, there is a separate function for each option, so that it +//! can be given an option-specific type signature. +//! +//! # References for all `get_*` functions: +//! +//! - [POSIX `getsockopt`] +//! - [Linux `getsockopt`] +//! - [Winsock2 `getsockopt`] +//! - [Apple `getsockopt`] +//! - [FreeBSD `getsockopt`] +//! - [NetBSD `getsockopt`] +//! - [OpenBSD `getsockopt`] +//! - [DragonFly BSD `getsockopt`] +//! - [illumos `getsockopt`] +//! - [glibc `getsockopt`] +//! +//! [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html +//! [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html +//! [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt +//! [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html +//! [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 +//! [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 +//! [OpenBSD `getsockopt`]: https://man.openbsd.org/getsockopt.2 +//! [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 +//! [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt +//! [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html +//! +//! # References for all `set_*` functions: +//! +//! - [POSIX `setsockopt`] +//! - [Linux `setsockopt`] +//! - [Winsock2 `setsockopt`] +//! - [Apple `setsockopt`] +//! - [FreeBSD `setsockopt`] +//! - [NetBSD `setsockopt`] +//! - [OpenBSD `setsockopt`] +//! - [DragonFly BSD `setsockopt`] +//! - [illumos `setsockopt`] +//! - [glibc `setsockopt`] +//! +//! [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html +//! [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html +//! [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt +//! [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html +//! [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 +//! [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 +//! [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 +//! [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 +//! [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt +//! [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html +//! +//! # References for `get_socket_*` and `set_socket_*` functions: +//! +//! - [References for all `get_*` functions] +//! - [References for all `set_*` functions] +//! - [POSIX `sys/socket.h`] +//! - [Linux `socket`] +//! - [Winsock2 `SOL_SOCKET` options] +//! - [glibc `SOL_SOCKET` Options] +//! +//! [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html +//! [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html +//! [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options +//! [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +//! +//! # References for `get_ip_*` and `set_ip_*` functions: +//! +//! - [References for all `get_*` functions] +//! - [References for all `set_*` functions] +//! - [POSIX `netinet/in.h`] +//! - [Linux `ip`] +//! - [Winsock2 `IPPROTO_IP` options] +//! - [Apple `ip`] +//! - [FreeBSD `ip`] +//! - [NetBSD `ip`] +//! - [OpenBSD `ip`] +//! - [DragonFly BSD `ip`] +//! - [illumos `ip`] +//! +//! [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html +//! [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html +//! [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options +//! [Apple `ip`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip.4.auto.html +//! [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4 +//! [NetBSD `ip`]: https://man.netbsd.org/ip.4 +//! [OpenBSD `ip`]: https://man.openbsd.org/ip.4 +//! [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4 +//! [illumos `ip`]: https://illumos.org/man/4P/ip +//! +//! # References for `get_ipv6_*` and `set_ipv6_*` functions: +//! +//! - [References for all `get_*` functions] +//! - [References for all `set_*` functions] +//! - [POSIX `netinet/in.h`] +//! - [Linux `ipv6`] +//! - [Winsock2 `IPPROTO_IPV6` options] +//! - [Apple `ip6`] +//! - [FreeBSD `ip6`] +//! - [NetBSD `ip6`] +//! - [OpenBSD `ip6`] +//! - [DragonFly BSD `ip6`] +//! - [illumos `ip6`] +//! +//! [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html +//! [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html +//! [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options +//! [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html +//! [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 +//! [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 +//! [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 +//! [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 +//! [illumos `ip6`]: https://illumos.org/man/4P/ip6 +//! +//! # References for `get_tcp_*` and `set_tcp_*` functions: +//! +//! - [References for all `get_*` functions] +//! - [References for all `set_*` functions] +//! - [POSIX `netinet/tcp.h`] +//! - [Linux `tcp`] +//! - [Winsock2 `IPPROTO_TCP` options] +//! - [Apple `tcp`] +//! - [FreeBSD `tcp`] +//! - [NetBSD `tcp`] +//! - [OpenBSD `tcp`] +//! - [DragonFly BSD `tcp`] +//! - [illumos `tcp`] +//! +//! [POSIX `netinet/tcp.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_tcp.h.html +//! [Linux `tcp`]: https://man7.org/linux/man-pages/man7/tcp.7.html +//! [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options +//! [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html +//! [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 +//! [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 +//! [OpenBSD `tcp`]: https://man.openbsd.org/tcp.4 +//! [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 +//! [illumos `tcp`]: https://illumos.org/man/4P/tcp +//! +//! [References for all `get_*` functions]: #references-for-all-get_-functions +//! [References for all `set_*` functions]: #references-for-all-set_-functions #![doc(alias = "getsockopt")] #![doc(alias = "setsockopt")] @@ -16,19 +153,38 @@ target_os = "haiku", target_os = "netbsd", target_os = "nto", + target_os = "vita", )))] use crate::net::AddressFamily; +#[cfg(any( + linux_kernel, + target_os = "freebsd", + target_os = "fuchsia", + target_os = "openbsd", + target_os = "redox", + target_env = "newlib" +))] +use crate::net::Protocol; +#[cfg(any(linux_kernel, target_os = "fuchsia"))] +use crate::net::SocketAddrV4; +#[cfg(linux_kernel)] +use crate::net::SocketAddrV6; use crate::net::{Ipv4Addr, Ipv6Addr, SocketType}; use crate::{backend, io}; +#[cfg(feature = "alloc")] +#[cfg(any( + linux_like, + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos" +))] +use alloc::string::String; use backend::c; use backend::fd::AsFd; use core::time::Duration; /// Timeout identifier for use with [`set_socket_timeout`] and /// [`get_socket_timeout`]. -/// -/// [`set_socket_timeout`]: crate::net::sockopt::set_socket_timeout. -/// [`get_socket_timeout`]: crate::net::sockopt::get_socket_timeout. #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] #[repr(u32)] pub enum Timeout { @@ -41,759 +197,241 @@ pub enum Timeout { /// `getsockopt(fd, SOL_SOCKET, SO_TYPE)`—Returns the type of a socket. /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_TYPE")] pub fn get_socket_type<Fd: AsFd>(fd: Fd) -> io::Result<SocketType> { - backend::net::syscalls::sockopt::get_socket_type(fd.as_fd()) + backend::net::sockopt::get_socket_type(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, value)` +/// `setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, value)`—Set whether local +/// addresses may be reused in `bind`. /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_REUSEADDR")] pub fn set_socket_reuseaddr<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_reuseaddr(fd.as_fd(), value) + backend::net::sockopt::set_socket_reuseaddr(fd.as_fd(), value) } /// `getsockopt(fd, SOL_SOCKET, SO_REUSEADDR)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_REUSEADDR")] pub fn get_socket_reuseaddr<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_socket_reuseaddr(fd.as_fd()) + backend::net::sockopt::get_socket_reuseaddr(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, SO_BROADCAST, broadcast)` +/// `setsockopt(fd, SOL_SOCKET, SO_BROADCAST, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_BROADCAST")] -pub fn set_socket_broadcast<Fd: AsFd>(fd: Fd, broadcast: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_broadcast(fd.as_fd(), broadcast) +pub fn set_socket_broadcast<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_socket_broadcast(fd.as_fd(), value) } /// `getsockopt(fd, SOL_SOCKET, SO_BROADCAST)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_BROADCAST")] pub fn get_socket_broadcast<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_socket_broadcast(fd.as_fd()) + backend::net::sockopt::get_socket_broadcast(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, SO_LINGER, linger)` +/// `setsockopt(fd, SOL_SOCKET, SO_LINGER, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_LINGER")] -pub fn set_socket_linger<Fd: AsFd>(fd: Fd, linger: Option<Duration>) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_linger(fd.as_fd(), linger) +pub fn set_socket_linger<Fd: AsFd>(fd: Fd, value: Option<Duration>) -> io::Result<()> { + backend::net::sockopt::set_socket_linger(fd.as_fd(), value) } /// `getsockopt(fd, SOL_SOCKET, SO_LINGER)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_LINGER")] pub fn get_socket_linger<Fd: AsFd>(fd: Fd) -> io::Result<Option<Duration>> { - backend::net::syscalls::sockopt::get_socket_linger(fd.as_fd()) + backend::net::sockopt::get_socket_linger(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, SO_PASSCRED, passcred)` +/// `setsockopt(fd, SOL_SOCKET, SO_PASSCRED, value)` /// -/// # References -/// - [Linux `setsockopt`] -/// - [Linux `socket`] +/// See the [module-level documentation] for more. /// -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[cfg(linux_kernel)] #[inline] #[doc(alias = "SO_PASSCRED")] -pub fn set_socket_passcred<Fd: AsFd>(fd: Fd, passcred: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_passcred(fd.as_fd(), passcred) +pub fn set_socket_passcred<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_socket_passcred(fd.as_fd(), value) } /// `getsockopt(fd, SOL_SOCKET, SO_PASSCRED)` /// -/// # References -/// - [Linux `getsockopt`] -/// - [Linux `socket`] +/// See the [module-level documentation] for more. /// -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[cfg(linux_kernel)] #[inline] #[doc(alias = "SO_PASSCRED")] pub fn get_socket_passcred<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_socket_passcred(fd.as_fd()) + backend::net::sockopt::get_socket_passcred(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, id, timeout)`—Set the sending or receiving +/// `setsockopt(fd, SOL_SOCKET, id, value)`—Set the sending or receiving /// timeout. /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_RCVTIMEO")] #[doc(alias = "SO_SNDTIMEO")] pub fn set_socket_timeout<Fd: AsFd>( fd: Fd, id: Timeout, - timeout: Option<Duration>, + value: Option<Duration>, ) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_timeout(fd.as_fd(), id, timeout) + backend::net::sockopt::set_socket_timeout(fd.as_fd(), id, value) } /// `getsockopt(fd, SOL_SOCKET, id)`—Get the sending or receiving timeout. /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_RCVTIMEO")] #[doc(alias = "SO_SNDTIMEO")] pub fn get_socket_timeout<Fd: AsFd>(fd: Fd, id: Timeout) -> io::Result<Option<Duration>> { - backend::net::syscalls::sockopt::get_socket_timeout(fd.as_fd(), id) + backend::net::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] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_ERROR")] pub fn get_socket_error<Fd: AsFd>(fd: Fd) -> io::Result<Result<(), io::Errno>> { - backend::net::syscalls::sockopt::get_socket_error(fd.as_fd()) + backend::net::sockopt::get_socket_error(fd.as_fd()) } /// `getsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html -#[cfg(any(apple, target_os = "freebsd"))] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(any(apple, freebsdlike, target_os = "netbsd"))] #[doc(alias = "SO_NOSIGPIPE")] #[inline] pub fn get_socket_nosigpipe<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_socket_nosigpipe(fd.as_fd()) + backend::net::sockopt::get_socket_nosigpipe(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, val)` +/// `setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html -#[cfg(any(apple, target_os = "freebsd"))] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(any(apple, freebsdlike, target_os = "netbsd"))] #[doc(alias = "SO_NOSIGPIPE")] #[inline] -pub fn set_socket_nosigpipe<Fd: AsFd>(fd: Fd, val: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_nosigpipe(fd.as_fd(), val) +pub fn set_socket_nosigpipe<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_socket_nosigpipe(fd.as_fd(), value) } -/// `setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, keepalive)` +/// `setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_KEEPALIVE")] -pub fn set_socket_keepalive<Fd: AsFd>(fd: Fd, keepalive: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_keepalive(fd.as_fd(), keepalive) +pub fn set_socket_keepalive<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_socket_keepalive(fd.as_fd(), value) } /// `getsockopt(fd, SOL_SOCKET, SO_KEEPALIVE)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_KEEPALIVE")] pub fn get_socket_keepalive<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_socket_keepalive(fd.as_fd()) + backend::net::sockopt::get_socket_keepalive(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, SO_RCVBUF, size)` +/// `setsockopt(fd, SOL_SOCKET, SO_RCVBUF, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_RCVBUF")] -pub fn set_socket_recv_buffer_size<Fd: AsFd>(fd: Fd, size: usize) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_recv_buffer_size(fd.as_fd(), size) +pub fn set_socket_recv_buffer_size<Fd: AsFd>(fd: Fd, value: usize) -> io::Result<()> { + backend::net::sockopt::set_socket_recv_buffer_size(fd.as_fd(), value) } /// `getsockopt(fd, SOL_SOCKET, SO_RCVBUF)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_RCVBUF")] pub fn get_socket_recv_buffer_size<Fd: AsFd>(fd: Fd) -> io::Result<usize> { - backend::net::syscalls::sockopt::get_socket_recv_buffer_size(fd.as_fd()) + backend::net::sockopt::get_socket_recv_buffer_size(fd.as_fd()) } -/// `setsockopt(fd, SOL_SOCKET, SO_SNDBUF, size)` +/// `setsockopt(fd, SOL_SOCKET, SO_SNDBUF, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `setsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `setsockopt`] -/// - [glibc `SOL_SOCKET` Options] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `sys/socket.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `socket`]: https://man7.org/linux/man-pages/man7/socket.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `SOL_SOCKET` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/sol-socket-socket-options -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/setsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/setsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/setsockopt -/// [glibc `setsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_SNDBUF")] -pub fn set_socket_send_buffer_size<Fd: AsFd>(fd: Fd, size: usize) -> io::Result<()> { - backend::net::syscalls::sockopt::set_socket_send_buffer_size(fd.as_fd(), size) +pub fn set_socket_send_buffer_size<Fd: AsFd>(fd: Fd, value: usize) -> io::Result<()> { + backend::net::sockopt::set_socket_send_buffer_size(fd.as_fd(), value) } /// `getsockopt(fd, SOL_SOCKET, SO_SNDBUF)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "SO_SNDBUF")] pub fn get_socket_send_buffer_size<Fd: AsFd>(fd: Fd) -> io::Result<usize> { - backend::net::syscalls::sockopt::get_socket_send_buffer_size(fd.as_fd()) + backend::net::sockopt::get_socket_send_buffer_size(fd.as_fd()) } /// `getsockopt(fd, SOL_SOCKET, SO_DOMAIN)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [Apple] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[cfg(not(any( apple, windows, @@ -804,709 +442,314 @@ pub fn get_socket_send_buffer_size<Fd: AsFd>(fd: Fd) -> io::Result<usize> { target_os = "haiku", target_os = "netbsd", target_os = "nto", + target_os = "vita", )))] #[inline] #[doc(alias = "SO_DOMAIN")] pub fn get_socket_domain<Fd: AsFd>(fd: Fd) -> io::Result<AddressFamily> { - backend::net::syscalls::sockopt::get_socket_domain(fd.as_fd()) + backend::net::sockopt::get_socket_domain(fd.as_fd()) } /// `getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `sys/socket.h`] -/// - [Linux `getsockopt`] -/// - [Linux `socket`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `SOL_SOCKET` options] -/// - [FreeBSD] -/// - [NetBSD] -/// - [OpenBSD] -/// - [DragonFly BSD] -/// - [illumos] -/// - [glibc `getsockopt`] -/// - [glibc `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 -/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [NetBSD]: https://man.netbsd.org/getsockopt.2 -/// [OpenBSD]: https://man.openbsd.org/getsockopt.2 -/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [illumos]: https://illumos.org/man/3SOCKET/getsockopt -/// [glibc `getsockopt`]: https://www.gnu.org/software/libc/manual/html_node/Socket-Option-Functions.html -/// [glibc `SOL_SOCKET` options]: https://www.gnu.org/software/libc/manual/html_node/Socket_002dLevel-Options.html +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[cfg(not(apple))] // Apple platforms declare the constant, but do not actually implement it. #[inline] #[doc(alias = "SO_ACCEPTCONN")] pub fn get_socket_acceptconn<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_socket_acceptconn(fd.as_fd()) + backend::net::sockopt::get_socket_acceptconn(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_IP, IP_TTL, ttl)` +/// `setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `setsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip`]: https://man.netbsd.org/ip.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip`]: https://man.openbsd.org/ip.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip`]: https://illumos.org/man/4P/ip +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[inline] +#[doc(alias = "SO_OOBINLINE")] +pub fn set_socket_oobinline<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_socket_oobinline(fd.as_fd(), value) +} + +/// `getsockopt(fd, SOL_SOCKET, SO_OOBINLINE)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[inline] +#[doc(alias = "SO_OOBINLINE")] +pub fn get_socket_oobinline<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_socket_oobinline(fd.as_fd()) +} + +/// `setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(not(any(solarish, windows)))] +#[cfg(not(windows))] +#[inline] +#[doc(alias = "SO_REUSEPORT")] +pub fn set_socket_reuseport<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_socket_reuseport(fd.as_fd(), value) +} + +/// `getsockopt(fd, SOL_SOCKET, SO_REUSEPORT)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(not(any(solarish, windows)))] +#[inline] +#[doc(alias = "SO_REUSEPORT")] +pub fn get_socket_reuseport<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_socket_reuseport(fd.as_fd()) +} + +/// `setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(target_os = "freebsd")] +#[inline] +#[doc(alias = "SO_REUSEPORT_LB")] +pub fn set_socket_reuseport_lb<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_socket_reuseport_lb(fd.as_fd(), value) +} + +/// `getsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(target_os = "freebsd")] +#[inline] +#[doc(alias = "SO_REUSEPORT_LB")] +pub fn get_socket_reuseport_lb<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_socket_reuseport_lb(fd.as_fd()) +} + +/// `getsockopt(fd, SOL_SOCKET, SO_PROTOCOL)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(any( + linux_kernel, + target_os = "freebsd", + target_os = "fuchsia", + target_os = "openbsd", + target_os = "redox", + target_env = "newlib" +))] +#[inline] +#[doc(alias = "SO_PROTOCOL")] +pub fn get_socket_protocol<Fd: AsFd>(fd: Fd) -> io::Result<Option<Protocol>> { + backend::net::sockopt::get_socket_protocol(fd.as_fd()) +} + +/// `getsockopt(fd, SOL_SOCKET, SO_COOKIE)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(target_os = "linux")] +#[inline] +#[doc(alias = "SO_COOKIE")] +pub fn get_socket_cookie<Fd: AsFd>(fd: Fd) -> io::Result<u64> { + backend::net::sockopt::get_socket_cookie(fd.as_fd()) +} + +/// `getsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(target_os = "linux")] +#[inline] +#[doc(alias = "SO_INCOMING_CPU")] +pub fn get_socket_incoming_cpu<Fd: AsFd>(fd: Fd) -> io::Result<u32> { + backend::net::sockopt::get_socket_incoming_cpu(fd.as_fd()) +} + +/// `setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions +#[cfg(target_os = "linux")] +#[inline] +#[doc(alias = "SO_INCOMING_CPU")] +pub fn set_socket_incoming_cpu<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> { + backend::net::sockopt::set_socket_incoming_cpu(fd.as_fd(), value) +} + +/// `setsockopt(fd, IPPROTO_IP, IP_TTL, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_socket_-and-set_socket_-functions #[inline] #[doc(alias = "IP_TTL")] -pub fn set_ip_ttl<Fd: AsFd>(fd: Fd, ttl: u32) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ip_ttl(fd.as_fd(), ttl) +pub fn set_ip_ttl<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> { + backend::net::sockopt::set_ip_ttl(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_IP, IP_TTL)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `getsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `getsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `getsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip`]: https://man.netbsd.org/ip.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip`]: https://man.openbsd.org/ip.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip`]: https://illumos.org/man/4P/ip +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions #[inline] #[doc(alias = "IP_TTL")] pub fn get_ip_ttl<Fd: AsFd>(fd: Fd) -> io::Result<u32> { - backend::net::syscalls::sockopt::get_ip_ttl(fd.as_fd()) + backend::net::sockopt::get_ip_ttl(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, only_v6)` +/// `setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `setsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] #[doc(alias = "IPV6_V6ONLY")] -pub fn set_ipv6_v6only<Fd: AsFd>(fd: Fd, only_v6: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ipv6_v6only(fd.as_fd(), only_v6) +pub fn set_ipv6_v6only<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_ipv6_v6only(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `getsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `getsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `getsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `getsockopt`]: https://man.openbsd.org/getsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] #[doc(alias = "IPV6_V6ONLY")] pub fn get_ipv6_v6only<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_ipv6_v6only(fd.as_fd()) + backend::net::sockopt::get_ipv6_v6only(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, multicast_loop)` +/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `setsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip`]: https://man.netbsd.org/ip.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip`]: https://man.openbsd.org/ip.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip`]: https://illumos.org/man/4P/ip +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions #[inline] #[doc(alias = "IP_MULTICAST_LOOP")] -pub fn set_ip_multicast_loop<Fd: AsFd>(fd: Fd, multicast_loop: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ip_multicast_loop(fd.as_fd(), multicast_loop) +pub fn set_ip_multicast_loop<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_ip_multicast_loop(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `getsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `getsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `getsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions #[inline] #[doc(alias = "IP_MULTICAST_LOOP")] pub fn get_ip_multicast_loop<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_ip_multicast_loop(fd.as_fd()) + backend::net::sockopt::get_ip_multicast_loop(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, multicast_ttl)` +/// `setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `setsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip`]: https://man.netbsd.org/ip.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip`]: https://man.openbsd.org/ip.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip`]: https://illumos.org/man/4P/ip +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions #[inline] #[doc(alias = "IP_MULTICAST_TTL")] -pub fn set_ip_multicast_ttl<Fd: AsFd>(fd: Fd, multicast_ttl: u32) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ip_multicast_ttl(fd.as_fd(), multicast_ttl) +pub fn set_ip_multicast_ttl<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> { + backend::net::sockopt::set_ip_multicast_ttl(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `getsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `getsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `getsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions #[inline] #[doc(alias = "IP_MULTICAST_TTL")] pub fn get_ip_multicast_ttl<Fd: AsFd>(fd: Fd) -> io::Result<u32> { - backend::net::syscalls::sockopt::get_ip_multicast_ttl(fd.as_fd()) + backend::net::sockopt::get_ip_multicast_ttl(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, multicast_loop)` +/// `setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `setsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] #[doc(alias = "IPV6_MULTICAST_LOOP")] -pub fn set_ipv6_multicast_loop<Fd: AsFd>(fd: Fd, multicast_loop: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ipv6_multicast_loop(fd.as_fd(), multicast_loop) +pub fn set_ipv6_multicast_loop<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_ipv6_multicast_loop(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `getsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `getsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `getsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `getsockopt`]: https://man.openbsd.org/getsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] #[doc(alias = "IPV6_MULTICAST_LOOP")] pub fn get_ipv6_multicast_loop<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_ipv6_multicast_loop(fd.as_fd()) + backend::net::sockopt::get_ipv6_multicast_loop(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, multicast_hops)` +/// `getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `setsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] -#[doc(alias = "IP_MULTICAST_TTL")] -pub fn set_ipv6_multicast_hops<Fd: AsFd>(fd: Fd, multicast_hops: u32) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ipv6_multicast_hops(fd.as_fd(), multicast_hops) +#[doc(alias = "IPV6_UNICAST_HOPS")] +pub fn get_ipv6_unicast_hops<Fd: AsFd>(fd: Fd) -> io::Result<u8> { + backend::net::sockopt::get_ipv6_unicast_hops(fd.as_fd()) } -/// `getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS)` +/// `setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, value)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `getsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `getsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `getsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `getsockopt`]: https://man.openbsd.org/getsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] #[doc(alias = "IPV6_UNICAST_HOPS")] -pub fn get_ipv6_unicast_hops<Fd: AsFd>(fd: Fd) -> io::Result<u8> { - backend::net::syscalls::sockopt::get_ipv6_unicast_hops(fd.as_fd()) +pub fn set_ipv6_unicast_hops<Fd: AsFd>(fd: Fd, value: Option<u8>) -> io::Result<()> { + backend::net::sockopt::set_ipv6_unicast_hops(fd.as_fd(), value) } -/// `setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, unicast_hops)` +/// `setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `setsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] -#[doc(alias = "IPV6_UNICAST_HOPS")] -pub fn set_ipv6_unicast_hops<Fd: AsFd>(fd: Fd, unicast_hops: Option<u8>) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ipv6_unicast_hops(fd.as_fd(), unicast_hops) +#[doc(alias = "IPV6_MULTICAST_HOPS")] +pub fn set_ipv6_multicast_hops<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> { + backend::net::sockopt::set_ipv6_multicast_hops(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `getsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `getsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `getsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `getsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `getsockopt`]: https://man7.org/linux/man-pages/man2/getsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `getsockopt`]: https://man.openbsd.org/getsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] -#[doc(alias = "IP_MULTICAST_TTL")] +#[doc(alias = "IPV6_MULTICAST_HOPS")] pub fn get_ipv6_multicast_hops<Fd: AsFd>(fd: Fd) -> io::Result<u32> { - backend::net::syscalls::sockopt::get_ipv6_multicast_hops(fd.as_fd()) + backend::net::sockopt::get_ipv6_multicast_hops(fd.as_fd()) } /// `setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, multiaddr, interface)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `setsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip`]: https://man.netbsd.org/ip.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip`]: https://man.openbsd.org/ip.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip`]: https://illumos.org/man/4P/ip +/// This is similar to [`set_ip_add_membership`] but always sets `ifindex` +/// value to zero. +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions #[inline] #[doc(alias = "IP_ADD_MEMBERSHIP")] pub fn set_ip_add_membership<Fd: AsFd>( @@ -1514,51 +757,90 @@ pub fn set_ip_add_membership<Fd: AsFd>( multiaddr: &Ipv4Addr, interface: &Ipv4Addr, ) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ip_add_membership(fd.as_fd(), multiaddr, interface) + backend::net::sockopt::set_ip_add_membership(fd.as_fd(), multiaddr, interface) +} + +/// `setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, multiaddr, address, +/// ifindex)` +/// +/// This is similar to [`set_ip_add_membership_with_ifindex`] but additionally +/// allows a `ifindex` value to be given. +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any( + apple, + freebsdlike, + linux_like, + target_os = "fuchsia", + target_os = "openbsd" +))] +#[inline] +#[doc(alias = "IP_ADD_MEMBERSHIP")] +pub fn set_ip_add_membership_with_ifindex<Fd: AsFd>( + fd: Fd, + multiaddr: &Ipv4Addr, + address: &Ipv4Addr, + ifindex: i32, +) -> io::Result<()> { + backend::net::sockopt::set_ip_add_membership_with_ifindex( + fd.as_fd(), + multiaddr, + address, + ifindex, + ) +} + +/// `setsockopt(fd, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any(apple, freebsdlike, linux_like, solarish, target_os = "aix"))] +#[inline] +#[doc(alias = "IP_ADD_SOURCE_MEMBERSHIP")] +pub fn set_ip_add_source_membership<Fd: AsFd>( + fd: Fd, + multiaddr: &Ipv4Addr, + interface: &Ipv4Addr, + sourceaddr: &Ipv4Addr, +) -> io::Result<()> { + backend::net::sockopt::set_ip_add_source_membership( + fd.as_fd(), + multiaddr, + interface, + sourceaddr, + ) +} + +/// `setsockopt(fd, IPPROTO_IP, IP_DROP_SOURCE_MEMBERSHIP, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any(apple, freebsdlike, linux_like, solarish, target_os = "aix"))] +#[inline] +#[doc(alias = "IP_DROP_SOURCE_MEMBERSHIP")] +pub fn set_ip_drop_source_membership<Fd: AsFd>( + fd: Fd, + multiaddr: &Ipv4Addr, + interface: &Ipv4Addr, + sourceaddr: &Ipv4Addr, +) -> io::Result<()> { + backend::net::sockopt::set_ip_drop_source_membership( + fd.as_fd(), + multiaddr, + interface, + sourceaddr, + ) } /// `setsockopt(fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, multiaddr, interface)` /// -/// `IPV6_ADD_MEMBERSHIP` is the same as `IPV6_JOIN_GROUP` in POSIX. +/// See the [module-level documentation] for more. /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `setsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] #[doc(alias = "IPV6_JOIN_GROUP")] #[doc(alias = "IPV6_ADD_MEMBERSHIP")] @@ -1567,49 +849,17 @@ pub fn set_ipv6_add_membership<Fd: AsFd>( multiaddr: &Ipv6Addr, interface: u32, ) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ipv6_add_membership(fd.as_fd(), multiaddr, interface) + backend::net::sockopt::set_ipv6_add_membership(fd.as_fd(), multiaddr, interface) } /// `setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, multiaddr, interface)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ip`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IP` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip`] -/// - [illumos `setsockopt`] -/// - [illumos `ip`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ip`]: https://man7.org/linux/man-pages/man7/ip.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip`]: https://man.freebsd.org/cgi/man.cgi?query=ip&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip`]: https://man.netbsd.org/ip.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip`]: https://man.openbsd.org/ip.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip`]: https://man.dragonflybsd.org/?command=ip§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip`]: https://illumos.org/man/4P/ip +/// This is similar to [`set_ip_drop_membership`] but always sets `ifindex` +/// value to zero. +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions #[inline] #[doc(alias = "IP_DROP_MEMBERSHIP")] pub fn set_ip_drop_membership<Fd: AsFd>( @@ -1617,51 +867,45 @@ pub fn set_ip_drop_membership<Fd: AsFd>( multiaddr: &Ipv4Addr, interface: &Ipv4Addr, ) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ip_drop_membership(fd.as_fd(), multiaddr, interface) + backend::net::sockopt::set_ip_drop_membership(fd.as_fd(), multiaddr, interface) +} + +/// `setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, multiaddr, interface)` +/// +/// This is similar to [`set_ip_drop_membership_with_ifindex`] but additionally +/// allows a `ifindex` value to be given. +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any( + apple, + freebsdlike, + linux_like, + target_os = "fuchsia", + target_os = "openbsd" +))] +#[inline] +#[doc(alias = "IP_DROP_MEMBERSHIP")] +pub fn set_ip_drop_membership_with_ifindex<Fd: AsFd>( + fd: Fd, + multiaddr: &Ipv4Addr, + address: &Ipv4Addr, + ifindex: i32, +) -> io::Result<()> { + backend::net::sockopt::set_ip_drop_membership_with_ifindex( + fd.as_fd(), + multiaddr, + address, + ifindex, + ) } /// `setsockopt(fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, multiaddr, interface)` /// -/// `IPV6_DROP_MEMBERSHIP` is the same as `IPV6_LEAVE_GROUP` in POSIX. +/// See the [module-level documentation] for more. /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/in.h`] -/// - [Linux `setsockopt`] -/// - [Linux `ipv6`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_IPV6` options] -/// - [Apple `setsockopt`] -/// - [Apple `ip6`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `ip6`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `ip6`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `ip6`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `ip6`] -/// - [illumos `setsockopt`] -/// - [illumos `ip6`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/in.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.2.html -/// [Linux `ipv6`]: https://man7.org/linux/man-pages/man7/ipv6.7.html -/// [Winsock2 `setsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt -/// [Winsock2 `IPPROTO_IPV6` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `ip6`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/ip6.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `ip6`]: https://man.freebsd.org/cgi/man.cgi?query=ip6&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `ip6`]: https://man.netbsd.org/ip6.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `ip6`]: https://man.openbsd.org/ip6.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `ip6`]: https://man.dragonflybsd.org/?command=ip6§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `ip6`]: https://illumos.org/man/4P/ip6 +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions #[inline] #[doc(alias = "IPV6_LEAVE_GROUP")] #[doc(alias = "IPV6_DROP_MEMBERSHIP")] @@ -1670,361 +914,462 @@ pub fn set_ipv6_drop_membership<Fd: AsFd>( multiaddr: &Ipv6Addr, interface: u32, ) -> io::Result<()> { - backend::net::syscalls::sockopt::set_ipv6_drop_membership(fd.as_fd(), multiaddr, interface) + backend::net::sockopt::set_ipv6_drop_membership(fd.as_fd(), multiaddr, interface) } -/// `setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, nodelay)` +/// `setsockopt(fd, IPPROTO_IP, IP_TOS, value)` /// -/// # References -/// - [POSIX `setsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `setsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `setsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `setsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `setsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `setsockopt`] -/// - [NetBSD `tcp`] -/// - [OpenBSD `setsockopt`] -/// - [OpenBSD `tcp`] -/// - [DragonFly BSD `setsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `setsockopt`] -/// - [illumos `tcp`] -/// -/// [POSIX `setsockopt`]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html -/// [POSIX `netinet/tcp.h`]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_tcp.h.html -/// [Linux `setsockopt`]: https://man7.org/linux/man-pages/man2/setsockopt.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 -/// [Apple `setsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `setsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=setsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `setsockopt`]: https://man.netbsd.org/setsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [OpenBSD `setsockopt`]: https://man.openbsd.org/setsockopt.2 -/// [OpenBSD `tcp`]: https://man.openbsd.org/tcp.4 -/// [DragonFly BSD `setsockopt`]: https://man.dragonflybsd.org/?command=setsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `setsockopt`]: https://illumos.org/man/3SOCKET/setsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any( + bsd, + linux_like, + target_os = "aix", + target_os = "fuchsia", + target_os = "haiku", + target_os = "nto", + target_env = "newlib" +))] +#[inline] +#[doc(alias = "IP_TOS")] +pub fn set_ip_tos<Fd: AsFd>(fd: Fd, value: u8) -> io::Result<()> { + backend::net::sockopt::set_ip_tos(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_IP, IP_TOS)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any( + bsd, + linux_like, + target_os = "aix", + target_os = "fuchsia", + target_os = "haiku", + target_os = "nto", + target_env = "newlib" +))] +#[inline] +#[doc(alias = "IP_TOS")] +pub fn get_ip_tos<Fd: AsFd>(fd: Fd) -> io::Result<u8> { + backend::net::sockopt::get_ip_tos(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_IP, IP_RECVTOS, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))] +#[inline] +#[doc(alias = "IP_RECVTOS")] +pub fn set_ip_recvtos<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_ip_recvtos(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_IP, IP_RECVTOS)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ip_-and-set_ip_-functions +#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))] +#[inline] +#[doc(alias = "IP_RECVTOS")] +pub fn get_ip_recvtos<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_ip_recvtos(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_IPV6, IPV6_RECVTCLASS, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(any( + bsd, + linux_like, + target_os = "aix", + target_os = "fuchsia", + target_os = "nto" +))] +#[inline] +#[doc(alias = "IPV6_RECVTCLASS")] +pub fn set_ipv6_recvtclass<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_ipv6_recvtclass(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_IPV6, IPV6_RECVTCLASS)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(any( + bsd, + linux_like, + target_os = "aix", + target_os = "fuchsia", + target_os = "nto" +))] +#[inline] +#[doc(alias = "IPV6_RECVTCLASS")] +pub fn get_ipv6_recvtclass<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_ipv6_recvtclass(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_IP, IP_FREEBIND, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(any(linux_kernel, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "IP_FREEBIND")] +pub fn set_ip_freebind<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_ip_freebind(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_IP, IP_FREEBIND)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(any(linux_kernel, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "IP_FREEBIND")] +pub fn get_ip_freebind<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_ip_freebind(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_IPV6, IPV6_FREEBIND, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(linux_kernel)] +#[inline] +#[doc(alias = "IPV6_FREEBIND")] +pub fn set_ipv6_freebind<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_ipv6_freebind(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_IPV6, IPV6_FREEBIND)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(linux_kernel)] +#[inline] +#[doc(alias = "IPV6_FREEBIND")] +pub fn get_ipv6_freebind<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_ipv6_freebind(fd.as_fd()) +} + +/// `getsockopt(fd, IPPROTO_IP, SO_ORIGINAL_DST)` +/// +/// Even though this corresponnds to a `SO_*` constant, it is an `IPPROTO_IP` +/// option. +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(any(linux_kernel, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "SO_ORIGINAL_DST")] +pub fn get_ip_original_dst<Fd: AsFd>(fd: Fd) -> io::Result<SocketAddrV4> { + backend::net::sockopt::get_ip_original_dst(fd.as_fd()) +} + +/// `getsockopt(fd, IPPROTO_IPV6, IP6T_SO_ORIGINAL_DST)` +/// +/// Even though this corresponnds to a `IP6T_*` constant, it is an +/// `IPPROTO_IPV6` option. +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(linux_kernel)] +#[inline] +#[doc(alias = "IP6T_SO_ORIGINAL_DST")] +pub fn get_ipv6_original_dst<Fd: AsFd>(fd: Fd) -> io::Result<SocketAddrV6> { + backend::net::sockopt::get_ipv6_original_dst(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(not(any( + solarish, + windows, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" +)))] +#[inline] +#[doc(alias = "IPV6_TCLASS")] +pub fn set_ipv6_tclass<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> { + backend::net::sockopt::set_ipv6_tclass(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_ipv6_-and-set_ipv6_-functions +#[cfg(not(any( + solarish, + windows, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" +)))] +#[inline] +#[doc(alias = "IPV6_TCLASS")] +pub fn get_ipv6_tclass<Fd: AsFd>(fd: Fd) -> io::Result<u32> { + backend::net::sockopt::get_ipv6_tclass(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[inline] #[doc(alias = "TCP_NODELAY")] -pub fn set_tcp_nodelay<Fd: AsFd>(fd: Fd, nodelay: bool) -> io::Result<()> { - backend::net::syscalls::sockopt::set_tcp_nodelay(fd.as_fd(), nodelay) +pub fn set_tcp_nodelay<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_tcp_nodelay(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_TCP, TCP_NODELAY)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `getsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `getsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `tcp`] -/// - [OpenBSD `getsockopt`] -/// - [OpenBSD `tcp`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `getsockopt`] -/// - [illumos `tcp`] -/// -/// [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 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [OpenBSD `getsockopt`]: https://man.openbsd.org/getsockopt.2 -/// [OpenBSD `tcp`]: https://man.openbsd.org/tcp.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[inline] #[doc(alias = "TCP_NODELAY")] pub fn get_tcp_nodelay<Fd: AsFd>(fd: Fd) -> io::Result<bool> { - backend::net::syscalls::sockopt::get_tcp_nodelay(fd.as_fd()) + backend::net::sockopt::get_tcp_nodelay(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, count)` +/// `setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, value)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `getsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `getsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `tcp`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `getsockopt`] -/// - [illumos `tcp`] -/// -/// [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 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp -#[inline] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] +#[inline] #[doc(alias = "TCP_KEEPCNT")] -pub fn set_tcp_keepcnt<Fd: AsFd>(fd: Fd, count: u32) -> io::Result<()> { - backend::net::syscalls::sockopt::set_tcp_keepcnt(fd.as_fd(), count) +pub fn set_tcp_keepcnt<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> { + backend::net::sockopt::set_tcp_keepcnt(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `getsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `getsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `tcp`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `getsockopt`] -/// - [illumos `tcp`] -/// -/// [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 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp -#[inline] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] +#[inline] #[doc(alias = "TCP_KEEPCNT")] pub fn get_tcp_keepcnt<Fd: AsFd>(fd: Fd) -> io::Result<u32> { - backend::net::syscalls::sockopt::get_tcp_keepcnt(fd.as_fd()) + backend::net::sockopt::get_tcp_keepcnt(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, duration)` +/// `setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, value)` /// /// `TCP_KEEPALIVE` on Apple platforms. /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `getsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `getsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `tcp`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `getsockopt`] -/// - [illumos `tcp`] -/// -/// [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 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp -#[inline] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] +#[inline] #[doc(alias = "TCP_KEEPIDLE")] -pub fn set_tcp_keepidle<Fd: AsFd>(fd: Fd, duration: Duration) -> io::Result<()> { - backend::net::syscalls::sockopt::set_tcp_keepidle(fd.as_fd(), duration) +pub fn set_tcp_keepidle<Fd: AsFd>(fd: Fd, value: Duration) -> io::Result<()> { + backend::net::sockopt::set_tcp_keepidle(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE)` /// /// `TCP_KEEPALIVE` on Apple platforms. /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `getsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `getsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `tcp`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `getsockopt`] -/// - [illumos `tcp`] -/// -/// [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 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp -#[inline] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] +#[inline] #[doc(alias = "TCP_KEEPIDLE")] pub fn get_tcp_keepidle<Fd: AsFd>(fd: Fd) -> io::Result<Duration> { - backend::net::syscalls::sockopt::get_tcp_keepidle(fd.as_fd()) + backend::net::sockopt::get_tcp_keepidle(fd.as_fd()) } -/// `setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, duration)` +/// `setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, value)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `getsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `getsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `tcp`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `getsockopt`] -/// - [illumos `tcp`] -/// -/// [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 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp -#[inline] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] +#[inline] #[doc(alias = "TCP_KEEPINTVL")] -pub fn set_tcp_keepintvl<Fd: AsFd>(fd: Fd, duration: Duration) -> io::Result<()> { - backend::net::syscalls::sockopt::set_tcp_keepintvl(fd.as_fd(), duration) +pub fn set_tcp_keepintvl<Fd: AsFd>(fd: Fd, value: Duration) -> io::Result<()> { + backend::net::sockopt::set_tcp_keepintvl(fd.as_fd(), value) } /// `getsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL)` /// -/// # References -/// - [POSIX `getsockopt`] -/// - [POSIX `netinet/tcp.h`] -/// - [Linux `getsockopt`] -/// - [Linux `tcp`] -/// - [Winsock2 `getsockopt`] -/// - [Winsock2 `IPPROTO_TCP` options] -/// - [Apple `getsockopt`] -/// - [Apple `tcp`] -/// - [FreeBSD `getsockopt`] -/// - [FreeBSD `tcp`] -/// - [NetBSD `getsockopt`] -/// - [NetBSD `tcp`] -/// - [DragonFly BSD `getsockopt`] -/// - [DragonFly BSD `tcp`] -/// - [illumos `getsockopt`] -/// - [illumos `tcp`] -/// -/// [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 `getsockopt`]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt -/// [Winsock2 `IPPROTO_TCP` options]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options -/// [Apple `getsockopt`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getsockopt.2.html -/// [Apple `tcp`]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/man/man4/tcp.4.auto.html -/// [FreeBSD `getsockopt`]: https://man.freebsd.org/cgi/man.cgi?query=getsockopt&sektion=2 -/// [FreeBSD `tcp`]: https://man.freebsd.org/cgi/man.cgi?query=tcp&sektion=4 -/// [NetBSD `getsockopt`]: https://man.netbsd.org/getsockopt.2 -/// [NetBSD `tcp`]: https://man.netbsd.org/tcp.4 -/// [DragonFly BSD `getsockopt`]: https://man.dragonflybsd.org/?command=getsockopt§ion=2 -/// [DragonFly BSD `tcp`]: https://man.dragonflybsd.org/?command=tcp§ion=4 -/// [illumos `getsockopt`]: https://illumos.org/man/3SOCKET/getsockopt -/// [illumos `tcp`]: https://illumos.org/man/4P/tcp -#[inline] +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions #[cfg(not(any(target_os = "openbsd", target_os = "haiku", target_os = "nto")))] +#[inline] #[doc(alias = "TCP_KEEPINTVL")] pub fn get_tcp_keepintvl<Fd: AsFd>(fd: Fd) -> io::Result<Duration> { - backend::net::syscalls::sockopt::get_tcp_keepintvl(fd.as_fd()) + backend::net::sockopt::get_tcp_keepintvl(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_USER_TIMEOUT")] +pub fn set_tcp_user_timeout<Fd: AsFd>(fd: Fd, value: u32) -> io::Result<()> { + backend::net::sockopt::set_tcp_user_timeout(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_USER_TIMEOUT")] +pub fn get_tcp_user_timeout<Fd: AsFd>(fd: Fd) -> io::Result<u32> { + backend::net::sockopt::get_tcp_user_timeout(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_QUICKACK")] +pub fn set_tcp_quickack<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_tcp_quickack(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_TCP, TCP_QUICKACK)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_QUICKACK")] +pub fn get_tcp_quickack<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_tcp_quickack(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_TCP, TCP_CONGESTION, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any( + linux_like, + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos" +))] +#[inline] +#[doc(alias = "TCP_CONGESTION")] +pub fn set_tcp_congestion<Fd: AsFd>(fd: Fd, value: &str) -> io::Result<()> { + backend::net::sockopt::set_tcp_congestion(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_TCP, TCP_CONGESTION)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(feature = "alloc")] +#[cfg(any( + linux_like, + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos" +))] +#[inline] +#[doc(alias = "TCP_CONGESTION")] +pub fn get_tcp_congestion<Fd: AsFd>(fd: Fd) -> io::Result<String> { + backend::net::sockopt::get_tcp_congestion(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_THIN_LINEAR_TIMEOUTS")] +pub fn set_tcp_thin_linear_timeouts<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_tcp_thin_linear_timeouts(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_TCP, TCP_THIN_LINEAR_TIMEOUTS)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_THIN_LINEAR_TIMEOUTS")] +pub fn get_tcp_thin_linear_timeouts<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_tcp_thin_linear_timeouts(fd.as_fd()) +} + +/// `setsockopt(fd, IPPROTO_TCP, TCP_CORK, value)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, solarish, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_CORK")] +pub fn set_tcp_cork<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> { + backend::net::sockopt::set_tcp_cork(fd.as_fd(), value) +} + +/// `getsockopt(fd, IPPROTO_TCP, TCP_CORK)` +/// +/// See the [module-level documentation] for more. +/// +/// [module-level documentation]: self#references-for-get_tcp_-and-set_tcp_-functions +#[cfg(any(linux_like, solarish, target_os = "fuchsia"))] +#[inline] +#[doc(alias = "TCP_CORK")] +pub fn get_tcp_cork<Fd: AsFd>(fd: Fd) -> io::Result<bool> { + backend::net::sockopt::get_tcp_cork(fd.as_fd()) +} + +/// Get credentials of Unix domain socket peer process +/// +/// # References +/// - [Linux `unix`] +/// +/// [Linux `unix`]: https://man7.org/linux/man-pages/man7/unix.7.html +#[cfg(linux_kernel)] +#[doc(alias = "SO_PEERCRED")] +pub fn get_socket_peercred<Fd: AsFd>(fd: Fd) -> io::Result<super::UCred> { + backend::net::sockopt::get_socket_peercred(fd.as_fd()) } #[test] diff --git a/vendor/rustix/src/net/types.rs b/vendor/rustix/src/net/types.rs index 53116f9c8..711174354 100644 --- a/vendor/rustix/src/net/types.rs +++ b/vendor/rustix/src/net/types.rs @@ -92,6 +92,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const NETLINK: Self = Self(c::AF_NETLINK as _); /// `AF_UNIX`, aka `AF_LOCAL` @@ -106,16 +107,18 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const AX25: Self = Self(c::AF_AX25 as _); /// `AF_IPX` #[cfg(not(any( - target_os = "espidf", target_os = "aix", + target_os = "espidf", + target_os = "vita", )))] pub const IPX: Self = Self(c::AF_IPX as _); /// `AF_APPLETALK` - #[cfg(not(target_os = "espidf"))] + #[cfg(not(any(target_os = "espidf", target_os = "vita")))] pub const APPLETALK: Self = Self(c::AF_APPLETALK as _); /// `AF_NETROM` #[cfg(not(any( @@ -126,6 +129,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const NETROM: Self = Self(c::AF_NETROM as _); /// `AF_BRIDGE` @@ -137,6 +141,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const BRIDGE: Self = Self(c::AF_BRIDGE as _); /// `AF_ATMPVC` @@ -148,6 +153,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const ATMPVC: Self = Self(c::AF_ATMPVC as _); /// `AF_X25` @@ -158,6 +164,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const X25: Self = Self(c::AF_X25 as _); /// `AF_ROSE` @@ -169,10 +176,11 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const ROSE: Self = Self(c::AF_ROSE as _); /// `AF_DECnet` - #[cfg(not(any(target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "vita")))] pub const DECnet: Self = Self(c::AF_DECnet as _); /// `AF_NETBEUI` #[cfg(not(any( @@ -183,6 +191,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const NETBEUI: Self = Self(c::AF_NETBEUI as _); /// `AF_SECURITY` @@ -194,6 +203,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const SECURITY: Self = Self(c::AF_SECURITY as _); /// `AF_KEY` @@ -204,6 +214,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const KEY: Self = Self(c::AF_KEY as _); /// `AF_PACKET` @@ -219,6 +230,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const PACKET: Self = Self(c::AF_PACKET as _); /// `AF_ASH` @@ -230,6 +242,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const ASH: Self = Self(c::AF_ASH as _); /// `AF_ECONET` @@ -241,6 +254,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const ECONET: Self = Self(c::AF_ECONET as _); /// `AF_ATMSVC` @@ -252,6 +266,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const ATMSVC: Self = Self(c::AF_ATMSVC as _); /// `AF_RDS` @@ -263,10 +278,11 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const RDS: Self = Self(c::AF_RDS as _); /// `AF_SNA` - #[cfg(not(any(target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any(target_os = "espidf", target_os = "haiku", target_os = "vita")))] pub const SNA: Self = Self(c::AF_SNA as _); /// `AF_IRDA` #[cfg(not(any( @@ -276,6 +292,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const IRDA: Self = Self(c::AF_IRDA as _); /// `AF_PPPOX` @@ -287,6 +304,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const PPPOX: Self = Self(c::AF_PPPOX as _); /// `AF_WANPIPE` @@ -298,6 +316,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const WANPIPE: Self = Self(c::AF_WANPIPE as _); /// `AF_LLC` @@ -309,6 +328,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const LLC: Self = Self(c::AF_LLC as _); /// `AF_CAN` @@ -320,6 +340,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const CAN: Self = Self(c::AF_CAN as _); /// `AF_TIPC` @@ -331,6 +352,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const TIPC: Self = Self(c::AF_TIPC as _); /// `AF_BLUETOOTH` @@ -340,6 +362,7 @@ impl AddressFamily { windows, target_os = "aix", target_os = "espidf", + target_os = "vita", )))] pub const BLUETOOTH: Self = Self(c::AF_BLUETOOTH as _); /// `AF_IUCV` @@ -351,6 +374,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const IUCV: Self = Self(c::AF_IUCV as _); /// `AF_RXRPC` @@ -362,6 +386,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const RXRPC: Self = Self(c::AF_RXRPC as _); /// `AF_ISDN` @@ -371,6 +396,7 @@ impl AddressFamily { target_os = "aix", target_os = "espidf", target_os = "haiku", + target_os = "vita", )))] pub const ISDN: Self = Self(c::AF_ISDN as _); /// `AF_PHONET` @@ -382,6 +408,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const PHONET: Self = Self(c::AF_PHONET as _); /// `AF_IEEE802154` @@ -393,6 +420,7 @@ impl AddressFamily { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const IEEE802154: Self = Self(c::AF_IEEE802154 as _); /// `AF_802` @@ -610,26 +638,58 @@ pub mod ipproto { /// `IPPROTO_ICMP` pub const ICMP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_ICMP as _)); /// `IPPROTO_IGMP` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const IGMP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_IGMP as _)); /// `IPPROTO_IPIP` - #[cfg(not(any(solarish, windows, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + windows, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const IPIP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_IPIP as _)); /// `IPPROTO_TCP` pub const TCP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_TCP as _)); /// `IPPROTO_EGP` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const EGP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_EGP as _)); /// `IPPROTO_PUP` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const PUP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_PUP as _)); /// `IPPROTO_UDP` pub const UDP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_UDP as _)); /// `IPPROTO_IDP` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const IDP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_IDP as _)); /// `IPPROTO_TP` - #[cfg(not(any(solarish, windows, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + windows, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const TP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_TP as _)); /// `IPPROTO_DCCP` #[cfg(not(any( @@ -642,21 +702,44 @@ pub mod ipproto { target_os = "haiku", target_os = "nto", target_os = "openbsd", + target_os = "vita", )))] pub const DCCP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_DCCP as _)); /// `IPPROTO_IPV6` pub const IPV6: Protocol = Protocol(new_raw_protocol(c::IPPROTO_IPV6 as _)); /// `IPPROTO_RSVP` - #[cfg(not(any(solarish, windows, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + windows, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const RSVP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_RSVP as _)); /// `IPPROTO_GRE` - #[cfg(not(any(solarish, windows, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + windows, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const GRE: Protocol = Protocol(new_raw_protocol(c::IPPROTO_GRE as _)); /// `IPPROTO_ESP` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const ESP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_ESP as _)); /// `IPPROTO_AH` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const AH: Protocol = Protocol(new_raw_protocol(c::IPPROTO_AH as _)); /// `IPPROTO_MTP` #[cfg(not(any( @@ -667,6 +750,7 @@ pub mod ipproto { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const MTP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_MTP as _)); /// `IPPROTO_BEETPH` @@ -677,7 +761,8 @@ pub mod ipproto { target_os = "aix", target_os = "espidf", target_os = "haiku", - target_os = "nto" + target_os = "nto", + target_os = "vita", )))] pub const BEETPH: Protocol = Protocol(new_raw_protocol(c::IPPROTO_BEETPH as _)); /// `IPPROTO_ENCAP` @@ -687,10 +772,17 @@ pub mod ipproto { target_os = "aix", target_os = "espidf", target_os = "haiku", + target_os = "vita", )))] pub const ENCAP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_ENCAP as _)); /// `IPPROTO_PIM` - #[cfg(not(any(solarish, target_os = "aix", target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "aix", + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const PIM: Protocol = Protocol(new_raw_protocol(c::IPPROTO_PIM as _)); /// `IPPROTO_COMP` #[cfg(not(any( @@ -700,7 +792,8 @@ pub mod ipproto { target_os = "aix", target_os = "espidf", target_os = "haiku", - target_os = "nto" + target_os = "nto", + target_os = "vita", )))] pub const COMP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_COMP as _)); /// `IPPROTO_SCTP` @@ -709,7 +802,8 @@ pub mod ipproto { target_os = "dragonfly", target_os = "espidf", target_os = "haiku", - target_os = "openbsd" + target_os = "openbsd", + target_os = "vita", )))] pub const SCTP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_SCTP as _)); /// `IPPROTO_UDPLITE` @@ -723,6 +817,7 @@ pub mod ipproto { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const UDPLITE: Protocol = Protocol(new_raw_protocol(c::IPPROTO_UDPLITE as _)); /// `IPPROTO_MPLS` @@ -736,13 +831,14 @@ pub mod ipproto { target_os = "haiku", target_os = "netbsd", target_os = "nto", + target_os = "vita", )))] pub const MPLS: Protocol = Protocol(new_raw_protocol(c::IPPROTO_MPLS as _)); /// `IPPROTO_ETHERNET` #[cfg(linux_kernel)] pub const ETHERNET: Protocol = Protocol(new_raw_protocol(c::IPPROTO_ETHERNET as _)); /// `IPPROTO_RAW` - #[cfg(not(target_os = "espidf"))] + #[cfg(not(any(target_os = "espidf", target_os = "vita")))] pub const RAW: Protocol = Protocol(new_raw_protocol(c::IPPROTO_RAW as _)); /// `IPPROTO_MPTCP` #[cfg(not(any( @@ -755,10 +851,16 @@ pub mod ipproto { target_os = "fuchsia", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const MPTCP: Protocol = Protocol(new_raw_protocol(c::IPPROTO_MPTCP as _)); /// `IPPROTO_FRAGMENT` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const FRAGMENT: Protocol = Protocol(new_raw_protocol(c::IPPROTO_FRAGMENT as _)); /// `IPPROTO_ICMPV6` pub const ICMPV6: Protocol = Protocol(new_raw_protocol(c::IPPROTO_ICMPV6 as _)); @@ -772,10 +874,16 @@ pub mod ipproto { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] pub const MH: Protocol = Protocol(new_raw_protocol(c::IPPROTO_MH as _)); /// `IPPROTO_ROUTING` - #[cfg(not(any(solarish, target_os = "espidf", target_os = "haiku")))] + #[cfg(not(any( + solarish, + target_os = "espidf", + target_os = "haiku", + target_os = "vita" + )))] pub const ROUTING: Protocol = Protocol(new_raw_protocol(c::IPPROTO_ROUTING as _)); } @@ -1323,6 +1431,7 @@ bitflags! { target_os = "espidf", target_os = "haiku", target_os = "nto", + target_os = "vita", )))] const NONBLOCK = bitcast!(c::SOCK_NONBLOCK); @@ -1336,6 +1445,25 @@ bitflags! { } } +/// UNIX credentials of socket peer, for use with [`get_socket_peercred`] +/// [`SendAncillaryMessage::ScmCredentials`] and +/// [`RecvAncillaryMessage::ScmCredentials`]. +/// +/// [`get_socket_peercred`]: crate::net::sockopt::get_socket_peercred +/// [`SendAncillaryMessage::ScmCredentials`]: crate::net::SendAncillaryMessage::ScmCredentials +/// [`RecvAncillaryMessage::ScmCredentials`]: crate::net::RecvAncillaryMessage::ScmCredentials +#[cfg(linux_kernel)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] +#[repr(C)] +pub struct UCred { + /// Process ID of peer + pub pid: crate::pid::Pid, + /// User ID of peer + pub uid: crate::ugid::Uid, + /// Group ID of peer + pub gid: crate::ugid::Gid, +} + #[test] fn test_sizes() { use c::c_int; @@ -1361,4 +1489,7 @@ fn test_sizes() { let t: Option<Protocol> = Some(Protocol::from_raw(RawProtocol::new(4567).unwrap())); assert_eq!(4567_u32, transmute::<Option<Protocol>, u32>(t)); } + + #[cfg(linux_kernel)] + assert_eq_size!(UCred, libc::ucred); } |