summaryrefslogtreecommitdiff
path: root/src/sys/socket/addr.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-12-21 17:52:21 +0000
committerGitHub <noreply@github.com>2021-12-21 17:52:21 +0000
commit1dcc582f8eba50f6233bc0bf398ada4032469c1f (patch)
treebbaea69b57959959e1bfae5792778cede6e3177f /src/sys/socket/addr.rs
parentd1c6fed481638405b0a87e5b7eecf82ce89b2268 (diff)
parent771c710e903c7176eb362fe632fb9fbf0e6f6910 (diff)
downloadnix-1dcc582f8eba50f6233bc0bf398ada4032469c1f.zip
Merge #1611
1611: feature-gate most Nix functions r=rtzoeller a=asomers Using features reduces build time and size for consumer crates. By default all features are enabled. Co-authored-by: Vincent Dagonneau <vincentdagonneau@gmail.com> Co-authored-by: Alan Somers <asomers@gmail.com>
Diffstat (limited to 'src/sys/socket/addr.rs')
-rw-r--r--src/sys/socket/addr.rs119
1 files changed, 113 insertions, 6 deletions
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index b119642b..fa62706e 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -13,7 +13,7 @@ use crate::sys::socket::addr::netlink::NetlinkAddr;
use crate::sys::socket::addr::alg::AlgAddr;
#[cfg(any(target_os = "ios", target_os = "macos"))]
use std::os::unix::io::RawFd;
-#[cfg(any(target_os = "ios", target_os = "macos"))]
+#[cfg(all(feature = "ioctl", any(target_os = "ios", target_os = "macos")))]
use crate::sys::socket::addr::sys_control::SysControlAddr;
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -25,6 +25,7 @@ use crate::sys::socket::addr::sys_control::SysControlAddr;
target_os = "netbsd",
target_os = "openbsd",
target_os = "fuchsia"))]
+#[cfg(feature = "net")]
pub use self::datalink::LinkAddr;
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use self::vsock::VsockAddr;
@@ -43,6 +44,7 @@ pub enum AddressFamily {
Inet6 = libc::AF_INET6,
/// Kernel user interface device (see [`netlink(7)`](https://man7.org/linux/man-pages/man7/netlink.7.html))
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Netlink = libc::AF_NETLINK,
/// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html))
#[cfg(any(target_os = "android",
@@ -50,84 +52,117 @@ pub enum AddressFamily {
target_os = "illumos",
target_os = "fuchsia",
target_os = "solaris"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Packet = libc::AF_PACKET,
/// KEXT Controls and Notifications
#[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
System = libc::AF_SYSTEM,
/// Amateur radio AX.25 protocol
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Ax25 = libc::AF_AX25,
/// IPX - Novell protocols
Ipx = libc::AF_IPX,
/// AppleTalk
AppleTalk = libc::AF_APPLETALK,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
NetRom = libc::AF_NETROM,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Bridge = libc::AF_BRIDGE,
/// Access to raw ATM PVCs
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
AtmPvc = libc::AF_ATMPVC,
/// ITU-T X.25 / ISO-8208 protocol (see [`x25(7)`](https://man7.org/linux/man-pages/man7/x25.7.html))
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
X25 = libc::AF_X25,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Rose = libc::AF_ROSE,
Decnet = libc::AF_DECnet,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
NetBeui = libc::AF_NETBEUI,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Security = libc::AF_SECURITY,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Key = libc::AF_KEY,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Ash = libc::AF_ASH,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Econet = libc::AF_ECONET,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
AtmSvc = libc::AF_ATMSVC,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Rds = libc::AF_RDS,
Sna = libc::AF_SNA,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Irda = libc::AF_IRDA,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Pppox = libc::AF_PPPOX,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Wanpipe = libc::AF_WANPIPE,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Llc = libc::AF_LLC,
#[cfg(target_os = "linux")]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Ib = libc::AF_IB,
#[cfg(target_os = "linux")]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Mpls = libc::AF_MPLS,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Can = libc::AF_CAN,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Tipc = libc::AF_TIPC,
#[cfg(not(any(target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "solaris")))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Bluetooth = libc::AF_BLUETOOTH,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Iucv = libc::AF_IUCV,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
RxRpc = libc::AF_RXRPC,
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Isdn = libc::AF_ISDN,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Phonet = libc::AF_PHONET,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Ieee802154 = libc::AF_IEEE802154,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Caif = libc::AF_CAIF,
/// Interface to kernel crypto API
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Alg = libc::AF_ALG,
#[cfg(target_os = "linux")]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Nfc = libc::AF_NFC,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Vsock = libc::AF_VSOCK,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -135,6 +170,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
ImpLink = libc::AF_IMPLINK,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -142,6 +178,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Pup = libc::AF_PUP,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -149,11 +186,13 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Chaos = libc::AF_CHAOS,
#[cfg(any(target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Ns = libc::AF_NS,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -161,6 +200,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Iso = libc::AF_ISO,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -168,6 +208,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Datakit = libc::AF_DATAKIT,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -175,6 +216,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Ccitt = libc::AF_CCITT,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -182,6 +224,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Dli = libc::AF_DLI,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -189,6 +232,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Lat = libc::AF_LAT,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -196,6 +240,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Hylink = libc::AF_HYLINK,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -204,6 +249,7 @@ pub enum AddressFamily {
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Link = libc::AF_LINK,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -211,6 +257,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Coip = libc::AF_COIP,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -218,6 +265,7 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Cnt = libc::AF_CNT,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -225,9 +273,11 @@ pub enum AddressFamily {
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Natm = libc::AF_NATM,
/// Unspecified address family, (see [`getaddrinfo(3)`](https://man7.org/linux/man-pages/man3/getaddrinfo.3.html))
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Unspec = libc::AF_UNSPEC,
}
@@ -263,6 +313,9 @@ impl AddressFamily {
}
}
+feature! {
+#![feature = "net"]
+
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum InetAddr {
V4(libc::sockaddr_in),
@@ -515,6 +568,7 @@ impl fmt::Display for Ipv6Addr {
self.to_std().fmt(fmt)
}
}
+}
/// A wrapper around `sockaddr_un`.
#[derive(Clone, Copy, Debug)]
@@ -586,6 +640,7 @@ impl UnixAddr {
/// This is a Linux-specific extension, primarily used to allow chrooted
/// processes to communicate with processes having a different filesystem view.
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
pub fn new_abstract(path: &[u8]) -> Result<UnixAddr> {
unsafe {
let mut ret = libc::sockaddr_un {
@@ -644,6 +699,7 @@ impl UnixAddr {
/// For abstract sockets only the bare name is returned, without the
/// leading null byte. `None` is returned for unnamed or path-backed sockets.
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
pub fn as_abstract(&self) -> Option<&[u8]> {
match self.kind() {
UnixAddrKind::Abstract(name) => Some(name),
@@ -709,13 +765,18 @@ impl Hash for UnixAddr {
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum SockAddr {
+ #[cfg(feature = "net")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Inet(InetAddr),
Unix(UnixAddr),
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Netlink(NetlinkAddr),
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Alg(AlgAddr),
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(all(feature = "ioctl", any(target_os = "ios", target_os = "macos")))]
+ #[cfg_attr(docsrs, doc(cfg(feature = "ioctl")))]
SysControl(SysControlAddr),
/// Datalink address (MAC)
#[cfg(any(target_os = "android",
@@ -727,52 +788,68 @@ pub enum SockAddr {
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg(feature = "net")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Link(LinkAddr),
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
Vsock(VsockAddr),
}
impl SockAddr {
+ feature! {
+ #![feature = "net"]
pub fn new_inet(addr: InetAddr) -> SockAddr {
SockAddr::Inet(addr)
}
+ }
pub fn new_unix<P: ?Sized + NixPath>(path: &P) -> Result<SockAddr> {
Ok(SockAddr::Unix(UnixAddr::new(path)?))
}
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
pub fn new_netlink(pid: u32, groups: u32) -> SockAddr {
SockAddr::Netlink(NetlinkAddr::new(pid, groups))
}
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
pub fn new_alg(alg_type: &str, alg_name: &str) -> SockAddr {
SockAddr::Alg(AlgAddr::new(alg_type, alg_name))
}
+ feature! {
+ #![feature = "ioctl"]
#[cfg(any(target_os = "ios", target_os = "macos"))]
pub fn new_sys_control(sockfd: RawFd, name: &str, unit: u32) -> Result<SockAddr> {
SysControlAddr::from_name(sockfd, name, unit).map(SockAddr::SysControl)
}
+ }
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
pub fn new_vsock(cid: u32, port: u32) -> SockAddr {
SockAddr::Vsock(VsockAddr::new(cid, port))
}
pub fn family(&self) -> AddressFamily {
match *self {
+ #[cfg(feature = "net")]
SockAddr::Inet(InetAddr::V4(..)) => AddressFamily::Inet,
+ #[cfg(feature = "net")]
SockAddr::Inet(InetAddr::V6(..)) => AddressFamily::Inet6,
SockAddr::Unix(..) => AddressFamily::Unix,
#[cfg(any(target_os = "android", target_os = "linux"))]
SockAddr::Netlink(..) => AddressFamily::Netlink,
#[cfg(any(target_os = "android", target_os = "linux"))]
SockAddr::Alg(..) => AddressFamily::Alg,
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(all(feature = "ioctl",
+ any(target_os = "ios", target_os = "macos")))]
SockAddr::SysControl(..) => AddressFamily::System,
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(feature = "net")]
SockAddr::Link(..) => AddressFamily::Packet,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
@@ -781,6 +858,7 @@ impl SockAddr {
target_os = "netbsd",
target_os = "illumos",
target_os = "openbsd"))]
+ #[cfg(feature = "net")]
SockAddr::Link(..) => AddressFamily::Link,
#[cfg(any(target_os = "android", target_os = "linux"))]
SockAddr::Vsock(..) => AddressFamily::Vsock,
@@ -802,23 +880,28 @@ impl SockAddr {
/// unsafe because it takes a raw pointer as argument. The caller must
/// ensure that the pointer is valid.
#[cfg(not(target_os = "fuchsia"))]
+ #[cfg(feature = "net")]
pub(crate) unsafe fn from_libc_sockaddr(addr: *const libc::sockaddr) -> Option<SockAddr> {
if addr.is_null() {
None
} else {
match AddressFamily::from_i32(i32::from((*addr).sa_family)) {
Some(AddressFamily::Unix) => None,
+ #[cfg(feature = "net")]
Some(AddressFamily::Inet) => Some(SockAddr::Inet(
InetAddr::V4(*(addr as *const libc::sockaddr_in)))),
+ #[cfg(feature = "net")]
Some(AddressFamily::Inet6) => Some(SockAddr::Inet(
InetAddr::V6(*(addr as *const libc::sockaddr_in6)))),
#[cfg(any(target_os = "android", target_os = "linux"))]
Some(AddressFamily::Netlink) => Some(SockAddr::Netlink(
NetlinkAddr(*(addr as *const libc::sockaddr_nl)))),
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(all(feature = "ioctl",
+ any(target_os = "ios", target_os = "macos")))]
Some(AddressFamily::System) => Some(SockAddr::SysControl(
SysControlAddr(*(addr as *const libc::sockaddr_ctl)))),
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(feature = "net")]
Some(AddressFamily::Packet) => Some(SockAddr::Link(
LinkAddr(*(addr as *const libc::sockaddr_ll)))),
#[cfg(any(target_os = "dragonfly",
@@ -828,6 +911,7 @@ impl SockAddr {
target_os = "netbsd",
target_os = "illumos",
target_os = "openbsd"))]
+ #[cfg(feature = "net")]
Some(AddressFamily::Link) => {
let ether_addr = LinkAddr(*(addr as *const libc::sockaddr_dl));
if ether_addr.is_empty() {
@@ -855,6 +939,7 @@ impl SockAddr {
/// a sockaddr * need to take the size of the underlying type as well and then internally cast it back.
pub fn as_ffi_pair(&self) -> (&libc::sockaddr, libc::socklen_t) {
match *self {
+ #[cfg(feature = "net")]
SockAddr::Inet(InetAddr::V4(ref addr)) => (
// This cast is always allowed in C
unsafe {
@@ -862,6 +947,7 @@ impl SockAddr {
},
mem::size_of_val(addr) as libc::socklen_t
),
+ #[cfg(feature = "net")]
SockAddr::Inet(InetAddr::V6(ref addr)) => (
// This cast is always allowed in C
unsafe {
@@ -892,7 +978,8 @@ impl SockAddr {
},
mem::size_of_val(sa) as libc::socklen_t
),
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(all(feature = "ioctl",
+ any(target_os = "ios", target_os = "macos")))]
SockAddr::SysControl(SysControlAddr(ref sa)) => (
// This cast is always allowed in C
unsafe {
@@ -902,6 +989,7 @@ impl SockAddr {
),
#[cfg(any(target_os = "android", target_os = "linux"))]
+ #[cfg(feature = "net")]
SockAddr::Link(LinkAddr(ref addr)) => (
// This cast is always allowed in C
unsafe {
@@ -916,6 +1004,7 @@ impl SockAddr {
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
+ #[cfg(feature = "net")]
SockAddr::Link(LinkAddr(ref addr)) => (
// This cast is always allowed in C
unsafe {
@@ -938,13 +1027,15 @@ impl SockAddr {
impl fmt::Display for SockAddr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
+ #[cfg(feature = "net")]
SockAddr::Inet(ref inet) => inet.fmt(f),
SockAddr::Unix(ref unix) => unix.fmt(f),
#[cfg(any(target_os = "android", target_os = "linux"))]
SockAddr::Netlink(ref nl) => nl.fmt(f),
#[cfg(any(target_os = "android", target_os = "linux"))]
SockAddr::Alg(ref nl) => nl.fmt(f),
- #[cfg(any(target_os = "ios", target_os = "macos"))]
+ #[cfg(all(feature = "ioctl",
+ any(target_os = "ios", target_os = "macos")))]
SockAddr::SysControl(ref sc) => sc.fmt(f),
#[cfg(any(target_os = "android",
target_os = "dragonfly",
@@ -955,6 +1046,7 @@ impl fmt::Display for SockAddr {
target_os = "netbsd",
target_os = "illumos",
target_os = "openbsd"))]
+ #[cfg(feature = "net")]
SockAddr::Link(ref ether_addr) => ether_addr.fmt(f),
#[cfg(any(target_os = "android", target_os = "linux"))]
SockAddr::Vsock(ref svm) => svm.fmt(f),
@@ -963,6 +1055,7 @@ impl fmt::Display for SockAddr {
}
#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg_attr(docsrs, doc(cfg(all())))]
pub mod netlink {
use crate::sys::socket::addr::AddressFamily;
use libc::{sa_family_t, sockaddr_nl};
@@ -998,6 +1091,7 @@ pub mod netlink {
}
#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg_attr(docsrs, doc(cfg(all())))]
pub mod alg {
use libc::{AF_ALG, sockaddr_alg, c_char};
use std::{fmt, mem, str};
@@ -1060,6 +1154,8 @@ pub mod alg {
}
}
+feature! {
+#![feature = "ioctl"]
#[cfg(any(target_os = "ios", target_os = "macos"))]
pub mod sys_control {
use crate::sys::socket::addr::AddressFamily;
@@ -1130,10 +1226,14 @@ pub mod sys_control {
}
}
}
+}
#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia"))]
+#[cfg_attr(docsrs, doc(cfg(all())))]
mod datalink {
+ feature! {
+ #![feature = "net"]
use super::{fmt, AddressFamily};
/// Hardware Address
@@ -1197,6 +1297,7 @@ mod datalink {
addr[5])
}
}
+ }
}
#[cfg(any(target_os = "dragonfly",
@@ -1206,7 +1307,10 @@ mod datalink {
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
+#[cfg_attr(docsrs, doc(cfg(all())))]
mod datalink {
+ feature! {
+ #![feature = "net"]
use super::{fmt, AddressFamily};
/// Hardware Address
@@ -1216,6 +1320,7 @@ mod datalink {
impl LinkAddr {
/// Total length of sockaddr
#[cfg(not(target_os = "illumos"))]
+ #[cfg_attr(docsrs, doc(cfg(all())))]
pub fn len(&self) -> usize {
self.0.sdl_len as usize
}
@@ -1291,9 +1396,11 @@ mod datalink {
addr[5])
}
}
+ }
}
#[cfg(any(target_os = "android", target_os = "linux"))]
+#[cfg_attr(docsrs, doc(cfg(all())))]
pub mod vsock {
use crate::sys::socket::addr::AddressFamily;
use libc::{sa_family_t, sockaddr_vm};