Skip to content

Commit

Permalink
Merge pull request #297 from jonkerj/fix-network-global-ipv6
Browse files Browse the repository at this point in the history
Network: Only resolve interface name on IPv6 link-local addresses
  • Loading branch information
mhennerich authored Aug 6, 2019
2 parents 915adbb + 0fbb31f commit c0012d0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,15 +1537,17 @@ struct iio_context * network_create_context(const char *host)
inet_ntop(AF_INET6, &in->sin6_addr,
description, INET6_ADDRSTRLEN);

ptr = if_indextoname(in->sin6_scope_id, description +
strlen(description) + 1);
if (!ptr) {
ret = -errno;
ERROR("Unable to lookup interface of IPv6 address\n");
goto err_free_description;
}
if (IN6_IS_ADDR_LINKLOCAL(&in->sin6_addr)) {
ptr = if_indextoname(in->sin6_scope_id, description +
strlen(description) + 1);
if (!ptr) {
ret = -errno;
ERROR("Unable to lookup interface of IPv6 address\n");
goto err_free_description;
}

*(ptr - 1) = '%';
*(ptr - 1) = '%';
}
}
#endif
if (res->ai_family == AF_INET) {
Expand Down

0 comments on commit c0012d0

Please sign in to comment.