summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2022-08-23 12:50:42 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2022-09-07 20:21:42 +0000
commitd22bf20236dca5f93c21e9fc0b6d8d4b5092ac56 (patch)
tree809617665956a951776bf786196568b9541f314a
parentb2a976bd47009a3c417949b3de245aeae616e4bc (diff)
downloadlibmbim-d22bf20236dca5f93c21e9fc0b6d8d4b5092ac56.tar.gz
ms-uicc-low-level-access: add support for 'File Status' operation
$ sudo mbimcli -p -d /dev/wwan0mbim0 --ms-query-uicc-file-status="application-id=A0000000871002FF34FF0789312E30FF,file-path=7FFF6F3E" [/dev/wwan0mbim0] UICC file status retrieved: Status word 1: 144 Status word 2: 0 Accessibility: unknown Type: unknown Structure: transparent Item count: 1 Item size: 1 Access conditions: Read: pin1 Update: adm Activate: adm Deactivate: adm $ sudo mbimcli -p -d /dev/wwan0mbim0 --ms-query-uicc-file-status="application-id=A0000000871002FF34FF0789312E30FF,file-path=3F002FE2" [/dev/wwan0mbim0] UICC file status retrieved: Status word 1: 144 Status word 2: 0 Accessibility: unknown Type: unknown Structure: transparent Item count: 1 Item size: 10 Access conditions: Read: unknown Update: unknown Activate: adm Deactivate: adm
-rw-r--r--data/mbim-service-ms-uicc-low-level-access.json44
-rw-r--r--docs/reference/libmbim-glib/libmbim-glib-common.sections15
-rw-r--r--src/libmbim-glib/mbim-cid.c3
-rw-r--r--src/libmbim-glib/mbim-cid.h2
-rw-r--r--src/libmbim-glib/mbim-enums.h54
-rw-r--r--src/mbimcli/mbimcli-ms-uicc-low-level-access.c189
6 files changed, 303 insertions, 4 deletions
diff --git a/data/mbim-service-ms-uicc-low-level-access.json b/data/mbim-service-ms-uicc-low-level-access.json
index 43a5760..e249040 100644
--- a/data/mbim-service-ms-uicc-low-level-access.json
+++ b/data/mbim-service-ms-uicc-low-level-access.json
@@ -128,6 +128,48 @@
{ "name" : "Applications",
"format" : "ref-struct-array" ,
"struct-type" : "MbimUiccApplication",
- "array-size-field" : "ApplicationCount" } ] }
+ "array-size-field" : "ApplicationCount" } ] },
+ // *********************************************************************************
+
+ { "name" : "File Status",
+ "type" : "Command",
+ "since" : "1.28",
+ "query" : [ { "name" : "Version",
+ "format" : "guint32" },
+ { "name" : "ApplicationId",
+ "format" : "ref-byte-array" },
+ { "name" : "FilePath",
+ "format" : "ref-byte-array" } ],
+ "response" : [ { "name" : "Version",
+ "format" : "guint32" },
+ { "name" : "StatusWord1",
+ "format" : "guint32" },
+ { "name" : "StatusWord2",
+ "format" : "guint32" },
+ { "name" : "FileAccessibility",
+ "format" : "guint32",
+ "public-format" : "MbimUiccFileAccessibility" },
+ { "name" : "FileType",
+ "format" : "guint32",
+ "public-format" : "MbimUiccFileType" },
+ { "name" : "FileStructure",
+ "format" : "guint32",
+ "public-format" : "MbimUiccFileStructure" },
+ { "name" : "FileItemCount",
+ "format" : "guint32" },
+ { "name" : "FileItemSize",
+ "format" : "guint32" },
+ { "name" : "AccessConditionRead",
+ "format" : "guint32",
+ "public-format" : "MbimPinType" },
+ { "name" : "AccessConditionUpdate",
+ "format" : "guint32",
+ "public-format" : "MbimPinType" },
+ { "name" : "AccessConditionActivate",
+ "format" : "guint32",
+ "public-format" : "MbimPinType" },
+ { "name" : "AccessConditionDeactivate",
+ "format" : "guint32",
+ "public-format" : "MbimPinType" } ] }
]
diff --git a/docs/reference/libmbim-glib/libmbim-glib-common.sections b/docs/reference/libmbim-glib/libmbim-glib-common.sections
index 7dd5ddc..dd9c4ab 100644
--- a/docs/reference/libmbim-glib/libmbim-glib-common.sections
+++ b/docs/reference/libmbim-glib/libmbim-glib-common.sections
@@ -411,6 +411,9 @@ MbimAccessMediaType
MbimIntelServingCellInfo
MbimIntelBootMode
MbimUiccApplicationType
+MbimUiccFileAccessibility
+MbimUiccFileType
+MbimUiccFileStructure
<SUBSECTION Methods>
mbim_device_type_get_string
mbim_cellular_class_build_string_from_mask
@@ -503,6 +506,9 @@ mbim_access_media_type_get_string
mbim_intel_serving_cell_info_get_string
mbim_intel_boot_mode_get_string
mbim_uicc_application_type_get_string
+mbim_uicc_file_accessibility_get_string
+mbim_uicc_file_type_get_string
+mbim_uicc_file_structure_get_string
<SUBSECTION Private>
mbim_device_type_build_string_from_mask
mbim_cellular_class_get_string
@@ -597,6 +603,9 @@ mbim_access_media_type_build_string_from_mask
mbim_intel_serving_cell_info_build_string_from_mask
mbim_intel_boot_mode_build_string_from_mask
mbim_uicc_application_type_build_string_from_mask
+mbim_uicc_file_accessibility_build_string_from_mask
+mbim_uicc_file_type_build_string_from_mask
+mbim_uicc_file_structure_build_string_from_mask
<SUBSECTION Standard>
MBIM_TYPE_ACTIVATION_COMMAND
MBIM_TYPE_ACTIVATION_STATE
@@ -694,6 +703,9 @@ MBIM_TYPE_ACCESS_MEDIA_TYPE
MBIM_TYPE_INTEL_SERVING_CELL_INFO
MBIM_TYPE_INTEL_BOOT_MODE
MBIM_TYPE_UICC_APPLICATION_TYPE
+MBIM_TYPE_UICC_FILE_ACCESSIBILITY
+MBIM_TYPE_UICC_FILE_TYPE
+MBIM_TYPE_UICC_FILE_STRUCTURE
mbim_activation_command_get_type
mbim_activation_state_get_type
mbim_auth_protocol_get_type
@@ -790,6 +802,9 @@ mbim_access_media_type_get_type
mbim_intel_serving_cell_info_get_type
mbim_intel_boot_mode_get_type
mbim_uicc_application_type_get_type
+mbim_uicc_file_accessibility_get_type
+mbim_uicc_file_type_get_type
+mbim_uicc_file_structure_get_type
</SECTION>
<SECTION>
diff --git a/src/libmbim-glib/mbim-cid.c b/src/libmbim-glib/mbim-cid.c
index e10d0c0..ccdae25 100644
--- a/src/libmbim-glib/mbim-cid.c
+++ b/src/libmbim-glib/mbim-cid.c
@@ -179,7 +179,7 @@ static const CidConfig cid_qdu_config [MBIM_CID_QDU_LAST] = {
};
/* Note: index of the array is CID-1 */
-#define MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_LAST MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_APPLICATION_LIST
+#define MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_LAST MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_FILE_STATUS
static const CidConfig cid_ms_uicc_low_level_access_config [MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_LAST] = {
{ NO_SET, QUERY, NO_NOTIFY }, /* MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_ATR */
{ SET, NO_QUERY, NO_NOTIFY }, /* MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_OPEN_CHANNEL */
@@ -188,6 +188,7 @@ static const CidConfig cid_ms_uicc_low_level_access_config [MBIM_CID_MS_UICC_LOW
{ SET, QUERY, NO_NOTIFY }, /* MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_TERMINAL_CAPABILITY */
{ SET, QUERY, NO_NOTIFY }, /* MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_RESET */
{ NO_SET, QUERY, NO_NOTIFY }, /* MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_APPLICATION_LIST */
+ { NO_SET, QUERY, NO_NOTIFY }, /* MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_FILE_STATUS */
};
/* Note: index of the array is CID-1 */
diff --git a/src/libmbim-glib/mbim-cid.h b/src/libmbim-glib/mbim-cid.h
index 3fb8d0d..13b6cae 100644
--- a/src/libmbim-glib/mbim-cid.h
+++ b/src/libmbim-glib/mbim-cid.h
@@ -378,6 +378,7 @@ typedef enum { /*< since=1.18 >*/
* @MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_TERMINAL_CAPABILITY: Terminal capabilities.
* @MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_RESET: Reset.
* @MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_APPLICATION_LIST: Retrieve application list. Since 1.28.
+ * @MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_FILE_STATUS: Retrieve information about a specific UICC file. Since 1.28.
*
* MBIM commands in the %MBIM_SERVICE_MS_UICC_LOW_LEVEL_ACCESS service.
*
@@ -392,6 +393,7 @@ typedef enum { /*< since=1.26 >*/
MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_TERMINAL_CAPABILITY = 5,
MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_RESET = 6,
MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_APPLICATION_LIST = 7,
+ MBIM_CID_MS_UICC_LOW_LEVEL_ACCESS_FILE_STATUS = 8,
} MbimCidMsUiccLowLevelAccess;
/**
diff --git a/src/libmbim-glib/mbim-enums.h b/src/libmbim-glib/mbim-enums.h
index 2e59187..9dcdfd1 100644
--- a/src/libmbim-glib/mbim-enums.h
+++ b/src/libmbim-glib/mbim-enums.h
@@ -1953,6 +1953,60 @@ typedef enum { /*< since=1.28 >*/
MBIM_UICC_APPLICATION_TYPE_ISIM = 6,
} MbimUiccApplicationType;
+/**
+ * MbimUiccFileAccessibility:
+ * @MBIM_UICC_FILE_ACCESSIBILITY_UNKNOWN: Unknown.
+ * @MBIM_UICC_FILE_ACCESSIBILITY_NOT_SHAREABLE: Not shareable.
+ * @MBIM_UICC_FILE_ACCESSIBILITY_SHAREABLE: Shareable.
+ *
+ * The UICC file accessibility.
+ *
+ * Since: 1.28
+ */
+typedef enum { /*< since=1.28 >*/
+ MBIM_UICC_FILE_ACCESSIBILITY_UNKNOWN = 0,
+ MBIM_UICC_FILE_ACCESSIBILITY_NOT_SHAREABLE = 1,
+ MBIM_UICC_FILE_ACCESSIBILITY_SHAREABLE = 2,
+} MbimUiccFileAccessibility;
+
+/**
+ * MbimUiccFileType:
+ * @MBIM_UICC_FILE_TYPE_UNKNOWN: Unknown.
+ * @MBIM_UICC_FILE_TYPE_WORKING_EF: Working EF.
+ * @MBIM_UICC_FILE_TYPE_INTERNAL_EF: Internal EF.
+ * @MBIM_UICC_FILE_TYPE_DF_OR_ADF: Dedicated file, DF or ADF.
+ *
+ * The UICC file type.
+ *
+ * Since: 1.28
+ */
+typedef enum { /*< since=1.28 >*/
+ MBIM_UICC_FILE_TYPE_UNKNOWN = 0,
+ MBIM_UICC_FILE_TYPE_WORKING_EF = 1,
+ MBIM_UICC_FILE_TYPE_INTERNAL_EF = 2,
+ MBIM_UICC_FILE_TYPE_DF_OR_ADF = 3,
+} MbimUiccFileType;
+
+/**
+ * MbimUiccFileStructure:
+ * @MBIM_UICC_FILE_STRUCTURE_UNKNOWN: Unknown.
+ * @MBIM_UICC_FILE_STRUCTURE_TRANSPARENT: A single record of variable length.
+ * @MBIM_UICC_FILE_STRUCTURE_CYCLIC: A cyclic set of records, each of the same length.
+ * @MBIM_UICC_FILE_STRUCTURE_LINEAR: A linear set of records, each of the same length.
+ * @MBIM_UICC_FILE_STRUCTURE_BER_TLV: A set of data values accessible by tag.
+ *
+ * The UICC file structure.
+ *
+ * Since: 1.28
+ */
+typedef enum { /*< since=1.28 >*/
+ MBIM_UICC_FILE_STRUCTURE_UNKNOWN = 0,
+ MBIM_UICC_FILE_STRUCTURE_TRANSPARENT = 1,
+ MBIM_UICC_FILE_STRUCTURE_CYCLIC = 2,
+ MBIM_UICC_FILE_STRUCTURE_LINEAR = 3,
+ MBIM_UICC_FILE_STRUCTURE_BER_TLV = 4,
+} MbimUiccFileStructure;
+
G_END_DECLS
#endif /* _LIBMBIM_GLIB_MBIM_ENUMS_H_ */
diff --git a/src/mbimcli/mbimcli-ms-uicc-low-level-access.c b/src/mbimcli/mbimcli-ms-uicc-low-level-access.c
index 443bc62..707e83c 100644
--- a/src/mbimcli/mbimcli-ms-uicc-low-level-access.c
+++ b/src/mbimcli/mbimcli-ms-uicc-low-level-access.c
@@ -31,13 +31,18 @@ typedef struct {
static Context *ctx;
/* Options */
-static gboolean query_uicc_application_list_flag;
+static gboolean query_uicc_application_list_flag;
+static gchar *query_uicc_file_status_str;
static GOptionEntry entries[] = {
{ "ms-query-uicc-application-list", 0, 0, G_OPTION_ARG_NONE, &query_uicc_application_list_flag,
"Query UICC application list",
NULL
},
+ { "ms-query-uicc-file-status", 0, 0, G_OPTION_ARG_STRING, &query_uicc_file_status_str,
+ "Query UICC file status (allowed keys: application-id, file-path)",
+ "[\"key=value,...\"]"
+ },
{ NULL }
};
@@ -65,7 +70,8 @@ mbimcli_ms_uicc_low_level_access_options_enabled (void)
if (checked)
return !!n_actions;
- n_actions = query_uicc_application_list_flag;
+ n_actions = query_uicc_application_list_flag +
+ !!query_uicc_file_status_str;
if (n_actions > 1) {
g_printerr ("error: too many Microsoft UICC Low Level Access Service actions requested\n");
@@ -98,6 +104,152 @@ shutdown (gboolean operation_status)
}
static void
+file_status_query_ready (MbimDevice *device,
+ GAsyncResult *res)
+{
+ g_autoptr(MbimMessage) response = NULL;
+ g_autoptr(GError) error = NULL;
+ guint32 status_word_1;
+ guint32 status_word_2;
+ MbimUiccFileAccessibility file_accessibility;
+ MbimUiccFileType file_type;
+ MbimUiccFileStructure file_structure;
+ guint32 file_item_count;
+ guint32 file_item_size;
+ MbimPinType access_condition_read;
+ MbimPinType access_condition_update;
+ MbimPinType access_condition_activate;
+ MbimPinType access_condition_deactivate;
+
+ response = mbim_device_command_finish (device, res, &error);
+ if (!response || !mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error)) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ shutdown (FALSE);
+ return;
+ }
+
+ if (!mbim_message_ms_uicc_low_level_access_file_status_response_parse (
+ response,
+ NULL, /* version */
+ &status_word_1,
+ &status_word_2,
+ &file_accessibility,
+ &file_type,
+ &file_structure,
+ &file_item_count,
+ &file_item_size,
+ &access_condition_read,
+ &access_condition_update,
+ &access_condition_activate,
+ &access_condition_deactivate,
+ &error)) {
+ g_printerr ("error: couldn't parse response message: %s\n", error->message);
+ shutdown (FALSE);
+ return;
+ }
+
+ g_print ("[%s] UICC file status retrieved:\n"
+ "\t Status word 1: %u\n"
+ "\t Status word 2: %u\n"
+ "\t Accessibility: %s\n"
+ "\t Type: %s\n"
+ "\t Structure: %s\n"
+ "\t Item count: %u\n"
+ "\t Item size: %u\n"
+ "\tAccess conditions:\n"
+ "\t Read: %s\n"
+ "\t Update: %s\n"
+ "\t Activate: %s\n"
+ "\t Deactivate: %s\n",
+ mbim_device_get_path_display (device),
+ status_word_1,
+ status_word_2,
+ mbim_uicc_file_accessibility_get_string (file_accessibility),
+ mbim_uicc_file_type_get_string (file_type),
+ mbim_uicc_file_structure_get_string (file_structure),
+ file_item_count,
+ file_item_size,
+ mbim_pin_type_get_string (access_condition_read),
+ mbim_pin_type_get_string (access_condition_update),
+ mbim_pin_type_get_string (access_condition_activate),
+ mbim_pin_type_get_string (access_condition_deactivate));
+
+ shutdown (TRUE);
+}
+
+typedef struct {
+ gsize application_id_size;
+ guint8 *application_id;
+ gsize file_path_size;
+ guint8 *file_path;
+} FileStatusQueryProperties;
+
+static void
+file_status_query_properties_clear (FileStatusQueryProperties *props)
+{
+ g_clear_pointer (&props->application_id, g_free);
+ g_clear_pointer (&props->file_path, g_free);
+}
+
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(FileStatusQueryProperties, file_status_query_properties_clear);
+
+static gboolean
+file_status_query_properties_handle (const gchar *key,
+ const gchar *value,
+ GError **error,
+ gpointer user_data)
+{
+ FileStatusQueryProperties *props = user_data;
+
+ if (g_ascii_strcasecmp (key, "application-id") == 0) {
+ g_clear_pointer (&props->application_id, g_free);
+ props->application_id_size = 0;
+ props->application_id = mbimcli_read_buffer_from_string (value, -1, &props->application_id_size, error);
+ if (!props->application_id)
+ return FALSE;
+ } else if (g_ascii_strcasecmp (key, "file-path") == 0) {
+ g_clear_pointer (&props->file_path, g_free);
+ props->file_path_size = 0;
+ props->file_path = mbimcli_read_buffer_from_string (value, -1, &props->file_path_size, error);
+ if (!props->file_path)
+ return FALSE;
+ } else {
+ g_set_error (error, MBIM_CORE_ERROR, MBIM_CORE_ERROR_FAILED,
+ "unrecognized option '%s'", key);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+file_status_query_input_parse (const gchar *str,
+ FileStatusQueryProperties *props,
+ GError **error)
+{
+
+ if (!mbimcli_parse_key_value_string (str,
+ error,
+ file_status_query_properties_handle,
+ props))
+ return FALSE;
+
+ if (!props->application_id_size || !props->application_id) {
+ g_set_error (error, MBIM_CORE_ERROR, MBIM_CORE_ERROR_FAILED,
+ "Option 'application-id' is missing");
+ return FALSE;
+ }
+
+ if (!props->file_path_size || !props->file_path) {
+ g_set_error (error, MBIM_CORE_ERROR, MBIM_CORE_ERROR_FAILED,
+ "Option 'file-path' is missing");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
application_list_query_ready (MbimDevice *device,
GAsyncResult *res)
{
@@ -155,6 +307,7 @@ mbimcli_ms_uicc_low_level_access_run (MbimDevice *device,
GCancellable *cancellable)
{
g_autoptr(MbimMessage) request = NULL;
+ g_autoptr(GError) error = NULL;
/* Initialize context */
ctx = g_slice_new (Context);
@@ -174,5 +327,37 @@ mbimcli_ms_uicc_low_level_access_run (MbimDevice *device,
return;
}
+ /* Request to query UICC file status? */
+ if (query_uicc_file_status_str) {
+ g_auto(FileStatusQueryProperties) props = {
+ .application_id_size = 0,
+ .application_id = NULL,
+ .file_path_size = 0,
+ .file_path = NULL,
+ };
+
+ g_debug ("Asynchronously querying UICC file status...");
+
+ if (!file_status_query_input_parse (query_uicc_file_status_str, &props, &error)) {
+ g_printerr ("error: couldn't parse input arguments: %s\n", error->message);
+ shutdown (FALSE);
+ return;
+ }
+
+ request = mbim_message_ms_uicc_low_level_access_file_status_query_new (1, /* version fixed */
+ props.application_id_size,
+ props.application_id,
+ props.file_path_size,
+ props.file_path,
+ NULL);
+ mbim_device_command (ctx->device,
+ request,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)file_status_query_ready,
+ NULL);
+ return;
+ }
+
g_warn_if_reached ();
}