From b1db516b102c86397f68fc55111f9bb85d986024 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 12 Mar 2021 06:16:17 +0000 Subject: [PATCH] Enable all Linux `phy` components for Android as well. Fixes #433. --- src/phy/mod.rs | 4 ++-- src/phy/sys/mod.rs | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/phy/mod.rs b/src/phy/mod.rs index 03bc779..e2962fd 100644 --- a/src/phy/mod.rs +++ b/src/phy/mod.rs @@ -98,7 +98,7 @@ mod pcap_writer; mod loopback; #[cfg(all(feature = "phy-raw_socket", unix))] mod raw_socket; -#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))] +#[cfg(all(feature = "phy-tap_interface", any(target_os = "linux", target_os = "android")))] mod tap_interface; #[cfg(all(any(feature = "phy-raw_socket", feature = "phy-tap_interface"), unix))] @@ -112,7 +112,7 @@ pub use self::pcap_writer::{PcapLinkType, PcapMode, PcapSink, PcapWriter}; pub use self::loopback::Loopback; #[cfg(all(feature = "phy-raw_socket", unix))] pub use self::raw_socket::RawSocket; -#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))] +#[cfg(all(feature = "phy-tap_interface", any(target_os = "linux", target_os = "android")))] pub use self::tap_interface::TapInterface; #[cfg(feature = "ethernet")] diff --git a/src/phy/sys/mod.rs b/src/phy/sys/mod.rs index 6f1665b..59f59cf 100644 --- a/src/phy/sys/mod.rs +++ b/src/phy/sys/mod.rs @@ -4,22 +4,22 @@ use std::{mem, ptr, io}; use std::os::unix::io::RawFd; use crate::time::Duration; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "android"))] #[path = "linux.rs"] mod imp; -#[cfg(all(feature = "phy-raw_socket", target_os = "linux"))] +#[cfg(all(feature = "phy-raw_socket", any(target_os = "linux", target_os = "android")))] pub mod raw_socket; -#[cfg(all(feature = "phy-raw_socket", not(target_os = "linux"), unix))] +#[cfg(all(feature = "phy-raw_socket", not(any(target_os = "linux", target_os = "android")), unix))] pub mod bpf; -#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))] +#[cfg(all(feature = "phy-tap_interface", any(target_os = "linux", target_os = "android")))] pub mod tap_interface; -#[cfg(all(feature = "phy-raw_socket", target_os = "linux"))] +#[cfg(all(feature = "phy-raw_socket", any(target_os = "linux", target_os = "android")))] pub use self::raw_socket::RawSocketDesc; -#[cfg(all(feature = "phy-raw_socket", not(target_os = "linux"), unix))] +#[cfg(all(feature = "phy-raw_socket", not(any(target_os = "linux", target_os = "android")), unix))] pub use self::bpf::BpfDevice as RawSocketDesc; -#[cfg(all(feature = "phy-tap_interface", target_os = "linux"))] +#[cfg(all(feature = "phy-tap_interface", any(target_os = "linux", target_os = "android")))] pub use self::tap_interface::TapInterfaceDesc; /// Wait until given file descriptor becomes readable, but no longer than given timeout. @@ -79,7 +79,8 @@ fn ifreq_for(name: &str) -> ifreq { ifreq } -#[cfg(all(target_os = "linux", any(feature = "phy-tap_interface", feature = "phy-raw_socket")))] +#[cfg(all(any(target_os = "linux", target_os = "android"), + any(feature = "phy-tap_interface", feature = "phy-raw_socket")))] fn ifreq_ioctl(lower: libc::c_int, ifreq: &mut ifreq, cmd: libc::c_ulong) -> io::Result { unsafe {