diff options
author | Jussi Kukkonen <jussi.kukkonen@intel.com> | 2012-04-20 15:54:21 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2012-04-20 16:03:54 +0200 |
commit | 209127678cedcc8bc52a4cc547fed95f07120a64 (patch) | |
tree | f55009c111a0741f4a08d9645dc97d0f1246c6e5 /plugins/ofono.c | |
parent | 339bb964398c427feb93ff6444010324e74901b7 (diff) | |
download | connman-209127678cedcc8bc52a4cc547fed95f07120a64.tar.gz connman-209127678cedcc8bc52a4cc547fed95f07120a64.tar.bz2 connman-209127678cedcc8bc52a4cc547fed95f07120a64.zip |
ofono: Only register network when APN is set
Empty AccessPointName in a oFono internet context means it cannot
be activated: Don't create networks in this situation.
The conditions for adding a network are then
a) modem supports NetworkRegistration
b) modem has a context with a valid APN
Fixes BMC#24959
Diffstat (limited to 'plugins/ofono.c')
-rw-r--r-- | plugins/ofono.c | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/plugins/ofono.c b/plugins/ofono.c index 29c53fba..5585f445 100644 --- a/plugins/ofono.c +++ b/plugins/ofono.c @@ -172,6 +172,7 @@ struct modem_data { /* ConnectionContext Interface */ connman_bool_t active; connman_bool_t set_active; + connman_bool_t valid_apn; /* APN is 'valid' if length > 0 */ /* SimManager Interface */ char *imsi; @@ -1106,8 +1107,17 @@ static int add_cm_context(struct modem_data *modem, const char *context_path, dbus_message_iter_get_basic(&value, &active); DBG("%s Active %d", modem->path, active); - } + } else if (g_str_equal(key, "AccessPointName") == TRUE) { + const char *apn; + + dbus_message_iter_get_basic(&value, &apn); + if (apn != NULL && strlen(apn) > 0) + modem->valid_apn = TRUE; + else + modem->valid_apn = FALSE; + DBG("%s AccessPointName '%s'", modem->path, apn); + } dbus_message_iter_next(dict); } @@ -1121,6 +1131,12 @@ static int add_cm_context(struct modem_data *modem, const char *context_path, g_hash_table_replace(context_hash, g_strdup(context_path), modem); + if (modem->valid_apn == TRUE && + has_interface(modem->interfaces, + OFONO_API_NETREG) == TRUE) { + add_network(modem); + } + return 0; } @@ -1137,6 +1153,11 @@ static void remove_cm_context(struct modem_data *modem, network_context_free(modem->context); modem->context = NULL; + + modem->valid_apn = FALSE; + + if (modem->network != NULL) + remove_network(modem); } static gboolean context_changed(DBusConnection *connection, @@ -1184,6 +1205,36 @@ static gboolean context_changed(DBusConnection *connection, set_connected(modem); else set_disconnected(modem); + } else if (g_str_equal(key, "AccessPointName") == TRUE) { + const char *apn; + + dbus_message_iter_get_basic(&value, &apn); + + DBG("%s AccessPointName %s", modem->path, apn); + + if (apn != NULL && strlen(apn) > 0) { + modem->valid_apn = TRUE; + + if (modem->network != NULL) + return TRUE; + + if (has_interface(modem->interfaces, + OFONO_API_NETREG) == FALSE) { + return TRUE; + } + + add_network(modem); + + if (modem->active == TRUE) + set_connected(modem); + } else { + modem->valid_apn = FALSE; + + if (modem->network == NULL) + return TRUE; + + remove_network(modem); + } } return TRUE; @@ -1522,7 +1573,8 @@ static void netreg_properties_reply(struct modem_data *modem, return; } - add_network(modem); + if (modem->valid_apn == TRUE) + add_network(modem); if (modem->active == TRUE) set_connected(modem); |