diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 0c69543e7..813a703fb 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -138,10 +138,12 @@ POSSIBILITY OF SUCH DAMAGE. #endif #endif #define TORRENT_HAS_FALLOCATE 0 +#define TORRENT_USE_IFADDRS 1 // ==== LINUX === #elif defined __linux__ #define TORRENT_LINUX +#define TORRENT_USE_IFADDRS 1 // ==== MINGW === #elif defined __MINGW32__ @@ -287,6 +289,10 @@ inline int snprintf(char* buf, int len, char const* fmt, ...) #define TORRENT_USE_RLIMIT 1 #endif +#ifndef TORRENT_USE_IFADDRS +#define TORRENT_USE_IFADDRS 0 +#endif + #ifndef TORRENT_USE_IPV6 #define TORRENT_USE_IPV6 1 #endif diff --git a/src/enum_net.cpp b/src/enum_net.cpp index b5c6f4e3d..baf3d7446 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -81,6 +81,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#endif + +#if TORRENT_USE_IFADDRS #include #endif @@ -281,7 +284,7 @@ namespace libtorrent { namespace } #endif -#if defined TORRENT_LINUX +#if TORRENT_USE_IFADDRS bool iface_from_ifaddrs(ifaddrs *ifa, ip_interface &rv, error_code& ec) { int family = ifa->ifa_addr->sa_family; @@ -400,7 +403,7 @@ namespace libtorrent std::vector enum_net_interfaces(io_service& ios, error_code& ec) { std::vector ret; -#if defined TORRENT_LINUX +#if TORRENT_USE_IFADDRS int s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { @@ -446,7 +449,7 @@ namespace libtorrent close(s); freeifaddrs(ifaddr); // MacOS X, BSD and solaris -#elif defined TORRENT_BSD || defined TORRENT_SOLARIS +#elif defined TORRENT_LINUX || defined TORRENT_BSD || defined TORRENT_SOLARIS int s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { @@ -519,7 +522,7 @@ namespace libtorrent #if defined TORRENT_BSD int current_size = item.ifr_addr.sa_len + IFNAMSIZ; -#elif defined TORRENT_LINUX || defined TORRENT_SOLARIS +#else int current_size = sizeof(ifreq); #endif ifr += current_size;