Skip to content

Commit 6d9de21

Browse files
committed
adding if_nameindex/if_freenameindex support for Android.
[ref](https://android.googlesource.com/platform/bionic/+/master/libc/include/net/if.h#52) close rust-langGH-4246
1 parent 0f9f8c9 commit 6d9de21

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

libc-test/build.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,8 @@ fn test_android(target: &str) {
18461846

18471847
// FIXME: "'__uint128' undeclared" in C
18481848
"__uint128" => true,
1849+
// Added in API level 24
1850+
"if_nameindex" => true,
18491851

18501852
_ => false,
18511853
}
@@ -2089,6 +2091,9 @@ fn test_android(target: &str) {
20892091
| "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower"
20902092
| "toupper" => true,
20912093

2094+
// Added in API level 24
2095+
"if_nameindex" | "if_freenameindex" => true,
2096+
20922097
_ => false,
20932098
}
20942099
});

libc-test/semver/android.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,7 +3379,9 @@ group
33793379
hostent
33803380
id_t
33813381
idtype_t
3382+
if_freenameindex
33823383
if_indextoname
3384+
if_nameindex
33833385
if_nametoindex
33843386
ifaddrs
33853387
ifconf

src/unix/linux_like/android/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,11 @@ s! {
517517
pub ifr6_prefixlen: u32,
518518
pub ifr6_ifindex: c_int,
519519
}
520+
521+
pub struct if_nameindex {
522+
pub if_index: c_uint,
523+
pub if_name: *mut c_char,
524+
}
520525
}
521526

522527
s_no_extra_traits! {
@@ -4084,6 +4089,9 @@ extern "C" {
40844089
newpath: *const c_char,
40854090
flags: c_uint,
40864091
) -> c_int;
4092+
4093+
pub fn if_nameindex() -> *mut if_nameindex;
4094+
pub fn if_freenameindex(ptr: *mut if_nameindex);
40874095
}
40884096

40894097
cfg_if! {

0 commit comments

Comments
 (0)