service: Factor out reading ipconfigs from create functions
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 22 Aug 2011 10:44:26 +0000 (13:44 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 23 Aug 2011 14:24:44 +0000 (16:24 +0200)
Create new read functions for IPv4 and IPv6 from the code in
__connman_service_create_ip*config functions.

src/connman.h
src/service.c

index 6e68c99..17add6d 100644 (file)
@@ -473,9 +473,10 @@ struct connman_service *__connman_service_create_from_network(struct connman_net
 struct connman_service *__connman_service_create_from_provider(struct connman_provider *provider);
 void __connman_service_update_from_network(struct connman_network *network);
 void __connman_service_remove_from_network(struct connman_network *network);
-
+void __connman_service_read_ip4config(struct connman_service *service);
 void __connman_service_create_ip4config(struct connman_service *service,
                                                                int index);
+void __connman_service_read_ip6config(struct connman_service *service);
 void __connman_service_create_ip6config(struct connman_service *service,
                                                                int index);
 struct connman_ipconfig *__connman_service_get_ip4config(
index 7cd21b5..6482b50 100644 (file)
@@ -4623,57 +4623,69 @@ static void setup_ip6config(struct connman_service *service, int index)
        connman_ipconfig_set_ops(service->ipconfig_ipv6, &service_ops);
 }
 
-void __connman_service_create_ip4config(struct connman_service *service,
-                                                               int index)
+void __connman_service_read_ip4config(struct connman_service *service)
 {
        const char *ident = service->profile;
        GKeyFile *keyfile;
 
+       if (ident == NULL)
+               return;
+       if (service->ipconfig_ipv4 == NULL)
+               return;
+
+       keyfile = __connman_storage_open_profile(ident);
+       if (keyfile == NULL)
+               return;
+
+       __connman_ipconfig_load(service->ipconfig_ipv4, keyfile,
+                               service->identifier, "IPv4.");
+
+       g_key_file_free(keyfile);
+}
+
+void __connman_service_create_ip4config(struct connman_service *service,
+                                       int index)
+{
        DBG("ipv4 %p", service->ipconfig_ipv4);
 
        if (service->ipconfig_ipv4 != NULL)
                return;
 
        setup_ip4config(service, index, CONNMAN_IPCONFIG_METHOD_DHCP);
+       __connman_service_read_ip4config(service);
+}
+
+void __connman_service_read_ip6config(struct connman_service *service)
+{
+       const char *ident = service->profile;
+       GKeyFile *keyfile;
 
        if (ident == NULL)
                return;
+       if (service->ipconfig_ipv6 == NULL)
+               return;
 
        keyfile = __connman_storage_open_profile(ident);
+
        if (keyfile == NULL)
                return;
 
-       if (service->ipconfig_ipv4)
-               __connman_ipconfig_load(service->ipconfig_ipv4, keyfile,
-                                       service->identifier, "IPv4.");
+       __connman_ipconfig_load(service->ipconfig_ipv6, keyfile,
+                               service->identifier, "IPv6.");
+
        g_key_file_free(keyfile);
 }
 
 void __connman_service_create_ip6config(struct connman_service *service,
                                                                int index)
 {
-       const char *ident = service->profile;
-       GKeyFile *keyfile;
-
        DBG("ipv6 %p", service->ipconfig_ipv6);
 
        if (service->ipconfig_ipv6 != NULL)
                return;
 
        setup_ip6config(service, index);
-
-       if (ident == NULL)
-               return;
-
-       keyfile = __connman_storage_open_profile(ident);
-       if (keyfile == NULL)
-               return;
-
-       if (service->ipconfig_ipv6 != NULL)
-               __connman_ipconfig_load(service->ipconfig_ipv6, keyfile,
-                                       service->identifier, "IPv6.");
-
-       g_key_file_free(keyfile);
+       __connman_service_read_ip6config(service);
 }
 
 /**