From 7e833da5feab7c68924280e4e183784504e664ba Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 8 Feb 2010 12:08:45 +0000 Subject: [PATCH] * 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 --- ChangeLog | 5 +++++ ext/socket/socket.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae8c1afcc7..aeeb5b70af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Feb 8 21:03:53 2010 Tanaka Akira + + * 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 * dmyversion.c: empty load path in miniruby. 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)); } }