Skip to content

Commit f896024

Browse files
author
Markus Wanner (mwa)
committed
Re-conditionalize the correct portions.
Even though destination and broadcast address usually are the same field, they have different names between Linux and BSD: ifa_ifu vs. ifa_dstaddr.
1 parent 9801746 commit f896024

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/ifaddrs.rs

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

48-
let ifo = unsafe { SockAddr::from_libc_sockaddr(info.ifa_ifu) };
48+
let ifu : *mut libc::sockaddr;
49+
50+
#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "fuchsia"))]
51+
{ ifu = info.ifa_ifu; }
52+
53+
#[cfg(not(any(target_os = "linux", target_os = "emscripten", target_os = "fuchsia")))]
54+
{ ifu = info.ifa_dstaddr; }
55+
4956
if addr.flags.contains(IFF_POINTOPOINT) {
50-
addr.destination = ifo;
51-
}
52-
if addr.flags.contains(IFF_BROADCAST) {
53-
addr.broadcast = ifo;
57+
addr.destination = unsafe { SockAddr::from_libc_sockaddr(ifu) };
58+
} else if addr.flags.contains(IFF_BROADCAST) {
59+
addr.broadcast = unsafe { SockAddr::from_libc_sockaddr(ifu) };
5460
}
5561

5662
addr

0 commit comments

Comments
 (0)