|
|
@ -67,8 +67,12 @@ int inet_pton_xp (int af, const char *src, void *dst) |
|
|
|
} |
|
|
|
} |
|
|
|
#else /* !_WIN32 => UNIX */ |
|
|
|
#else /* !_WIN32 => UNIX */ |
|
|
|
#include <sys/types.h> |
|
|
|
#include <sys/types.h> |
|
|
|
|
|
|
|
#ifdef ANDROID |
|
|
|
|
|
|
|
#include "ifaddrs.h" |
|
|
|
|
|
|
|
#else |
|
|
|
#include <ifaddrs.h> |
|
|
|
#include <ifaddrs.h> |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#define address_pair_v4(a,b) { boost::asio::ip::address_v4::from_string (a).to_ulong (), boost::asio::ip::address_v4::from_string (b).to_ulong () } |
|
|
|
#define address_pair_v4(a,b) { boost::asio::ip::address_v4::from_string (a).to_ulong (), boost::asio::ip::address_v4::from_string (b).to_ulong () } |
|
|
|
#define address_pair_v6(a,b) { boost::asio::ip::address_v6::from_string (a).to_bytes (), boost::asio::ip::address_v6::from_string (b).to_bytes () } |
|
|
|
#define address_pair_v6(a,b) { boost::asio::ip::address_v6::from_string (a).to_bytes (), boost::asio::ip::address_v6::from_string (b).to_bytes () } |
|
|
@ -380,11 +384,11 @@ namespace net |
|
|
|
return boost::asio::ip::address::from_string("127.0.0.1"); |
|
|
|
return boost::asio::ip::address::from_string("127.0.0.1"); |
|
|
|
#else |
|
|
|
#else |
|
|
|
int af = (ipv6 ? AF_INET6 : AF_INET); |
|
|
|
int af = (ipv6 ? AF_INET6 : AF_INET); |
|
|
|
ifaddrs * addrs = nullptr; |
|
|
|
ifaddrs *addrs, *cur = nullptr; |
|
|
|
if(getifaddrs(&addrs) == 0) |
|
|
|
if(getifaddrs(&addrs) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// got ifaddrs
|
|
|
|
// got ifaddrs
|
|
|
|
ifaddrs * cur = addrs; |
|
|
|
cur = addrs; |
|
|
|
while(cur) |
|
|
|
while(cur) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::string cur_ifname(cur->ifa_name); |
|
|
|
std::string cur_ifname(cur->ifa_name); |
|
|
@ -431,10 +435,7 @@ namespace net |
|
|
|
|
|
|
|
|
|
|
|
boost::asio::ip::address_v6 GetYggdrasilAddress () |
|
|
|
boost::asio::ip::address_v6 GetYggdrasilAddress () |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if defined(ANDROID) |
|
|
|
#if defined(_WIN32) |
|
|
|
// TODO: implement
|
|
|
|
|
|
|
|
return boost::asio::ip::address_v6 (); |
|
|
|
|
|
|
|
#elif defined(_WIN32) |
|
|
|
|
|
|
|
ULONG outBufLen = 0; |
|
|
|
ULONG outBufLen = 0; |
|
|
|
PIP_ADAPTER_ADDRESSES pAddresses = nullptr; |
|
|
|
PIP_ADAPTER_ADDRESSES pAddresses = nullptr; |
|
|
|
PIP_ADAPTER_ADDRESSES pCurrAddresses = nullptr; |
|
|
|
PIP_ADAPTER_ADDRESSES pCurrAddresses = nullptr; |
|
|
@ -482,11 +483,11 @@ namespace net |
|
|
|
FREE(pAddresses); |
|
|
|
FREE(pAddresses); |
|
|
|
return boost::asio::ip::address_v6 (); |
|
|
|
return boost::asio::ip::address_v6 (); |
|
|
|
#else |
|
|
|
#else |
|
|
|
ifaddrs * addrs = nullptr; |
|
|
|
ifaddrs *addrs, *cur = nullptr; |
|
|
|
auto err = getifaddrs(&addrs); |
|
|
|
auto err = getifaddrs(&addrs); |
|
|
|
if (!err) |
|
|
|
if (!err) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ifaddrs * cur = addrs; |
|
|
|
cur = addrs; |
|
|
|
while(cur) |
|
|
|
while(cur) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (cur->ifa_addr && cur->ifa_addr->sa_family == AF_INET6) |
|
|
|
if (cur->ifa_addr && cur->ifa_addr->sa_family == AF_INET6) |
|
|
|