Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. Re: [RFC v2 1/8] ofono: create a list of contexts (Patrik Flykt)
2. Re: [RFC v2 5/8] ofono: remove the context struct in modem
one (Patrik Flykt)
3. Re: [RFC v2 3/8] ofono: move "network" property to context
struct (Patrik Flykt)
----------------------------------------------------------------------
Message: 1
Date: Thu, 10 Dec 2015 10:31:55 +0200
From: Patrik Flykt <[email protected]>
To: Mylene JOSSERAND <[email protected]>
Cc: [email protected]
Subject: Re: [RFC v2 1/8] ofono: create a list of contexts
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"
Hi,
On Fri, 2015-11-27 at 19:37 +0100, Mylene JOSSERAND wrote:
> The current commit creates a list of contexts which will be used
> when the user adds many contexts for one modem.
> ---
> plugins/ofono.c | 67
> ++++++++++++++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 54 insertions(+), 13 deletions(-)
>
> diff --git a/plugins/ofono.c b/plugins/ofono.c
> index 4337d45..54822fd 100644
> --- a/plugins/ofono.c
> +++ b/plugins/ofono.c
> @@ -150,6 +150,7 @@ struct modem_data {
> struct connman_network *network;
>
> struct network_context *context;
> + GSList *context_list;
>
> /* Modem Interface */
> char *serial;
> @@ -219,6 +220,24 @@ static char *get_ident(const char *path)
> return pos + 1;
> }
>
> +
Nitpick: unnecessary empty line added here.
> +static struct network_context *get_context_with_path(GSList
> *context_list,
> + const gchar *path)
Patrik
------------------------------
Message: 2
Date: Thu, 10 Dec 2015 10:32:04 +0200
From: Patrik Flykt <[email protected]>
To: Mylene JOSSERAND <[email protected]>
Cc: [email protected]
Subject: Re: [RFC v2 5/8] ofono: remove the context struct in modem
one
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"
Hi,
This one gets gcc to complain:
plugins/ofono.c: In function ?cdma_cm_set_powered?:
plugins/ofono.c:675:3: error: ?return? with no value, in function returning
non-void [-Werror=return-type]
return;
^
plugins/ofono.c: In function ?add_cm_context?:
plugins/ofono.c:1181:11: error: ?struct modem_data? has no member named
?context?
if (modem->context) {
^
On Fri, 2015-11-27 at 19:37 +0100, Mylene JOSSERAND wrote:
> The current commit removes the context structure of the modem one
> to use only the list of contexts.
> ---
> plugins/ofono.c | 41 +++++++++++++++++++++++------------------
> 1 file changed, 23 insertions(+), 18 deletions(-)
>
> diff --git a/plugins/ofono.c b/plugins/ofono.c
> index 2fa16c1..e4a6c55 100644
> --- a/plugins/ofono.c
> +++ b/plugins/ofono.c
> @@ -152,7 +152,6 @@ struct modem_data {
>
> struct connman_device *device;
>
> - struct network_context *context;
> GSList *context_list;
>
> /* Modem Interface */
> @@ -670,10 +669,16 @@ static void cdma_cm_set_powered_reply(struct modem_data
> *modem,
> static int cdma_cm_set_powered(struct modem_data *modem, dbus_bool_t powered)
> {
> int err;
> + struct network_context *context = NULL;
> +
> + if (!modem->context_list)
> + return;
>
> DBG("%s powered %d", modem->path, powered);
>
> - err = set_property(modem, modem->context, modem->path,
> + /* In case of CDMA, there is only one context */
> + context = g_slist_nth_data(modem->context_list, 0);
Hmm, here one could do context = modem->context_list->data for
simplicity as the context_list was checked already earlier for NULL.
> + err = set_property(modem, context, modem->path,
> OFONO_CDMA_CM_INTERFACE,
> "Powered", DBUS_TYPE_BOOLEAN,
> &powered,
> @@ -1241,7 +1246,6 @@ static int add_cm_context(struct modem_data *modem,
> const char *context_path,
> if (ip_protocol)
> set_context_ipconfig(context, ip_protocol);
>
> - modem->context = context;
> context->active = active;
>
> modem->context_list = g_slist_prepend(modem->context_list, context);
> @@ -1257,8 +1261,6 @@ static int add_cm_context(struct modem_data *modem,
> const char *context_path,
> static void remove_cm_context(struct modem_data *modem,
> struct network_context *context)
> {
> - if (!modem->context)
> - return;
> if (!modem->context_list)
> return;
> if (!context)
> @@ -1270,8 +1272,8 @@ static void remove_cm_context(struct modem_data *modem,
> remove_network(modem, context);
> modem->context_list = g_slist_remove(modem->context_list, context);
>
> - network_context_free(modem->context);
> - modem->context = NULL;
> + network_context_free(context);
> + context = NULL;
> }
>
> static void remove_all_contexts(struct modem_data *modem)
> @@ -1339,11 +1341,11 @@ static gboolean context_changed(DBusConnection *conn,
> if (g_str_equal(key, "Settings")) {
> DBG("%s Settings", modem->path);
>
> - extract_ipv4_settings(&value, modem->context);
> + extract_ipv4_settings(&value, context);
> } else if (g_str_equal(key, "IPv6.Settings")) {
> DBG("%s IPv6.Settings", modem->path);
>
> - extract_ipv6_settings(&value, modem->context);
> + extract_ipv6_settings(&value, context);
> } else if (g_str_equal(key, "Active")) {
> dbus_bool_t active;
>
> @@ -1395,7 +1397,7 @@ static gboolean context_changed(DBusConnection *conn,
>
> dbus_message_iter_get_basic(&value, &ip_protocol);
>
> - set_context_ipconfig(modem->context, ip_protocol);
> + set_context_ipconfig(context, ip_protocol);
> }
>
> return TRUE;
> @@ -1852,7 +1854,7 @@ static gboolean cdma_netreg_changed(DBusConnection
> *conn,
> if (modem->registered)
> add_cdma_network(modem);
> else
> - remove_network(modem, modem->context);
> + remove_all_networks(modem);
>
> return TRUE;
> }
> @@ -1887,7 +1889,7 @@ static void cdma_netreg_properties_reply(struct
> modem_data *modem,
> if (modem->registered)
> add_cdma_network(modem);
> else
> - remove_network(modem, modem->context);
> + remove_all_networks(modem);
> }
>
> static int cdma_netreg_get_properties(struct modem_data *modem)
> @@ -1907,7 +1909,7 @@ static void cm_update_attached(struct modem_data *modem,
> DBG("%s Attached %d", modem->path, modem->attached);
>
> if (!modem->attached) {
> - remove_network(modem, modem->context);
> + remove_all_networks(modem);
> return;
> }
>
> @@ -1968,6 +1970,7 @@ static gboolean cm_changed(DBusConnection *conn,
> DBusMessage *message,
> static void cdma_cm_update_powered(struct modem_data *modem,
> DBusMessageIter *value)
> {
> + struct network_context *context = NULL;
> dbus_bool_t cdma_cm_powered;
>
> dbus_message_iter_get_basic(value, &cdma_cm_powered);
> @@ -1975,13 +1978,15 @@ static void cdma_cm_update_powered(struct modem_data
> *modem,
>
> DBG("%s CDMA cm Powered %d", modem->path, modem->cdma_cm_powered);
>
> - if (!modem->context)
> + if (!modem->context_list)
> return;
>
> + /* In case of CDMA, there is only one context */
> + context = g_slist_nth_data(modem->context_list, 0);
> if (modem->cdma_cm_powered)
> - set_connected(modem, modem->context);
> + set_connected(modem, context);
> else
> - set_disconnected(modem->context);
> + set_disconnected(context);
> }
>
> static void cdma_cm_update_settings(struct modem_data *modem,
> @@ -1989,7 +1994,7 @@ static void cdma_cm_update_settings(struct modem_data
> *modem,
> {
> DBG("%s Settings", modem->path);
>
> - extract_ipv4_settings(value, modem->context);
> + extract_ipv4_settings(value, g_slist_nth_data(modem->context_list, 0));
> }
>
> static gboolean cdma_cm_changed(DBusConnection *conn,
> @@ -2004,7 +2009,7 @@ static gboolean cdma_cm_changed(DBusConnection *conn,
> if (!modem)
> return TRUE;
>
> - if (modem->online && !modem->context)
> + if (modem->online && !modem->context_list)
> cdma_netreg_get_properties(modem);
>
> if (!dbus_message_iter_init(message, &iter))
Patrik
------------------------------
Message: 3
Date: Thu, 10 Dec 2015 10:32:02 +0200
From: Patrik Flykt <[email protected]>
To: Mylene JOSSERAND <[email protected]>
Cc: [email protected]
Subject: Re: [RFC v2 3/8] ofono: move "network" property to context
struct
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"
Hi,
Otherwise good, except that gcc complains:
CC src/src_connmand-plugin.o
plugins/ofono.c: In function ?context_set_active?:
plugins/ofono.c:607:5: warning: passing argument 7 of ?set_property? from
incompatible pointer type
context_set_active_reply);
^
plugins/ofono.c:410:12: note: expected ?set_property_cb? but argument is of
type ?void (*)(struct modem_data *, struct network_context *, _Bool)?
static int set_property(struct modem_data *modem,
^
plugins/ofono.c: In function ?cdma_cm_set_powered?:
plugins/ofono.c:657:5: warning: passing argument 7 of ?set_property? from
incompatible pointer type
cdma_cm_set_powered_reply);
^
plugins/ofono.c:410:12: note: expected ?set_property_cb? but argument is of
type ?void (*)(struct modem_data *, struct network_context *, _Bool)?
static int set_property(struct modem_data *modem,
^
plugins/ofono.c: In function ?add_cdma_network?:
plugins/ofono.c:1770:26: warning: ?context? may be used uninitialized in this
function [-Wmaybe-uninitialized]
struct network_context *context;
^
Applying patch 4/8 seems to get rid of all the warnings except the last
one that the context may be used uninitialized in the function.
Patrik
On Fri, 2015-11-27 at 19:37 +0100, Mylene JOSSERAND wrote:
> The current commit moves the "network" property to the context
> structure. Many modifications are needed to take into account
> some network modifications using a context instead of a modem struct.
> ---
> plugins/ofono.c | 280
> +++++++++++++++++++++++++++++++++-----------------------
> 1 file changed, 163 insertions(+), 117 deletions(-)
>
> diff --git a/plugins/ofono.c b/plugins/ofono.c
> index be247bb..5c8b429 100644
> --- a/plugins/ofono.c
> +++ b/plugins/ofono.c
> @@ -133,6 +133,7 @@ static GHashTable *context_hash;
> struct network_context {
> char *path;
> int index;
> + struct connman_network *network;
>
> enum connman_ipconfig_method ipv4_method;
> struct connman_ipaddress *ipv4_address;
> @@ -150,7 +151,6 @@ struct modem_data {
> char *path;
>
> struct connman_device *device;
> - struct connman_network *network;
>
> struct network_context *context;
> GSList *context_list;
> @@ -272,7 +272,8 @@ static void network_context_free(struct network_context
> *context)
> free(context);
> }
>
> -static void set_connected(struct modem_data *modem)
> +static void set_connected(struct modem_data *modem,
> + struct network_context *context)
> {
> struct connman_service *service;
> bool setip = false;
> @@ -282,21 +283,21 @@ static void set_connected(struct modem_data *modem)
>
> DBG("%s", modem->path);
>
> - index = modem->context->index;
> + index = context->index;
>
> - method = modem->context->ipv4_method;
> - if (index < 0 || (!modem->context->ipv4_address &&
> + method = context->ipv4_method;
> + if (index < 0 || (!context->ipv4_address &&
> method == CONNMAN_IPCONFIG_METHOD_FIXED)) {
> connman_error("Invalid index and/or address");
> return;
> }
>
> - service = connman_service_lookup_from_network(modem->network);
> + service = connman_service_lookup_from_network(context->network);
> if (!service)
> return;
>
> connman_service_create_ip4config(service, index);
> - connman_network_set_ipv4_method(modem->network, method);
> + connman_network_set_ipv4_method(context->network, method);
>
> if (method == CONNMAN_IPCONFIG_METHOD_FIXED ||
> method == CONNMAN_IPCONFIG_METHOD_DHCP) {
> @@ -304,58 +305,58 @@ static void set_connected(struct modem_data *modem)
> }
>
> if (method == CONNMAN_IPCONFIG_METHOD_FIXED) {
> - connman_network_set_ipaddress(modem->network,
> - modem->context->ipv4_address);
> + connman_network_set_ipaddress(context->network,
> + context->ipv4_address);
> }
>
> - method = modem->context->ipv6_method;
> + method = context->ipv6_method;
> connman_service_create_ip6config(service, index);
> - connman_network_set_ipv6_method(modem->network, method);
> + connman_network_set_ipv6_method(context->network, method);
>
> if (method == CONNMAN_IPCONFIG_METHOD_AUTO) {
> setip = true;
> }
>
> /* Set the nameservers */
> - if (modem->context->ipv4_nameservers &&
> - modem->context->ipv6_nameservers) {
> + if (context->ipv4_nameservers &&
> + context->ipv6_nameservers) {
> nameservers = g_strdup_printf("%s %s",
> - modem->context->ipv4_nameservers,
> - modem->context->ipv6_nameservers);
> - connman_network_set_nameservers(modem->network, nameservers);
> + context->ipv4_nameservers,
> + context->ipv6_nameservers);
> + connman_network_set_nameservers(context->network, nameservers);
> g_free(nameservers);
> - } else if (modem->context->ipv4_nameservers) {
> - connman_network_set_nameservers(modem->network,
> - modem->context->ipv4_nameservers);
> - } else if (modem->context->ipv6_nameservers) {
> - connman_network_set_nameservers(modem->network,
> - modem->context->ipv6_nameservers);
> + } else if (context->ipv4_nameservers) {
> + connman_network_set_nameservers(context->network,
> + context->ipv4_nameservers);
> + } else if (context->ipv6_nameservers) {
> + connman_network_set_nameservers(context->network,
> + context->ipv6_nameservers);
> }
>
> if (setip) {
> - connman_network_set_index(modem->network, index);
> - connman_network_set_connected(modem->network, true);
> + connman_network_set_index(context->network, index);
> + connman_network_set_connected(context->network, true);
> }
> }
>
> -static void set_disconnected(struct modem_data *modem)
> +static void set_disconnected(struct network_context *context)
> {
> - DBG("%s", modem->path);
> + DBG("%s", context->path);
>
> - if (modem->network)
> - connman_network_set_connected(modem->network, false);
> + if (context->network)
> + connman_network_set_connected(context->network, false);
>
> - if (modem->context) {
> - g_free(modem->context->ipv4_nameservers);
> - modem->context->ipv4_nameservers = NULL;
> - if (modem->context->ipv4_method != CONNMAN_IPCONFIG_METHOD_OFF)
> - modem->context->ipv4_method =
> + if (context) {
> + g_free(context->ipv4_nameservers);
> + context->ipv4_nameservers = NULL;
> + if (context->ipv4_method != CONNMAN_IPCONFIG_METHOD_OFF)
> + context->ipv4_method =
> CONNMAN_IPCONFIG_METHOD_UNKNOWN;
>
> - g_free(modem->context->ipv6_nameservers);
> - modem->context->ipv6_nameservers = NULL;
> - if (modem->context->ipv6_method != CONNMAN_IPCONFIG_METHOD_OFF)
> - modem->context->ipv6_method =
> + g_free(context->ipv6_nameservers);
> + context->ipv6_nameservers = NULL;
> + if (context->ipv6_method != CONNMAN_IPCONFIG_METHOD_OFF)
> + context->ipv6_method =
> CONNMAN_IPCONFIG_METHOD_UNKNOWN;
> }
> }
> @@ -560,9 +561,9 @@ static int get_properties(const char *path, const char
> *interface,
> }
>
> static void context_set_active_reply(struct modem_data *modem,
> - bool success)
> + struct network_context *context, bool success)
> {
> - DBG("%s", modem->path);
> + DBG("%s", context->path);
>
> if (success) {
> /*
> @@ -579,7 +580,7 @@ static void context_set_active_reply(struct modem_data
> *modem,
> * cycle the modem in such cases?
> */
>
> - if (!modem->network) {
> + if (!context->network) {
> /*
> * In the case where we power down the device
> * we don't wait for the reply, therefore the network
> @@ -588,7 +589,7 @@ static void context_set_active_reply(struct modem_data
> *modem,
> return;
> }
>
> - connman_network_set_error(modem->network,
> + connman_network_set_error(context->network,
> CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
> }
>
> @@ -612,9 +613,9 @@ static int context_set_active(struct modem_data *modem,
> }
>
> static void cdma_cm_set_powered_reply(struct modem_data *modem,
> - bool success)
> + struct network_context *context, bool success)
> {
> - DBG("%s", modem->path);
> + DBG("%s", context->path);
>
> if (success) {
> /*
> @@ -631,7 +632,7 @@ static void cdma_cm_set_powered_reply(struct modem_data
> *modem,
> * cycle the modem in such cases?
> */
>
> - if (!modem->network) {
> + if (!context->network) {
> /*
> * In the case where we power down the device
> * we don't wait for the reply, therefore the network
> @@ -640,7 +641,7 @@ static void cdma_cm_set_powered_reply(struct modem_data
> *modem,
> return;
> }
>
> - connman_network_set_error(modem->network,
> + connman_network_set_error(context->network,
> CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
> }
>
> @@ -1035,71 +1036,68 @@ static void destroy_device(struct modem_data *modem)
>
> connman_device_set_powered(modem->device, false);
>
> - if (modem->network) {
> - connman_device_remove_network(modem->device, modem->network);
> - connman_network_unref(modem->network);
> - modem->network = NULL;
> - }
> -
> connman_device_unregister(modem->device);
> connman_device_unref(modem->device);
>
> modem->device = NULL;
> }
>
> -static void add_network(struct modem_data *modem)
> +static void add_network(struct modem_data *modem,
> + struct network_context *context)
> {
> const char *group;
>
> DBG("%s", modem->path);
>
> - if (modem->network)
> + if (context->network)
> return;
>
> - modem->network = connman_network_create(modem->context->path,
> - CONNMAN_NETWORK_TYPE_CELLULAR);
> - if (!modem->network)
> + context->network = connman_network_create(context->path,
> + CONNMAN_NETWORK_TYPE_CELLULAR);
> + if (!context->network)
> return;
>
> - DBG("network %p", modem->network);
> + DBG("network %p", context->network);
>
> - connman_network_set_data(modem->network, modem);
> + connman_network_set_data(context->network, modem);
>
> - connman_network_set_string(modem->network, "Path",
> - modem->context->path);
> + connman_network_set_string(context->network, "Path",
> + context->path);
>
> if (modem->name)
> - connman_network_set_name(modem->network, modem->name);
> + connman_network_set_name(context->network, modem->name);
> else
> - connman_network_set_name(modem->network, "");
> + connman_network_set_name(context->network, "");
>
> - connman_network_set_strength(modem->network, modem->strength);
> + connman_network_set_strength(context->network, modem->strength);
>
> - group = get_ident(modem->context->path);
> - connman_network_set_group(modem->network, group);
> + group = get_ident(context->path);
> + connman_network_set_group(context->network, group);
>
> - connman_network_set_bool(modem->network, "Roaming",
> - modem->roaming);
> + connman_network_set_bool(context->network, "Roaming",
> + modem->roaming);
>
> - if (connman_device_add_network(modem->device, modem->network) < 0) {
> - connman_network_unref(modem->network);
> - modem->network = NULL;
> + if (connman_device_add_network(modem->device, context->network) < 0) {
> + connman_network_unref(context->network);
> + context->network = NULL;
> return;
> }
> }
>
> -static void remove_network(struct modem_data *modem)
> +static void remove_network(struct modem_data *modem,
> + struct network_context *context)
> {
> DBG("%s", modem->path);
>
> - if (!modem->network)
> + if (!context)
> return;
>
> - DBG("network %p", modem->network);
> + DBG("network %p", context->network);
>
> - connman_device_remove_network(modem->device, modem->network);
> - connman_network_unref(modem->network);
> - modem->network = NULL;
> + if (modem->device)
> + connman_device_remove_network(modem->device, context->network);
> + connman_network_unref(context->network);
> + context->network = NULL;
> }
>
> static int set_context_ipconfig(struct network_context *context,
> @@ -1227,10 +1225,8 @@ 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 (context->valid_apn && modem->attached &&
> - has_interface(modem->interfaces,
> - OFONO_API_NETREG)) {
> - add_network(modem);
> - }
> + has_interface(modem->interfaces, OFONO_API_NETREG))
> + add_network(modem, context);
>
> return 0;
> }
> @@ -1245,11 +1241,10 @@ static void remove_cm_context(struct modem_data
> *modem,
> if (!context)
> return;
>
> - if (modem->network)
> - remove_network(modem);
> -
> g_hash_table_remove(context_hash, context->path);
>
> + if (context->network)
> + remove_network(modem, context);
> modem->context_list = g_slist_remove(modem->context_list, context);
>
> network_context_free(modem->context);
> @@ -1274,6 +1269,17 @@ static void remove_all_contexts(struct modem_data
> *modem)
> modem->context_list = NULL;
> }
>
> +static void remove_all_networks(struct modem_data *modem)
> +{
> + GSList *list;
> +
> + for (list = modem->context_list; list; list = list->next) {
> + struct network_context *context = list->data;
> +
> + remove_network(modem, context);
> + }
> +}
> +
> static gboolean context_changed(DBusConnection *conn,
> DBusMessage *message,
> void *user_data)
> @@ -1324,9 +1330,9 @@ static gboolean context_changed(DBusConnection *conn,
> DBG("%s Active %d", modem->path, context->active);
>
> if (context->active)
> - set_connected(modem);
> + set_connected(modem, context);
> else
> - set_disconnected(modem);
> + set_disconnected(context);
> } else if (g_str_equal(key, "AccessPointName")) {
> const char *apn;
>
> @@ -1337,7 +1343,7 @@ static gboolean context_changed(DBusConnection *conn,
> if (apn && strlen(apn) > 0) {
> context->valid_apn = true;
>
> - if (modem->network)
> + if (context->network)
> return TRUE;
>
> if (!modem->attached)
> @@ -1347,17 +1353,17 @@ static gboolean context_changed(DBusConnection *conn,
> OFONO_API_NETREG))
> return TRUE;
>
> - add_network(modem);
> + add_network(modem, context);
>
> if (context->active)
> - set_connected(modem);
> + set_connected(modem, context);
> } else {
> context->valid_apn = false;
>
> - if (!modem->network)
> + if (!context->network)
> return TRUE;
>
> - remove_network(modem);
> + remove_network(modem, context);
> }
>
> } else if (g_str_equal(key, "Protocol") &&
> @@ -1518,6 +1524,7 @@ static void netreg_update_name(struct modem_data *modem,
> DBusMessageIter* value)
> {
> char *name;
> + GSList *list;
>
> dbus_message_iter_get_basic(value, &name);
>
> @@ -1526,21 +1533,30 @@ static void netreg_update_name(struct modem_data
> *modem,
> g_free(modem->name);
> modem->name = g_strdup(name);
>
> - if (!modem->network)
> + if (!modem->context_list)
> return;
>
> - connman_network_set_name(modem->network, modem->name);
> - connman_network_update(modem->network);
> + /* For all the context */
> + for (list = modem->context_list; list; list = list->next) {
> + struct network_context *context = list->data;
> +
> + if (context->network) {
> + connman_network_set_name(context->network, modem->name);
> + connman_network_update(context->network);
> + }
> + }
> }
>
> static void netreg_update_strength(struct modem_data *modem,
> DBusMessageIter *value)
> {
> + GSList *list;
> +
> dbus_message_iter_get_basic(value, &modem->strength);
>
> DBG("%s Strength %d", modem->path, modem->strength);
>
> - if (!modem->network)
> + if (!modem->context_list)
> return;
>
> /*
> @@ -1559,19 +1575,29 @@ static void netreg_update_strength(struct modem_data
> *modem,
> if (modem->data_strength != 0)
> return;
>
> - connman_network_set_strength(modem->network, modem->strength);
> - connman_network_update(modem->network);
> + /* For all the context */
> + for (list = modem->context_list; list; list = list->next) {
> + struct network_context *context = list->data;
> +
> + if (context->network) {
> + connman_network_set_strength(context->network,
> + modem->strength);
> + connman_network_update(context->network);
> + }
> + }
> }
>
> /* Retrieve 1xEVDO Data Strength signal */
> static void netreg_update_datastrength(struct modem_data *modem,
> DBusMessageIter *value)
> {
> + GSList *list;
> +
> dbus_message_iter_get_basic(value, &modem->data_strength);
>
> DBG("%s Data Strength %d", modem->path, modem->data_strength);
>
> - if (!modem->network)
> + if (!modem->context_list)
> return;
>
> /*
> @@ -1582,8 +1608,16 @@ static void netreg_update_datastrength(struct
> modem_data *modem,
> if (modem->data_strength == 0)
> return;
>
> - connman_network_set_strength(modem->network, modem->data_strength);
> - connman_network_update(modem->network);
> + /* For all the context */
> + for (list = modem->context_list; list; list = list->next) {
> + struct network_context *context = list->data;
> +
> + if (context->network) {
> + connman_network_set_strength(context->network,
> + modem->data_strength);
> + connman_network_update(context->network);
> + }
> + }
> }
>
> static void netreg_update_status(struct modem_data *modem,
> @@ -1591,6 +1625,7 @@ static void netreg_update_status(struct modem_data
> *modem,
> {
> char *status;
> bool roaming;
> + GSList *list;
>
> dbus_message_iter_get_basic(value, &status);
>
> @@ -1602,12 +1637,19 @@ static void netreg_update_status(struct modem_data
> *modem,
>
> modem->roaming = roaming;
>
> - if (!modem->network)
> + if (!modem->context_list)
> return;
>
> - connman_network_set_bool(modem->network,
> + /* For all the context */
> + for (list = modem->context_list; list; list = list->next) {
> + struct network_context *context = list->data;
> +
> + if (context->network) {
> + connman_network_set_bool(context->network,
> "Roaming", modem->roaming);
> - connman_network_update(modem->network);
> + connman_network_update(context->network);
> + }
> + }
> }
>
> static void netreg_update_regdom(struct modem_data *modem,
> @@ -1711,9 +1753,9 @@ static void netreg_properties_reply(struct modem_data
> *modem,
> struct network_context *context = list->data;
>
> if (context->valid_apn)
> - add_network(modem);
> + add_network(modem, context);
> if (context->active)
> - set_connected(modem);
> + set_connected(modem, context);
> }
> }
>
> @@ -1725,6 +1767,7 @@ static int netreg_get_properties(struct modem_data
> *modem)
>
> static void add_cdma_network(struct modem_data *modem)
> {
> + struct network_context *context;
> /* Be sure that device is created before adding CDMA network */
> if (!modem->device)
> return;
> @@ -1733,16 +1776,19 @@ static void add_cdma_network(struct modem_data *modem)
> * CDMA modems don't need contexts for data call, however the current
> * add_network() logic needs one, so we create one to proceed.
> */
> - if (!modem->context)
> - modem->context = network_context_alloc(modem->path);
> + if (!modem->context_list) {
> + context = network_context_alloc(modem->path);
> + modem->context_list = g_slist_prepend(modem->context_list,
> + context);
> + }
>
> if (!modem->name)
> modem->name = g_strdup("CDMA Network");
>
> - add_network(modem);
> + add_network(modem, context);
>
> if (modem->cdma_cm_powered)
> - set_connected(modem);
> + set_connected(modem, context);
> }
>
> static gboolean cdma_netreg_changed(DBusConnection *conn,
> @@ -1783,7 +1829,7 @@ static gboolean cdma_netreg_changed(DBusConnection
> *conn,
> if (modem->registered)
> add_cdma_network(modem);
> else
> - remove_network(modem);
> + remove_network(modem, modem->context);
>
> return TRUE;
> }
> @@ -1818,7 +1864,7 @@ static void cdma_netreg_properties_reply(struct
> modem_data *modem,
> if (modem->registered)
> add_cdma_network(modem);
> else
> - remove_network(modem);
> + remove_network(modem, modem->context);
> }
>
> static int cdma_netreg_get_properties(struct modem_data *modem)
> @@ -1838,7 +1884,7 @@ static void cm_update_attached(struct modem_data *modem,
> DBG("%s Attached %d", modem->path, modem->attached);
>
> if (!modem->attached) {
> - remove_network(modem);
> + remove_network(modem, modem->context);
> return;
> }
>
> @@ -1906,13 +1952,13 @@ static void cdma_cm_update_powered(struct modem_data
> *modem,
>
> DBG("%s CDMA cm Powered %d", modem->path, modem->cdma_cm_powered);
>
> - if (!modem->network)
> + if (!modem->context)
> return;
>
> if (modem->cdma_cm_powered)
> - set_connected(modem);
> + set_connected(modem, modem->context);
> else
> - set_disconnected(modem);
> + set_disconnected(modem->context);
> }
>
> static void cdma_cm_update_settings(struct modem_data *modem,
> @@ -1935,7 +1981,7 @@ static gboolean cdma_cm_changed(DBusConnection *conn,
> if (!modem)
> return TRUE;
>
> - if (modem->online && !modem->network)
> + if (modem->online && !modem->context)
> cdma_netreg_get_properties(modem);
>
> if (!dbus_message_iter_init(message, &iter))
> @@ -2206,10 +2252,10 @@ static void modem_update_interfaces(struct modem_data
> *modem,
> remove_all_contexts(modem);
>
> if (api_removed(old_ifaces, new_ifaces, OFONO_API_NETREG))
> - remove_network(modem);
> + remove_all_networks(modem);
>
> if (api_removed(old_ifaces, new_ifaces, OFONO_API_CDMA_NETREG))
> - remove_network(modem);
> + remove_all_networks(modem);
> }
>
> static gboolean modem_changed(DBusConnection *conn, DBusMessage *message,
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 2, Issue 10
**************************************