Update state machine handling for wireless networks
[platform/upstream/connman.git] / src / dhcp.c
index 8af6dab..3b6ba63 100644 (file)
@@ -61,10 +61,12 @@ int connman_dhcp_update(struct connman_iface *iface,
                DBG("broadcast %s", inet_ntoa(ipv4->broadcast));
                DBG("nameserver %s", inet_ntoa(ipv4->nameserver));
 
-               if (iface->driver->set_ipv4) {
-                       iface->driver->set_ipv4(iface, ipv4);
-                       iface->ipv4 = *ipv4;
-               }
+               ipv4->method = CONNMAN_IPV4_METHOD_DHCP;
+
+               connman_iface_set_ipv4(iface, ipv4);
+               iface->ipv4 = *ipv4;
+
+               connman_iface_indicate_configured(iface);
        }
 
        return 0;
@@ -74,8 +76,13 @@ int __connman_dhcp_request(struct connman_iface *iface)
 {
        struct connman_dhcp_driver *driver = g_slist_nth_data(drivers, 0);
 
-       if (driver && driver->request)
+       if (iface->flags & CONNMAN_IFACE_FLAG_DHCP)
+               return -1;
+
+       if (driver && driver->request) {
+               iface->flags |= CONNMAN_IFACE_FLAG_DHCP;
                return driver->request(iface);
+       }
 
        return -1;
 }
@@ -84,8 +91,13 @@ int __connman_dhcp_release(struct connman_iface *iface)
 {
        struct connman_dhcp_driver *driver = g_slist_nth_data(drivers, 0);
 
-       if (driver && driver->release)
+       if (!(iface->flags & CONNMAN_IFACE_FLAG_DHCP))
+               return -1;
+
+       if (driver && driver->release) {
+               iface->flags &= ~CONNMAN_IFACE_FLAG_DHCP;
                return driver->release(iface);
+       }
 
        return -1;
 }