Use dedicated code path for fixed IP settings
authorSamuel Ortiz <sameo@linux.intel.com>
Mon, 14 Jun 2010 20:09:42 +0000 (22:09 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 14 Jun 2010 20:09:42 +0000 (22:09 +0200)
src/network.c

index 74b104b..eed9759 100644 (file)
@@ -741,6 +741,46 @@ static void set_configuration(struct connman_network *network)
                                        CONNMAN_SERVICE_STATE_CONFIGURATION);
 }
 
+static int set_connected_fixed(struct connman_network *network)
+{
+       struct connman_service *service;
+       struct connman_element *parent, *element;
+
+       DBG("");
+
+       service = __connman_service_lookup_from_network(network);
+
+       parent = connman_network_get_element(network);
+
+       set_configuration(network);
+
+       if (parent->ipv4.address == NULL)
+               return -EINVAL;
+
+       if (parent->ipv4.netmask == NULL)
+               return -EINVAL;
+
+       element = connman_element_create(NULL);
+       if (element == NULL) {
+               connman_error("Can not create connman_element");
+               return -ENOMEM;
+       }
+
+       element->type = CONNMAN_ELEMENT_TYPE_IPV4;
+       element->index = parent->index;
+
+       if (connman_element_register(element, parent) < 0) {
+               connman_error("Can not register connman_element");
+               return -EINVAL;
+       }
+
+       network->connecting = FALSE;
+
+       connman_network_set_associating(network, FALSE);
+
+       return 0;
+}
+
 static void set_connected_manual(struct connman_network *network)
 {
        struct connman_service *service;
@@ -825,8 +865,14 @@ static gboolean set_connected(gpointer user_data)
                case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
                case CONNMAN_IPCONFIG_METHOD_OFF:
                        return FALSE;
-               case CONNMAN_IPCONFIG_METHOD_MANUAL:
                case CONNMAN_IPCONFIG_METHOD_FIXED:
+                       if (set_connected_fixed(network) < 0) {
+                               connman_network_set_error(network,
+                                       CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
+                               return FALSE;
+                       }
+                       return TRUE;
+               case CONNMAN_IPCONFIG_METHOD_MANUAL:
                        set_connected_manual(network);
                        return TRUE;
                case CONNMAN_IPCONFIG_METHOD_DHCP: