aix,ibmi: use uv_interface_addresses instead of getifaddrs (#4222)
AIX and IBM i don't have getifaddrs but we do have code in `uv_interface_addresses` to get the interface addresses. Refs: https://github.com/libuv/libuv/issues/4117
This commit is contained in:
parent
51a22f60d6
commit
8861a97efa
@ -220,14 +220,32 @@ static int uv__is_ipv6_link_local(const struct sockaddr* addr) {
|
||||
|
||||
|
||||
static int uv__ipv6_link_local_scope_id(void) {
|
||||
/* disable link local on AIX & PASE for now */
|
||||
#if defined(_AIX)
|
||||
return 0;
|
||||
#else
|
||||
struct sockaddr_in6* a6;
|
||||
int rv;
|
||||
#if defined(_AIX)
|
||||
/* AIX & IBM i do not have ifaddrs
|
||||
* so fallback to use uv_interface_addresses */
|
||||
uv_interface_address_t* interfaces;
|
||||
uv_interface_address_t* ifa;
|
||||
int count, i;
|
||||
|
||||
if (uv_interface_addresses(&interfaces, &count))
|
||||
return 0;
|
||||
|
||||
rv = 0;
|
||||
|
||||
for (ifa = interfaces; ifa != &interfaces[count]; ifa++) {
|
||||
if (uv__is_ipv6_link_local((struct sockaddr*) &ifa->address)) {
|
||||
rv = ifa->address.address6.sin6_scope_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uv_free_interface_addresses(interfaces, count);
|
||||
|
||||
#else
|
||||
struct ifaddrs* ifa;
|
||||
struct ifaddrs* p;
|
||||
int rv;
|
||||
|
||||
if (getifaddrs(&ifa))
|
||||
return 0;
|
||||
@ -244,8 +262,9 @@ static int uv__ipv6_link_local_scope_id(void) {
|
||||
}
|
||||
|
||||
freeifaddrs(ifa);
|
||||
#endif /* defined(_AIX) */
|
||||
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user