1999-01-20 07:59:39 +03:00
|
|
|
require 'mkmf'
|
2000-12-22 06:22:25 +03:00
|
|
|
|
2011-06-21 16:31:17 +04:00
|
|
|
$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
|
|
|
|
|
2000-05-13 20:13:31 +04:00
|
|
|
case RUBY_PLATFORM
|
2010-11-01 18:26:58 +03:00
|
|
|
when /(ms|bcc)win(32|64)|mingw/
|
2002-06-11 05:27:48 +04:00
|
|
|
test_func = "WSACleanup"
|
|
|
|
have_library("ws2_32", "WSACleanup")
|
1999-08-13 09:37:52 +04:00
|
|
|
when /cygwin/
|
1999-01-20 07:59:39 +03:00
|
|
|
test_func = "socket"
|
|
|
|
when /beos/
|
|
|
|
test_func = "socket"
|
|
|
|
have_library("net", "socket")
|
2008-08-07 00:52:44 +04:00
|
|
|
when /haiku/
|
|
|
|
test_func = "socket"
|
|
|
|
have_library("network", "socket")
|
1999-08-13 09:37:52 +04:00
|
|
|
when /i386-os2_emx/
|
|
|
|
test_func = "socket"
|
|
|
|
have_library("socket", "socket")
|
1998-01-16 15:19:22 +03:00
|
|
|
else
|
|
|
|
test_func = "socket"
|
1999-01-20 07:59:39 +03:00
|
|
|
have_library("nsl", "t_open")
|
1998-01-16 15:19:22 +03:00
|
|
|
have_library("socket", "socket")
|
|
|
|
end
|
1999-08-13 09:37:52 +04:00
|
|
|
|
2005-02-06 17:51:44 +03:00
|
|
|
unless $mswin or $bccwin or $mingw
|
|
|
|
headers = %w<sys/types.h netdb.h string.h sys/socket.h netinet/in.h>
|
|
|
|
end
|
|
|
|
if /solaris/ =~ RUBY_PLATFORM and !try_compile("")
|
|
|
|
# bug of gcc 3.0 on Solaris 8 ?
|
|
|
|
headers << "sys/feature_tests.h"
|
|
|
|
end
|
2006-09-02 23:44:42 +04:00
|
|
|
if have_header("arpa/inet.h")
|
|
|
|
headers << "arpa/inet.h"
|
|
|
|
end
|
2005-02-06 17:51:44 +03:00
|
|
|
|
2006-05-26 03:44:08 +04:00
|
|
|
ipv6 = false
|
2009-07-22 14:24:37 +04:00
|
|
|
default_ipv6 = /mswin|cygwin|beos|haiku/ !~ RUBY_PLATFORM
|
2002-06-04 13:33:39 +04:00
|
|
|
if enable_config("ipv6", default_ipv6)
|
2005-02-06 17:51:44 +03:00
|
|
|
if checking_for("ipv6") {try_link(<<EOF)}
|
1999-08-13 09:37:52 +04:00
|
|
|
#include <sys/types.h>
|
2009-07-22 12:30:41 +04:00
|
|
|
#ifndef _WIN32
|
1999-08-13 09:37:52 +04:00
|
|
|
#include <sys/socket.h>
|
2009-07-22 12:30:41 +04:00
|
|
|
#endif
|
2008-08-10 03:15:08 +04:00
|
|
|
int
|
2011-12-01 12:45:22 +04:00
|
|
|
main(void)
|
1999-08-13 09:37:52 +04:00
|
|
|
{
|
|
|
|
socket(AF_INET6, SOCK_STREAM, 0);
|
2011-12-01 12:45:22 +04:00
|
|
|
return 0;
|
1999-08-13 09:37:52 +04:00
|
|
|
}
|
|
|
|
EOF
|
2006-05-26 03:44:08 +04:00
|
|
|
$defs << "-DENABLE_IPV6" << "-DINET6"
|
|
|
|
ipv6 = true
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-05-26 03:44:08 +04:00
|
|
|
if ipv6
|
2009-08-12 16:10:10 +04:00
|
|
|
if $mingw
|
2012-01-12 22:28:17 +04:00
|
|
|
$CPPFLAGS << " -D_WIN32_WINNT=0x501" unless $CPPFLAGS.include?("_WIN32_WINNT")
|
2009-08-12 16:10:10 +04:00
|
|
|
end
|
2006-05-26 03:44:08 +04:00
|
|
|
ipv6lib = nil
|
|
|
|
class << (fmt = "unknown")
|
|
|
|
def %(s) s || self end
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
2006-05-26 03:44:08 +04:00
|
|
|
idirs, ldirs = dir_config("inet6", %w[/usr/inet6 /usr/local/v6].find {|d| File.directory?(d)})
|
|
|
|
checking_for("ipv6 type", fmt) do
|
|
|
|
if have_macro("IPV6_INRIA_VERSION", "netinet/in.h")
|
|
|
|
"inria"
|
|
|
|
elsif have_macro("__KAME__", "netinet/in.h")
|
|
|
|
have_library(ipv6lib = "inet6")
|
|
|
|
"kame"
|
|
|
|
elsif have_macro("_TOSHIBA_INET6", "sys/param.h")
|
|
|
|
have_library(ipv6lib = "inet6") and "toshiba"
|
|
|
|
elsif have_macro("__V6D__", "sys/v6config.h")
|
|
|
|
have_library(ipv6lib = "v6") and "v6d"
|
|
|
|
elsif have_macro("_ZETA_MINAMI_INET6", "sys/param.h")
|
|
|
|
have_library(ipv6lib = "inet6") and "zeta"
|
|
|
|
elsif ipv6lib = with_config("ipv6-lib")
|
|
|
|
warn <<EOS
|
|
|
|
--with-ipv6-lib and --with-ipv6-libdir option will be obsolete, use
|
|
|
|
--with-inet6lib and --with-inet6-{include,lib} options instead.
|
1999-08-13 09:37:52 +04:00
|
|
|
EOS
|
2006-05-26 03:44:08 +04:00
|
|
|
find_library(ipv6lib, nil, with_config("ipv6-libdir", ldirs)) and
|
|
|
|
ipv6lib
|
|
|
|
elsif have_library("inet6")
|
|
|
|
"inet6"
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
2006-05-26 03:44:08 +04:00
|
|
|
end or not ipv6lib or abort <<EOS
|
|
|
|
|
|
|
|
Fatal: no #{ipv6lib} library found. cannot continue.
|
|
|
|
You need to fetch lib#{ipv6lib}.a from appropriate
|
|
|
|
ipv6 kit and compile beforehand.
|
|
|
|
EOS
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
|
|
|
|
2005-02-06 17:51:44 +03:00
|
|
|
if have_struct_member("struct sockaddr_in", "sin_len", headers)
|
|
|
|
$defs[-1] = "-DHAVE_SIN_LEN"
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
|
|
|
|
2005-02-06 17:51:44 +03:00
|
|
|
# doug's fix, NOW add -Dss_family... only if required!
|
|
|
|
doug = proc {have_struct_member("struct sockaddr_storage", "ss_family", headers)}
|
2005-02-10 07:55:34 +03:00
|
|
|
if (doug[] or
|
2009-10-28 19:41:33 +03:00
|
|
|
with_cppflags($CPPFLAGS + " -Dss_family=__ss_family", &doug))
|
2005-02-06 17:51:44 +03:00
|
|
|
$defs[-1] = "-DHAVE_SOCKADDR_STORAGE"
|
2009-10-28 19:41:33 +03:00
|
|
|
doug = proc {have_struct_member("struct sockaddr_storage", "ss_len", headers)}
|
|
|
|
doug[] or with_cppflags($CPPFLAGS + " -Dss_len=__ss_len", &doug)
|
2000-02-01 06:12:21 +03:00
|
|
|
end
|
|
|
|
|
2005-02-06 17:51:44 +03:00
|
|
|
if have_struct_member("struct sockaddr", "sa_len", headers)
|
|
|
|
$defs[-1] = "-DHAVE_SA_LEN "
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
|
|
|
|
2010-01-26 15:34:51 +03:00
|
|
|
have_header("netinet/tcp.h") if /cygwin/ !~ RUBY_PLATFORM # for cygwin 1.1.5
|
1999-10-12 08:53:36 +04:00
|
|
|
have_header("netinet/udp.h")
|
1999-08-13 09:37:52 +04:00
|
|
|
|
2010-05-12 06:40:09 +04:00
|
|
|
if !have_macro("IPPROTO_IPV6", headers) && have_const("IPPROTO_IPV6", headers)
|
|
|
|
IO.read(File.join(File.dirname(__FILE__), "mkconstants.rb")).sub(/\A.*^__END__$/m, '').split(/\r?\n/).grep(/\AIPPROTO_\w*/){$&}.each {|name|
|
|
|
|
have_const(name, headers) unless $defs.include?("-DHAVE_CONST_#{name.upcase}")
|
|
|
|
}
|
|
|
|
end
|
2010-05-11 18:10:34 +04:00
|
|
|
|
2010-09-13 14:56:52 +04:00
|
|
|
if have_func("sendmsg") | have_func("recvmsg")
|
2003-10-07 05:04:07 +04:00
|
|
|
have_struct_member('struct msghdr', 'msg_control', ['sys/types.h', 'sys/socket.h'])
|
|
|
|
have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
|
2003-07-30 04:32:03 +04:00
|
|
|
end
|
2002-03-01 00:31:35 +03:00
|
|
|
|
2011-07-24 15:35:56 +04:00
|
|
|
if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") {try_run(cpp_include(headers) + <<'EOF')}
|
2011-07-24 03:57:50 +04:00
|
|
|
#include <stdlib.h>
|
2011-07-24 15:35:56 +04:00
|
|
|
#include <stdio.h>
|
2011-07-24 03:57:50 +04:00
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-07-24 15:35:56 +04:00
|
|
|
int ps[2], sv[2];
|
2011-07-24 03:57:50 +04:00
|
|
|
int ret;
|
|
|
|
ssize_t ss;
|
|
|
|
int s_fd, r_fd;
|
|
|
|
struct msghdr s_msg, r_msg;
|
|
|
|
union {
|
|
|
|
struct cmsghdr hdr;
|
|
|
|
char dummy[CMSG_SPACE(sizeof(int))];
|
|
|
|
} s_cmsg, r_cmsg;
|
|
|
|
struct iovec s_iov, r_iov;
|
|
|
|
char s_buf[1], r_buf[1];
|
2011-07-24 15:04:11 +04:00
|
|
|
struct stat s_statbuf, r_statbuf;
|
2011-07-24 03:57:50 +04:00
|
|
|
|
2011-07-24 15:35:56 +04:00
|
|
|
ret = pipe(ps);
|
|
|
|
if (ret == -1) { perror("pipe"); exit(EXIT_FAILURE); }
|
|
|
|
|
|
|
|
s_fd = ps[0];
|
2011-07-24 03:57:50 +04:00
|
|
|
|
|
|
|
ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, sv);
|
|
|
|
if (ret == -1) { perror("socketpair"); exit(EXIT_FAILURE); }
|
|
|
|
|
|
|
|
s_msg.msg_name = NULL;
|
|
|
|
s_msg.msg_namelen = 0;
|
|
|
|
s_msg.msg_iov = &s_iov;
|
|
|
|
s_msg.msg_iovlen = 1;
|
|
|
|
s_msg.msg_control = &s_cmsg;
|
|
|
|
s_msg.msg_controllen = CMSG_SPACE(sizeof(int));;
|
|
|
|
s_msg.msg_flags = 0;
|
|
|
|
|
|
|
|
s_iov.iov_base = &s_buf;
|
|
|
|
s_iov.iov_len = sizeof(s_buf);
|
|
|
|
|
|
|
|
s_buf[0] = 'a';
|
|
|
|
|
|
|
|
s_cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
|
|
|
|
s_cmsg.hdr.cmsg_level = SOL_SOCKET;
|
|
|
|
s_cmsg.hdr.cmsg_type = SCM_RIGHTS;
|
|
|
|
memcpy(CMSG_DATA(&s_cmsg.hdr), (char *)&s_fd, sizeof(int));
|
|
|
|
|
|
|
|
ss = sendmsg(sv[0], &s_msg, 0);
|
|
|
|
if (ss == -1) { perror("sendmsg"); exit(EXIT_FAILURE); }
|
|
|
|
|
|
|
|
r_msg.msg_name = NULL;
|
|
|
|
r_msg.msg_namelen = 0;
|
|
|
|
r_msg.msg_iov = &r_iov;
|
|
|
|
r_msg.msg_iovlen = 1;
|
|
|
|
r_msg.msg_control = &r_cmsg;
|
|
|
|
r_msg.msg_controllen = CMSG_SPACE(sizeof(int));
|
|
|
|
r_msg.msg_flags = 0;
|
|
|
|
|
|
|
|
r_iov.iov_base = &r_buf;
|
|
|
|
r_iov.iov_len = sizeof(r_buf);
|
|
|
|
|
|
|
|
r_buf[0] = '0';
|
|
|
|
|
|
|
|
memset(&r_cmsg, 0xff, CMSG_SPACE(sizeof(int)));
|
|
|
|
|
|
|
|
ss = recvmsg(sv[1], &r_msg, MSG_PEEK);
|
|
|
|
if (ss == -1) { perror("recvmsg"); exit(EXIT_FAILURE); }
|
|
|
|
|
2011-07-24 15:35:56 +04:00
|
|
|
if (ss != 1) {
|
|
|
|
fprintf(stderr, "unexpected return value from recvmsg: %ld\n", (long)ss);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
if (r_buf[0] != 'a') {
|
|
|
|
fprintf(stderr, "unexpected return data from recvmsg: 0x%02x\n", r_buf[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-07-24 03:57:50 +04:00
|
|
|
|
2011-07-24 15:35:56 +04:00
|
|
|
if (r_msg.msg_controllen < CMSG_LEN(sizeof(int))) {
|
|
|
|
fprintf(stderr, "unexpected: r_msg.msg_controllen < CMSG_LEN(sizeof(int)) not hold: %ld\n",
|
|
|
|
(long)r_msg.msg_controllen);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
if (r_cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(int))) {
|
|
|
|
fprintf(stderr, "unexpected: r_cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(int)) not hold: %ld\n",
|
|
|
|
(long)r_cmsg.hdr.cmsg_len);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-07-24 15:04:11 +04:00
|
|
|
memcpy((char *)&r_fd, CMSG_DATA(&r_cmsg.hdr), sizeof(int));
|
2011-07-24 03:57:50 +04:00
|
|
|
|
2011-07-24 15:35:56 +04:00
|
|
|
if (r_fd < 0) {
|
|
|
|
fprintf(stderr, "negative r_fd: %d\n", r_fd);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-07-24 03:57:50 +04:00
|
|
|
|
2011-07-24 15:35:56 +04:00
|
|
|
if (r_fd == s_fd) {
|
|
|
|
fprintf(stderr, "r_fd and s_fd is same: %d\n", r_fd);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2011-07-24 15:04:11 +04:00
|
|
|
|
|
|
|
ret = fstat(s_fd, &s_statbuf);
|
2011-07-24 15:35:56 +04:00
|
|
|
if (ret == -1) { perror("fstat(s_fd)"); exit(EXIT_FAILURE); }
|
2011-07-24 15:04:11 +04:00
|
|
|
|
|
|
|
ret = fstat(r_fd, &r_statbuf);
|
2011-07-24 15:35:56 +04:00
|
|
|
if (ret == -1) { perror("fstat(r_fd)"); exit(EXIT_FAILURE); }
|
2011-07-24 03:57:50 +04:00
|
|
|
|
2011-07-24 15:04:11 +04:00
|
|
|
if (s_statbuf.st_dev != r_statbuf.st_dev ||
|
|
|
|
s_statbuf.st_ino != r_statbuf.st_ino) {
|
2011-07-24 15:35:56 +04:00
|
|
|
fprintf(stderr, "dev/ino doesn't match: s_fd:%ld/%ld r_fd:%ld/%ld\n",
|
|
|
|
(long)s_statbuf.st_dev, (long)s_statbuf.st_ino,
|
|
|
|
(long)r_statbuf.st_dev, (long)r_statbuf.st_ino);
|
2011-07-24 15:04:11 +04:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2011-07-24 03:57:50 +04:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
$defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK"
|
|
|
|
end
|
|
|
|
|
2009-12-30 23:56:41 +03:00
|
|
|
getaddr_info_ok = (enable_config("wide-getaddrinfo") && :wide) ||
|
|
|
|
(checking_for("wide getaddrinfo") {try_run(<<EOF)} && :os)
|
2005-02-06 17:51:44 +03:00
|
|
|
#{cpp_include(headers)}
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifndef EXIT_SUCCESS
|
|
|
|
#define EXIT_SUCCESS 0
|
|
|
|
#endif
|
|
|
|
#ifndef EXIT_FAILURE
|
|
|
|
#define EXIT_FAILURE 1
|
|
|
|
#endif
|
1999-08-13 09:37:52 +04:00
|
|
|
|
1999-10-18 13:03:16 +04:00
|
|
|
#ifndef AF_LOCAL
|
|
|
|
#define AF_LOCAL AF_UNIX
|
|
|
|
#endif
|
|
|
|
|
2008-08-10 03:15:08 +04:00
|
|
|
int
|
2011-12-01 12:45:22 +04:00
|
|
|
main(void)
|
1999-08-13 09:37:52 +04:00
|
|
|
{
|
|
|
|
int passive, gaierr, inet4 = 0, inet6 = 0;
|
|
|
|
struct addrinfo hints, *ai, *aitop;
|
|
|
|
char straddr[INET6_ADDRSTRLEN], strport[16];
|
2008-07-14 08:37:21 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
WSADATA retdata;
|
|
|
|
|
|
|
|
WSAStartup(MAKEWORD(2, 0), &retdata);
|
|
|
|
#endif
|
1999-08-13 09:37:52 +04:00
|
|
|
|
|
|
|
for (passive = 0; passive <= 1; passive++) {
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_family = AF_UNSPEC;
|
2003-05-06 20:48:51 +04:00
|
|
|
hints.ai_protocol = IPPROTO_TCP;
|
1999-08-13 09:37:52 +04:00
|
|
|
hints.ai_flags = passive ? AI_PASSIVE : 0;
|
|
|
|
hints.ai_socktype = SOCK_STREAM;
|
|
|
|
if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
|
|
|
|
(void)gai_strerror(gaierr);
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
for (ai = aitop; ai; ai = ai->ai_next) {
|
1999-10-18 13:03:16 +04:00
|
|
|
if (ai->ai_family == AF_LOCAL) continue;
|
2005-06-07 20:33:01 +04:00
|
|
|
if (ai->ai_addr == NULL)
|
|
|
|
goto bad;
|
|
|
|
#if defined(_AIX)
|
2006-11-02 18:38:59 +03:00
|
|
|
if (ai->ai_family == AF_INET6 && passive) {
|
|
|
|
inet6++;
|
|
|
|
continue;
|
|
|
|
}
|
2005-06-07 20:33:01 +04:00
|
|
|
ai->ai_addr->sa_len = ai->ai_addrlen;
|
|
|
|
ai->ai_addr->sa_family = ai->ai_family;
|
|
|
|
#endif
|
|
|
|
if (ai->ai_addrlen == 0 ||
|
1999-08-13 09:37:52 +04:00
|
|
|
getnameinfo(ai->ai_addr, ai->ai_addrlen,
|
|
|
|
straddr, sizeof(straddr), strport, sizeof(strport),
|
|
|
|
NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
if (strcmp(strport, "54321") != 0) {
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
switch (ai->ai_family) {
|
|
|
|
case AF_INET:
|
|
|
|
if (passive) {
|
|
|
|
if (strcmp(straddr, "0.0.0.0") != 0) {
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (strcmp(straddr, "127.0.0.1") != 0) {
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inet4++;
|
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
if (passive) {
|
|
|
|
if (strcmp(straddr, "::") != 0) {
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (strcmp(straddr, "::1") != 0) {
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inet6++;
|
|
|
|
break;
|
|
|
|
case AF_UNSPEC:
|
|
|
|
goto bad;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* another family support? */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-23 08:23:12 +03:00
|
|
|
if (!(inet4 == 0 || inet4 == 2))
|
|
|
|
goto bad;
|
|
|
|
if (!(inet6 == 0 || inet6 == 2))
|
1999-08-13 09:37:52 +04:00
|
|
|
goto bad;
|
|
|
|
|
|
|
|
if (aitop)
|
|
|
|
freeaddrinfo(aitop);
|
2011-12-01 12:45:22 +04:00
|
|
|
return EXIT_SUCCESS;
|
1999-08-13 09:37:52 +04:00
|
|
|
|
|
|
|
bad:
|
|
|
|
if (aitop)
|
|
|
|
freeaddrinfo(aitop);
|
2011-12-01 12:45:22 +04:00
|
|
|
return EXIT_FAILURE;
|
1999-08-13 09:37:52 +04:00
|
|
|
}
|
|
|
|
EOF
|
2006-05-26 03:44:08 +04:00
|
|
|
if ipv6 and not getaddr_info_ok
|
2005-02-06 17:51:44 +03:00
|
|
|
abort <<EOS
|
1999-08-13 09:37:52 +04:00
|
|
|
|
|
|
|
Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
|
|
|
|
But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
|
|
|
|
you cannot compile IPv6 socket classes with broken these functions.
|
2002-06-04 11:34:19 +04:00
|
|
|
You can try --enable-wide-getaddrinfo.
|
1999-08-13 09:37:52 +04:00
|
|
|
EOS
|
|
|
|
end
|
2005-02-06 17:51:44 +03:00
|
|
|
|
2000-05-30 08:24:17 +04:00
|
|
|
case with_config("lookup-order-hack", "UNSPEC")
|
2000-05-18 08:32:13 +04:00
|
|
|
when "INET"
|
2005-02-06 17:51:44 +03:00
|
|
|
$defs << "-DLOOKUP_ORDER_HACK_INET"
|
2000-05-18 08:32:13 +04:00
|
|
|
when "INET6"
|
2005-02-06 17:51:44 +03:00
|
|
|
$defs << "-DLOOKUP_ORDER_HACK_INET6"
|
2000-05-18 08:32:13 +04:00
|
|
|
when "UNSPEC"
|
2000-05-30 08:24:17 +04:00
|
|
|
# nothing special
|
2000-05-18 08:32:13 +04:00
|
|
|
else
|
2005-02-06 17:51:44 +03:00
|
|
|
abort <<EOS
|
2000-05-18 08:32:13 +04:00
|
|
|
|
2000-05-30 08:24:17 +04:00
|
|
|
Fatal: invalid value for --with-lookup-order-hack (expected INET, INET6 or UNSPEC)
|
2000-05-18 08:32:13 +04:00
|
|
|
EOS
|
|
|
|
end
|
1999-08-13 09:37:52 +04:00
|
|
|
|
2009-12-30 23:56:41 +03:00
|
|
|
have_type("struct addrinfo", headers)
|
|
|
|
have_func("freehostent")
|
|
|
|
have_func("freeaddrinfo")
|
|
|
|
if /haiku/ !~ RUBY_PLATFORM and have_func("gai_strerror")
|
|
|
|
if checking_for("gai_strerror() returns const pointer") {!try_compile(<<EOF)}
|
|
|
|
#{cpp_include(headers)}
|
|
|
|
#include <stdlib.h>
|
|
|
|
void
|
|
|
|
conftest_gai_strerror_is_const()
|
|
|
|
{
|
|
|
|
*gai_strerror(0) = 0;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
$defs << "-DGAI_STRERROR_CONST"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-01 03:26:19 +04:00
|
|
|
have_func("accept4")
|
|
|
|
|
2009-01-17 07:11:27 +03:00
|
|
|
$objs = [
|
|
|
|
"init.#{$OBJEXT}",
|
|
|
|
"constants.#{$OBJEXT}",
|
|
|
|
"basicsocket.#{$OBJEXT}",
|
|
|
|
"socket.#{$OBJEXT}",
|
|
|
|
"ipsocket.#{$OBJEXT}",
|
|
|
|
"tcpsocket.#{$OBJEXT}",
|
|
|
|
"tcpserver.#{$OBJEXT}",
|
|
|
|
"sockssocket.#{$OBJEXT}",
|
|
|
|
"udpsocket.#{$OBJEXT}",
|
|
|
|
"unixsocket.#{$OBJEXT}",
|
|
|
|
"unixserver.#{$OBJEXT}",
|
2009-02-02 04:53:02 +03:00
|
|
|
"option.#{$OBJEXT}",
|
2009-02-02 05:51:02 +03:00
|
|
|
"ancdata.#{$OBJEXT}",
|
2009-01-17 07:11:27 +03:00
|
|
|
"raddrinfo.#{$OBJEXT}"
|
|
|
|
]
|
1999-08-13 09:37:52 +04:00
|
|
|
|
2009-12-30 23:56:41 +03:00
|
|
|
if getaddr_info_ok == :wide or
|
|
|
|
!have_func("getnameinfo", headers) or !have_func("getaddrinfo", headers)
|
2005-02-06 17:51:44 +03:00
|
|
|
if have_struct_member("struct in6_addr", "s6_addr8", headers)
|
2009-12-30 23:56:41 +03:00
|
|
|
$defs[-1] = "s6_addr=s6_addr8"
|
|
|
|
end
|
|
|
|
if ipv6 == "kame" && have_struct_member("struct in6_addr", "s6_addr32", headers)
|
|
|
|
$defs[-1] = "-DFAITH"
|
2005-02-06 17:51:44 +03:00
|
|
|
end
|
|
|
|
$CPPFLAGS="-I. "+$CPPFLAGS
|
1999-08-13 09:37:52 +04:00
|
|
|
$objs += ["getaddrinfo.#{$OBJEXT}"]
|
|
|
|
$objs += ["getnameinfo.#{$OBJEXT}"]
|
2009-01-13 15:41:12 +03:00
|
|
|
$defs << "-DGETADDRINFO_EMU"
|
1999-08-13 09:37:52 +04:00
|
|
|
end
|
|
|
|
|
2011-12-01 11:59:21 +04:00
|
|
|
have_func('inet_ntop(0, (const void *)0, (char *)0, 0)') or
|
|
|
|
have_func("inet_ntoa(*(struct in_addr *)NULL)")
|
|
|
|
have_func('inet_pton(0, "", (void *)0)') or have_func('inet_aton("", (struct in_addr *)0)')
|
|
|
|
have_func('getservbyport(0, "")')
|
2010-12-25 20:21:08 +03:00
|
|
|
have_header("arpa/nameser.h")
|
|
|
|
have_header("resolv.h")
|
|
|
|
|
2009-01-20 14:19:09 +03:00
|
|
|
have_header("ifaddrs.h")
|
|
|
|
have_func("getifaddrs")
|
|
|
|
have_header("sys/ioctl.h")
|
|
|
|
have_header("sys/sockio.h")
|
2009-02-07 05:44:07 +03:00
|
|
|
have_header("net/if.h", headers)
|
2009-01-20 14:19:09 +03:00
|
|
|
|
2009-02-08 18:37:55 +03:00
|
|
|
have_header("sys/param.h", headers)
|
|
|
|
have_header("sys/ucred.h", headers)
|
|
|
|
|
2005-02-06 17:51:44 +03:00
|
|
|
unless have_type("socklen_t", headers)
|
|
|
|
$defs << "-Dsocklen_t=int"
|
2000-05-09 08:53:16 +04:00
|
|
|
end
|
|
|
|
|
1998-01-16 15:13:05 +03:00
|
|
|
have_header("sys/un.h")
|
2002-03-01 00:31:35 +03:00
|
|
|
have_header("sys/uio.h")
|
2009-02-03 19:29:23 +03:00
|
|
|
have_type("struct in_pktinfo", headers) {|src|
|
2009-02-03 01:58:03 +03:00
|
|
|
src.sub(%r'^/\*top\*/', '\1'"\n#if defined(IPPROTO_IP) && defined(IP_PKTINFO)") <<
|
2009-02-03 19:40:42 +03:00
|
|
|
"#else\n" << "#error\n" << ">>>>>> no in_pktinfo <<<<<<\n" << "#endif\n"
|
2009-12-31 00:01:13 +03:00
|
|
|
} and have_struct_member("struct in_pktinfo", "ipi_spec_dst", headers)
|
2009-02-03 19:29:23 +03:00
|
|
|
have_type("struct in6_pktinfo", headers) {|src|
|
2009-02-03 01:58:03 +03:00
|
|
|
src.sub(%r'^/\*top\*/', '\1'"\n#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO)") <<
|
2009-02-03 19:40:42 +03:00
|
|
|
"#else\n" << "#error\n" << ">>>>>> no in6_pktinfo <<<<<<\n" << "#endif\n"
|
2009-02-03 01:58:03 +03:00
|
|
|
}
|
1999-08-13 09:37:52 +04:00
|
|
|
|
2009-02-08 14:36:18 +03:00
|
|
|
have_type("struct sockcred", headers)
|
2009-02-08 15:53:55 +03:00
|
|
|
have_type("struct cmsgcred", headers)
|
2009-02-08 14:36:18 +03:00
|
|
|
|
2009-02-11 04:22:08 +03:00
|
|
|
have_func("getpeereid")
|
|
|
|
|
2009-02-12 15:43:04 +03:00
|
|
|
have_header("ucred.h", headers)
|
|
|
|
have_func("getpeerucred")
|
|
|
|
|
2010-12-25 19:41:13 +03:00
|
|
|
have_func("if_indextoname")
|
|
|
|
|
* ext/socket/option.c (inspect_ipv4_add_drop_membership): new function
to inspect struct ip_mreq and struct ip_mreqn for
IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
Socket::Option.new(:INET, :IP, :ADD_MEMBERSHIP,
[239,255,99,81, 0,0,0,0].pack("CCCCCCCC")).inspect is now
"#<Socket::Option: INET IP ADD_MEMBERSHIP 239.255.99.81 0.0.0.0>".
(inspect_ipv4_multicast_if): new function to inspect struct in_addr
and struct ip_mreqn for IP_MULTICAST_IF.
Socket::Option.new(:INET, :IP, :MULTICAST_IF,
[192,168,0,7].pack("CCCC")).inspect is now
"#<Socket::Option: INET IP MULTICAST_IF 192.168.0.7>".
* ext/socket/extconf.rb: check struct ip_mreq and struct ip_mreqn.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 17:35:28 +03:00
|
|
|
have_type("struct ip_mreq", headers) # 4.4BSD
|
|
|
|
have_type("struct ip_mreqn", headers) # Linux 2.4
|
|
|
|
have_type("struct ipv6_mreq", headers) # RFC 3493
|
* ext/socket/option.c (inspect_ipv6_mreq): new function to inspect
struct ipv6_mreq for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
Socket::Option.new(:INET6, :IPV6, :JOIN_GROUP,
[0xff12,0,0,0,0,0,0,1, 2].pack("nnnnnnnnI!")).inspect is now:
"#<Socket::Option: INET6 IPV6 JOIN_GROUP ff12::1 eth0>"
* ext/socket/extconf.rb: check struct ipv6_mreq.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 12:29:24 +03:00
|
|
|
|
2009-07-22 15:43:32 +04:00
|
|
|
# workaround for recent Windows SDK
|
2010-05-12 06:40:09 +04:00
|
|
|
$defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if $defs.include?("-DHAVE_CONST_IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6")
|
2009-07-22 15:43:32 +04:00
|
|
|
|
2009-01-22 11:02:41 +03:00
|
|
|
$distcleanfiles << "constants.h" << "constdefs.*"
|
2005-10-18 06:01:24 +04:00
|
|
|
|
1998-01-16 15:19:22 +03:00
|
|
|
if have_func(test_func)
|
1998-01-16 15:13:05 +03:00
|
|
|
have_func("hsterror")
|
2003-10-01 17:41:35 +04:00
|
|
|
have_func("getipnodebyname") or have_func("gethostbyname2")
|
2011-12-05 09:29:31 +04:00
|
|
|
if !have_func("socketpair(0, 0, 0, 0)") and have_func("rb_w32_socketpair(0, 0, 0, 0)")
|
|
|
|
$defs << "-Dsocketpair(a,b,c,d)=rb_w32_socketpair((a),(b),(c),(d))"
|
2011-12-08 07:59:10 +04:00
|
|
|
$defs << "-DHAVE_SOCKETPAIR"
|
2011-12-05 09:29:31 +04:00
|
|
|
end
|
2011-12-01 11:59:21 +04:00
|
|
|
unless have_func("gethostname((char *)0, 0)")
|
1998-01-16 15:13:05 +03:00
|
|
|
have_func("uname")
|
|
|
|
end
|
2003-07-29 22:26:55 +04:00
|
|
|
if enable_config("socks", ENV["SOCKS_SERVER"])
|
1999-09-22 08:30:11 +04:00
|
|
|
if have_library("socks5", "SOCKSinit")
|
2005-02-06 17:51:44 +03:00
|
|
|
$defs << "-DSOCKS5" << "-DSOCKS"
|
1999-09-22 08:30:11 +04:00
|
|
|
elsif have_library("socks", "Rconnect")
|
2005-02-06 17:51:44 +03:00
|
|
|
$defs << "-DSOCKS"
|
1998-01-16 15:13:05 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
create_makefile("socket")
|
|
|
|
end
|