[PATCH v4 1/5] session: Add parameter Service into CreateSession call of ConnMan session API
by sutar.mounesh@gmail.com
From: Bjoern Thorwirth <external.bjoern.thorwirth(a)de.bosch.com>
The calling process, that implements the session API is identified by the user ID
as it is runs. All processes of the same user share the same list of allowed bearers,
and the same priority for choosing between available bearers.
This extension allows processes to select a service context dependent behaviour
for which the routing decision is made.
This is an extention to session API interface. Helps to enable a service differentiation
for processes run by the same user. Allows ConnMan to differentiate between bearer
usage permissions and the respective priorities based on the requested service type.
---
doc/session-api.txt | 12 ++++++++++++
include/session.h | 1 +
src/session.c | 17 +++++++++++++++++
3 files changed, 30 insertions(+)
diff --git a/doc/session-api.txt b/doc/session-api.txt
index e8da522..139bcca 100644
--- a/doc/session-api.txt
+++ b/doc/session-api.txt
@@ -205,3 +205,15 @@ Settings string State [readonly]
a default route. When the source IP rule is enabled,
an application can select which session/interface to
send traffic on, using bind-before-connect mechanism.
+
+ string Service [readwrite]
+
+ This designates context of service for a Session.
+ The calling process that implements the session API
+ is identified by the user ID as it is runs.
+ All processes of the same user share the same list of
+ allowed bearers, and the same priority for choosing
+ between available bearers.
+
+ This field is used to implement service context
+ dependent behavior.
diff --git a/include/session.h b/include/session.h
index 5106e88..3b3c53f 100644
--- a/include/session.h
+++ b/include/session.h
@@ -74,6 +74,7 @@ struct connman_session_config {
GSList *allowed_bearers;
char *allowed_interface;
bool source_ip_rule;
+ char *service;
};
typedef int (* connman_session_config_func_t) (struct connman_session *session,
diff --git a/src/session.c b/src/session.c
index 9e3c559..a62f93e 100644
--- a/src/session.c
+++ b/src/session.c
@@ -548,6 +548,7 @@ struct creation_data {
GSList *allowed_bearers;
char *allowed_interface;
bool source_ip_rule;
+ char *service;
};
static void cleanup_creation_data(struct creation_data *creation_data)
@@ -557,6 +558,8 @@ static void cleanup_creation_data(struct creation_data *creation_data)
if (creation_data->pending)
dbus_message_unref(creation_data->pending);
+ if (creation_data->service)
+ g_free(creation_data->service);
g_slist_free(creation_data->allowed_bearers);
g_free(creation_data->allowed_interface);
@@ -927,6 +930,17 @@ static void append_notify(DBusMessageIter *dict,
}
if (session->append_all ||
+ info->config.service != info_last->config.service) {
+ char *ifname = info->config.service;
+ if (!ifname)
+ ifname = "";
+ connman_dbus_dict_append_basic(dict, "Service",
+ DBUS_TYPE_STRING,
+ &ifname);
+ info_last->config.service = info->config.service;
+ }
+
+ if (session->append_all ||
info->config.source_ip_rule != info_last->config.source_ip_rule) {
dbus_bool_t source_ip_rule = FALSE;
if (info->config.source_ip_rule)
@@ -1474,6 +1488,9 @@ int __connman_session_create(DBusMessage *msg)
connman_session_parse_connection_type(val);
user_connection_type = true;
+ } else if (g_str_equal(key, "Service")) {
+ dbus_message_iter_get_basic(&value, &val);
+ creation_data->service = g_strdup(val);
} else if (g_str_equal(key, "AllowedInterface")) {
dbus_message_iter_get_basic(&value, &val);
creation_data->allowed_interface = g_strdup(val);
--
2.7.4