summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2022-05-29 00:19:54 +0200
committerAleksander Morgado <aleksander@aleksander.es>2022-06-19 15:58:49 +0200
commit0cda0bf7fc43c3e374b6a2596511c126db64324c (patch)
treeeb02e0813cf1cb931a3fab80268a2ef5a33a2413
parente45b82ad556929702fd0158041b9bf3e702dfe8e (diff)
libqmi,qmicli: support Foxconn FCC authentication v2 format
This new message reuses the same 0x5571 DMS command as the original one, but instead of one single magic number, the command expects first a magic string as TLV 0x01 and then a magic number as TLV 0x02. The prerequisite added to TLV 0x02 is so that it's ordered last (order of the TLVs matters in this operation) nothing else. Based on a MBIM traffic dump retrieved when using the lenovo-wwan-dpr tool by Thilo-Alexander Ginkel <thilo@ginkel.com>. (cherry picked from commit d63110fa1ea914c894c466bb1a3db5513255cf39)
-rw-r--r--data/qmi-service-dms.json26
-rw-r--r--docs/reference/libqmi-glib/libqmi-glib-docs.xml1
-rw-r--r--src/qmicli/qmicli-dms.c77
3 files changed, 103 insertions, 1 deletions
diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json
index 0a226b0..812bbf8 100644
--- a/data/qmi-service-dms.json
+++ b/data/qmi-service-dms.json
@@ -1439,6 +1439,30 @@
"type" : "TLV",
"since" : "1.28.6",
"format" : "guint8" } ],
- "output" : [ { "common-ref" : "Operation Result" } ] }
+ "output" : [ { "common-ref" : "Operation Result" } ] },
+ // *********************************************************************************
+ { "name" : "Foxconn Set FCC Authentication v2",
+ "type" : "Message",
+ "service" : "DMS",
+ "id" : "0x5571",
+ // this vendor id number just needs to be different to any other one
+ // defined in other messages; in this case both are foxconn messages, so
+ // we +1 the foxconn vid. A better solution would be to rename this field
+ // to something like "unique-id" and forget about defining any vendor id
+ // there.
+ "vendor" : "0x0490",
+ "since" : "1.32",
+ "input" : [ { "name" : "Magic String",
+ "id" : "0x01",
+ "type" : "TLV",
+ "since" : "1.32",
+ "format" : "string" },
+ { "name" : "Magic Number",
+ "id" : "0x02",
+ "type" : "TLV",
+ "since" : "1.32",
+ "format" : "guint8",
+ "prerequisites" : "0x01-first" } ],
+ "output" : [ { "common-ref" : "Operation Result" } ] }
]
diff --git a/docs/reference/libqmi-glib/libqmi-glib-docs.xml b/docs/reference/libqmi-glib/libqmi-glib-docs.xml
index 74a2e36..7d87d4c 100644
--- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml
+++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml
@@ -132,6 +132,7 @@
<xi:include href="xml/qmi-message-dms-set-fcc-authentication.xml"/>
<xi:include href="xml/qmi-message-dms-foxconn-change-device-mode.xml"/>
<xi:include href="xml/qmi-message-dms-foxconn-set-fcc-authentication.xml"/>
+ <xi:include href="xml/qmi-message-dms-foxconn-set-fcc-authentication-v2.xml"/>
<xi:include href="xml/qmi-message-dms-get-supported-messages.xml"/>
</section>
</chapter>
diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c
index 50b1918..1c530a0 100644
--- a/src/qmicli/qmicli-dms.c
+++ b/src/qmicli/qmicli-dms.c
@@ -106,6 +106,7 @@ static gchar *foxconn_change_device_mode_str;
static gchar *dell_get_firmware_version_str; /* deprecated */
static gchar *foxconn_get_firmware_version_str;
static gint foxconn_set_fcc_authentication_int = -1;
+static gchar *foxconn_set_fcc_authentication_v2_str;
static gchar *get_mac_address_str;
static gboolean reset_flag;
static gboolean noop_flag;
@@ -436,6 +437,12 @@ static GOptionEntry entries[] = {
"[magic]"
},
#endif
+#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2
+ { "dms-foxconn-set-fcc-authentication-v2", 0, 0, G_OPTION_ARG_STRING, &foxconn_set_fcc_authentication_v2_str,
+ "Set FCC authentication (Foxconn specific, v2)",
+ "[magic-string,magic-number]"
+ },
+#endif
#if defined HAVE_QMI_MESSAGE_DMS_GET_MAC_ADDRESS
{ "dms-get-mac-address", 0, 0, G_OPTION_ARG_STRING, &get_mac_address_str,
"Get default MAC address",
@@ -548,6 +555,7 @@ qmicli_dms_options_enabled (void)
!!dell_get_firmware_version_str +
!!foxconn_get_firmware_version_str +
(foxconn_set_fcc_authentication_int >= 0) +
+ !!foxconn_set_fcc_authentication_v2_str +
!!get_mac_address_str +
reset_flag +
noop_flag);
@@ -4318,6 +4326,35 @@ foxconn_set_fcc_authentication_ready (QmiClientDms *client,
#endif /* HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION */
+#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2
+
+static void
+foxconn_set_fcc_authentication_v2_ready (QmiClientDms *client,
+ GAsyncResult *res)
+{
+ g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationV2Output) output = NULL;
+ g_autoptr(GError) error = NULL;
+
+ output = qmi_client_dms_foxconn_set_fcc_authentication_v2_finish (client, res, &error);
+ if (!output) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ if (!qmi_message_dms_foxconn_set_fcc_authentication_v2_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't run Foxconn FCC authentication: %s\n", error->message);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ g_print ("[%s] Successfully run Foxconn FCC authentication v2\n",
+ qmi_device_get_path_display (ctx->device));
+ operation_shutdown (TRUE);
+}
+
+#endif /* HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2 */
+
#if defined HAVE_QMI_MESSAGE_DMS_GET_MAC_ADDRESS
static QmiMessageDmsGetMacAddressInput *
@@ -5335,6 +5372,46 @@ qmicli_dms_run (QmiDevice *device,
}
#endif
+#if defined HAVE_QMI_MESSAGE_DMS_FOXCONN_SET_FCC_AUTHENTICATION_V2
+ if (foxconn_set_fcc_authentication_v2_str) {
+ g_autoptr(QmiMessageDmsFoxconnSetFccAuthenticationV2Input) input = NULL;
+ g_auto(GStrv) split = NULL;
+ gulong magic_number;
+
+ split = g_strsplit (foxconn_set_fcc_authentication_v2_str, ",", -1);
+ if (g_strv_length (split) < 2) {
+ g_printerr ("error: missing fields\n");
+ operation_shutdown (FALSE);
+ return;
+ }
+ if (g_strv_length (split) > 2) {
+ g_printerr ("error: too many fields given\n");
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ magic_number = strtoul (split[1], NULL, 10);
+ if (magic_number > 0xFF) {
+ g_printerr ("error: magic number value out of [0,255] range\n");
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ g_debug ("Asynchronously running Foxconn FCC authentication v2...");
+
+ input = qmi_message_dms_foxconn_set_fcc_authentication_v2_input_new ();
+ qmi_message_dms_foxconn_set_fcc_authentication_v2_input_set_magic_string (input, split[0], NULL);
+ qmi_message_dms_foxconn_set_fcc_authentication_v2_input_set_magic_number (input, magic_number, NULL);
+ qmi_client_dms_foxconn_set_fcc_authentication_v2 (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)foxconn_set_fcc_authentication_v2_ready,
+ NULL);
+ return;
+ }
+#endif
+
#if defined HAVE_QMI_MESSAGE_DMS_GET_MAC_ADDRESS
if (get_mac_address_str) {
QmiMessageDmsGetMacAddressInput *input;