diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2011-08-22 13:44:26 +0300 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-08-23 16:24:44 +0200 |
commit | 9a384100dc3eaddce677fc3988d1853d9b01e8ad (patch) | |
tree | 0213639e5c172e0f951a77c339f03627ee14121f | |
parent | 0fc3a31aef878e229234aae35d01915c8cb27f4c (diff) | |
download | connman-9a384100dc3eaddce677fc3988d1853d9b01e8ad.tar.gz connman-9a384100dc3eaddce677fc3988d1853d9b01e8ad.tar.bz2 connman-9a384100dc3eaddce677fc3988d1853d9b01e8ad.zip |
service: Factor out reading ipconfigs from create functions
Create new read functions for IPv4 and IPv6 from the code in
__connman_service_create_ip*config functions.
-rw-r--r-- | src/connman.h | 3 | ||||
-rw-r--r-- | src/service.c | 54 |
2 files changed, 35 insertions, 22 deletions
diff --git a/src/connman.h b/src/connman.h index 6e68c993..17add6db 100644 --- a/src/connman.h +++ b/src/connman.h @@ -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( diff --git a/src/service.c b/src/service.c index 7cd21b5b..6482b50a 100644 --- a/src/service.c +++ b/src/service.c @@ -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); } /** |