* ext/socket/extconf.rb: check the existence of if_indextoname().

* ext/socket/option.c: yesterday's akr's commits destroyed the build of
  some unrelated platforms (such as Windows).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2010-12-25 16:41:13 +00:00
Родитель 01da08a29c
Коммит 7c9fbd226b
3 изменённых файлов: 36 добавлений и 6 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Sun Dec 26 01:37:10 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/extconf.rb: check the existence of if_indextoname().
* ext/socket/option.c: yesterday's akr's commits destroyed the build of
some unrelated platforms (such as Windows).
Sat Dec 25 23:29:11 2010 Tanaka Akira <akr@fsij.org> Sat Dec 25 23:29:11 2010 Tanaka Akira <akr@fsij.org>
* ext/socket/option.c (inspect_ipv4_add_drop_membership): new function * ext/socket/option.c (inspect_ipv4_add_drop_membership): new function

Просмотреть файл

@ -340,6 +340,8 @@ have_func("getpeereid")
have_header("ucred.h", headers) have_header("ucred.h", headers)
have_func("getpeerucred") have_func("getpeerucred")
have_func("if_indextoname")
have_type("struct ip_mreq", headers) # 4.4BSD have_type("struct ip_mreq", headers) # 4.4BSD
have_type("struct ip_mreqn", headers) # Linux 2.4 have_type("struct ip_mreqn", headers) # Linux 2.4
have_type("struct ipv6_mreq", headers) # RFC 3493 have_type("struct ipv6_mreq", headers) # RFC 3493

Просмотреть файл

@ -433,6 +433,27 @@ inspect_timeval_as_interval(int level, int optname, VALUE data, VALUE ret)
* it is not distinguishable by the size. * it is not distinguishable by the size.
*/ */
#ifdef __HAIKU__
#define HAVE_INET_NTOP
#endif
#ifndef HAVE_INET_NTOP
static char *
inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
{
#ifdef HAVE_INET_NTOA
struct in_addr in;
memcpy(&in.s_addr, addr, sizeof(in.s_addr));
snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));
#else
unsigned long x = ntohl(*(unsigned long*)addr);
snprintf(numaddr, numaddr_len, "%d.%d.%d.%d",
(int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
(int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff);
#endif
return numaddr;
}
#endif
#if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQ) /* 4.4BSD, GNU/Linux */ #if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQ) /* 4.4BSD, GNU/Linux */
static int static int
inspect_ipv4_mreq(int level, int optname, VALUE data, VALUE ret) inspect_ipv4_mreq(int level, int optname, VALUE data, VALUE ret)
@ -457,7 +478,7 @@ inspect_ipv4_mreq(int level, int optname, VALUE data, VALUE ret)
} }
#endif #endif
#if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQN) /* GNU/Linux, FreeBSD 7 */ #if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQN) && defined(HAVE_IF_INDEXTONAME) /* GNU/Linux, FreeBSD 7 */
static int static int
inspect_ipv4_mreqn(int level, int optname, VALUE data, VALUE ret) inspect_ipv4_mreqn(int level, int optname, VALUE data, VALUE ret)
{ {
@ -500,7 +521,7 @@ inspect_ipv4_add_drop_membership(int level, int optname, VALUE data, VALUE ret)
} }
#endif #endif
#if defined(IPPROTO_IP) && defined(IP_MULTICAST_IF) /* 4.4BSD, GNU/Linux */ #if defined(IPPROTO_IP) && defined(IP_MULTICAST_IF) && defined(HAVE_TYPE_STRUCT_IP_MREQN) /* 4.4BSD, GNU/Linux */
static int static int
inspect_ipv4_multicast_if(int level, int optname, VALUE data, VALUE ret) inspect_ipv4_multicast_if(int level, int optname, VALUE data, VALUE ret)
{ {
@ -523,7 +544,7 @@ inspect_ipv4_multicast_if(int level, int optname, VALUE data, VALUE ret)
} }
#endif #endif
#if defined(IPPROTO_IPV6) && defined(HAVE_TYPE_STRUCT_IPV6_MREQ) /* POSIX, RFC 3493 */ #if defined(IPPROTO_IPV6) && defined(HAVE_TYPE_STRUCT_IPV6_MREQ) && defined(HAVE_IF_INDEXTONAME) /* POSIX, RFC 3493 */
static int static int
inspect_ipv6_mreq(int level, int optname, VALUE data, VALUE ret) inspect_ipv6_mreq(int level, int optname, VALUE data, VALUE ret)
{ {
@ -741,7 +762,7 @@ sockopt_inspect(VALUE self)
# if defined(IPPROTO_IP) # if defined(IPPROTO_IP)
case IPPROTO_IP: case IPPROTO_IP:
switch (optname) { switch (optname) {
# if defined(IP_MULTICAST_IF) /* 4.4BSD, GNU/Linux */ # if defined(IP_MULTICAST_IF) && defined(HAVE_TYPE_STRUCT_IP_MREQN) /* 4.4BSD, GNU/Linux */
case IP_MULTICAST_IF: inspected = inspect_ipv4_multicast_if(level, optname, data, ret); break; case IP_MULTICAST_IF: inspected = inspect_ipv4_multicast_if(level, optname, data, ret); break;
# endif # endif
# if defined(IP_ADD_MEMBERSHIP) /* 4.4BSD, GNU/Linux */ # if defined(IP_ADD_MEMBERSHIP) /* 4.4BSD, GNU/Linux */
@ -766,10 +787,10 @@ sockopt_inspect(VALUE self)
# if defined(IPV6_MULTICAST_LOOP) /* POSIX */ # if defined(IPV6_MULTICAST_LOOP) /* POSIX */
case IPV6_MULTICAST_LOOP: inspected = inspect_uint(level, optname, data, ret); break; case IPV6_MULTICAST_LOOP: inspected = inspect_uint(level, optname, data, ret); break;
# endif # endif
# if defined(IPV6_JOIN_GROUP) /* POSIX */ # if defined(IPV6_JOIN_GROUP) && defined(HAVE_IF_INDEXTONAME) /* POSIX */
case IPV6_JOIN_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break; case IPV6_JOIN_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break;
# endif # endif
# if defined(IPV6_LEAVE_GROUP) /* POSIX */ # if defined(IPV6_LEAVE_GROUP) && defined(HAVE_IF_INDEXTONAME) /* POSIX */
case IPV6_LEAVE_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break; case IPV6_LEAVE_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break;
# endif # endif
# if defined(IPV6_UNICAST_HOPS) /* POSIX */ # if defined(IPV6_UNICAST_HOPS) /* POSIX */