summaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2012-11-13 09:01:48 +0100
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2012-11-23 13:47:24 +0100
commit2882f67ff02adbb2ce64b74cb4fe25e834b2021e (patch)
treeb7595322758bb8b35b41551467a2dbfbf435d67a /src/session.c
parent0fdbc9ad6df05ff942afe1bb2f665742987422b8 (diff)
downloadconnman-2882f67ff02adbb2ce64b74cb4fe25e834b2021e.tar.gz
connman-2882f67ff02adbb2ce64b74cb4fe25e834b2021e.tar.bz2
connman-2882f67ff02adbb2ce64b74cb4fe25e834b2021e.zip
session: Factor out set default config helper
Whenever a configuration gets invalid (e.g. a configuration is removed) then we need to be able to drop back to the default configutation.
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/session.c b/src/session.c
index 0b0321fc..c2327886 100644
--- a/src/session.c
+++ b/src/session.c
@@ -352,6 +352,22 @@ void connman_session_policy_unregister(struct connman_session_policy *policy)
remove_policy(policy);
}
+int connman_session_set_default_config(struct connman_session_config *config)
+{
+ config->priority = FALSE;
+ config->roaming_policy = CONNMAN_SESSION_ROAMING_POLICY_DEFAULT;
+ config->type = CONNMAN_SESSION_TYPE_ANY;
+ config->ecall = FALSE;
+
+ g_slist_free(config->allowed_bearers);
+ config->allowed_bearers = g_slist_prepend(NULL,
+ GINT_TO_POINTER(CONNMAN_SERVICE_TYPE_UNKNOWN));
+ if (config->allowed_bearers == NULL)
+ return -ENOMEM;
+
+ return 0;
+}
+
struct connman_session_config *connman_session_create_default_config(void)
{
struct connman_session_config *config;
@@ -360,13 +376,7 @@ struct connman_session_config *connman_session_create_default_config(void)
if (config == NULL)
return NULL;
- config->priority = FALSE;
- config->roaming_policy = CONNMAN_SESSION_ROAMING_POLICY_DEFAULT;
- config->type = CONNMAN_SESSION_TYPE_ANY;
- config->ecall = FALSE;
- config->allowed_bearers = g_slist_prepend(NULL,
- GINT_TO_POINTER(CONNMAN_SERVICE_TYPE_UNKNOWN));
- if (config->allowed_bearers == NULL) {
+ if (connman_session_set_default_config(config) < 0) {
g_free(config);
return NULL;
}