summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-10-08 22:23:03 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-10-12 22:27:12 +0200
commit9506fd86267dabe0e6bdad44c5e82576ce2bfd0b (patch)
treea6d16cd3e300224e80cde9ac99508b9e4332607b
parent2bb3cc67418eb53f90b97c810b32477ac89202ea (diff)
ms-basic-connect-v3: switch 'Basic Connect' to use MbimTlvs
The logic is updated to avoid requiring intermediate structs in the API; for the string TLVs that are included as named fields we'll use the 'tlv-string' types. We also add support for the unnamed IEs as 'tlv-list' fields at the end of the messages.
-rw-r--r--data/mbim-service-ms-basic-connect-v3.json47
-rw-r--r--src/libmbim-glib/test/test-message-builder.c86
-rw-r--r--src/libmbim-glib/test/test-message-parser.c314
-rw-r--r--src/mbimcli/mbimcli-basic-connect.c52
4 files changed, 433 insertions, 66 deletions
diff --git a/data/mbim-service-ms-basic-connect-v3.json b/data/mbim-service-ms-basic-connect-v3.json
index 06e2bf3..a8b5e67 100644
--- a/data/mbim-service-ms-basic-connect-v3.json
+++ b/data/mbim-service-ms-basic-connect-v3.json
@@ -108,32 +108,8 @@
"struct-type" : "MbimTai" } ] },
// *********************************************************************************
- { "name" : "MbimConnectAccessString",
- "type" : "Struct",
- "since" : "1.28",
- "contents" : [ { "name" : "Type",
- "format" : "guint16" },
- { "name" : "Data",
- "format" : "string-tlv" } ] },
-
- { "name" : "MbimConnectUserName",
- "type" : "Struct",
- "since" : "1.28",
- "contents" : [ { "name" : "Type",
- "format" : "guint16" },
- { "name" : "Data",
- "format" : "string-tlv" } ] },
-
- { "name" : "MbimConnectPassword",
- "type" : "Struct",
- "since" : "1.28",
- "contents" : [ { "name" : "Type",
- "format" : "guint16" },
- { "name" : "Data",
- "format" : "string-tlv" } ] },
-
{ "name" : "Connect",
- "service" : "Basic Connect V3",
+ "service" : "Basic Connect",
"type" : "Command",
"since" : "1.28",
"set" : [ { "name" : "SessionId",
@@ -156,14 +132,13 @@
"format" : "guint32",
"public-format" : "MbimAccessMediaType" },
{ "name" : "AccessString",
- "format" : "struct" ,
- "struct-type" : "MbimConnectAccessString" },
+ "format" : "tlv-string" },
{ "name" : "UserName",
- "format" : "struct" ,
- "struct-type" : "MbimConnectUserName" },
+ "format" : "tlv-string" },
{ "name" : "Password",
- "format" : "struct" ,
- "struct-type" : "MbimConnectPassword" } ],
+ "format" : "tlv-string" },
+ { "name" : "UnnamedIes",
+ "format" : "tlv-list" } ],
"query" : [ { "name" : "SessionId",
"format" : "guint32" } ],
"response" : [ { "name" : "SessionId",
@@ -185,8 +160,9 @@
"format" : "guint32",
"public-format" : "MbimAccessMediaType" },
{ "name" : "AccessString",
- "format" : "struct" ,
- "struct-type" : "MbimConnectAccessString" } ],
+ "format" : "tlv-string" },
+ { "name" : "UnnamedIes",
+ "format" : "tlv-list" } ],
"notification" : [ { "name" : "SessionId",
"format" : "guint32" },
{ "name" : "ActivationState",
@@ -206,6 +182,7 @@
"format" : "guint32",
"public-format" : "MbimAccessMediaType" },
{ "name" : "AccessString",
- "format" : "struct" ,
- "struct-type" : "MbimConnectAccessString" } ] }
+ "format" : "tlv-string" },
+ { "name" : "UnnamedIes",
+ "format" : "tlv-list" } ] }
]
diff --git a/src/libmbim-glib/test/test-message-builder.c b/src/libmbim-glib/test/test-message-builder.c
index a04c3bc..61bf3f5 100644
--- a/src/libmbim-glib/test/test-message-builder.c
+++ b/src/libmbim-glib/test/test-message-builder.c
@@ -1632,6 +1632,91 @@ test_message_builder_ms_basic_connect_extensions_registration_parameters_set_3_u
test_message_printable (message, 3, 0);
}
+static void
+test_message_builder_ms_basic_connect_v3_connect_set (void)
+{
+ GError *error = NULL;
+ MbimMessage *message;
+ const guint8 expected_message [] = {
+ /* header */
+ 0x03, 0x00, 0x00, 0x00, /* type */
+ 0x80, 0x00, 0x00, 0x00, /* length */
+ 0x01, 0x00, 0x00, 0x00, /* transaction id */
+ /* fragment header */
+ 0x01, 0x00, 0x00, 0x00, /* total */
+ 0x00, 0x00, 0x00, 0x00, /* current */
+ /* command_message */
+ 0xA2, 0x89, 0xCC, 0x33, /* service id */
+ 0xBC, 0xBB, 0x8B, 0x4F,
+ 0xB6, 0xB0, 0x13, 0x3E,
+ 0xC2, 0xAA, 0xE6, 0xDF,
+ 0x0C, 0x00, 0x00, 0x00, /* command id */
+ 0x01, 0x00, 0x00, 0x00, /* command_type */
+ 0x50, 0x00, 0x00, 0x00, /* buffer_length */
+ /* information buffer */
+ 0x01, 0x00, 0x00, 0x00, /* session id */
+ 0x01, 0x00, 0x00, 0x00, /* activation command */
+ 0x00, 0x00, 0x00, 0x00, /* compression */
+ 0x01, 0x00, 0x00, 0x00, /* auth protocol */
+ 0x01, 0x00, 0x00, 0x00, /* ip type */
+ 0x7E, 0x5E, 0x2A, 0x7E, /* context type */
+ 0x4E, 0x6F, 0x72, 0x72,
+ 0x73, 0x6B, 0x65, 0x6E,
+ 0x7E, 0x5E, 0x2A, 0x7E,
+ 0x01, 0x00, 0x00, 0x00, /* media preference */
+ 0x0A, 0x00, 0x00, 0x00, /* access string */
+ 0x10, 0x00, 0x00, 0x00,
+ 0x69, 0x00, 0x6E, 0x00,
+ 0x74, 0x00, 0x65, 0x00,
+ 0x72, 0x00, 0x6E, 0x00,
+ 0x65, 0x00, 0x74, 0x00,
+ 0x0A, 0x00, 0x00, 0x00, /* username */
+ 0x00, 0x00, 0x00, 0x00,
+ 0x0A, 0x00, 0x00, 0x00, /* password */
+ 0x00, 0x00, 0x00, 0x00,
+ /* no unnamed TLVs */
+ };
+
+ /* CONNECT set message */
+ message = (mbim_message_ms_basic_connect_v3_connect_set_new (
+ 0x01,
+ MBIM_ACTIVATION_COMMAND_ACTIVATE,
+ MBIM_COMPRESSION_NONE,
+ MBIM_AUTH_PROTOCOL_PAP,
+ MBIM_CONTEXT_IP_TYPE_IPV4,
+ mbim_uuid_from_context_type (MBIM_CONTEXT_TYPE_INTERNET),
+ MBIM_ACCESS_MEDIA_TYPE_3GPP,
+ "internet",
+ "",
+ "",
+ NULL, /* no unnamed ies */
+ &error));
+
+ g_assert_no_error (error);
+ g_assert (message != NULL);
+ mbim_message_set_transaction_id (message, 1);
+
+ test_message_trace ((const guint8 *)((GByteArray *)message)->data,
+ ((GByteArray *)message)->len,
+ expected_message,
+ sizeof (expected_message));
+
+ g_assert_cmpuint (mbim_message_get_transaction_id (message), ==, 1);
+ g_assert_cmpuint (mbim_message_get_message_type (message), ==, MBIM_MESSAGE_TYPE_COMMAND);
+ g_assert_cmpuint (mbim_message_get_message_length (message), ==, sizeof (expected_message));
+
+ g_assert_cmpuint (mbim_message_command_get_service (message), ==, MBIM_SERVICE_BASIC_CONNECT);
+ g_assert_cmpuint (mbim_message_command_get_cid (message), ==, MBIM_CID_BASIC_CONNECT_CONNECT);
+ g_assert_cmpuint (mbim_message_command_get_command_type (message), ==, MBIM_MESSAGE_COMMAND_TYPE_SET);
+
+ g_assert_cmpuint (((GByteArray *)message)->len, ==, sizeof (expected_message));
+ g_assert (memcmp (((GByteArray *)message)->data, expected_message, sizeof (expected_message)) == 0);
+
+ test_message_printable (message, 3, 0);
+
+ mbim_message_unref (message);
+}
+
int main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
@@ -1656,6 +1741,7 @@ int main (int argc, char **argv)
g_test_add_func ("/libmbim-glib/message/builder/ms-basic-connect-extensions/registration-parameters/set/0-unnamed-tlvs", test_message_builder_ms_basic_connect_extensions_registration_parameters_set_0_unnamed_tlvs);
g_test_add_func ("/libmbim-glib/message/builder/ms-basic-connect-extensions/registration-parameters/set/1-unnamed-tlv", test_message_builder_ms_basic_connect_extensions_registration_parameters_set_1_unnamed_tlv);
g_test_add_func ("/libmbim-glib/message/builder/ms-basic-connect-extensions/registration-parameters/set/3-unnamed-tlvs", test_message_builder_ms_basic_connect_extensions_registration_parameters_set_3_unnamed_tlvs);
+ g_test_add_func ("/libmbim-glib/message/builder/ms-basic-connect-v3/connect/set", test_message_builder_ms_basic_connect_v3_connect_set);
return g_test_run ();
}
diff --git a/src/libmbim-glib/test/test-message-parser.c b/src/libmbim-glib/test/test-message-parser.c
index e180f5a..4144c6a 100644
--- a/src/libmbim-glib/test/test-message-parser.c
+++ b/src/libmbim-glib/test/test-message-parser.c
@@ -2271,6 +2271,317 @@ test_message_parser_ms_basic_connect_extensions_registration_parameters_3_unname
g_list_free_full (unnamed_ies, (GDestroyNotify)mbim_tlv_unref);
}
+static void
+test_message_parser_ms_basic_connect_v3_connect_0_unnamed_tlvs (void)
+{
+ g_autoptr(GError) error = NULL;
+ g_autoptr(MbimMessage) response = NULL;
+ gboolean result;
+ GList *unnamed_ies = NULL;
+ guint32 session_id;
+ MbimActivationState activation_state;
+ MbimVoiceCallState voice_call_state;
+ MbimContextIpType ip_type;
+ MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN;
+ g_autofree gchar *access_string = NULL;
+ const MbimUuid *context_type;
+ guint32 nw_error;
+
+ const guint8 buffer [] = {
+ /* header */
+ 0x03, 0x00, 0x00, 0x80, /* type */
+ 0x6C, 0x00, 0x00, 0x00, /* length */
+ 0x04, 0x00, 0x00, 0x00, /* transaction id */
+ /* fragment header */
+ 0x01, 0x00, 0x00, 0x00, /* total */
+ 0x00, 0x00, 0x00, 0x00, /* current */
+ /* command_done_message */
+ 0xA2, 0x89, 0xCC, 0x33, /* service id */
+ 0xBC, 0xBB, 0x8B, 0x4F,
+ 0xB6, 0xB0, 0x13, 0x3E,
+ 0xC2, 0xAA, 0xE6, 0xDF,
+ 0x0C, 0x00, 0x00, 0x00, /* command id */
+ 0x00, 0x00, 0x00, 0x00, /* status code */
+ 0x3C, 0x00, 0x00, 0x00, /* buffer_length */
+ /* information buffer */
+ 0x01, 0x00, 0x00, 0x00, /* session id */
+ 0x01, 0x00, 0x00, 0x00, /* activation state */
+ 0x00, 0x00, 0x00, 0x00, /* voice call state */
+ 0x01, 0x00, 0x00, 0x00, /* ip type */
+ 0x7E, 0x5E, 0x2A, 0x7E, /* context type */
+ 0x4E, 0x6F, 0x72, 0x72,
+ 0x73, 0x6B, 0x65, 0x6E,
+ 0x7E, 0x5E, 0x2A, 0x7E,
+ 0x00, 0x00, 0x00, 0x00, /* nw error */
+ 0x01, 0x00, 0x00, 0x00, /* media type */
+ 0x0A, 0x00, 0x00, 0x00, /* access string */
+ 0x10, 0x00, 0x00, 0x00,
+ 0x69, 0x00, 0x6E, 0x00,
+ 0x74, 0x00, 0x65, 0x00,
+ 0x72, 0x00, 0x6E, 0x00,
+ 0x65, 0x00, 0x74, 0x00,
+ /* no unnamed TLVs */
+ };
+
+ response = mbim_message_new (buffer, sizeof (buffer));
+ test_message_printable (response, 3, 0);
+
+ result = (mbim_message_ms_basic_connect_v3_connect_response_parse (
+ response,
+ &session_id,
+ &activation_state,
+ &voice_call_state,
+ &ip_type,
+ &context_type,
+ &nw_error,
+ &media_type,
+ &access_string,
+ &unnamed_ies,
+ &error));
+
+ g_assert_no_error (error);
+ g_assert (result);
+
+ g_assert_cmpuint (session_id, ==, 1);
+ g_assert_cmpuint (activation_state, ==, MBIM_ACTIVATION_STATE_ACTIVATED);
+ g_assert_cmpuint (voice_call_state, ==, MBIM_VOICE_CALL_STATE_NONE);
+ g_assert_cmpuint (ip_type, ==, MBIM_CONTEXT_IP_TYPE_IPV4);
+ g_assert_cmpuint (mbim_uuid_to_context_type (context_type), ==, MBIM_CONTEXT_TYPE_INTERNET);
+ g_assert_cmpuint (media_type, ==, MBIM_ACCESS_MEDIA_TYPE_3GPP);
+ g_assert_cmpstr (access_string, ==, "internet");
+ g_assert_cmpuint (g_list_length (unnamed_ies), ==, 0);
+}
+
+static void
+test_message_parser_ms_basic_connect_v3_connect_1_unnamed_tlv (void)
+{
+ g_autoptr(GError) error = NULL;
+ g_autoptr(MbimMessage) response = NULL;
+ gboolean result;
+ GList *unnamed_ies = NULL;
+ guint32 session_id;
+ MbimActivationState activation_state;
+ MbimVoiceCallState voice_call_state;
+ MbimContextIpType ip_type;
+ MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN;
+ g_autofree gchar *access_string = NULL;
+ const MbimUuid *context_type;
+ guint32 nw_error;
+ MbimTlv *tlv;
+ g_autofree gchar *tlv_str = NULL;
+
+ const guint8 buffer [] = {
+ /* header */
+ 0x03, 0x00, 0x00, 0x80, /* type */
+ 0x82, 0x00, 0x00, 0x00, /* length */
+ 0x04, 0x00, 0x00, 0x00, /* transaction id */
+ /* fragment header */
+ 0x01, 0x00, 0x00, 0x00, /* total */
+ 0x00, 0x00, 0x00, 0x00, /* current */
+ /* command_done_message */
+ 0xA2, 0x89, 0xCC, 0x33, /* service id */
+ 0xBC, 0xBB, 0x8B, 0x4F,
+ 0xB6, 0xB0, 0x13, 0x3E,
+ 0xC2, 0xAA, 0xE6, 0xDF,
+ 0x0C, 0x00, 0x00, 0x00, /* command id */
+ 0x00, 0x00, 0x00, 0x00, /* status code */
+ 0x52, 0x00, 0x00, 0x00, /* buffer_length */
+ /* information buffer */
+ 0x01, 0x00, 0x00, 0x00, /* session id */
+ 0x01, 0x00, 0x00, 0x00, /* activation state */
+ 0x00, 0x00, 0x00, 0x00, /* voice call state */
+ 0x01, 0x00, 0x00, 0x00, /* ip type */
+ 0x7E, 0x5E, 0x2A, 0x7E, /* context type */
+ 0x4E, 0x6F, 0x72, 0x72,
+ 0x73, 0x6B, 0x65, 0x6E,
+ 0x7E, 0x5E, 0x2A, 0x7E,
+ 0x00, 0x00, 0x00, 0x00, /* nw error */
+ 0x01, 0x00, 0x00, 0x00, /* media type */
+ 0x0A, 0x00, 0x00, 0x00, /* access string */
+ 0x10, 0x00, 0x00, 0x00,
+ 0x69, 0x00, 0x6E, 0x00,
+ 0x74, 0x00, 0x65, 0x00,
+ 0x72, 0x00, 0x6E, 0x00,
+ 0x65, 0x00, 0x74, 0x00,
+ /* First unnamed TLV */
+ 0x0A, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, no padding */
+ 0x0C, 0x00, 0x00, 0x00, /* TLV data length */
+ 0x4F, 0x00, 0x72, 0x00, /* TLV data string */
+ 0x61, 0x00, 0x6E, 0x00,
+ 0x67, 0x00, 0x65, 0x00,
+ };
+
+ response = mbim_message_new (buffer, sizeof (buffer));
+ test_message_printable (response, 3, 0);
+
+ result = (mbim_message_ms_basic_connect_v3_connect_response_parse (
+ response,
+ &session_id,
+ &activation_state,
+ &voice_call_state,
+ &ip_type,
+ &context_type,
+ &nw_error,
+ &media_type,
+ &access_string,
+ &unnamed_ies,
+ &error));
+
+ g_assert_no_error (error);
+ g_assert (result);
+
+ g_assert_cmpuint (session_id, ==, 1);
+ g_assert_cmpuint (activation_state, ==, MBIM_ACTIVATION_STATE_ACTIVATED);
+ g_assert_cmpuint (voice_call_state, ==, MBIM_VOICE_CALL_STATE_NONE);
+ g_assert_cmpuint (ip_type, ==, MBIM_CONTEXT_IP_TYPE_IPV4);
+ g_assert_cmpuint (mbim_uuid_to_context_type (context_type), ==, MBIM_CONTEXT_TYPE_INTERNET);
+ g_assert_cmpuint (media_type, ==, MBIM_ACCESS_MEDIA_TYPE_3GPP);
+ g_assert_cmpstr (access_string, ==, "internet");
+ g_assert_cmpuint (g_list_length (unnamed_ies), ==, 1);
+
+ tlv = (MbimTlv *)(unnamed_ies->data);
+ g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR);
+
+ tlv_str = mbim_tlv_string_get (tlv, &error);
+ g_assert_no_error (error);
+ g_assert_cmpstr (tlv_str, ==, "Orange");
+
+ g_list_free_full (unnamed_ies, (GDestroyNotify)mbim_tlv_unref);
+}
+
+static void
+test_message_parser_ms_basic_connect_v3_connect_3_unnamed_tlvs (void)
+{
+ g_autoptr(GError) error = NULL;
+ g_autoptr(MbimMessage) response = NULL;
+ gboolean result;
+ GList *unnamed_ies = NULL;
+ guint32 session_id;
+ MbimActivationState activation_state;
+ MbimVoiceCallState voice_call_state;
+ MbimContextIpType ip_type;
+ MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN;
+ g_autofree gchar *access_string = NULL;
+ const MbimUuid *context_type;
+ guint32 nw_error;
+ GList *iter;
+ MbimTlv *tlv;
+ g_autofree gchar *tlv_str_1 = NULL;
+ const gchar *expected_tlv_str_1 = "abcde";
+ g_autofree gchar *tlv_str_2 = NULL;
+ const gchar *expected_tlv_str_2 = "Orange";
+ const guint8 *pco_3 = NULL;
+ guint32 pco_3_size = 0;
+ const guint8 expected_pco[] = { 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B };
+
+ const guint8 buffer [] = {
+ /* header */
+ 0x03, 0x00, 0x00, 0x80, /* type */
+ 0xAA, 0x00, 0x00, 0x00, /* length */
+ 0x04, 0x00, 0x00, 0x00, /* transaction id */
+ /* fragment header */
+ 0x01, 0x00, 0x00, 0x00, /* total */
+ 0x00, 0x00, 0x00, 0x00, /* current */
+ /* command_done_message */
+ 0xA2, 0x89, 0xCC, 0x33, /* service id */
+ 0xBC, 0xBB, 0x8B, 0x4F,
+ 0xB6, 0xB0, 0x13, 0x3E,
+ 0xC2, 0xAA, 0xE6, 0xDF,
+ 0x0C, 0x00, 0x00, 0x00, /* command id */
+ 0x00, 0x00, 0x00, 0x00, /* status code */
+ 0x7A, 0x00, 0x00, 0x00, /* buffer_length */
+ /* information buffer */
+ 0x01, 0x00, 0x00, 0x00, /* session id */
+ 0x01, 0x00, 0x00, 0x00, /* activation state */
+ 0x00, 0x00, 0x00, 0x00, /* voice call state */
+ 0x01, 0x00, 0x00, 0x00, /* ip type */
+ 0x7E, 0x5E, 0x2A, 0x7E, /* context type */
+ 0x4E, 0x6F, 0x72, 0x72,
+ 0x73, 0x6B, 0x65, 0x6E,
+ 0x7E, 0x5E, 0x2A, 0x7E,
+ 0x00, 0x00, 0x00, 0x00, /* nw error */
+ 0x01, 0x00, 0x00, 0x00, /* media type */
+ 0x0A, 0x00, 0x00, 0x00, /* access string */
+ 0x10, 0x00, 0x00, 0x00,
+ 0x69, 0x00, 0x6E, 0x00,
+ 0x74, 0x00, 0x65, 0x00,
+ 0x72, 0x00, 0x6E, 0x00,
+ 0x65, 0x00, 0x74, 0x00,
+ /* First unnamed TLV */
+ 0x0A, 0x00, 0x00, 0x02, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, padding 2 */
+ 0x0A, 0x00, 0x00, 0x00, /* TLV data length */
+ 0x61, 0x00, 0x62, 0x00, /* TLV data string */
+ 0x63, 0x00, 0x64, 0x00,
+ 0x65, 0x00, 0x00, 0x00,
+ /* Second unnamed TLV */
+ 0x0A, 0x00, 0x00, 0x00, /* TLV type MBIM_TLV_TYPE_WCHAR_STR, no padding */
+ 0x0C, 0x00, 0x00, 0x00, /* TLV data length */
+ 0x4F, 0x00, 0x72, 0x00, /* TLV data string */
+ 0x61, 0x00, 0x6E, 0x00,
+ 0x67, 0x00, 0x65, 0x00,
+ /* Third unnamed TLV */
+ 0x0D, 0x00, 0x00, 0x01, /* TLV type MBIM_TLV_TYPE_PCO, padding 1 */
+ 0x0B, 0x00, 0x00, 0x00, /* TLV data length */
+ 0x01, 0x02, 0x03, 0x04, /* TLV data bytes */
+ 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x00,
+ };
+
+ response = mbim_message_new (buffer, sizeof (buffer));
+ test_message_printable (response, 3, 0);
+
+ result = (mbim_message_ms_basic_connect_v3_connect_response_parse (
+ response,
+ &session_id,
+ &activation_state,
+ &voice_call_state,
+ &ip_type,
+ &context_type,
+ &nw_error,
+ &media_type,
+ &access_string,
+ &unnamed_ies,
+ &error));
+
+ g_assert_no_error (error);
+ g_assert (result);
+
+ g_assert_cmpuint (session_id, ==, 1);
+ g_assert_cmpuint (activation_state, ==, MBIM_ACTIVATION_STATE_ACTIVATED);
+ g_assert_cmpuint (voice_call_state, ==, MBIM_VOICE_CALL_STATE_NONE);
+ g_assert_cmpuint (ip_type, ==, MBIM_CONTEXT_IP_TYPE_IPV4);
+ g_assert_cmpuint (mbim_uuid_to_context_type (context_type), ==, MBIM_CONTEXT_TYPE_INTERNET);
+ g_assert_cmpuint (media_type, ==, MBIM_ACCESS_MEDIA_TYPE_3GPP);
+ g_assert_cmpstr (access_string, ==, "internet");
+ g_assert_cmpuint (g_list_length (unnamed_ies), ==, 3);
+
+
+ iter = unnamed_ies;
+ tlv = (MbimTlv *)(iter->data);
+ g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR);
+ tlv_str_1 = mbim_tlv_string_get (tlv, &error);
+ g_assert_no_error (error);
+ g_assert_cmpstr (tlv_str_1, ==, expected_tlv_str_1);
+
+ iter = g_list_next (iter);
+ tlv = (MbimTlv *)(iter->data);
+ g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_WCHAR_STR);
+ tlv_str_2 = mbim_tlv_string_get (tlv, &error);
+ g_assert_no_error (error);
+ g_assert_cmpstr (tlv_str_2, ==, expected_tlv_str_2);
+
+ iter = g_list_next (iter);
+ tlv = (MbimTlv *)(iter->data);
+ g_assert_cmpuint (mbim_tlv_get_tlv_type (tlv), ==, MBIM_TLV_TYPE_PCO);
+ pco_3 = mbim_tlv_get_tlv_data (tlv, &pco_3_size);
+ g_assert_cmpuint (pco_3_size, ==, sizeof (expected_pco));
+ g_assert (memcmp (pco_3, expected_pco, sizeof (expected_pco)) == 0);
+
+ g_list_free_full (unnamed_ies, (GDestroyNotify)mbim_tlv_unref);
+}
+
int main (int argc, char **argv)
{
g_test_init (&argc, &argv, NULL);
@@ -2301,6 +2612,9 @@ int main (int argc, char **argv)
g_test_add_func ("/libmbim-glib/message/parser/basic-connect-extensions/registration-parameters/0-unnamed-tlvs", test_message_parser_ms_basic_connect_extensions_registration_parameters_0_unnamed_tlvs);
g_test_add_func ("/libmbim-glib/message/parser/basic-connect-extensions/registration-parameters/1-unnamed-tlv", test_message_parser_ms_basic_connect_extensions_registration_parameters_1_unnamed_tlv);
g_test_add_func ("/libmbim-glib/message/parser/basic-connect-extensions/registration-parameters/3-unnamed-tlvs", test_message_parser_ms_basic_connect_extensions_registration_parameters_3_unnamed_tlvs);
+ g_test_add_func ("/libmbim-glib/message/parser/basic-connect-v3/connect/0-unnamed-tlvs", test_message_parser_ms_basic_connect_v3_connect_0_unnamed_tlvs);
+ g_test_add_func ("/libmbim-glib/message/parser/basic-connect-v3/connect/1-unnamed-tlv", test_message_parser_ms_basic_connect_v3_connect_1_unnamed_tlv);
+ g_test_add_func ("/libmbim-glib/message/parser/basic-connect-v3/connect/3-unnamed-tlvs", test_message_parser_ms_basic_connect_v3_connect_3_unnamed_tlvs);
return g_test_run ();
}
diff --git a/src/mbimcli/mbimcli-basic-connect.c b/src/mbimcli/mbimcli-basic-connect.c
index 0116411..11b844d 100644
--- a/src/mbimcli/mbimcli-basic-connect.c
+++ b/src/mbimcli/mbimcli-basic-connect.c
@@ -886,8 +886,8 @@ connect_ready (MbimDevice *device,
MbimActivationState activation_state;
MbimVoiceCallState voice_call_state;
MbimContextIpType ip_type;
- MbimAccessMediaType media_type;
- MbimConnectAccessString *access_string;
+ MbimAccessMediaType media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN;
+ g_autofree gchar *access_string = NULL;
const MbimUuid *context_type;
guint32 nw_error;
@@ -909,6 +909,7 @@ connect_ready (MbimDevice *device,
&nw_error,
&media_type,
&access_string,
+ NULL, /* unnamed IEs ignored */
&error)) {
g_printerr ("error: couldn't parse response message: %s\n", error->message);
shutdown (FALSE);
@@ -962,7 +963,7 @@ connect_ready (MbimDevice *device,
g_print ("\tAccess media type: '%s'\n"
"\t Access string: '%s'\n",
VALIDATE_UNKNOWN (mbim_access_media_type_get_string (media_type)),
- access_string->data);
+ access_string);
}
if (GPOINTER_TO_UINT (user_data) == CONNECT) {
@@ -2236,39 +2237,27 @@ mbimcli_basic_connect_run (MbimDevice *device,
.compression = MBIM_COMPRESSION_NONE,
.context_type = MBIM_CONTEXT_TYPE_INTERNET,
.media_type = MBIM_ACCESS_MEDIA_TYPE_UNKNOWN,
- };
- MbimConnectAccessString *access_string_v3 = NULL;
- MbimConnectUserName *username_v3 = NULL;
- MbimConnectPassword *password_v3 = NULL;
+ };
if (!set_connect_activate_parse (set_connect_activate_str, &props, device)) {
shutdown (FALSE);
return;
}
- if (mbim_device_check_ms_mbimex_version (device, 3, 0)) {
- access_string_v3 = g_new0 (MbimConnectAccessString, 1);
- username_v3 = g_new0 (MbimConnectUserName, 1);
- password_v3 = g_new0 (MbimConnectPassword, 1);
- access_string_v3->type = 10;
- username_v3->type = 10;
- password_v3->type = 10;
- access_string_v3->data = props.access_string;
- username_v3->data = props.username;
- password_v3->data = props.password;
- g_debug ("acstr %s, username %s, password %s, media %s, auth %s", access_string_v3->data, username_v3->data, password_v3->data, mbim_access_media_type_get_string(props.media_type), mbim_auth_protocol_get_string(props.auth_protocol));
- request = mbim_message_ms_basic_connect_v3_connect_set_new (props.session_id,
- MBIM_ACTIVATION_COMMAND_ACTIVATE,
- props.compression,
- props.auth_protocol,
- props.ip_type,
- mbim_uuid_from_context_type (props.context_type),
- props.media_type,
- access_string_v3,
- username_v3,
- password_v3,
- &error);
- } else {
+ if (mbim_device_check_ms_mbimex_version (device, 3, 0)) {
+ request = mbim_message_ms_basic_connect_v3_connect_set_new (props.session_id,
+ MBIM_ACTIVATION_COMMAND_ACTIVATE,
+ props.compression,
+ props.auth_protocol,
+ props.ip_type,
+ mbim_uuid_from_context_type (props.context_type),
+ props.media_type,
+ props.access_string,
+ props.username,
+ props.password,
+ NULL, /* unnamed IEs */
+ &error);
+ } else {
request = mbim_message_connect_set_new (props.session_id,
MBIM_ACTIVATION_COMMAND_ACTIVATE,
props.access_string,
@@ -2279,7 +2268,7 @@ mbimcli_basic_connect_run (MbimDevice *device,
props.ip_type,
mbim_uuid_from_context_type (props.context_type),
&error);
- }
+ }
if (!request) {
g_printerr ("error: couldn't create request: %s\n", error->message);
@@ -2331,6 +2320,7 @@ mbimcli_basic_connect_run (MbimDevice *device,
NULL,
NULL,
NULL,
+ NULL,
&error);
} else {
request = mbim_message_connect_set_new (session_id,