aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-08 12:08:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-08 12:08:45 +0000
commit7e833da5feab7c68924280e4e183784504e664ba (patch)
tree52b03dd6d237ddb64a24e3518a4e10780616f063 /ext
parenta7926befe0e9eeb5a1ccc76e05e4f4aebb5f8caf (diff)
downloadruby-7e833da5feab7c68924280e4e183784504e664ba.tar.gz
* ext/socket/socket.c (socket_s_ip_address_list): obtain the scope_id
of IPv6 link local address on OpenSolaris. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/socket.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 16394820f4..ab7bd95094 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1554,13 +1554,22 @@ socket_s_ip_address_list(VALUE self)
goto finish;
}
- close(fd);
- fd = -1;
-
list = rb_ary_new();
for (i = 0; i < ln.lifn_count; i++) {
struct lifreq *req = &lc.lifc_req[i];
if (IS_IP_FAMILY(req->lifr_addr.ss_family)) {
+ if (req->lifr_addr.ss_family == AF_INET6 &&
+ IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_addr) &&
+ ((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_scope_id == 0) {
+ struct lifreq req2;
+ memcpy(req2.lifr_name, req->lifr_name, LIFNAMSIZ);
+ ret = ioctl(fd, SIOCGLIFINDEX, &req2);
+ if (ret == -1) {
+ reason = "SIOCGLIFINDEX";
+ goto finish;
+ }
+ ((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_scope_id = req2.lifr_index;
+ }
rb_ary_push(list, sockaddr_obj((struct sockaddr *)&req->lifr_addr));
}
}