Skip to content

Commit 3947c8c

Browse files
lattice0laudrup
authored andcommitted
android workaround (mfontanini#471)
1 parent 7661e80 commit 3947c8c

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/network_interface.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ NetworkInterface::Info NetworkInterface::info() const {
331331
}
332332

333333
#else // _WIN32
334-
334+
#ifndef ANDROID
335335
struct ifaddrs* ifaddrs = 0;
336336
struct ifaddrs* if_it = 0;
337337
getifaddrs(&ifaddrs);
@@ -341,7 +341,9 @@ NetworkInterface::Info NetworkInterface::info() const {
341341
if (ifaddrs) {
342342
freeifaddrs(ifaddrs);
343343
}
344-
344+
#else
345+
throw new std::runtime_error("android ifaddr not supported");
346+
#endif
345347
#endif // _WIN32
346348

347349
// If we didn't even get the hw address or ip address, this went wrong

src/utils/routing_utils.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -413,17 +413,21 @@ set<string> network_interfaces() {
413413
}
414414
#else
415415
set<string> network_interfaces() {
416-
set<string> output;
417-
struct ifaddrs* ifaddrs = 0;
418-
struct ifaddrs* if_it = 0;
419-
getifaddrs(&ifaddrs);
420-
for (if_it = ifaddrs; if_it; if_it = if_it->ifa_next) {
421-
output.insert(if_it->ifa_name);
422-
}
423-
if (ifaddrs) {
424-
freeifaddrs(ifaddrs);
425-
}
416+
#ifndef ANDROID
417+
set<string> output;
418+
struct ifaddrs* ifaddrs = 0;
419+
struct ifaddrs* if_it = 0;
420+
getifaddrs(&ifaddrs);
421+
for (if_it = ifaddrs; if_it; if_it = if_it->ifa_next) {
422+
output.insert(if_it->ifa_name);
423+
}
424+
if (ifaddrs) {
425+
freeifaddrs(ifaddrs);
426+
}
426427
return output;
428+
#else
429+
throw std::runtime_error("android ifaddr not supported");
430+
#endif
427431
}
428432
#endif // _WIN32
429433

0 commit comments

Comments
 (0)