summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-10-10 13:20:46 +0200
committerAleksander Morgado <aleksander@aleksander.es>2018-10-17 11:38:02 +0200
commit0073cbed59a270e1a8f18f591d31cbaf64a995ae (patch)
tree93095c430d373b54f4b8f8e3d9f099502f7802c9
parent8f491a2d885db43c4814407bfa36f62adf4561c0 (diff)
downloadlibmbim-0073cbed59a270e1a8f18f591d31cbaf64a995ae.tar.gz
libmbim-glib: explicitly configure only non-standard services
The MBIM documentation states that the DEVICE_SERVICE_SUBSCRIBE_LIST message may be used by clients to specify which indications it is interested in receiving, and then the modem "must only indicate notifications for CIDs which have been enabled via this command". A bit later it says that "Upon OPEN_DONE completion, notifications for CIDs defined in this specification are enabled (aka subscribed to) by default, and vendor extension notifications are off by default." These two previous statements seem to contradict each other, as this would mean that devices emit by default indications for all standard services, regardless of whether clients have subscribed to them explicitly via DEVICE_SERVICE_SUBSCRIBE_LIST. Looking at actual real devices, giving a DEVICE_SERVICE_SUBSCRIBE_LIST that includes NO basic service CID enabled does NOT disable all indications of the standard services, which means we have no way to do so. This commit simplifies the "merged" service subscribe list handling by making the assumption that basic services are by default already subscribed to and also that there is no way to un-subscribe from them. We will use DEVICE_SERVICE_SUBSCRIBE_LIST only to track the subscriptions to CIDs of non-standard services in the device. If the client subscribes to standard services explicitly, the proxy will ignore those and will not send those explicit subscriptions to the device. In the same way, if the client un-subscribes from standard services it was previously subscribed to, we will also ignore those attempts. Clients should be simplified and ignore these subscriptions, but meanwhile the proxy should really behave as the real device. And while trying to behave as the real device, the indications emitted for standard services should always be sent to the clients, even if the clients tried to do custom management of which CIDs of the standard services it's subscribed to. We shouldn't add additional filtering in our end if the device isn't doing that.
-rw-r--r--src/libmbim-glib/mbim-proxy-helpers.c30
-rw-r--r--src/libmbim-glib/mbim-proxy-helpers.h1
-rw-r--r--src/libmbim-glib/mbim-proxy.c115
-rw-r--r--src/libmbim-glib/test/test-proxy-helpers.c303
4 files changed, 164 insertions, 285 deletions
diff --git a/src/libmbim-glib/mbim-proxy-helpers.c b/src/libmbim-glib/mbim-proxy-helpers.c
index d0cd0d2..c53f6a5 100644
--- a/src/libmbim-glib/mbim-proxy-helpers.c
+++ b/src/libmbim-glib/mbim-proxy-helpers.c
@@ -130,30 +130,6 @@ _mbim_proxy_helper_service_subscribe_list_debug (const MbimEventEntry * const *l
/*****************************************************************************/
MbimEventEntry **
-_mbim_proxy_helper_service_subscribe_standard_list_new (gsize *out_size)
-{
- gsize i;
- MbimService service;
- MbimEventEntry **out;
-
- g_assert (out_size != NULL);
-
- out = g_new0 (MbimEventEntry *, 1 + (MBIM_SERVICE_DSS - MBIM_SERVICE_BASIC_CONNECT + 1));
-
- for (service = MBIM_SERVICE_BASIC_CONNECT, i = 0;
- service <= MBIM_SERVICE_DSS;
- service++, i++) {
- out[i] = g_new0 (MbimEventEntry, 1);
- memcpy (&out[i]->device_service_id, mbim_uuid_from_service (service), sizeof (MbimUuid));
- }
-
- *out_size = i;
- return out;
-}
-
-/*****************************************************************************/
-
-MbimEventEntry **
_mbim_proxy_helper_service_subscribe_request_parse (MbimMessage *message,
gsize *out_size)
{
@@ -219,6 +195,12 @@ _mbim_proxy_helper_service_subscribe_list_merge (MbimEventEntry **in,
for (m = 0; m < merge_size; m++) {
MbimEventEntry *entry = NULL;
+ MbimService id;
+
+ /* ignore all merge additions for standard services */
+ id = mbim_uuid_to_service (&merge[m]->device_service_id);
+ if (id >= MBIM_SERVICE_BASIC_CONNECT && id <= MBIM_SERVICE_DSS)
+ continue;
/* look for matching uuid */
if (in && in_size) {
diff --git a/src/libmbim-glib/mbim-proxy-helpers.h b/src/libmbim-glib/mbim-proxy-helpers.h
index 6b43cde..3c5f6a6 100644
--- a/src/libmbim-glib/mbim-proxy-helpers.h
+++ b/src/libmbim-glib/mbim-proxy-helpers.h
@@ -43,7 +43,6 @@ gboolean _mbim_proxy_helper_service_subscribe_list_cmp (const M
gsize b_size);
void _mbim_proxy_helper_service_subscribe_list_debug (const MbimEventEntry * const *list,
gsize list_size);
-MbimEventEntry **_mbim_proxy_helper_service_subscribe_standard_list_new (gsize *out_size);
MbimEventEntry **_mbim_proxy_helper_service_subscribe_request_parse (MbimMessage *message,
gsize *out_size);
MbimEventEntry **_mbim_proxy_helper_service_subscribe_list_merge (MbimEventEntry **original,
diff --git a/src/libmbim-glib/mbim-proxy.c b/src/libmbim-glib/mbim-proxy.c
index 1cb3cef..9489e77 100644
--- a/src/libmbim-glib/mbim-proxy.c
+++ b/src/libmbim-glib/mbim-proxy.c
@@ -122,7 +122,6 @@ typedef struct {
MbimDevice *device;
guint indication_id;
- gboolean service_subscriber_list_enabled;
MbimEventEntry **mbim_event_entry_array;
gsize mbim_event_entry_array_size;
} Client;
@@ -259,50 +258,57 @@ untrack_client (MbimProxy *self,
/* Client indications */
static void
+forward_indication (Client *client,
+ MbimMessage *message)
+{
+ GError *error = NULL;
+
+ if (!client_send_message (client, message, &error)) {
+ g_warning ("couldn't forward indication to client");
+ g_error_free (error);
+ }
+}
+
+static void
client_indication_cb (MbimDevice *device,
MbimMessage *message,
Client *client)
{
- guint i;
- GError *error = NULL;
- gboolean forward_indication = FALSE;
- MbimEventEntry *event = NULL;
-
- if (client->service_subscriber_list_enabled) {
- /* if client sent the device service subscribe list with element count 0 then
- * ignore all indications */
- if (client->mbim_event_entry_array) {
- for (i = 0; i < client->mbim_event_entry_array_size; i++) {
- if (mbim_uuid_cmp (mbim_message_indicate_status_get_service_id (message),
- &client->mbim_event_entry_array[i]->device_service_id)) {
- event = client->mbim_event_entry_array[i];
- break;
- }
- }
-
- if (event) {
- /* found matching service, search for cid */
- if (event->cids_count) {
- for (i = 0; i < event->cids_count; i++) {
- if (mbim_message_indicate_status_get_cid (message) == event->cids[i]) {
- forward_indication = TRUE;
- break;
- }
- }
- } else
- /* cids_count of 0 enables all indications for the service */
- forward_indication = TRUE;
- }
+ MbimService service;
+ MbimEventEntry *entry;
+ guint i;
+
+ /* standard service indications are always forwarded to clients */
+ service = mbim_message_indicate_status_get_service (message);
+ if (service >= MBIM_SERVICE_BASIC_CONNECT && service <= MBIM_SERVICE_DSS) {
+ forward_indication (client, message);
+ return;
+ }
+
+ /* if client didn't provide a custom subscribe list for non-standard services, we're done. */
+ if (!client->mbim_event_entry_array)
+ return;
+
+ /* Look for the event list associated to the service */
+ entry = NULL;
+ for (i = 0; i < client->mbim_event_entry_array_size; i++) {
+ if (mbim_uuid_cmp (mbim_message_indicate_status_get_service_id (message),
+ &client->mbim_event_entry_array[i]->device_service_id)) {
+ entry = client->mbim_event_entry_array[i];
+ break;
}
- } else if (mbim_message_indicate_status_get_service (message) != MBIM_SERVICE_INVALID &&
- !mbim_service_id_is_custom (mbim_message_indicate_status_get_service (message)))
- /* only forward standard service indications if service subscriber list is not enabled */
- forward_indication = TRUE;
-
- if (forward_indication) {
- if (!client_send_message (client, message, &error)) {
- g_warning ("couldn't forward indication to client");
- g_error_free (error);
+ }
+
+ /* if client didn't subscribe to anything in this service, we're done */
+ if (!entry)
+ return;
+
+ /* Look for the specific cid in the event list */
+ for (i = 0; i < entry->cids_count; i++) {
+ if (mbim_message_indicate_status_get_cid (message) == entry->cids[i]) {
+ /* exact match in the subscription */
+ forward_indication (client, message);
+ return;
}
}
}
@@ -820,11 +826,10 @@ static void
track_service_subscribe_list (Client *client,
MbimMessage *message)
{
- client->service_subscriber_list_enabled = TRUE;
-
- if (client->mbim_event_entry_array)
- mbim_event_entry_array_free (client->mbim_event_entry_array);
-
+ /* On each new request from the client, it should provide the FULL list of
+ * non-standard events it's subscribed to, so we can safely recreate the
+ * whole array each time. */
+ g_clear_pointer (&client->mbim_event_entry_array, mbim_event_entry_array_free);
client->mbim_event_entry_array = _mbim_proxy_helper_service_subscribe_request_parse (message, &client->mbim_event_entry_array_size);
if (mbim_utils_get_traces_enabled ()) {
@@ -1234,9 +1239,12 @@ device_context_get (MbimDevice *device)
ctx = g_object_get_qdata (G_OBJECT (device), device_context_quark);
if (!ctx) {
ctx = g_slice_new0 (DeviceContext);
- /* By default, we assume we have all default services enabled.
- * This is the default in the MBIM protocol. */
- ctx->mbim_event_entry_array = _mbim_proxy_helper_service_subscribe_standard_list_new (&ctx->mbim_event_entry_array_size);
+ /* By default, we assume we have all default services enabled
+ * (the default in the MBIM protocol). We also assume we cannot
+ * disable the default services in any way, as the protocol does
+ * not support that. We don't track the default services in the
+ * merged list, because those are implicit. */
+ ctx->mbim_event_entry_array = NULL;
g_object_set_qdata_full (G_OBJECT (device), device_context_quark, ctx, (GDestroyNotify)device_context_free);
}
@@ -1258,6 +1266,11 @@ merge_client_service_subscribe_lists (MbimProxy *self,
g_assert (out_size != NULL);
+ /* NOTE! the list_merge() command will IGNORE all basic services when building
+ * the merged list. If any client tries to subscribe to any of those, we'll track
+ * them in the client-specific lists, but NOT in the device-merged list, as
+ * there is no point in doing so. */
+
/* Add previous global list */
updated = _mbim_proxy_helper_service_subscribe_list_merge (NULL, 0,
ctx->mbim_event_entry_array, ctx->mbim_event_entry_array_size,
@@ -1288,7 +1301,7 @@ merge_client_service_subscribe_lists (MbimProxy *self,
}
/* Lists are different, updated stored one */
- mbim_event_entry_array_free (ctx->mbim_event_entry_array);
+ g_clear_pointer (&ctx->mbim_event_entry_array, mbim_event_entry_array_free);
ctx->mbim_event_entry_array = updated;
ctx->mbim_event_entry_array_size = updated_size;
@@ -1326,8 +1339,8 @@ reset_client_service_subscribe_lists (MbimProxy *self,
}
/* And reset the device-specific merged list */
- mbim_event_entry_array_free (ctx->mbim_event_entry_array);
- ctx->mbim_event_entry_array = _mbim_proxy_helper_service_subscribe_standard_list_new (&ctx->mbim_event_entry_array_size);
+ g_clear_pointer (&ctx->mbim_event_entry_array, mbim_event_entry_array_free);
+ ctx->mbim_event_entry_array_size = 0;
}
static void
diff --git a/src/libmbim-glib/test/test-proxy-helpers.c b/src/libmbim-glib/test/test-proxy-helpers.c
index 84c773e..ab7e6a4 100644
--- a/src/libmbim-glib/test/test-proxy-helpers.c
+++ b/src/libmbim-glib/test/test-proxy-helpers.c
@@ -121,84 +121,29 @@ test_parse_single_service_5_cids (void)
/*****************************************************************************/
-static MbimEventEntry *
-find_service_in_list (MbimEventEntry **list,
- gsize list_size,
- MbimService service)
-{
- gsize i;
-
- for (i = 0; i < list_size; i++) {
- if (mbim_uuid_cmp (&(list[i]->device_service_id), mbim_uuid_from_service (service)))
- return list[i];
- }
-
- return NULL;
-}
-
-static void
-check_standard_list (MbimEventEntry **list,
- gsize list_size)
-{
- MbimEventEntry *tmp;
- MbimService s;
- gsize i;
-
- for (i = 0; list[i]; i++);
- g_assert_cmpuint (i, ==, list_size);
- g_assert_cmpuint (i, ==, (MBIM_SERVICE_DSS - MBIM_SERVICE_BASIC_CONNECT + 1));
-
- for (s = MBIM_SERVICE_BASIC_CONNECT; s <= MBIM_SERVICE_DSS; s++) {
- tmp = find_service_in_list (list, list_size, s);
- g_assert (tmp != NULL);
- g_assert_cmpuint (tmp->cids_count, ==, 0);
- g_assert (tmp->cids == NULL);
- }
-}
-
-static void
-test_standard_list (void)
-{
- MbimEventEntry **out;
- gsize out_size = 0;
-
- out = _mbim_proxy_helper_service_subscribe_standard_list_new (&out_size);
- check_standard_list (out, out_size);
- mbim_event_entry_array_free (out);
-}
-
-/*****************************************************************************/
-
static void
-test_merge_standard_list_full_none (void)
+test_merge_none (void)
{
- MbimEventEntry **list;
+ MbimEventEntry **list = NULL;
gsize list_size = 0;
gsize out_size = 0;
- /* list with all standard services */
- list = _mbim_proxy_helper_service_subscribe_standard_list_new (&list_size);
-
/* merge */
list = _mbim_proxy_helper_service_subscribe_list_merge (list, list_size, NULL, 0, &out_size);
- check_standard_list (list, out_size);
-
- mbim_event_entry_array_free (list);
+ g_assert (list == NULL);
+ g_assert_cmpuint (out_size, ==, 0);
}
static void
-test_merge_standard_list_full_subset (void)
+test_merge_standard_services (void)
{
- MbimEventEntry **list;
+ MbimEventEntry **list = NULL;
gsize list_size = 0;
MbimEventEntry **addition;
gsize addition_size;
gsize out_size = 0;
- /* list with all standard services */
- list = _mbim_proxy_helper_service_subscribe_standard_list_new (&list_size);
-
/* setup a new list with a subset of standard services */
addition_size = 2;
addition = g_new0 (MbimEventEntry *, addition_size + 1);
@@ -221,103 +166,52 @@ test_merge_standard_list_full_subset (void)
/* merge */
list = _mbim_proxy_helper_service_subscribe_list_merge (list, list_size, addition, addition_size, &out_size);
- /* Now, as we added a subset of the elements of the standard list to the
- * full standard list, we should still get as output the full standard list
- */
- check_standard_list (list, out_size);
+ /* The new list should be empty, as standard services are ignored */
+ g_assert (list == NULL);
+ g_assert_cmpuint (out_size, ==, 0);
- mbim_event_entry_array_free (list);
mbim_event_entry_array_free (addition);
}
static void
-test_merge_standard_list_full_full (void)
+test_merge_other_services (void)
{
- MbimEventEntry **list;
+ MbimEventEntry **list = NULL;
gsize list_size = 0;
MbimEventEntry **addition;
- gsize addition_size = 0;
- gsize out_size = 0;
-
- /* list with all standard services */
- list = _mbim_proxy_helper_service_subscribe_standard_list_new (&list_size);
- /* again, list with all standard services */
- addition = _mbim_proxy_helper_service_subscribe_standard_list_new (&addition_size);
-
- /* merge */
- list = _mbim_proxy_helper_service_subscribe_list_merge (list, list_size, addition, addition_size, &out_size);
-
- /* Now, as we added a subset of the elements of the standard list to the
- * full standard list, we should still get as output the full standard list
- */
- check_standard_list (list, out_size);
-
- mbim_event_entry_array_free (list);
- mbim_event_entry_array_free (addition);
-}
-
-static void
-test_merge_standard_list_subset_full (void)
-{
- MbimEventEntry **list;
- gsize list_size;
- MbimEventEntry **addition;
- gsize addition_size = 0;
+ gsize addition_size;
gsize out_size = 0;
- /* setup a new list with a subset of standard services */
- list_size = 2;
- list = g_new0 (MbimEventEntry *, list_size + 1);
- list[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&list[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
- list[0]->cids_count = 5;
- list[0]->cids = g_new0 (guint32, list[0]->cids_count);
- list[0]->cids[0] = MBIM_CID_BASIC_CONNECT_SUBSCRIBER_READY_STATUS;
- list[0]->cids[1] = MBIM_CID_BASIC_CONNECT_RADIO_STATE;
- list[0]->cids[2] = MBIM_CID_BASIC_CONNECT_SIGNAL_STATE;
- list[0]->cids[3] = MBIM_CID_BASIC_CONNECT_IP_CONFIGURATION;
- list[0]->cids[4] = MBIM_CID_BASIC_CONNECT_NETWORK_IDLE_HINT;
- list[1] = g_new0 (MbimEventEntry, 1);
- memcpy (&list[1]->device_service_id, MBIM_UUID_SMS, sizeof (MbimUuid));
- list[1]->cids_count = 2;
- list[1]->cids = g_new0 (guint32, list[1]->cids_count);
- list[1]->cids[0] = MBIM_CID_SMS_READ;
- list[1]->cids[1] = MBIM_CID_SMS_SEND;
-
- /* list with all standard services */
- addition = _mbim_proxy_helper_service_subscribe_standard_list_new (&addition_size);
+ /* setup a new list with a subset of other services */
+ addition_size = 2;
+ addition = g_new0 (MbimEventEntry *, addition_size + 1);
+ addition[0] = g_new0 (MbimEventEntry, 1);
+ memcpy (&addition[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
+ addition[0]->cids_count = 5;
+ addition[0]->cids = g_new0 (guint32, addition[0]->cids_count);
+ addition[0]->cids[0] = MBIM_CID_ATDS_SIGNAL;
+ addition[0]->cids[1] = MBIM_CID_ATDS_LOCATION;
+ addition[0]->cids[2] = MBIM_CID_ATDS_OPERATORS;
+ addition[0]->cids[3] = MBIM_CID_ATDS_RAT;
+ addition[0]->cids[4] = MBIM_CID_ATDS_REGISTER_STATE;
+ addition[1] = g_new0 (MbimEventEntry, 1);
+ memcpy (&addition[1]->device_service_id, MBIM_UUID_QMI, sizeof (MbimUuid));
+ addition[1]->cids_count = 1;
+ addition[1]->cids = g_new0 (guint32, addition[1]->cids_count);
+ addition[1]->cids[0] = MBIM_CID_QMI_MSG;
/* merge */
list = _mbim_proxy_helper_service_subscribe_list_merge (list, list_size, addition, addition_size, &out_size);
- /* Now, as we added the full standard list to a subset, we should still get
- * as output the full standard list */
- check_standard_list (list, out_size);
+ /* The new list should be totally equal to the addition, as the original list was empty. */
+ g_assert (_mbim_proxy_helper_service_subscribe_list_cmp ((const MbimEventEntry * const *)list, out_size,
+ (const MbimEventEntry * const *)addition, addition_size));
mbim_event_entry_array_free (list);
mbim_event_entry_array_free (addition);
}
static void
-test_merge_standard_list_none_full (void)
-{
- MbimEventEntry **list, **merged_list;
- gsize addition_size = 0;
- gsize out_size = 0;
-
- /* list with all standard services */
- list = _mbim_proxy_helper_service_subscribe_standard_list_new (&addition_size);
-
- /* merge */
- merged_list = _mbim_proxy_helper_service_subscribe_list_merge (NULL, 0, list, addition_size, &out_size);
-
- check_standard_list (merged_list, out_size);
-
- mbim_event_entry_array_free (list);
- mbim_event_entry_array_free (merged_list);
-}
-
-static void
test_merge_list_same_service (void)
{
MbimEventEntry **list;
@@ -328,26 +222,26 @@ test_merge_list_same_service (void)
gsize expected_size;
gsize out_size = 0;
- /* setup a new list with a subset of standard services */
+ /* setup a new list with a subset of non-standard services */
list_size = 1;
list = g_new0 (MbimEventEntry *, list_size + 1);
list[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&list[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
+ memcpy (&list[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
list[0]->cids_count = 2;
list[0]->cids = g_new0 (guint32, list[0]->cids_count);
- list[0]->cids[0] = MBIM_CID_BASIC_CONNECT_IP_CONFIGURATION;
- list[0]->cids[1] = MBIM_CID_BASIC_CONNECT_NETWORK_IDLE_HINT;
+ list[0]->cids[0] = MBIM_CID_ATDS_SIGNAL;
+ list[0]->cids[1] = MBIM_CID_ATDS_LOCATION;
- /* setup a new list with a subset of standard services */
+ /* setup a new list with a subset of non-standard services */
addition_size = 1;
addition = g_new0 (MbimEventEntry *, addition_size + 1);
addition[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&addition[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
+ memcpy (&addition[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
addition[0]->cids_count = 3;
addition[0]->cids = g_new0 (guint32, addition[0]->cids_count);
- addition[0]->cids[0] = MBIM_CID_BASIC_CONNECT_SUBSCRIBER_READY_STATUS;
- addition[0]->cids[1] = MBIM_CID_BASIC_CONNECT_RADIO_STATE;
- addition[0]->cids[2] = MBIM_CID_BASIC_CONNECT_SIGNAL_STATE;
+ addition[0]->cids[0] = MBIM_CID_ATDS_OPERATORS;
+ addition[0]->cids[1] = MBIM_CID_ATDS_RAT;
+ addition[0]->cids[2] = MBIM_CID_ATDS_REGISTER_STATE;
/* merge */
list = _mbim_proxy_helper_service_subscribe_list_merge (list, list_size, addition, addition_size, &out_size);
@@ -356,14 +250,14 @@ test_merge_list_same_service (void)
expected_size = 1;
expected = g_new0 (MbimEventEntry *, expected_size + 1);
expected[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&expected[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
+ memcpy (&expected[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
expected[0]->cids_count = 5;
expected[0]->cids = g_new0 (guint32, expected[0]->cids_count);
- expected[0]->cids[0] = MBIM_CID_BASIC_CONNECT_SUBSCRIBER_READY_STATUS;
- expected[0]->cids[1] = MBIM_CID_BASIC_CONNECT_RADIO_STATE;
- expected[0]->cids[2] = MBIM_CID_BASIC_CONNECT_SIGNAL_STATE;
- expected[0]->cids[3] = MBIM_CID_BASIC_CONNECT_IP_CONFIGURATION;
- expected[0]->cids[4] = MBIM_CID_BASIC_CONNECT_NETWORK_IDLE_HINT;
+ expected[0]->cids[0] = MBIM_CID_ATDS_SIGNAL;
+ expected[0]->cids[1] = MBIM_CID_ATDS_LOCATION;
+ expected[0]->cids[2] = MBIM_CID_ATDS_OPERATORS;
+ expected[0]->cids[3] = MBIM_CID_ATDS_RAT;
+ expected[0]->cids[4] = MBIM_CID_ATDS_REGISTER_STATE;
/* Compare */
g_assert (_mbim_proxy_helper_service_subscribe_list_cmp ((const MbimEventEntry * const *)list, out_size,
@@ -385,28 +279,24 @@ test_merge_list_different_services (void)
gsize expected_size;
gsize out_size = 0;
- /* setup a new list with a subset of standard services */
+ /* setup a new list with a subset of non-standard services */
list_size = 1;
list = g_new0 (MbimEventEntry *, list_size + 1);
list[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&list[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
- list[0]->cids_count = 5;
+ memcpy (&list[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
+ list[0]->cids_count = 2;
list[0]->cids = g_new0 (guint32, list[0]->cids_count);
- list[0]->cids[0] = MBIM_CID_BASIC_CONNECT_IP_CONFIGURATION;
- list[0]->cids[1] = MBIM_CID_BASIC_CONNECT_NETWORK_IDLE_HINT;
- list[0]->cids[2] = MBIM_CID_BASIC_CONNECT_SUBSCRIBER_READY_STATUS;
- list[0]->cids[3] = MBIM_CID_BASIC_CONNECT_RADIO_STATE;
- list[0]->cids[4] = MBIM_CID_BASIC_CONNECT_SIGNAL_STATE;
+ list[0]->cids[0] = MBIM_CID_ATDS_SIGNAL;
+ list[0]->cids[1] = MBIM_CID_ATDS_LOCATION;
- /* setup a new list with a subset of standard services */
+ /* setup a new list with a subset of non-standard services */
addition_size = 1;
addition = g_new0 (MbimEventEntry *, addition_size + 1);
addition[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&addition[0]->device_service_id, MBIM_UUID_SMS, sizeof (MbimUuid));
- addition[0]->cids_count = 2;
+ memcpy (&addition[0]->device_service_id, MBIM_UUID_QMI, sizeof (MbimUuid));
+ addition[0]->cids_count = 1;
addition[0]->cids = g_new0 (guint32, addition[0]->cids_count);
- addition[0]->cids[0] = MBIM_CID_SMS_READ;
- addition[0]->cids[1] = MBIM_CID_SMS_SEND;
+ addition[0]->cids[0] = MBIM_CID_QMI_MSG;
/* merge */
list = _mbim_proxy_helper_service_subscribe_list_merge (list, list_size, addition, addition_size, &out_size);
@@ -415,20 +305,16 @@ test_merge_list_different_services (void)
expected_size = 2;
expected = g_new0 (MbimEventEntry *, expected_size + 1);
expected[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&expected[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
- expected[0]->cids_count = 5;
+ memcpy (&expected[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
+ expected[0]->cids_count = 2;
expected[0]->cids = g_new0 (guint32, expected[0]->cids_count);
- expected[0]->cids[0] = MBIM_CID_BASIC_CONNECT_SUBSCRIBER_READY_STATUS;
- expected[0]->cids[1] = MBIM_CID_BASIC_CONNECT_RADIO_STATE;
- expected[0]->cids[2] = MBIM_CID_BASIC_CONNECT_SIGNAL_STATE;
- expected[0]->cids[3] = MBIM_CID_BASIC_CONNECT_IP_CONFIGURATION;
- expected[0]->cids[4] = MBIM_CID_BASIC_CONNECT_NETWORK_IDLE_HINT;
+ expected[0]->cids[0] = MBIM_CID_ATDS_SIGNAL;
+ expected[0]->cids[1] = MBIM_CID_ATDS_LOCATION;
expected[1] = g_new0 (MbimEventEntry, 1);
- memcpy (&expected[1]->device_service_id, MBIM_UUID_SMS, sizeof (MbimUuid));
- expected[1]->cids_count = 2;
+ memcpy (&expected[1]->device_service_id, MBIM_UUID_QMI, sizeof (MbimUuid));
+ expected[1]->cids_count = 1;
expected[1]->cids = g_new0 (guint32, expected[1]->cids_count);
- expected[1]->cids[0] = MBIM_CID_SMS_READ;
- expected[1]->cids[1] = MBIM_CID_SMS_SEND;
+ expected[1]->cids[0] = MBIM_CID_QMI_MSG;
/* Compare */
g_assert (_mbim_proxy_helper_service_subscribe_list_cmp ((const MbimEventEntry * const *)list, out_size,
@@ -450,58 +336,60 @@ test_merge_list_merged_services (void)
gsize expected_size;
gsize out_size = 0;
- /* setup a new list with a subset of standard services */
+ /* setup a new list with a subset of non-standard services */
list_size = 2;
list = g_new0 (MbimEventEntry *, list_size + 1);
list[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&list[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
+ memcpy (&list[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
list[0]->cids_count = 3;
list[0]->cids = g_new0 (guint32, list[0]->cids_count);
- list[0]->cids[0] = MBIM_CID_BASIC_CONNECT_SUBSCRIBER_READY_STATUS;
- list[0]->cids[1] = MBIM_CID_BASIC_CONNECT_RADIO_STATE;
- list[0]->cids[2] = MBIM_CID_BASIC_CONNECT_SIGNAL_STATE;
+ list[0]->cids[0] = MBIM_CID_ATDS_SIGNAL;
+ list[0]->cids[1] = MBIM_CID_ATDS_LOCATION;
+ list[0]->cids[2] = MBIM_CID_ATDS_OPERATORS;
list[1] = g_new0 (MbimEventEntry, 1);
- memcpy (&list[1]->device_service_id, MBIM_UUID_SMS, sizeof (MbimUuid));
+ memcpy (&list[1]->device_service_id, MBIM_UUID_QMI, sizeof (MbimUuid));
list[1]->cids_count = 1;
list[1]->cids = g_new0 (guint32, list[1]->cids_count);
- list[1]->cids[0] = MBIM_CID_SMS_READ;
+ list[1]->cids[0] = MBIM_CID_QMI_MSG;
- /* setup a new list with a subset of standard services */
+ /* setup a new list with a subset of standard and non-standard services */
addition_size = 2;
addition = g_new0 (MbimEventEntry *, addition_size + 1);
addition[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&addition[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
- addition[0]->cids_count = 2;
+ memcpy (&addition[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
+ addition[0]->cids_count = 1;
addition[0]->cids = g_new0 (guint32, addition[0]->cids_count);
- addition[0]->cids[0] = MBIM_CID_BASIC_CONNECT_IP_CONFIGURATION;
- addition[0]->cids[1] = MBIM_CID_BASIC_CONNECT_NETWORK_IDLE_HINT;
+ addition[0]->cids[0] = MBIM_CID_ATDS_RAT;
addition[1] = g_new0 (MbimEventEntry, 1);
- memcpy (&addition[1]->device_service_id, MBIM_UUID_SMS, sizeof (MbimUuid));
+ memcpy (&addition[1]->device_service_id, MBIM_UUID_MS_HOST_SHUTDOWN, sizeof (MbimUuid));
addition[1]->cids_count = 1;
addition[1]->cids = g_new0 (guint32, addition[1]->cids_count);
- addition[1]->cids[0] = MBIM_CID_SMS_SEND;
+ addition[1]->cids[0] = MBIM_CID_MS_HOST_SHUTDOWN_NOTIFY;
/* merge */
list = _mbim_proxy_helper_service_subscribe_list_merge (list, list_size, addition, addition_size, &out_size);
/* setup the expected list */
- expected_size = 2;
+ expected_size = 3;
expected = g_new0 (MbimEventEntry *, expected_size + 1);
expected[0] = g_new0 (MbimEventEntry, 1);
- memcpy (&expected[0]->device_service_id, MBIM_UUID_BASIC_CONNECT, sizeof (MbimUuid));
- expected[0]->cids_count = 5;
+ memcpy (&expected[0]->device_service_id, MBIM_UUID_ATDS, sizeof (MbimUuid));
+ expected[0]->cids_count = 4;
expected[0]->cids = g_new0 (guint32, expected[0]->cids_count);
- expected[0]->cids[0] = MBIM_CID_BASIC_CONNECT_SUBSCRIBER_READY_STATUS;
- expected[0]->cids[1] = MBIM_CID_BASIC_CONNECT_RADIO_STATE;
- expected[0]->cids[2] = MBIM_CID_BASIC_CONNECT_SIGNAL_STATE;
- expected[0]->cids[3] = MBIM_CID_BASIC_CONNECT_IP_CONFIGURATION;
- expected[0]->cids[4] = MBIM_CID_BASIC_CONNECT_NETWORK_IDLE_HINT;
+ expected[0]->cids[0] = MBIM_CID_ATDS_SIGNAL;
+ expected[0]->cids[1] = MBIM_CID_ATDS_LOCATION;
+ expected[0]->cids[2] = MBIM_CID_ATDS_OPERATORS;
+ expected[0]->cids[3] = MBIM_CID_ATDS_RAT;
expected[1] = g_new0 (MbimEventEntry, 1);
- memcpy (&expected[1]->device_service_id, MBIM_UUID_SMS, sizeof (MbimUuid));
- expected[1]->cids_count = 2;
+ memcpy (&expected[1]->device_service_id, MBIM_UUID_QMI, sizeof (MbimUuid));
+ expected[1]->cids_count = 1;
expected[1]->cids = g_new0 (guint32, expected[1]->cids_count);
- expected[1]->cids[0] = MBIM_CID_SMS_READ;
- expected[1]->cids[1] = MBIM_CID_SMS_SEND;
+ expected[1]->cids[0] = MBIM_CID_QMI_MSG;
+ expected[2] = g_new0 (MbimEventEntry, 1);
+ memcpy (&expected[2]->device_service_id, MBIM_UUID_MS_HOST_SHUTDOWN, sizeof (MbimUuid));
+ expected[2]->cids_count = 1;
+ expected[2]->cids = g_new0 (guint32, expected[2]->cids_count);
+ expected[2]->cids[0] = MBIM_CID_MS_HOST_SHUTDOWN_NOTIFY;
/* Compare */
g_assert (_mbim_proxy_helper_service_subscribe_list_cmp ((const MbimEventEntry * const *)list, out_size,
@@ -518,15 +406,12 @@ int main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/libmbim-glib/proxy/standard-list", test_standard_list);
g_test_add_func ("/libmbim-glib/proxy/parse/single-service/0", test_parse_single_service_0_cids);
g_test_add_func ("/libmbim-glib/proxy/parse/single-service/1", test_parse_single_service_1_cids);
g_test_add_func ("/libmbim-glib/proxy/parse/single-service/5", test_parse_single_service_5_cids);
- g_test_add_func ("/libmbim-glib/proxy/merge/standard/full_none", test_merge_standard_list_full_none);
- g_test_add_func ("/libmbim-glib/proxy/merge/standard/full_subset", test_merge_standard_list_full_subset);
- g_test_add_func ("/libmbim-glib/proxy/merge/standard/full_full", test_merge_standard_list_full_full);
- g_test_add_func ("/libmbim-glib/proxy/merge/standard/subset_full", test_merge_standard_list_subset_full);
- g_test_add_func ("/libmbim-glib/proxy/merge/standard/none_full", test_merge_standard_list_none_full);
+ g_test_add_func ("/libmbim-glib/proxy/merge/none", test_merge_none);
+ g_test_add_func ("/libmbim-glib/proxy/merge/standard", test_merge_standard_services);
+ g_test_add_func ("/libmbim-glib/proxy/merge/other", test_merge_other_services);
g_test_add_func ("/libmbim-glib/proxy/merge/same-service", test_merge_list_same_service);
g_test_add_func ("/libmbim-glib/proxy/merge/different-services", test_merge_list_different_services);
g_test_add_func ("/libmbim-glib/proxy/merge/merged-services", test_merge_list_merged_services);