Enable all Linux `phy` components for Android as well.

Fixes #433.
This commit is contained in:
whitequark 2021-03-12 06:16:17 +00:00
parent 9f0213765c
commit b1db516b10
2 changed files with 11 additions and 10 deletions

View File

@ -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")]

View File

@ -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<libc::c_int> {
unsafe {