This project is closed and read-only.
Backport #2514 » getaddrinfo.diff
| ext/socket/getaddrinfo.c (working copy) | ||
|---|---|---|
|
#include "sockport.h"
|
||
|
#if defined(__KAME__) && defined(INET6)
|
||
|
# define FAITH
|
||
|
#endif
|
||
|
#define SUCCESS 0
|
||
|
#define ANY 0
|
||
| ... | ... | |
|
#ifdef INET6
|
||
|
case AF_INET6:
|
||
|
#ifdef HAVE_ADDR8
|
||
|
pfx = ((struct in6_addr *)pton)->s6_addr8[0];
|
||
|
#else
|
||
|
pfx = ((struct in6_addr *)pton)->s6_addr[0];
|
||
|
#endif
|
||
|
if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
|
||
|
pai->ai_flags &= ~AI_CANONNAME;
|
||
| ... | ... | |
|
GET_AI(cur->ai_next, &afdl[N_INET6], ap, port);
|
||
|
in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr;
|
||
|
memcpy(&in6->s6_addr32[0], &faith_prefix,
|
||
|
sizeof(struct in6_addr) - sizeof(struct in_addr));
|
||
|
memcpy(&in6->s6_addr32[3], ap, sizeof(struct in_addr));
|
||
|
memcpy(&in6->s6_addr, &faith_prefix,
|
||
|
sizeof(struct in6_addr) - sizeof(struct in_addr));
|
||
|
memcpy(&in6->s6_addr + sizeof(struct in_addr), ap,
|
||
|
sizeof(struct in_addr));
|
||
|
} else
|
||
|
#endif /* FAITH */
|
||
| ext/socket/extconf.rb (working copy) | ||
|---|---|---|
|
end
|
||
|
getaddr_info_ok = enable_config("wide-getaddrinfo") do
|
||
|
checking_for("wide getaddrinfo") {try_run(<<EOF)}
|
||
|
getaddr_info_ok = (enable_config("wide-getaddrinfo", nil) && :wide) ||
|
||
|
(checking_for("wide getaddrinfo") {try_run(<<EOF)} && :os)
|
||
|
#{cpp_include(headers)}
|
||
|
#include <stdlib.h>
|
||
| ... | ... | |
|
}
|
||
|
EOF
|
||
|
end
|
||
|
if ipv6 and not getaddr_info_ok
|
||
|
abort <<EOS
|
||
| ... | ... | |
|
$objs = ["socket.#{$OBJEXT}"]
|
||
|
unless getaddr_info_ok and have_func("getnameinfo", "netdb.h") and have_func("getaddrinfo", "netdb.h")
|
||
|
if !have_func("getnameinfo", "netdb.h") or !have_func("getaddrinfo", "netdb.h") or
|
||
|
getaddr_info_ok == :wide
|
||
|
if have_struct_member("struct in6_addr", "s6_addr8", headers)
|
||
|
$defs[-1] = "-DHAVE_ADDR8"
|
||
|
$defs[-1] = "s6_addr=s6_addr8"
|
||
|
end
|
||
|
if ipv6 == "kame" && have_struct_member("struct in6_addr", "s6_addr32", headers)
|
||
|
$defs[-1] = "-DFAITH"
|
||
|
end
|
||
|
$CPPFLAGS="-I. "+$CPPFLAGS
|
||
| ext/socket/addrinfo.h (working copy) | ||
|---|---|---|
|
extern void freehostent __P((struct hostent *));
|
||
|
extern void freeaddrinfo __P((struct addrinfo *));
|
||
|
#if defined __UCLIBC__
|
||
|
#ifdef GAI_STRERROR_CONST
|
||
|
const
|
||
|
#endif
|
||
| ext/socket/getnameinfo.c (working copy) | ||
|---|---|---|
|
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
|
||
|
const struct sockaddr *sa;
|
||
|
size_t salen;
|
||
|
socklen_t salen;
|
||
|
char *host;
|
||
|
size_t hostlen;
|
||
|
socklen_t hostlen;
|
||
|
char *serv;
|
||
|
size_t servlen;
|
||
|
socklen_t servlen;
|
||
|
int flags;
|
||
|
{
|
||