From: Pasi Sjöholm <[email protected]>
When set_connected is called, method needs to be set
CONNMAN_IPCONFIG_METHOD_UNKNOWN so that no old configuration
is used in case it was defined by any earlier active context and
it is not defined by the current active context.
---
plugins/ofono.c | 52 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 8821f1e..eb788e0 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -266,10 +266,8 @@ static void set_connected(struct modem_data *modem)
index = modem->context->index;
- method = modem->context->ipv4_method;
- if (index < 0 || (!modem->context->ipv4_address &&
- method == CONNMAN_IPCONFIG_METHOD_FIXED)) {
- connman_error("Invalid index and/or address");
+ if (index < 0 ) {
+ connman_error("Invalid index");
return;
}
@@ -277,28 +275,43 @@ static void set_connected(struct modem_data *modem)
if (!service)
return;
- if (method == CONNMAN_IPCONFIG_METHOD_FIXED ||
- method == CONNMAN_IPCONFIG_METHOD_DHCP) {
+ method = modem->context->ipv4_method;
+ if (method == CONNMAN_IPCONFIG_METHOD_DHCP) {
connman_service_create_ip4config(service, index);
- connman_network_set_index(modem->network, index);
-
connman_network_set_ipv4_method(modem->network, method);
setip = true;
- }
-
- if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
- connman_network_set_ipaddress(modem->network,
+ } else if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
+ if (modem->context->ipv4_address) {
+ connman_service_create_ip4config(service, index);
+ connman_network_set_ipv4_method(modem->network, method);
+ connman_network_set_ipaddress(modem->network,
modem->context->ipv4_address);
+ setip = true;
+ } else {
+ connman_error("Invalid ipv4-address");
+ return;
+ }
+ } else {
+ connman_service_create_ip4config(service, index);
+ connman_network_set_ipv4_method(modem->network,
CONNMAN_IPCONFIG_METHOD_UNKNOWN);
}
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,
+ if (modem->context->ipv6_address) {
+ connman_service_create_ip6config(service, index);
+ connman_network_set_ipv6_method(modem->network, method);
+ connman_network_set_ipaddress(modem->network,
modem->context->ipv6_address);
- setip = true;
+ setip = true;
+ } else {
+ connman_error("Invalid ipv6-address");
+ return;
+ }
+ } else {
+ connman_service_create_ip6config(service, index);
+ connman_network_set_ipv6_method(modem->network,
CONNMAN_IPCONFIG_METHOD_UNKNOWN);
}
/* Set the nameservers */
@@ -317,8 +330,13 @@ static void set_connected(struct modem_data *modem)
modem->context->ipv6_nameservers);
}
- if (setip)
+ if (setip) {
+ connman_network_set_index(modem->network, index);
connman_network_set_connected(modem->network, true);
+ } else {
+ connman_error("Invalid address(es)/methods");
+ }
+
}
static void set_disconnected(struct modem_data *modem)
--
2.1.0
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman