diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-08-10 11:59:01 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-08-14 09:01:52 +0300 |
commit | d5af2781ec8c11b0964511ee75319e3494f4725a (patch) | |
tree | 58fbc8be91d7df4eab8c1a70cc63bf2a7a01479e /plugins/ofono.c | |
parent | 3cb2ba35877c600e0a73d8d821f055e0a1f7973c (diff) | |
download | connman-d5af2781ec8c11b0964511ee75319e3494f4725a.tar.gz connman-d5af2781ec8c11b0964511ee75319e3494f4725a.tar.bz2 connman-d5af2781ec8c11b0964511ee75319e3494f4725a.zip |
ofono: Create ipconfig before setting index
Since connman_network_set_index() does not create magically the
ipconfig for us anymore, we need to create it inside set_connected().
Diffstat (limited to 'plugins/ofono.c')
-rw-r--r-- | plugins/ofono.c | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c index 1fb075ca..87bb956f 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -256,57 +256,50 @@ static void network_context_free(struct network_context *context) static void set_connected(struct modem_data *modem) { + struct connman_service *service; connman_bool_t setip = FALSE; + enum connman_ipconfig_method method; + int index; DBG("%s", modem->path); - if (modem->context->index < 0 || - modem->context->ipv4_address == NULL) { + index = modem->context->index; + + if (index < 0 || modem->context->ipv4_address == NULL) { connman_error("Invalid index and/or address"); return; } - connman_network_set_index(modem->network, modem->context->index); + service = connman_service_lookup_from_network(modem->network); + if (service == NULL) + return; + + method = modem->context->ipv4_method; + if (method == CONNMAN_IPCONFIG_METHOD_FIXED || + method == CONNMAN_IPCONFIG_METHOD_DHCP) + { + connman_service_create_ip4config(service, index); + connman_network_set_index(modem->network, index); - switch (modem->context->ipv4_method) { - case CONNMAN_IPCONFIG_METHOD_UNKNOWN: - case CONNMAN_IPCONFIG_METHOD_OFF: - case CONNMAN_IPCONFIG_METHOD_MANUAL: - case CONNMAN_IPCONFIG_METHOD_AUTO: - break; + connman_network_set_ipv4_method(modem->network, method); - case CONNMAN_IPCONFIG_METHOD_FIXED: - connman_network_set_ipv4_method(modem->network, - modem->context->ipv4_method); + setip = TRUE; + } + + if (method == CONNMAN_IPCONFIG_METHOD_FIXED) { connman_network_set_ipaddress(modem->network, modem->context->ipv4_address); connman_network_set_nameservers(modem->network, modem->context->ipv4_nameservers); - setip = TRUE; - break; - - case CONNMAN_IPCONFIG_METHOD_DHCP: - connman_network_set_ipv4_method(modem->network, - modem->context->ipv4_method); - setip = TRUE; - break; } - switch (modem->context->ipv6_method) { - case CONNMAN_IPCONFIG_METHOD_UNKNOWN: - case CONNMAN_IPCONFIG_METHOD_OFF: - case CONNMAN_IPCONFIG_METHOD_MANUAL: - case CONNMAN_IPCONFIG_METHOD_DHCP: - case CONNMAN_IPCONFIG_METHOD_AUTO: - break; - - case CONNMAN_IPCONFIG_METHOD_FIXED: - connman_network_set_ipv6_method(modem->network, - modem->context->ipv6_method); + method = modem->context->ipv6_method; + if (method == CONNMAN_IPCONFIG_METHOD_FIXED) { + connman_service_create_ip6config(service, index); + connman_network_set_ipv6_method(modem->network, method); connman_network_set_ipaddress(modem->network, - modem->context->ipv6_address); + modem->context->ipv6_address); setip = TRUE; - break; } if (setip == TRUE) @@ -1019,8 +1012,6 @@ static void add_network(struct modem_data *modem) connman_network_set_string(modem->network, "Path", modem->context->path); - connman_network_set_index(modem->network, modem->context->index); - if (modem->name != NULL) connman_network_set_name(modem->network, modem->name); else @@ -1041,12 +1032,6 @@ static void add_network(struct modem_data *modem) modem->network = NULL; return; } - - /* - * Create the ipconfig layer before trying to connect. Withouth - * the ipconfig layer the core is not ready to process errors. - */ - connman_network_set_index(modem->network, -1); } static void remove_network(struct modem_data *modem) |