[前][次][番号順一覧][スレッド一覧]

ruby-changes:14760

From: akr <ko1@a...>
Date: Mon, 8 Feb 2010 21:09:06 +0900 (JST)
Subject: [ruby-changes:14760] Ruby:r26621 (trunk): * ext/socket/socket.c (socket_s_ip_address_list): obtain the scope_id

akr	2010-02-08 21:08:45 +0900 (Mon, 08 Feb 2010)

  New Revision: 26621

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26621

  Log:
    * ext/socket/socket.c (socket_s_ip_address_list): obtain the scope_id
      of IPv6 link local address on OpenSolaris.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/socket.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26620)
+++ ChangeLog	(revision 26621)
@@ -1,3 +1,8 @@
+Mon Feb  8 21:03:53 2010  Tanaka Akira  <akr@f...>
+
+	* 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@r...>
 
 	* dmyversion.c: empty load path in miniruby.
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 26620)
+++ ext/socket/socket.c	(revision 26621)
@@ -1554,13 +1554,22 @@
 	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));
         }
     }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]