Skip to content

fix: enable the latest rtnetlink on Android #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/address_family_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ pub enum AddressFamily {
Pppox,
Wanpipe,
Llc,
#[cfg(not(target_os = "android"))]
Ib,
#[cfg(not(target_os = "android"))]
Mpls,
Can,
Tipc,
Expand Down Expand Up @@ -93,7 +95,9 @@ impl From<u8> for AddressFamily {
d if d == libc::AF_PPPOX as u8 => Self::Pppox,
d if d == libc::AF_WANPIPE as u8 => Self::Wanpipe,
d if d == libc::AF_LLC as u8 => Self::Llc,
#[cfg(not(target_os = "android"))]
d if d == libc::AF_IB as u8 => Self::Ib,
#[cfg(not(target_os = "android"))]
d if d == libc::AF_MPLS as u8 => Self::Mpls,
d if d == libc::AF_CAN as u8 => Self::Can,
d if d == libc::AF_TIPC as u8 => Self::Tipc,
Expand Down Expand Up @@ -149,7 +153,9 @@ impl From<AddressFamily> for u8 {
AddressFamily::Pppox => libc::AF_PPPOX as u8,
AddressFamily::Wanpipe => libc::AF_WANPIPE as u8,
AddressFamily::Llc => libc::AF_LLC as u8,
#[cfg(not(target_os = "android"))]
AddressFamily::Ib => libc::AF_IB as u8,
#[cfg(not(target_os = "android"))]
AddressFamily::Mpls => libc::AF_MPLS as u8,
AddressFamily::Can => libc::AF_CAN as u8,
AddressFamily::Tipc => libc::AF_TIPC as u8,
Expand Down
10 changes: 8 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ mod tests;

pub(crate) mod ip;

#[cfg(any(target_os = "linux", target_os = "fuchsia"))]
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "android"))]
mod address_family_linux;
#[cfg(any(target_os = "linux", target_os = "fuchsia"))]
#[cfg(any(
target_os = "linux",
target_os = "fuchsia",
target_os = "android"
))]
pub use self::address_family_linux::AddressFamily;

#[cfg(target_os = "freebsd")]
Expand All @@ -52,12 +56,14 @@ pub use self::address_family_freebsd::AddressFamily;
target_os = "linux",
target_os = "fuchsia",
target_os = "freebsd",
target_os = "android",
)))]
mod address_family_fallback;
#[cfg(not(any(
target_os = "linux",
target_os = "fuchsia",
target_os = "freebsd",
target_os = "android",
)))]
pub use self::address_family_fallback::AddressFamily;

Expand Down
4 changes: 2 additions & 2 deletions src/link/af_spec/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for AfSpecBridge {
}
}

#[cfg(any(target_os = "linux", target_os = "fuchsia"))]
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "android"))]
pub(crate) struct VecAfSpecBridge(pub(crate) Vec<AfSpecBridge>);

#[cfg(any(target_os = "linux", target_os = "fuchsia"))]
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "android"))]
impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
for VecAfSpecBridge
{
Expand Down
6 changes: 5 additions & 1 deletion src/link/af_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ pub use self::inet6_iface_flag::Inet6IfaceFlags;
pub use self::inet6_stats::{Inet6Stats, Inet6StatsBuffer};
pub use self::unspec::AfSpecUnspec;

#[cfg(any(target_os = "linux", target_os = "fuchsia"))]
#[cfg(any(
target_os = "linux",
target_os = "fuchsia",
target_os = "android"
))]
pub(crate) use self::bridge::VecAfSpecBridge;
pub(crate) use self::inet::VecAfSpecInet;
pub(crate) use self::inet6::VecAfSpecInet6;
Expand Down
24 changes: 20 additions & 4 deletions src/link/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ use netlink_packet_utils::{
DecodeError,
};

#[cfg(any(target_os = "linux", target_os = "fuchsia",))]
#[cfg(any(
target_os = "linux",
target_os = "fuchsia",
target_os = "android"
))]
use super::af_spec::VecAfSpecBridge;
#[cfg(any(target_os = "linux", target_os = "fuchsia",))]
#[cfg(any(
target_os = "linux",
target_os = "fuchsia",
target_os = "android"
))]
use super::proto_info::VecLinkProtoInfoBridge;
use super::{
af_spec::VecAfSpecUnspec,
Expand Down Expand Up @@ -441,7 +449,11 @@ impl<'a, T: AsRef<[u8]> + ?Sized>
.context(err(payload))?
.0,
),
#[cfg(any(target_os = "linux", target_os = "fuchsia",))]
#[cfg(any(
target_os = "linux",
target_os = "fuchsia",
target_os = "android"
))]
AddressFamily::Bridge => Self::ProtoInfoBridge(
VecLinkProtoInfoBridge::parse(&NlaBuffer::new_checked(
payload,
Expand Down Expand Up @@ -650,7 +662,11 @@ impl<'a, T: AsRef<[u8]> + ?Sized>
.0,
)
}
#[cfg(any(target_os = "linux", target_os = "fuchsia",))]
#[cfg(any(
target_os = "linux",
target_os = "fuchsia",
target_os = "android"
))]
AddressFamily::Bridge => {
let err = "invalid IFLA_AF_SPEC value for AF_BRIDGE";
Self::AfSpecBridge(
Expand Down
Loading