mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 09:33:59 +02:00
* ext/socket/extconf.rb: fix for wide-getaddrinfo option.
* ext/socket/addrinfo.c: rename {addr,name}info functions to ensure those are used on darwin. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6096bbf0c0
commit
36f9338707
7 changed files with 67 additions and 55 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Thu Dec 31 05:56:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/socket/extconf.rb: fix for wide-getaddrinfo option.
|
||||||
|
|
||||||
|
* ext/socket/addrinfo.c: rename {addr,name}info functions to ensure
|
||||||
|
those are used on darwin.
|
||||||
|
|
||||||
Thu Dec 31 01:58:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Dec 31 01:58:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/extmk.rb: fix for extstatic.
|
* ext/extmk.rb: fix for extstatic.
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#ifndef ADDR_INFO_H
|
#ifndef ADDR_INFO_H
|
||||||
#define ADDR_INFO_H
|
#define ADDR_INFO_H
|
||||||
#ifndef HAVE_GETADDRINFO
|
|
||||||
|
|
||||||
/* special compatibility hack */
|
/* special compatibility hack */
|
||||||
#undef EAI_ADDRFAMILY
|
#undef EAI_ADDRFAMILY
|
||||||
|
@ -61,17 +60,6 @@
|
||||||
#undef NI_NUMERICSERV
|
#undef NI_NUMERICSERV
|
||||||
#undef NI_DGRAM
|
#undef NI_DGRAM
|
||||||
|
|
||||||
#undef addrinfo
|
|
||||||
#define addrinfo addrinfo__compat
|
|
||||||
#undef getaddrinfo
|
|
||||||
#define getaddrinfo getaddrinfo__compat
|
|
||||||
#undef getnameinfo
|
|
||||||
#define getnameinfo getnameinfo__compat
|
|
||||||
#undef freehostent
|
|
||||||
#define freehostent freehostent__compat
|
|
||||||
#undef freeaddrinfo
|
|
||||||
#define freeaddrinfo freeaddrinfo__compat
|
|
||||||
|
|
||||||
#ifndef __P
|
#ifndef __P
|
||||||
# ifdef HAVE_PROTOTYPES
|
# ifdef HAVE_PROTOTYPES
|
||||||
# define __P(args) args
|
# define __P(args) args
|
||||||
|
@ -134,6 +122,7 @@
|
||||||
#define NI_NUMERICSERV 0x00000008
|
#define NI_NUMERICSERV 0x00000008
|
||||||
#define NI_DGRAM 0x00000010
|
#define NI_DGRAM 0x00000010
|
||||||
|
|
||||||
|
#ifndef HAVE_TYPE_STRUCT_ADDRINFO
|
||||||
struct addrinfo {
|
struct addrinfo {
|
||||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
||||||
int ai_family; /* PF_xxx */
|
int ai_family; /* PF_xxx */
|
||||||
|
@ -144,6 +133,24 @@ struct addrinfo {
|
||||||
struct sockaddr *ai_addr; /* binary address */
|
struct sockaddr *ai_addr; /* binary address */
|
||||||
struct addrinfo *ai_next; /* next structure in linked list */
|
struct addrinfo *ai_next; /* next structure in linked list */
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETADDRINFO
|
||||||
|
#undef getaddrinfo
|
||||||
|
#define getaddrinfo getaddrinfo__compat
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_GETNAMEINFO
|
||||||
|
#undef getnameinfo
|
||||||
|
#define getnameinfo getnameinfo__compat
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_FREEHOSTENT
|
||||||
|
#undef freehostent
|
||||||
|
#define freehostent freehostent__compat
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_FREEADDRINFO
|
||||||
|
#undef freeaddrinfo
|
||||||
|
#define freeaddrinfo freeaddrinfo__compat
|
||||||
|
#endif
|
||||||
|
|
||||||
extern int getaddrinfo __P((
|
extern int getaddrinfo __P((
|
||||||
const char *hostname, const char *servname,
|
const char *hostname, const char *servname,
|
||||||
|
@ -152,19 +159,20 @@ extern int getaddrinfo __P((
|
||||||
|
|
||||||
extern int getnameinfo __P((
|
extern int getnameinfo __P((
|
||||||
const struct sockaddr *sa,
|
const struct sockaddr *sa,
|
||||||
size_t salen,
|
socklen_t salen,
|
||||||
char *host,
|
char *host,
|
||||||
size_t hostlen,
|
socklen_t hostlen,
|
||||||
char *serv,
|
char *serv,
|
||||||
size_t servlen,
|
socklen_t servlen,
|
||||||
int flags));
|
int flags));
|
||||||
|
|
||||||
extern void freehostent __P((struct hostent *));
|
extern void freehostent __P((struct hostent *));
|
||||||
extern void freeaddrinfo __P((struct addrinfo *));
|
extern void freeaddrinfo __P((struct addrinfo *));
|
||||||
#if defined __UCLIBC__
|
extern
|
||||||
|
#ifdef GAI_STRERROR_CONST
|
||||||
const
|
const
|
||||||
#endif
|
#endif
|
||||||
extern char *gai_strerror __P((int));
|
char *gai_strerror __P((int));
|
||||||
|
|
||||||
/* In case there is no definition of offsetof() provided - though any proper
|
/* In case there is no definition of offsetof() provided - though any proper
|
||||||
Standard C system should have one. */
|
Standard C system should have one. */
|
||||||
|
@ -174,4 +182,3 @@ Standard C system should have one. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
socket.o : socket.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/rubyio.h $(hdrdir)/rubysig.h sockport.h
|
socket.o : socket.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h $(hdrdir)/rubyio.h $(hdrdir)/rubysig.h addrinfo.h sockport.h
|
||||||
getnameinfo.o: getnameinfo.c $(topdir)/config.h addrinfo.h sockport.h
|
getnameinfo.o: getnameinfo.c $(topdir)/config.h addrinfo.h sockport.h
|
||||||
getaddrinfo.o: getaddrinfo.c $(topdir)/config.h addrinfo.h sockport.h
|
getaddrinfo.o: getaddrinfo.c $(topdir)/config.h addrinfo.h sockport.h
|
||||||
|
|
|
@ -120,8 +120,8 @@ if have_func("sendmsg") | have_func("recvmsg")
|
||||||
have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
|
have_struct_member('struct msghdr', 'msg_accrights', ['sys/types.h', 'sys/socket.h'])
|
||||||
end
|
end
|
||||||
|
|
||||||
getaddr_info_ok = enable_config("wide-getaddrinfo") do
|
getaddr_info_ok = (enable_config("wide-getaddrinfo") && :wide) ||
|
||||||
checking_for("wide getaddrinfo") {try_run(<<EOF)}
|
(checking_for("wide getaddrinfo") {try_run(<<EOF)} && :os)
|
||||||
#{cpp_include(headers)}
|
#{cpp_include(headers)}
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -224,7 +224,6 @@ main()
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
end
|
|
||||||
if ipv6 and not getaddr_info_ok
|
if ipv6 and not getaddr_info_ok
|
||||||
abort <<EOS
|
abort <<EOS
|
||||||
|
|
||||||
|
@ -249,20 +248,11 @@ Fatal: invalid value for --with-lookup-order-hack (expected INET, INET6 or UNSPE
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
$objs = ["socket.#{$OBJEXT}"]
|
have_type("struct addrinfo", headers)
|
||||||
|
have_func("freehostent")
|
||||||
unless getaddr_info_ok and have_func("getnameinfo", "netdb.h") and have_func("getaddrinfo", "netdb.h")
|
have_func("freeaddrinfo")
|
||||||
if have_struct_member("struct in6_addr", "s6_addr8", headers)
|
if have_func("gai_strerror")
|
||||||
$defs[-1] = "-DHAVE_ADDR8"
|
if checking_for("gai_strerror() returns const pointer") {!try_compile(<<EOF)}
|
||||||
end
|
|
||||||
$CPPFLAGS="-I. "+$CPPFLAGS
|
|
||||||
$objs += ["getaddrinfo.#{$OBJEXT}"]
|
|
||||||
$objs += ["getnameinfo.#{$OBJEXT}"]
|
|
||||||
have_func("inet_ntop") or have_func("inet_ntoa")
|
|
||||||
have_func("inet_pton") or have_func("inet_aton")
|
|
||||||
have_func("getservbyport")
|
|
||||||
if have_func("gai_strerror")
|
|
||||||
unless checking_for("gai_strerror() returns const pointer") {!try_compile(<<EOF)}
|
|
||||||
#{cpp_include(headers)}
|
#{cpp_include(headers)}
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
void
|
void
|
||||||
|
@ -273,7 +263,24 @@ conftest_gai_strerror_is_const()
|
||||||
EOF
|
EOF
|
||||||
$defs << "-DGAI_STRERROR_CONST"
|
$defs << "-DGAI_STRERROR_CONST"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
$objs = ["socket.#{$OBJEXT}"]
|
||||||
|
|
||||||
|
if getaddr_info_ok == :wide or
|
||||||
|
!have_func("getnameinfo", headers) or !have_func("getaddrinfo", headers)
|
||||||
|
if have_struct_member("struct in6_addr", "s6_addr8", headers)
|
||||||
|
$defs[-1] = "s6_addr=s6_addr8"
|
||||||
end
|
end
|
||||||
|
if ipv6 == "kame" && have_struct_member("struct in6_addr", "s6_addr32", headers)
|
||||||
|
$defs[-1] = "-DFAITH"
|
||||||
|
end
|
||||||
|
$CPPFLAGS="-I. "+$CPPFLAGS
|
||||||
|
$objs += ["getaddrinfo.#{$OBJEXT}"]
|
||||||
|
$objs += ["getnameinfo.#{$OBJEXT}"]
|
||||||
|
have_func("inet_ntop") or have_func("inet_ntoa")
|
||||||
|
have_func("inet_pton") or have_func("inet_aton")
|
||||||
|
have_func("getservbyport")
|
||||||
have_header("arpa/nameser.h")
|
have_header("arpa/nameser.h")
|
||||||
have_header("resolv.h")
|
have_header("resolv.h")
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,10 +87,6 @@
|
||||||
#include "addrinfo.h"
|
#include "addrinfo.h"
|
||||||
#include "sockport.h"
|
#include "sockport.h"
|
||||||
|
|
||||||
#if defined(__KAME__) && defined(INET6)
|
|
||||||
# define FAITH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SUCCESS 0
|
#define SUCCESS 0
|
||||||
#define ANY 0
|
#define ANY 0
|
||||||
#define YES 1
|
#define YES 1
|
||||||
|
@ -493,11 +489,7 @@ getaddrinfo(hostname, servname, hints, res)
|
||||||
break;
|
break;
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
#ifdef HAVE_ADDR8
|
|
||||||
pfx = ((struct in6_addr *)pton)->s6_addr8[0];
|
|
||||||
#else
|
|
||||||
pfx = ((struct in6_addr *)pton)->s6_addr[0];
|
pfx = ((struct in6_addr *)pton)->s6_addr[0];
|
||||||
#endif
|
|
||||||
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
|
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
|
||||||
pai->ai_flags &= ~AI_CANONNAME;
|
pai->ai_flags &= ~AI_CANONNAME;
|
||||||
break;
|
break;
|
||||||
|
@ -673,9 +665,10 @@ get_addr(hostname, af, res, pai, port0)
|
||||||
|
|
||||||
GET_AI(cur->ai_next, &afdl[N_INET6], ap, port);
|
GET_AI(cur->ai_next, &afdl[N_INET6], ap, port);
|
||||||
in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr;
|
in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr;
|
||||||
memcpy(&in6->s6_addr32[0], &faith_prefix,
|
memcpy(&in6->s6_addr, &faith_prefix,
|
||||||
sizeof(struct in6_addr) - sizeof(struct in_addr));
|
sizeof(struct in6_addr) - sizeof(struct in_addr));
|
||||||
memcpy(&in6->s6_addr32[3], ap, sizeof(struct in_addr));
|
memcpy(&in6->s6_addr + sizeof(struct in_addr), ap,
|
||||||
|
sizeof(struct in_addr));
|
||||||
} else
|
} else
|
||||||
#endif /* FAITH */
|
#endif /* FAITH */
|
||||||
GET_AI(cur->ai_next, afd, ap, port);
|
GET_AI(cur->ai_next, afd, ap, port);
|
||||||
|
|
|
@ -135,11 +135,11 @@ inet_ntop(af, addr, numaddr, numaddr_len)
|
||||||
int
|
int
|
||||||
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
|
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
|
||||||
const struct sockaddr *sa;
|
const struct sockaddr *sa;
|
||||||
size_t salen;
|
socklen_t salen;
|
||||||
char *host;
|
char *host;
|
||||||
size_t hostlen;
|
socklen_t hostlen;
|
||||||
char *serv;
|
char *serv;
|
||||||
size_t servlen;
|
socklen_t servlen;
|
||||||
int flags;
|
int flags;
|
||||||
{
|
{
|
||||||
struct afd *afd;
|
struct afd *afd;
|
||||||
|
|
|
@ -69,9 +69,7 @@
|
||||||
#ifndef EWOULDBLOCK
|
#ifndef EWOULDBLOCK
|
||||||
#define EWOULDBLOCK EAGAIN
|
#define EWOULDBLOCK EAGAIN
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAVE_GETADDRINFO
|
#include "addrinfo.h"
|
||||||
# include "addrinfo.h"
|
|
||||||
#endif
|
|
||||||
#include "sockport.h"
|
#include "sockport.h"
|
||||||
|
|
||||||
#if defined(__vms)
|
#if defined(__vms)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue