Skip to content

Commit 9801746

Browse files
author
Markus Wanner (mwa)
committed
Adjust to libc updates and drop some of the cfg conditions.
This is a best effort of conditionalizing the InterfaceFlags by grepping in libc source code. It looks like support for destination and broadcast addresses has been added to most if not all BSD variants. Therefore, cfg conditions have been removed. Let's try and see where this fails.
1 parent c9a2d80 commit 9801746

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

src/ifaddrs.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,12 @@ impl InterfaceAddress {
4545
destination: None,
4646
};
4747

48-
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "fuchsia"))]
49-
{
50-
let ifo = unsafe { SockAddr::from_libc_sockaddr(info.ifa_ifu) };
51-
if addr.flags.contains(IFF_POINTOPOINT) {
52-
addr.destination = ifo;
53-
} else if addr.flags.contains(IFF_BROADCAST) {
54-
addr.broadcast = ifo;
55-
}
48+
let ifo = unsafe { SockAddr::from_libc_sockaddr(info.ifa_ifu) };
49+
if addr.flags.contains(IFF_POINTOPOINT) {
50+
addr.destination = ifo;
5651
}
57-
58-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd",
59-
target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd",
60-
target_os = "bitrig", target_os = "solaris"))]
61-
{
62-
addr.destination = unsafe { SockAddr::from_libc_sockaddr(info.ifa_dstaddr) };
52+
if addr.flags.contains(IFF_BROADCAST) {
53+
addr.broadcast = ifo;
6354
}
6455

6556
addr

src/net/if_.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,28 @@ pub fn if_nametoindex<P: ?Sized + NixPath>(name: &P) -> Result<c_uint> {
2121
libc_bitflags!(
2222
/// Standard interface flags, used by `getifaddrs`
2323
pub struct InterfaceFlags: libc::c_int {
24-
#[cfg(any(target_os = "linux", target_os = "android"))]
2524
IFF_UP;
26-
#[cfg(any(target_os = "linux", target_os = "android"))]
2725
IFF_BROADCAST;
28-
#[cfg(any(target_os = "linux", target_os = "android"))]
2926
IFF_DEBUG;
3027
IFF_LOOPBACK;
31-
#[cfg(any(target_os = "linux", target_os = "android"))]
3228
IFF_POINTOPOINT;
33-
#[cfg(any(target_os = "linux", target_os = "android"))]
29+
#[cfg(not(any(target_os = "freebsd", target_os = "dragonfly", target_os = "haiku")))]
3430
IFF_NOTRAILERS;
35-
#[cfg(any(target_os = "linux", target_os = "android"))]
31+
#[cfg(not(any(target_os = "freebsd", target_os = "haiku")))]
3632
IFF_RUNNING;
37-
#[cfg(any(target_os = "linux", target_os = "android"))]
3833
IFF_NOARP;
39-
#[cfg(any(target_os = "linux", target_os = "android"))]
4034
IFF_PROMISC;
41-
#[cfg(any(target_os = "linux", target_os = "android"))]
4235
IFF_ALLMULTI;
43-
#[cfg(any(target_os = "linux", target_os = "android"))]
36+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "fuchsia"))]
4437
IFF_MASTER;
45-
#[cfg(any(target_os = "linux", target_os = "android"))]
38+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "fuchsia"))]
4639
IFF_SLAVE;
47-
#[cfg(any(target_os = "linux", target_os = "android"))]
4840
IFF_MULTICAST;
49-
#[cfg(any(target_os = "linux", target_os = "android"))]
41+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "fuchsia"))]
5042
IFF_PORTSEL;
51-
#[cfg(any(target_os = "linux", target_os = "android"))]
43+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "fuchsia"))]
5244
IFF_AUTOMEDIA;
53-
#[cfg(any(target_os = "linux", target_os = "android"))]
45+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "fuchsia"))]
5446
IFF_DYNAMIC;
5547
}
5648
);

0 commit comments

Comments
 (0)