ruby-changes:11007
From: akr <ko1@a...>
Date: Tue, 24 Feb 2009 22:03:14 +0900 (JST)
Subject: [ruby-changes:11007] Ruby:r22597 (trunk): * ext/socket/socket.c (sockaddr_obj): convert fe80:1::1 to fe80::1%1.
akr 2009-02-24 22:02:59 +0900 (Tue, 24 Feb 2009) New Revision: 22597 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22597 Log: * ext/socket/socket.c (sockaddr_obj): convert fe80:1::1 to fe80::1%1. Modified files: trunk/ChangeLog trunk/ext/socket/socket.c Index: ChangeLog =================================================================== --- ChangeLog (revision 22596) +++ ChangeLog (revision 22597) @@ -1,3 +1,7 @@ +Tue Feb 24 22:00:37 2009 Tanaka Akira <akr@f...> + + * ext/socket/socket.c (sockaddr_obj): convert fe80:1::1 to fe80::1%1. + Tue Feb 24 19:56:11 2009 Tanaka Akira <akr@f...> * ext/socket/ancdata.c (ancillary_timestamp): support SCM_BINTIME. Index: ext/socket/socket.c =================================================================== --- ext/socket/socket.c (revision 22596) +++ ext/socket/socket.c (revision 22597) @@ -1407,6 +1407,9 @@ sockaddr_obj(struct sockaddr *addr) { socklen_t len; +#if defined(AF_INET6) && defined(__KAME__) + struct sockaddr_in6 addr6; +#endif if (addr == NULL) return Qnil; @@ -1419,6 +1422,19 @@ #ifdef AF_INET6 case AF_INET6: len = sizeof(struct sockaddr_in6); +# ifdef __KAME__ + /* KAME uses the 2nd 16bit word of link local IPv6 address as interface index internally */ + /* convert fe80:1::1 to fe80::1%1 */ + memcpy(&addr6, addr, len); + addr = (struct sockaddr *)&addr6; + if (IN6_IS_ADDR_LINKLOCAL(&addr6.sin6_addr) && + addr6.sin6_scope_id == 0 && + (addr6.sin6_addr.s6_addr[2] || addr6.sin6_addr.s6_addr[3])) { + addr6.sin6_scope_id = (addr6.sin6_addr.s6_addr[2] << 8) | addr6.sin6_addr.s6_addr[3]; + addr6.sin6_addr.s6_addr[2] = 0; + addr6.sin6_addr.s6_addr[3] = 0; + } +# endif break; #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/