summaryrefslogtreecommitdiff
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
parenta7926befe0e9eeb5a1ccc76e05e4f4aebb5f8caf (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--ext/socket/socket.c15
2 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ae8c1afcc74..aeeb5b70af5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Feb 8 21:03:53 2010 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/socket.c (socket_s_ip_address_list): obtain the scope_id
+ of IPv6 link local address on OpenSolaris.
+
Mon Feb 8 16:27:57 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dmyversion.c: empty load path in miniruby.
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 16394820f42..ab7bd950945 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));
}
}