generalize use of getifaddrs
This commit is contained in:
parent
7eba4cc310
commit
d35670e53d
|
@ -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
|
||||
|
|
|
@ -81,6 +81,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_IFADDRS
|
||||
#include <ifaddrs.h>
|
||||
#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<ip_interface> enum_net_interfaces(io_service& ios, error_code& ec)
|
||||
{
|
||||
std::vector<ip_interface> 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;
|
||||
|
|
Loading…
Reference in New Issue