Skip to content

Commit 01f3990

Browse files
devnexentgross35
authored andcommitted
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 (backport <rust-lang#4247>) (cherry picked from commit 32821d4)
1 parent bc541bc commit 01f3990

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

libc-test/build.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1912,6 +1912,8 @@ fn test_android(target: &str) {
19121912

19131913
// FIXME(android): "'__uint128' undeclared" in C
19141914
"__uint128" => true,
1915+
// Added in API level 24
1916+
"if_nameindex" => true,
19151917

19161918
_ => false,
19171919
}
@@ -2166,6 +2168,9 @@ fn test_android(target: &str) {
21662168
| "ispunct" | "isspace" | "isupper" | "isxdigit" | "isblank" | "tolower"
21672169
| "toupper" => true,
21682170

2171+
// Added in API level 24
2172+
"if_nameindex" | "if_freenameindex" => true,
2173+
21692174
_ => false,
21702175
}
21712176
});

libc-test/semver/android.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3382,7 +3382,9 @@ group
33823382
hostent
33833383
id_t
33843384
idtype_t
3385+
if_freenameindex
33853386
if_indextoname
3387+
if_nameindex
33863388
if_nametoindex
33873389
ifaddrs
33883390
ifconf

src/unix/linux_like/android/mod.rs

+8
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! {
@@ -4136,6 +4141,9 @@ extern "C" {
41364141
newpath: *const c_char,
41374142
flags: c_uint,
41384143
) -> c_int;
4144+
4145+
pub fn if_nameindex() -> *mut if_nameindex;
4146+
pub fn if_freenameindex(ptr: *mut if_nameindex);
41394147
}
41404148

41414149
cfg_if! {

0 commit comments

Comments
 (0)