Skip to content

Commit

Permalink
[Android] Port getifaddrs implementation from Xamarin.Android (dotnet…
Browse files Browse the repository at this point in the history
…#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 dotnet#62780
Ref dotnet#51303
  • Loading branch information
simonrozsival authored Jul 12, 2022
1 parent 6e33ec9 commit 1de4a5c
Show file tree
Hide file tree
Showing 7 changed files with 815 additions and 85 deletions.
3 changes: 0 additions & 3 deletions src/mono/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,6 @@
/* Have getifaddrs */
#cmakedefine HAVE_GETIFADDRS 1

/* Have struct ifaddrs */
#cmakedefine HAVE_IFADDRS 1

/* Have access */
#cmakedefine HAVE_ACCESS 1

Expand Down
1 change: 0 additions & 1 deletion src/native/libs/Common/pal_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#cmakedefine01 HAVE_F_FULLFSYNC
#cmakedefine01 HAVE_O_CLOEXEC
#cmakedefine01 HAVE_GETIFADDRS
#cmakedefine01 HAVE_IFADDRS
#cmakedefine01 HAVE_UTSNAME_DOMAINNAME
#cmakedefine01 HAVE_STAT64
#cmakedefine01 HAVE_FORK
Expand Down
7 changes: 7 additions & 0 deletions src/native/libs/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake)
set(NATIVE_LIBS_EXTRA)
append_extra_system_libs(NATIVE_LIBS_EXTRA)

if (CLR_CMAKE_TARGET_ANDROID)
add_compile_options(-Wno-gnu-zero-variadic-macro-arguments)

list (APPEND NATIVE_LIBS_EXTRA -llog)
list (APPEND NATIVE_SOURCES pal_ifaddrs.c)
endif ()

if (GEN_SHARED_LIB)
add_library(System.Native
SHARED
Expand Down
Loading

0 comments on commit 1de4a5c

Please sign in to comment.