Skip to content

Commit 1de4a5c

Browse files
[Android] Port getifaddrs implementation from Xamarin.Android (#71943)
In recent Android versions the data returned by getifaddrs is invalid and doesn't allow us to implement System.Net.NetworkInformation.GetAllNetworkInterfaces(). It's possible to reimplement getifaddrs using Netlink and there's already an existing implementation in Xamarin.Android. Fixes dotnet/android#6973 Ref #62780 Ref #51303
1 parent 6e33ec9 commit 1de4a5c

File tree

7 files changed

+815
-85
lines changed

7 files changed

+815
-85
lines changed

src/mono/cmake/config.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,6 @@
517517
/* Have getifaddrs */
518518
#cmakedefine HAVE_GETIFADDRS 1
519519

520-
/* Have struct ifaddrs */
521-
#cmakedefine HAVE_IFADDRS 1
522-
523520
/* Have access */
524521
#cmakedefine HAVE_ACCESS 1
525522

src/native/libs/Common/pal_config.h.in

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#cmakedefine01 HAVE_F_FULLFSYNC
1212
#cmakedefine01 HAVE_O_CLOEXEC
1313
#cmakedefine01 HAVE_GETIFADDRS
14-
#cmakedefine01 HAVE_IFADDRS
1514
#cmakedefine01 HAVE_UTSNAME_DOMAINNAME
1615
#cmakedefine01 HAVE_STAT64
1716
#cmakedefine01 HAVE_FORK

src/native/libs/System.Native/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake)
8383
set(NATIVE_LIBS_EXTRA)
8484
append_extra_system_libs(NATIVE_LIBS_EXTRA)
8585

86+
if (CLR_CMAKE_TARGET_ANDROID)
87+
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)
88+
89+
list (APPEND NATIVE_LIBS_EXTRA -llog)
90+
list (APPEND NATIVE_SOURCES pal_ifaddrs.c)
91+
endif ()
92+
8693
if (GEN_SHARED_LIB)
8794
add_library(System.Native
8895
SHARED

0 commit comments

Comments
 (0)