From 415eeebda4e294f7aacb59d7632daed8646ea64d Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 11 Nov 2016 09:59:58 +1100 Subject: [PATCH] add --ipv6only=no test --- bin/tests/system/feature-test.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/bin/tests/system/feature-test.c b/bin/tests/system/feature-test.c index 77452cc6cc..8ccc8bf34b 100644 --- a/bin/tests/system/feature-test.c +++ b/bin/tests/system/feature-test.c @@ -15,6 +15,7 @@ #include #include +#include #include #ifdef WIN32 @@ -33,15 +34,16 @@ static void usage() { fprintf(stderr, "usage: feature-test \n"); fprintf(stderr, "args:\n"); - fprintf(stderr, " --enable-filter-aaaa\n"); fprintf(stderr, " --edns-version\n"); + fprintf(stderr, " --enable-filter-aaaa\n"); fprintf(stderr, " --gethostname\n"); fprintf(stderr, " --gssapi\n"); fprintf(stderr, " --have-dlopen\n"); fprintf(stderr, " --have-geoip\n"); fprintf(stderr, " --have-libxml2\n"); - fprintf(stderr, " --rpz-nsip\n"); + fprintf(stderr, " --ipv6only=no\n"); fprintf(stderr, " --rpz-nsdname\n"); + fprintf(stderr, " --rpz-nsip\n"); fprintf(stderr, " --with-idn\n"); } @@ -154,6 +156,25 @@ main(int argc, char **argv) { #endif } + if (strcmp(argv[1], "--ipv6only=no") == 0) { +#ifdef WIN32 + return (0); +#elif defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY) + int s; + int n; + int v6only = -1; + ISC_SOCKADDR_LEN_T len = sizeof(v6only); + + s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); + n = getsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&v6only, &len); + close(s); + return ((n == 0 && v6only == 0) ? 0 : 1); +#else + return (1); +#endif + } + fprintf(stderr, "unknown arg: %s\n", argv[1]); usage(); return (1);