diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-01 03:12:21 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-02-01 03:12:21 +0000 |
commit | e4b53b22228d935847b72e8f9ab0f49a15b54215 (patch) | |
tree | ae6cd78921bf626d54145b5485474bf59c3dceb4 /ext/socket | |
parent | 005f12582975d8382851b740690f97dba35aaa2a (diff) | |
download | ruby-e4b53b22228d935847b72e8f9ab0f49a15b54215.tar.gz |
2000-02-01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/extconf.rb | 21 | ||||
-rw-r--r-- | ext/socket/socket.c | 25 |
2 files changed, 41 insertions, 5 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 6975994ef8..b7aee1cc36 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -41,6 +41,7 @@ end $ipv6type = nil $ipv6lib = nil $ipv6libdir = nil +$ipv6trylibc = nil if $ipv6 if egrep_cpp("yes", <<EOF) #include <netinet/in.h> @@ -59,6 +60,7 @@ EOF $ipv6type = "kame" $ipv6lib="inet6" $ipv6libdir="/usr/local/v6/lib" + $ipv6trylibc=true $CFLAGS="-DINET6 "+$CFLAGS elsif File.directory? "/usr/inet6" $ipv6type = "linux" @@ -100,7 +102,7 @@ EOF if $ipv6lib if File.directory? $ipv6libdir and File.exist? "#{$ipv6libdir}/lib#{$ipv6lib}.a" $LOCAL_LIBS = " -L#$ipv6libdir -l#$ipv6lib" - else + elsif !$ipv6trylibc print <<EOS Fatal: no #$ipv6lib library found. cannot continue. @@ -135,6 +137,23 @@ end #include <netdb.h> #include <string.h> #include <sys/socket.h> +int +main() +{ + struct sockaddr_storage ss; + + ss.ss_family; + return 0; +} +EOF + $CFLAGS="-DHAVE_SOCKADDR_STORAGE "+$CFLAGS +end + + if try_link(<<EOF) +#include <sys/types.h> +#include <netdb.h> +#include <string.h> +#include <sys/socket.h> #include <netinet/in.h> int main() diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 37094026e4..d680adc325 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -81,10 +81,27 @@ int Rconnect(); #define INET_SERVER 1 #define INET_SOCKS 2 -#ifndef INET6 -# undef ss_family -# define sockaddr_storage sockaddr -# define ss_family sa_family +#ifndef HAVE_SOCKADDR_STORAGE +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(long long)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { +#ifdef HAVE_SA_LEN + unsigned char ss_len; /* address length */ + unsigned char ss_family; /* address family */ +#else + unsigned short ss_family; +#endif + char __ss_pad1[_SS_PAD1SIZE]; + long long __ss_align; /* force desired structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; #endif #ifdef NT |