mirror of
https://github.com/mfontanini/libtins
synced 2026-01-22 18:25:57 +01:00
android workaround (#471)
This commit is contained in:
@@ -331,7 +331,7 @@ NetworkInterface::Info NetworkInterface::info() const {
|
||||
}
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
#ifndef ANDROID
|
||||
struct ifaddrs* ifaddrs = 0;
|
||||
struct ifaddrs* if_it = 0;
|
||||
getifaddrs(&ifaddrs);
|
||||
@@ -341,7 +341,9 @@ NetworkInterface::Info NetworkInterface::info() const {
|
||||
if (ifaddrs) {
|
||||
freeifaddrs(ifaddrs);
|
||||
}
|
||||
|
||||
#else
|
||||
throw new std::runtime_error("android ifaddr not supported");
|
||||
#endif
|
||||
#endif // _WIN32
|
||||
|
||||
// If we didn't even get the hw address or ip address, this went wrong
|
||||
|
||||
@@ -413,17 +413,21 @@ set<string> network_interfaces() {
|
||||
}
|
||||
#else
|
||||
set<string> network_interfaces() {
|
||||
set<string> output;
|
||||
struct ifaddrs* ifaddrs = 0;
|
||||
struct ifaddrs* if_it = 0;
|
||||
getifaddrs(&ifaddrs);
|
||||
for (if_it = ifaddrs; if_it; if_it = if_it->ifa_next) {
|
||||
output.insert(if_it->ifa_name);
|
||||
}
|
||||
if (ifaddrs) {
|
||||
freeifaddrs(ifaddrs);
|
||||
}
|
||||
#ifndef ANDROID
|
||||
set<string> output;
|
||||
struct ifaddrs* ifaddrs = 0;
|
||||
struct ifaddrs* if_it = 0;
|
||||
getifaddrs(&ifaddrs);
|
||||
for (if_it = ifaddrs; if_it; if_it = if_it->ifa_next) {
|
||||
output.insert(if_it->ifa_name);
|
||||
}
|
||||
if (ifaddrs) {
|
||||
freeifaddrs(ifaddrs);
|
||||
}
|
||||
return output;
|
||||
#else
|
||||
throw std::runtime_error("android ifaddr not supported");
|
||||
#endif
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user