summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2012-10-17 10:34:41 (GMT)
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-10-18 10:27:10 (GMT)
commit23dad34ac87ef49184ceff697bff77aba949f48f (patch)
treefdb197e6e7796ec6b81360ca6a4bde239f7f38b6
parent46a6d0a487578b2a73ee7cb621f18ffaa5369967 (diff)
downloadconnman-23dad34ac87ef49184ceff697bff77aba949f48f.zip
connman-23dad34ac87ef49184ceff697bff77aba949f48f.tar.gz
connman-23dad34ac87ef49184ceff697bff77aba949f48f.tar.bz2
service: Keep only a single connected technology if configured
If SingleConnectedTechnology is enabled in main.conf, disconnect any previously connected services when the new service enters ready state.
-rw-r--r--src/service.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/service.c b/src/service.c
index b85e604..8857a47 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4943,6 +4943,35 @@ static int service_update_preferred_order(struct connman_service *default_servic
return -EALREADY;
}
+static void single_connected_tech(struct connman_service *allowed)
+{
+ GSList *services = NULL;
+ GSequenceIter *iter;
+ GSList *list;
+
+ iter = g_sequence_get_begin_iter(service_list);
+
+ while (g_sequence_iter_is_end(iter) == FALSE) {
+ struct connman_service *service = g_sequence_get(iter);
+
+ if (service != allowed && is_connected(service))
+ services = g_slist_prepend(services, service);
+
+ iter = g_sequence_iter_next(iter);
+ }
+
+ DBG("keeping %p %s", allowed, allowed->path);
+
+ for (list = services; list != NULL; list = list->next) {
+ struct connman_service *service = list->data;
+
+ DBG("disconnecting %p %s", service, service->path);
+ __connman_service_disconnect(service);
+ }
+
+ g_slist_free(services);
+}
+
static int service_indicate_state(struct connman_service *service)
{
enum connman_service_state old_state, new_state;
@@ -5068,6 +5097,10 @@ static int service_indicate_state(struct connman_service *service)
__connman_ipconfig_disable_ipv6(
service->ipconfig_ipv6);
+ if (connman_setting_get_bool("SingleConnectedTechnology")
+ == TRUE)
+ single_connected_tech(service);
+
} else if (new_state == CONNMAN_SERVICE_STATE_DISCONNECT) {
def_service = __connman_service_get_default();