Skip to content

Commit c9a2d80

Browse files
author
Markus Wanner (mwa)
committed
Adjust to changed libc_bitflags macro and constants.
1 parent 8c196d5 commit c9a2d80

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

src/net/if_.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,37 @@ pub fn if_nametoindex<P: ?Sized + NixPath>(name: &P) -> Result<c_uint> {
2020

2121
libc_bitflags!(
2222
/// Standard interface flags, used by `getifaddrs`
23-
pub flags InterfaceFlags: libc::c_int {
23+
pub struct InterfaceFlags: libc::c_int {
2424
#[cfg(any(target_os = "linux", target_os = "android"))]
25-
IFF_UP,
25+
IFF_UP;
2626
#[cfg(any(target_os = "linux", target_os = "android"))]
27-
IFF_BROADCAST,
27+
IFF_BROADCAST;
2828
#[cfg(any(target_os = "linux", target_os = "android"))]
29-
IFF_DEBUG,
30-
IFF_LOOPBACK,
29+
IFF_DEBUG;
30+
IFF_LOOPBACK;
3131
#[cfg(any(target_os = "linux", target_os = "android"))]
32-
IFF_POINTOPOINT,
32+
IFF_POINTOPOINT;
3333
#[cfg(any(target_os = "linux", target_os = "android"))]
34-
IFF_NOTRAILERS,
34+
IFF_NOTRAILERS;
3535
#[cfg(any(target_os = "linux", target_os = "android"))]
36-
IFF_RUNNING,
36+
IFF_RUNNING;
3737
#[cfg(any(target_os = "linux", target_os = "android"))]
38-
IFF_NOARP,
38+
IFF_NOARP;
3939
#[cfg(any(target_os = "linux", target_os = "android"))]
40-
IFF_PROMISC,
40+
IFF_PROMISC;
4141
#[cfg(any(target_os = "linux", target_os = "android"))]
42-
IFF_ALLMULTI,
42+
IFF_ALLMULTI;
4343
#[cfg(any(target_os = "linux", target_os = "android"))]
44-
IFF_MASTER,
44+
IFF_MASTER;
4545
#[cfg(any(target_os = "linux", target_os = "android"))]
46-
IFF_SLAVE,
46+
IFF_SLAVE;
4747
#[cfg(any(target_os = "linux", target_os = "android"))]
48-
IFF_MULTICAST,
48+
IFF_MULTICAST;
4949
#[cfg(any(target_os = "linux", target_os = "android"))]
50-
IFF_PORTSEL,
50+
IFF_PORTSEL;
5151
#[cfg(any(target_os = "linux", target_os = "android"))]
52-
IFF_AUTOMEDIA,
52+
IFF_AUTOMEDIA;
5353
#[cfg(any(target_os = "linux", target_os = "android"))]
54-
IFF_DYNAMIC
54+
IFF_DYNAMIC;
5555
}
5656
);

src/sys/socket/addr.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ pub enum AddressFamily {
204204
impl AddressFamily {
205205
pub fn from_i32(family: i32) -> Option<AddressFamily> {
206206
match family {
207-
consts::AF_UNIX => Some(AddressFamily::Unix),
208-
consts::AF_INET => Some(AddressFamily::Inet),
209-
consts::AF_INET6 => Some(AddressFamily::Inet6),
207+
libc::AF_UNIX => Some(AddressFamily::Unix),
208+
libc::AF_INET => Some(AddressFamily::Inet),
209+
libc::AF_INET6 => Some(AddressFamily::Inet6),
210210
#[cfg(any(target_os = "linux", target_os = "android"))]
211-
consts::AF_NETLINK => Some(AddressFamily::Netlink),
211+
libc::AF_NETLINK => Some(AddressFamily::Netlink),
212212
#[cfg(any(target_os = "linux", target_os = "android"))]
213-
consts::AF_PACKET => Some(AddressFamily::Packet),
213+
libc::AF_PACKET => Some(AddressFamily::Packet),
214214
#[cfg(any(target_os = "macos", target_os = "ios"))]
215-
consts::AF_SYSTEM => Some(AddressFamily::System),
215+
libc::AF_SYSTEM => Some(AddressFamily::System),
216216
_ => None
217217
}
218218
}
@@ -716,13 +716,15 @@ impl SockAddr {
716716
InetAddr::V4(*(addr as *mut libc::sockaddr_in)))),
717717
Some(AddressFamily::Inet6) => Some(SockAddr::Inet(
718718
InetAddr::V6(*(addr as *mut libc::sockaddr_in6)))),
719-
#[cfg(any(target_os = "linux", target_os = "android"))]
720-
Some(AddressFamily::Netlink) => None,
721-
#[cfg(any(target_os = "linux", target_os = "android"))]
722-
Some(AddressFamily::Packet) => None,
723-
#[cfg(any(target_os = "macos", target_os = "ios"))]
724-
Some(AddressFamily::System) => None,
725-
None => None
719+
#[cfg(any(target_os = "android", target_os = "linux"))]
720+
Some(AddressFamily::Netlink) => Some(SockAddr::Netlink(
721+
NetlinkAddr(*(addr as *mut libc::sockaddr_nl)))),
722+
#[cfg(any(target_os = "ios", target_os = "macos"))]
723+
Some(AddressFamily::SysControl) => Some(SockAddr::SysControl(
724+
SysControlAddr(*(addr as *mut sys_control::sockaddr_ctl)))),
725+
// No other address families are supported, including netlink and syscontrol.
726+
Some(_) => None,
727+
None => None,
726728
}
727729
}
728730
}

0 commit comments

Comments
 (0)