Clear and set IPv4 settings when connected
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 18 May 2010 10:48:13 +0000 (12:48 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 18 May 2010 14:37:21 +0000 (16:37 +0200)
If changed while connected, the IPv4 settings should be applied without
clients needing to go through a disconnect->connect cycle.

src/service.c

index 9774ef6..cfe33d8 100644 (file)
@@ -1068,13 +1068,29 @@ static DBusMessage *set_property(DBusConnection *conn,
                if (service->ipconfig == NULL)
                        return __connman_error_invalid_property(msg);
 
+               if (is_connecting(service) ||
+                       is_connected(service))
+                       __connman_network_clear_ipconfig(service->network,
+                                                       service->ipconfig);
+
                err = __connman_ipconfig_set_ipv4config(service->ipconfig,
                                                                &value);
-               if (err < 0)
+               if (err < 0) {
+                       if (is_connected(service) ||
+                               is_connecting(service))
+                               __connman_network_set_ipconfig(service->network,
+                                                       service->ipconfig);
+
                        return __connman_error_failed(msg, -err);
+               }
 
                ipv4_configuration_changed(service);
 
+               if (is_connecting(service) ||
+                       is_connected(service))
+                       __connman_network_set_ipconfig(service->network,
+                                                       service->ipconfig);
+
                __connman_storage_save_service(service);
        } else
                return __connman_error_invalid_property(msg);