android: Request and install an IPv6 DNS server
authorTobias Brunner <tobias@strongswan.org>
Thu, 7 Mar 2013 17:20:10 +0000 (18:20 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 20 Mar 2013 14:24:26 +0000 (15:24 +0100)
src/frontends/android/jni/libandroidbridge/backend/android_attr.c
src/frontends/android/jni/libandroidbridge/vpnservice_builder.c

index bf6073f..1d7bf14 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012-2013 Tobias Brunner
  * Copyright (C) 2012 Giuliano Grassi
  * Copyright (C) 2012 Ralf Sager
  * Hochschule fuer Technik Rapperswil
@@ -47,6 +47,9 @@ METHOD(attribute_handler_t, handle, bool,
                case INTERNAL_IP4_DNS:
                        dns = host_create_from_chunk(AF_INET, data, 0);
                        break;
+               case INTERNAL_IP6_DNS:
+                       dns = host_create_from_chunk(AF_INET6, data, 0);
+                       break;
                default:
                        return FALSE;
        }
@@ -70,22 +73,31 @@ METHOD(attribute_handler_t, release, void,
        /* DNS servers cannot be removed from an existing TUN device */
 }
 
-METHOD(enumerator_t, enumerate_dns, bool,
+METHOD(enumerator_t, enumerate_dns6, bool,
        enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
 {
-       *type = INTERNAL_IP4_DNS;
+       *type = INTERNAL_IP6_DNS;
        *data = chunk_empty;
        this->enumerate = (void*)return_false;
        return TRUE;
 }
 
+METHOD(enumerator_t, enumerate_dns4, bool,
+       enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
+{
+       *type = INTERNAL_IP4_DNS;
+       *data = chunk_empty;
+       this->enumerate = (void*)_enumerate_dns6;
+       return TRUE;
+}
+
 METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
        private_android_attr_t *this, identification_t *server, linked_list_t *vips)
 {
        enumerator_t *enumerator;
 
        INIT(enumerator,
-                       .enumerate = (void*)_enumerate_dns,
+                       .enumerate = (void*)_enumerate_dns4,
                        .destroy = (void*)free,
        );
        return enumerator;
index 5232bc4..6b10228 100644 (file)
@@ -161,16 +161,12 @@ METHOD(vpnservice_builder_t, add_dns, bool,
        JNIEnv *env;
        jmethodID method_id;
        jstring str;
-       char buf[INET_ADDRSTRLEN];
+       char buf[INET6_ADDRSTRLEN];
 
        androidjni_attach_thread(&env);
 
        DBG2(DBG_LIB, "builder: adding DNS server %H", dns);
 
-       if (dns->get_family(dns) != AF_INET)
-       {
-               goto failed;
-       }
        if (snprintf(buf, sizeof(buf), "%H", dns) >= sizeof(buf))
        {
                goto failed;