Changed the "resolve" test precheck program to verify that an IPv6 socket
can be created before resolving the IPv6 name. In the context of running a test, it doesn't make sense to run an IPv6 test when a host is resolvable but IPv6 isn't usable. This should fix failures of test 1085 on hosts with library and DNS support for IPv6 but where actual use of IPv6 has been administratively disabled.
This commit is contained in:
Родитель
6cdd067faf
Коммит
a10044e110
8
CHANGES
8
CHANGES
|
@ -6,6 +6,14 @@
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel Fandrich (28 Oct 2008)
|
||||||
|
- Changed the "resolve" test precheck program to verify that an IPv6 socket
|
||||||
|
can be created before resolving the IPv6 name. In the context of running
|
||||||
|
a test, it doesn't make sense to run an IPv6 test when a host is resolvable
|
||||||
|
but IPv6 isn't usable. This should fix failures of test 1085 on hosts with
|
||||||
|
library and DNS support for IPv6 but where actual use of IPv6 has been
|
||||||
|
administratively disabled.
|
||||||
|
|
||||||
Daniel Fandrich (24 Oct 2008)
|
Daniel Fandrich (24 Oct 2008)
|
||||||
- Added experimental support for zlib and OpenSSL on Symbian OS.
|
- Added experimental support for zlib and OpenSSL on Symbian OS.
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
#ifdef HAVE_SYS_SOCKET_H
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -61,9 +64,7 @@
|
||||||
/* include memdebug.h last */
|
/* include memdebug.h last */
|
||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
static bool use_ipv6 = FALSE;
|
static bool use_ipv6 = FALSE;
|
||||||
#endif
|
|
||||||
static const char *ipv_inuse = "IPv4";
|
static const char *ipv_inuse = "IPv4";
|
||||||
|
|
||||||
const char *serverlogfile=""; /* for a util.c function we don't use */
|
const char *serverlogfile=""; /* for a util.c function we don't use */
|
||||||
|
@ -72,7 +73,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int arg=1;
|
int arg=1;
|
||||||
const char *host = NULL;
|
const char *host = NULL;
|
||||||
int rc;
|
int rc = 0;
|
||||||
|
|
||||||
while(argc>arg) {
|
while(argc>arg) {
|
||||||
if(!strcmp("--version", argv[arg])) {
|
if(!strcmp("--version", argv[arg])) {
|
||||||
|
@ -86,18 +87,14 @@ int main(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(!strcmp("--ipv6", argv[arg])) {
|
else if(!strcmp("--ipv6", argv[arg])) {
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
ipv_inuse = "IPv6";
|
ipv_inuse = "IPv6";
|
||||||
use_ipv6 = TRUE;
|
use_ipv6 = TRUE;
|
||||||
#endif
|
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
else if(!strcmp("--ipv4", argv[arg])) {
|
else if(!strcmp("--ipv4", argv[arg])) {
|
||||||
/* for completeness, we support this option as well */
|
/* for completeness, we support this option as well */
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
ipv_inuse = "IPv4";
|
ipv_inuse = "IPv4";
|
||||||
use_ipv6 = FALSE;
|
use_ipv6 = FALSE;
|
||||||
#endif
|
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -107,9 +104,12 @@ int main(int argc, char *argv[])
|
||||||
if(!host) {
|
if(!host) {
|
||||||
puts("Usage: resolve [option] <host>\n"
|
puts("Usage: resolve [option] <host>\n"
|
||||||
" --version\n"
|
" --version\n"
|
||||||
" --ipv4\n"
|
" --ipv4"
|
||||||
" --ipv6");
|
#ifdef ENABLE_IPV6
|
||||||
return 0;
|
"\n --ipv6"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -117,10 +117,7 @@ int main(int argc, char *argv[])
|
||||||
atexit(win32_cleanup);
|
atexit(win32_cleanup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
if(!use_ipv6) {
|
||||||
if(!use_ipv6)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* gethostbyname() resolve */
|
/* gethostbyname() resolve */
|
||||||
struct hostent *he;
|
struct hostent *he;
|
||||||
|
|
||||||
|
@ -128,22 +125,38 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
rc = !he;
|
rc = !he;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
else {
|
else {
|
||||||
/* getaddrinfo() resolve */
|
#ifdef ENABLE_IPV6
|
||||||
struct addrinfo *ai;
|
/* Check that the system has IPv6 enabled before checking the resolver */
|
||||||
struct addrinfo hints;
|
int s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||||
|
if(s == -1)
|
||||||
|
/* an ipv6 address was requested and we can't get/use one */
|
||||||
|
rc = -1;
|
||||||
|
else {
|
||||||
|
sclose(s);
|
||||||
|
}
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
if (rc == 0) {
|
||||||
hints.ai_family = PF_INET6;
|
/* getaddrinfo() resolve */
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
struct addrinfo *ai;
|
||||||
hints.ai_flags = AI_CANONNAME;
|
struct addrinfo hints;
|
||||||
rc = (getaddrinfo)(host, "80", &hints, &ai);
|
|
||||||
|
|
||||||
}
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
hints.ai_family = PF_INET6;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_CANONNAME;
|
||||||
|
/* Use parenthesis around function to stop it from being replaced by
|
||||||
|
the macro in memdebug.h */
|
||||||
|
rc = (getaddrinfo)(host, "80", &hints, &ai);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
puts("IPv6 support has been disabled in this program");
|
||||||
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
if(rc)
|
if(rc)
|
||||||
printf("Resolving %s '%s' didn't work\n", ipv_inuse, host);
|
printf("Resolving %s '%s' didn't work\n", ipv_inuse, host);
|
||||||
|
|
||||||
return !rc?0:1;
|
return !!rc;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче