provider: Set nameservers if we receive them from vpnd
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Mon, 25 Mar 2013 14:58:56 +0000 (16:58 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Wed, 27 Mar 2013 14:00:09 +0000 (16:00 +0200)
If we receive nameservers from vpnd we must set them in provider.
The connman_provider_set_nameservers() function needs changes
because we get the nameservers as an array, it makes no sense to
convert the array to string and then back to array.

include/provider.h
plugins/vpn.c
src/provider.c

index fdd8ae0d71e375d8f546156372a9a4ea693c3e9b..1f33552de9ca38fdde686a49c2603ce1d2b2d564 100644 (file)
@@ -109,7 +109,7 @@ void connman_provider_put(struct connman_provider *provider);
 int connman_provider_set_domain(struct connman_provider *provider,
                                const char *domain);
 int connman_provider_set_nameservers(struct connman_provider *provider,
-                                       const char *nameservers);
+                                       char * const *nameservers);
 int connman_provider_append_route(struct connman_provider *provider,
                                        const char *key, const char *value);
 
index 038a833815e903a895623dff2cd351e4112f5572..d33d7c1feed1f63a4a1ea39f2d2052858b2019da 100644 (file)
@@ -643,6 +643,10 @@ static void add_connection(const char *path, DBusMessageIter *properties,
 
        resolv_host_addr(data);
 
+       if (data->nameservers != NULL)
+               connman_provider_set_nameservers(data->provider,
+                                               data->nameservers);
+
        if (data->connect_pending == TRUE)
                connect_provider(data, data->cb_data);
 
@@ -1756,7 +1760,10 @@ static gboolean property_changed(DBusConnection *conn,
                        set_routes(data->provider,
                                                CONNMAN_PROVIDER_ROUTE_USER);
        } else if (g_str_equal(key, "Nameservers") == TRUE) {
-               extract_nameservers(&value, data);
+               if (extract_nameservers(&value, data) == 0 &&
+                                               data->nameservers != NULL)
+                       connman_provider_set_nameservers(data->provider,
+                                                       data->nameservers);
        }
 
        if (ip_set == TRUE && err == 0) {
index f7bb4e10944a710245c064eecb19b4b00dbd5df9..1c3601725e8f0c4ff37c15451ec7dc30ee65561f 100644 (file)
@@ -552,26 +552,20 @@ int connman_provider_set_domain(struct connman_provider *provider,
 }
 
 int connman_provider_set_nameservers(struct connman_provider *provider,
-                                       const char *nameservers)
+                                       char * const * nameservers)
 {
        int i;
-       char **nameservers_array = NULL;
 
-       DBG("provider %p nameservers %s", provider, nameservers);
+       DBG("provider %p nameservers %p", provider, nameservers);
 
        __connman_service_nameserver_clear(provider->vpn_service);
 
        if (nameservers == NULL)
                return 0;
 
-       nameservers_array = g_strsplit(nameservers, " ", 0);
-
-       for (i = 0; nameservers_array[i] != NULL; i++) {
+       for (i = 0; nameservers[i] != NULL; i++)
                __connman_service_nameserver_append(provider->vpn_service,
-                                               nameservers_array[i], FALSE);
-       }
-
-       g_strfreev(nameservers_array);
+                                               nameservers[i], FALSE);
 
        return 0;
 }