build: Add conditional compilation
Two conditionals are introduced in this commit:
- if <ifaddrs.h> is not available, NetworkInterface helper will always return
an empty set of interfaces
- If dropping/elevating effective user/group is not supported, an error
will be thrown if used (e.g., if general.user or general.group is
configured)
Both conditionals are necessary on Android platform.
Change-Id: Ib360e03514af97ed2d68032fbcbe279a8dc84682
diff --git a/core/network-interface.cpp b/core/network-interface.cpp
index 1aad63e..c6d23a3 100644
--- a/core/network-interface.cpp
+++ b/core/network-interface.cpp
@@ -31,9 +31,11 @@
#include <type_traits>
#include <unordered_map>
+#ifdef HAVE_IFADDRS_H
+#include <ifaddrs.h> // for getifaddrs()
+
#include <arpa/inet.h> // for inet_ntop()
#include <netinet/in.h> // for struct sockaddr_in{,6}
-#include <ifaddrs.h> // for getifaddrs()
#if defined(__linux__)
#include <net/if_arp.h> // for ARPHRD_* constants
@@ -43,6 +45,9 @@
#include <net/if_types.h> // for IFT_* constants
#endif
+#endif // HAVE_IFADDRS_H
+
+
NFD_LOG_INIT("NetworkInterfaceInfo");
namespace nfd {
@@ -73,6 +78,7 @@
}
#endif
+#ifdef HAVE_IFADDRS_H
using namespace boost::asio::ip;
using std::strerror;
@@ -170,6 +176,9 @@
}
return v;
+#else
+ return {};
+#endif // HAVE_IFADDRS_H
}
} // namespace nfd