|
|
|
@ -312,15 +312,14 @@ namespace net
@@ -312,15 +312,14 @@ namespace net
|
|
|
|
|
if (cur_ifname == ifname && cur->ifa_addr && cur->ifa_addr->sa_family == af) |
|
|
|
|
{ |
|
|
|
|
// match
|
|
|
|
|
char * addr = new char[INET6_ADDRSTRLEN]; |
|
|
|
|
bzero(addr, INET6_ADDRSTRLEN); |
|
|
|
|
char addr[INET6_ADDRSTRLEN]; |
|
|
|
|
memset (addr, 0, INET6_ADDRSTRLEN); |
|
|
|
|
if(af == AF_INET) |
|
|
|
|
inet_ntop(af, &((sockaddr_in *)cur->ifa_addr)->sin_addr, addr, INET6_ADDRSTRLEN); |
|
|
|
|
else |
|
|
|
|
inet_ntop(af, &((sockaddr_in6 *)cur->ifa_addr)->sin6_addr, addr, INET6_ADDRSTRLEN); |
|
|
|
|
freeifaddrs(addrs); |
|
|
|
|
std::string cur_ifaddr(addr); |
|
|
|
|
delete[] addr; |
|
|
|
|
return boost::asio::ip::address::from_string(cur_ifaddr); |
|
|
|
|
} |
|
|
|
|
cur = cur->ifa_next; |
|
|
|
|