diff options
-rw-r--r-- | build-aux/qmi-codegen/Field.py | 8 | ||||
-rw-r--r-- | build-aux/qmi-codegen/Message.py | 7 | ||||
-rw-r--r-- | build-aux/qmi-codegen/Variable.py | 11 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableArray.py | 5 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableInteger.py | 32 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableSequence.py | 5 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableString.py | 29 | ||||
-rw-r--r-- | build-aux/qmi-codegen/VariableStruct.py | 5 | ||||
-rw-r--r-- | data/qmi-service-dms.json | 142 | ||||
-rw-r--r-- | data/qmi-service-uim.json | 13 | ||||
-rw-r--r-- | data/qmi-service-voice.json | 98 | ||||
-rw-r--r-- | data/qmi-service-wds.json | 12 | ||||
-rw-r--r-- | data/qmi-service-wms.json | 15 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/libqmi-glib-common.sections | 2 | ||||
-rw-r--r-- | src/libqmi-glib/qmi-device.c | 19 | ||||
-rw-r--r-- | src/libqmi-glib/qmi-message.c | 7 | ||||
-rw-r--r-- | src/libqmi-glib/qmi-utils.c | 14 | ||||
-rw-r--r-- | src/libqmi-glib/qmi-utils.h | 23 | ||||
-rw-r--r-- | src/qmicli/qmicli.c | 26 |
19 files changed, 325 insertions, 148 deletions
diff --git a/build-aux/qmi-codegen/Field.py b/build-aux/qmi-codegen/Field.py index 446c13ae..b1e455b7 100644 --- a/build-aux/qmi-codegen/Field.py +++ b/build-aux/qmi-codegen/Field.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -91,6 +92,11 @@ class Field: else: raise RuntimeError('Common type \'%s\' not found' % prerequisite_dictionary['name']) + if 'personal-info' in dictionary: + self.personal_info = True; + else: + self.personal_info = False; + @property def mandatory(self): @@ -473,7 +479,7 @@ class Field: f.write(string.Template(template).substitute(translations)) # Now, read the contents of the buffer into the printable representation - self.variable.emit_get_printable(f, ' ') + self.variable.emit_get_printable(f, ' ', self.personal_info) template = ( '\n' diff --git a/build-aux/qmi-codegen/Message.py b/build-aux/qmi-codegen/Message.py index f0fdcd45..c60e4593 100644 --- a/build-aux/qmi-codegen/Message.py +++ b/build-aux/qmi-codegen/Message.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -347,7 +348,11 @@ class Message: ' } else {\n' ' g_autofree gchar *value_hex = NULL;\n' '\n' - ' value_hex = qmi_helpers_str_hex (value, length, \':\');\n' + ' if (qmi_utils_get_show_personal_info ())\n' + ' value_hex = qmi_helpers_str_hex (value, length, \':\');\n' + ' else\n' + ' value_hex = g_strdup ("###...");\n' + '\n' ' g_string_append_printf (ctx->printable,\n' ' "%sTLV:\\n"\n' ' "%s type = \\"%s\\" (0x%02x)\\n"\n' diff --git a/build-aux/qmi-codegen/Variable.py b/build-aux/qmi-codegen/Variable.py index bb4fb026..65bca8d3 100644 --- a/build-aux/qmi-codegen/Variable.py +++ b/build-aux/qmi-codegen/Variable.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -108,6 +109,14 @@ class Variable: self.new_method_gir = '' self.free_method_gir = '' + """ + Whether the variable is personal info or not + """ + if 'personal-info' in dictionary: + self.personal_info = True; + else: + self.personal_info = False; + """ Emits the code to declare specific new types required by the variable. """ @@ -131,7 +140,7 @@ class Variable: """ Emits the code to get the contents of the given variable as a printable string. """ - def emit_get_printable(self, f, line_prefix): + def emit_get_printable(self, f, line_prefix, is_personal): pass """ diff --git a/build-aux/qmi-codegen/VariableArray.py b/build-aux/qmi-codegen/VariableArray.py index 607865f4..074f4710 100644 --- a/build-aux/qmi-codegen/VariableArray.py +++ b/build-aux/qmi-codegen/VariableArray.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -220,7 +221,7 @@ class VariableArray(Variable): f.write(string.Template(template).substitute(translations)) - def emit_get_printable(self, f, line_prefix): + def emit_get_printable(self, f, line_prefix, is_personal): common_var_prefix = utils.build_underscore_name(self.name) translations = { 'lp' : line_prefix, 'common_var_prefix' : common_var_prefix } @@ -272,7 +273,7 @@ class VariableArray(Variable): '${lp} g_string_append_printf (printable, " [%u] = \'", ${common_var_prefix}_i);\n') f.write(string.Template(template).substitute(translations)) - self.array_element.emit_get_printable(f, line_prefix + ' '); + self.array_element.emit_get_printable(f, line_prefix + ' ', self.personal_info or is_personal); template = ( '${lp} g_string_append (printable, " \'");\n' diff --git a/build-aux/qmi-codegen/VariableInteger.py b/build-aux/qmi-codegen/VariableInteger.py index 3076d1c2..11c51a21 100644 --- a/build-aux/qmi-codegen/VariableInteger.py +++ b/build-aux/qmi-codegen/VariableInteger.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -157,7 +158,7 @@ class VariableInteger(Variable): f.write(string.Template(template).substitute(translations)) - def emit_get_printable(self, f, line_prefix): + def emit_get_printable(self, f, line_prefix, is_personal): common_format = '' common_cast = '' @@ -214,30 +215,43 @@ class VariableInteger(Variable): '${lp} if (!qmi_message_tlv_read_${private_format} (message, init_offset, &offset,${endian} &tmp, &error))\n' '${lp} goto out;\n') + if self.personal_info or is_personal: + translations['if_show_field'] = 'if (qmi_utils_get_show_personal_info ()) ' + else: + translations['if_show_field'] = '' + + template += ( + '${lp} ${if_show_field}{\n') if self.public_format == 'gboolean': template += ( - '${lp} g_string_append_printf (printable, "%s", tmp ? "yes" : "no");\n') + '${lp} g_string_append_printf (printable, "%s", tmp ? "yes" : "no");\n') elif self.public_format != self.private_format: translations['public_type_underscore'] = utils.build_underscore_name_from_camelcase(self.public_format) translations['public_type_underscore_upper'] = utils.build_underscore_name_from_camelcase(self.public_format).upper() template += ( '#if defined __${public_type_underscore_upper}_IS_ENUM__\n' - '${lp} g_string_append_printf (printable, "%s", ${public_type_underscore}_get_string ((${public_format})tmp));\n' + '${lp} g_string_append_printf (printable, "%s", ${public_type_underscore}_get_string ((${public_format})tmp));\n' '#elif defined __${public_type_underscore_upper}_IS_FLAGS__\n' - '${lp} {\n' - '${lp} g_autofree gchar *flags_str = NULL;\n' + '${lp} {\n' + '${lp} g_autofree gchar *flags_str = NULL;\n' '\n' - '${lp} flags_str = ${public_type_underscore}_build_string_from_mask ((${public_format})tmp);\n' - '${lp} g_string_append_printf (printable, "%s", flags_str);\n' - '${lp} }\n' + '${lp} flags_str = ${public_type_underscore}_build_string_from_mask ((${public_format})tmp);\n' + '${lp} g_string_append_printf (printable, "%s", flags_str);\n' + '${lp} }\n' '#else\n' '# error unexpected public format: ${public_format}\n' '#endif\n') else: template += ( - '${lp} g_string_append_printf (printable, "${common_format}", ${common_cast}tmp);\n') + '${lp} g_string_append_printf (printable, "${common_format}", ${common_cast}tmp);\n') + + if self.personal_info or is_personal: + template += ( + '${lp} } else {\n' + '${lp} g_string_append_printf (printable, "\'###\'");\n') template += ( + '${lp} }\n' '${lp}}\n') f.write(string.Template(template).substitute(translations)) diff --git a/build-aux/qmi-codegen/VariableSequence.py b/build-aux/qmi-codegen/VariableSequence.py index bee40df2..4343d67c 100644 --- a/build-aux/qmi-codegen/VariableSequence.py +++ b/build-aux/qmi-codegen/VariableSequence.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -77,7 +78,7 @@ class VariableSequence(Variable): member['object'].emit_buffer_write(f, line_prefix, tlv_name, variable_name + '_' + member['name']) - def emit_get_printable(self, f, line_prefix): + def emit_get_printable(self, f, line_prefix, is_personal): translations = { 'lp' : line_prefix } template = ( @@ -90,7 +91,7 @@ class VariableSequence(Variable): '${lp}g_string_append (printable, " ${variable_name} = \'");\n') f.write(string.Template(template).substitute(translations)) - member['object'].emit_get_printable(f, line_prefix) + member['object'].emit_get_printable(f, line_prefix, self.personal_info or is_personal) template = ( '${lp}g_string_append (printable, "\'");\n') diff --git a/build-aux/qmi-codegen/VariableString.py b/build-aux/qmi-codegen/VariableString.py index eb47a635..b0526ab4 100644 --- a/build-aux/qmi-codegen/VariableString.py +++ b/build-aux/qmi-codegen/VariableString.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -128,7 +129,7 @@ class VariableString(Variable): f.write(string.Template(template).substitute(translations)) - def emit_get_printable(self, f, line_prefix): + def emit_get_printable(self, f, line_prefix, is_personal): translations = { 'lp' : line_prefix } if self.is_fixed_size: @@ -141,9 +142,7 @@ class VariableString(Variable): '\n' '${lp} if (!qmi_message_tlv_read_fixed_size_string (message, init_offset, &offset, ${fixed_size}, &tmp[0], &error))\n' '${lp} goto out;\n' - '${lp} tmp[${fixed_size}] = \'\\0\';\n' - '${lp} g_string_append (printable, tmp);\n' - '${lp}}\n') + '${lp} tmp[${fixed_size}] = \'\\0\';\n') else: translations['n_size_prefix_bytes'] = self.n_size_prefix_bytes translations['max_size'] = self.max_size if self.max_size != '' else '0' @@ -153,9 +152,25 @@ class VariableString(Variable): '${lp} g_autofree gchar *tmp = NULL;\n' '\n' '${lp} if (!qmi_message_tlv_read_string (message, init_offset, &offset, ${n_size_prefix_bytes}, ${max_size}, &tmp, &error))\n' - '${lp} goto out;\n' - '${lp} g_string_append (printable, tmp);\n' - '${lp}}\n') + '${lp} goto out;\n') + + if self.personal_info or is_personal: + translations['if_show_field'] = 'if (qmi_utils_get_show_personal_info ()) ' + else: + translations['if_show_field'] = '' + + template += ( + '${lp} ${if_show_field}{\n' + '${lp} g_string_append (printable, tmp);\n') + + if self.personal_info or is_personal: + template += ( + '${lp} } else {\n' + '${lp} g_string_append_printf (printable, "\'###\'");\n') + + template += ( + '${lp} }\n' + '${lp}}\n') f.write(string.Template(template).substitute(translations)) diff --git a/build-aux/qmi-codegen/VariableStruct.py b/build-aux/qmi-codegen/VariableStruct.py index 5148804e..0d084809 100644 --- a/build-aux/qmi-codegen/VariableStruct.py +++ b/build-aux/qmi-codegen/VariableStruct.py @@ -16,6 +16,7 @@ # # Copyright (C) 2012 Lanedo GmbH # Copyright (C) 2012-2022 Aleksander Morgado <aleksander@aleksander.es> +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. # import string @@ -247,7 +248,7 @@ class VariableStruct(Variable): member['object'].emit_buffer_write(f, line_prefix, tlv_name, variable_name + '.' + member['name']) - def emit_get_printable(self, f, line_prefix): + def emit_get_printable(self, f, line_prefix, is_personal): translations = { 'lp' : line_prefix } template = ( @@ -260,7 +261,7 @@ class VariableStruct(Variable): '${lp}g_string_append (printable, " ${variable_name} = \'");\n') f.write(string.Template(template).substitute(translations)) - member['object'].emit_get_printable(f, line_prefix) + member['object'].emit_get_printable(f, line_prefix, self.personal_info or is_personal) template = ( '${lp}g_string_append (printable, "\'");\n') diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json index bd28caef..a45a7b5b 100644 --- a/data/qmi-service-dms.json +++ b/data/qmi-service-dms.json @@ -245,25 +245,27 @@ "id" : "0x0025", "since" : "1.0", "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "Esn", - "id" : "0x10", - "type" : "TLV", - "since" : "1.0", - "format" : "string", - "prerequisites": [ { "common-ref" : "Success" } ] }, - { "name" : "Imei", - "id" : "0x11", - "type" : "TLV", - "since" : "1.0", - "format" : "string", - "max-size" : "15", - "prerequisites": [ { "common-ref" : "Success" } ] }, - { "name" : "Meid", - "id" : "0x12", - "type" : "TLV", - "since" : "1.0", - "format" : "string", - "prerequisites": [ { "common-ref" : "Success" } ] }, + { "name" : "Esn", + "id" : "0x10", + "type" : "TLV", + "since" : "1.0", + "format" : "string", + "prerequisites" : [ { "common-ref" : "Success" } ] }, + { "name" : "Imei", + "id" : "0x11", + "type" : "TLV", + "since" : "1.0", + "format" : "string", + "max-size" : "15", + "personal-info" : "true", + "prerequisites" : [ { "common-ref" : "Success" } ] }, + { "name" : "Meid", + "id" : "0x12", + "type" : "TLV", + "since" : "1.0", + "format" : "string", + "personal-info" : "true", + "prerequisites" : [ { "common-ref" : "Success" } ] }, { "name" : "Imei Software Version", "id" : "0x13", "type" : "TLV", @@ -306,8 +308,9 @@ { "name" : "Protection Enabled", "format" : "guint8", "public-format" : "gboolean" }, - { "name" : "PIN", - "format" : "string" } ] } ], + { "name" : "PIN", + "format" : "string", + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Pin Retries Status", "id" : "0x10", @@ -334,8 +337,9 @@ "contents" : [ { "name" : "Pin ID", "format" : "guint8", "public-format" : "QmiDmsUimPinId" }, - { "name" : "PIN", - "format" : "string" } ] } ], + { "name" : "PIN", + "format" : "string", + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Pin Retries Status", "id" : "0x10", @@ -362,10 +366,12 @@ "contents" : [ { "name" : "Pin ID", "format" : "guint8", "public-format" : "QmiDmsUimPinId" }, - { "name" : "PUK", - "format" : "string" }, - { "name" : "New PIN", - "format" : "string" } ] } ], + { "name" : "PUK", + "format" : "string", + "personal-info" : "true" }, + { "name" : "New PIN", + "format" : "string", + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Pin Retries Status", "id" : "0x10", @@ -392,10 +398,12 @@ "contents" : [ { "name" : "Pin ID", "format" : "guint8", "public-format" : "QmiDmsUimPinId" }, - { "name" : "Old PIN", - "format" : "string" }, - { "name" : "New PIN", - "format" : "string" } ] } ], + { "name" : "Old PIN", + "format" : "string", + "personal-info" : "true" }, + { "name" : "New PIN", + "format" : "string", + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Pin Retries Status", "id" : "0x10", @@ -587,37 +595,40 @@ "service" : "DMS", "id" : "0x0033", "since" : "1.0", - "input" : [ { "name" : "Info", - "id" : "0x01", - "type" : "TLV", + "input" : [ { "name" : "Info", + "id" : "0x01", + "type" : "TLV", // API updated in 1.6 - "since" : "1.6", - "format" : "sequence", - "contents" : [ { "name" : "Service Programming Code", - "format" : "string", - "fixed-size" : "6" }, - { "name" : "System Identification Number", - "format" : "guint16" }, - { "name" : "Mobile Directory Number", - "format" : "string", - "max-size" : "15" }, - { "name" : "Mobile Identification Number", - "format" : "string", - "max-size" : "15" } ] }, + "since" : "1.6", + "format" : "sequence", + "contents" : [ { "name" : "Service Programming Code", + "format" : "string", + "fixed-size" : "6" }, + { "name" : "System Identification Number", + "format" : "guint16" }, + { "name" : "Mobile Directory Number", + "format" : "string", + "max-size" : "15" }, + { "name" : "Mobile Identification Number", + "format" : "string", + "max-size" : "15" } ], + "personal-info" : "true" }, { "name" : "MN HA key", "id" : "0x11", "type" : "TLV", "since" : "1.0", "format" : "string", "max-size" : "16", - "size-prefix-format" : "guint8" }, + "size-prefix-format" : "guint8", + "personal-info" : "true" }, { "name" : "MN AAA key", "id" : "0x12", "type" : "TLV", "since" : "1.0", "format" : "string", "max-size" : "16", - "size-prefix-format" : "guint8" }, + "size-prefix-format" : "guint8", + "personal-info" : "true" }, { "name" : "PRL", "id" : "0x13", "type" : "TLV", @@ -661,9 +672,10 @@ "contents" : [ { "name" : "Enabled", "format" : "guint8", "public-format" : "gboolean" }, - { "name" : "Lock Code", - "format" : "string", - "fixed-size" : "4" } ] } ], + { "name" : "Lock Code", + "format" : "string", + "fixed-size" : "4", + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" } ] }, // ********************************************************************************* @@ -767,12 +779,13 @@ "id" : "0x003C", "since" : "1.0", "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "ICCID", - "id" : "0x01", - "type" : "TLV", - "since" : "1.0", - "format" : "string", - "prerequisites": [ { "common-ref" : "Success" } ] } ] }, + { "name" : "ICCID", + "id" : "0x01", + "type" : "TLV", + "since" : "1.0", + "format" : "string", + "personal-info" : "true", + "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* { "name" : "Set Firmware ID", @@ -872,12 +885,13 @@ "id" : "0x0043", "since" : "1.0", "output" : [ { "common-ref" : "Operation Result" }, - { "name" : "IMSI", - "id" : "0x01", - "type" : "TLV", - "since" : "1.0", - "format" : "string", - "prerequisites": [ { "common-ref" : "Success" } ] } ] }, + { "name" : "IMSI", + "id" : "0x01", + "type" : "TLV", + "since" : "1.0", + "format" : "string", + "personal-info" : "true", + "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* { "name" : "UIM Get State", diff --git a/data/qmi-service-uim.json b/data/qmi-service-uim.json index 1b6d2a4d..02f376d9 100644 --- a/data/qmi-service-uim.json +++ b/data/qmi-service-uim.json @@ -127,7 +127,8 @@ { "name" : "ICCID", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] } }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] } }, // ********************************************************************************* { "common-ref" : "Physical Slot Information", @@ -165,7 +166,9 @@ "contents" : [ { "name" : "EID", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] } }, + "array-element" : { "format" : "guint8" }, + + "personal-info" : "true" } ] } }, // ********************************************************************************* { "name" : "Reset", @@ -247,6 +250,7 @@ "format" : "array", "size-prefix-format" : "guint16", "array-element" : { "format" : "guint8" }, + "personal-info" : "true", "prerequisites" : [ { "common-ref" : "Success" } ] }, { "name" : "Response In Indication Token", "id" : "0x12", @@ -317,6 +321,7 @@ "format" : "array", "size-prefix-format" : "guint16", "array-element" : { "format" : "guint8" }, + "personal-info" : "true", "prerequisites" : [ { "common-ref" : "Success" } ] }, { "name" : "Additional Read Result", "id" : "0x12", @@ -325,6 +330,7 @@ "format" : "array", "size-prefix-format" : "guint16", "array-element" : { "format" : "guint8" }, + "personal-info" : "true", "prerequisites" : [ { "common-ref" : "Success" } ] }, { "name" : "Response In Indication Token", "id" : "0x13", @@ -823,7 +829,8 @@ "format" : "guint8", "public-format" : "QmiUimDepersonalizationOperation" }, { "name" : "Control Key", - "format" : "string" } ] }, + "format" : "string", + "personal-info" : "true" } ] }, { "name" : "Slot", "id" : "0x10", "type" : "TLV", diff --git a/data/qmi-service-voice.json b/data/qmi-service-voice.json index f975a689..db17cc32 100644 --- a/data/qmi-service-voice.json +++ b/data/qmi-service-voice.json @@ -130,7 +130,8 @@ "id" : "0x01", "type" : "TLV", "since" : "1.14", - "format" : "string" } ], + "format" : "string", + "personal-info" : "true" } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Call ID", "id" : "0x10", @@ -222,7 +223,8 @@ "format" : "guint8", "public-format" : "QmiVoicePresentation" }, { "name" : "Type", - "format" : "string" } ] } } ] }, + "format" : "string" } ] }, + "personal-info" : "true" } ] }, // ********************************************************************************* { "name" : "Get All Call Info", "type" : "Message", @@ -275,6 +277,7 @@ "public-format" : "QmiVoicePresentation" }, { "name" : "Type", "format" : "string" } ] }, + "personal-info" : "true", "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* @@ -380,7 +383,8 @@ { "name" : "Data", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] } ], + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Failure Cause", "id" : "0x10", @@ -399,7 +403,8 @@ { "name" : "Alpha", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "USS Data", "id" : "0x12", "type" : "TLV", @@ -411,7 +416,8 @@ { "name" : "Data", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "Call Control Result Type", "id" : "0x13", "type" : "TLV", @@ -435,7 +441,8 @@ "since" : "1.26", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint16" } } ] }, + "array-element" : { "format" : "guint16" }, + "personal-info" : "true" } ] }, // ********************************************************************************* { "name" : "Answer USSD", @@ -454,7 +461,8 @@ { "name" : "Data", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] } ], + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" } ] }, // ********************************************************************************* @@ -495,14 +503,16 @@ { "name" : "Data", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "USS Data UTF16", "id" : "0x11", "type" : "TLV", "since" : "1.26", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint16" } } ] }, + "array-element" : { "format" : "guint16" }, + "personal-info" : "true" } ] }, // ********************************************************************************* { "name" : "Get Config", @@ -655,7 +665,8 @@ { "name" : "Data", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] } ], + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" } ] }, { "name" : "Originate USSD No Wait", @@ -685,7 +696,8 @@ { "name" : "Data", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "Alpha Identifier", "id" : "0x13", "type" : "TLV", @@ -697,14 +709,16 @@ { "name" : "Alpha", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "USS Data UTF16", "id" : "0x14", "type" : "TLV", "since" : "1.26", "format" : "array", "size-prefix-format" : "guint8", - "array-element" : { "format" : "guint16" } } ] }, + "array-element" : { "format" : "guint16" }, + "personal-info" : "true" } ] }, // ********************************************************************************* { "name" : "Burst DTMF", @@ -712,61 +726,67 @@ "service" : "VOICE", "id" : "0x0028", "since" : "1.32", - "input" : [ { "name" : "Data", - "id" : "0x01", - "type" : "TLV", - "since" : "1.32", - "format" : "sequence", - "contents" : [ { "name" : "Call ID", - "format" : "guint8" }, - { "name" : "Digit Buffer", - "format" : "string", - "size-prefix-format" : "guint8" } ] } ], + "input" : [ { "name" : "Data", + "id" : "0x01", + "type" : "TLV", + "since" : "1.32", + "format" : "sequence", + "contents" : [ { "name" : "Call ID", + "format" : "guint8" }, + { "name" : "Digit Buffer", + "format" : "string", + "size-prefix-format" : "guint8" } ], + "personal-info" : "true" } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Call ID", "id" : "0x10", "type" : "TLV", "since" : "1.32", "format" : "guint8", + "personal-info" : "true", "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, { "name" : "Start Continuous DTMF", "type" : "Message", "service" : "VOICE", "id" : "0x0029", "since" : "1.32", - "input" : [ { "name" : "Data", - "id" : "0x01", - "type" : "TLV", - "since" : "1.32", - "format" : "sequence", - "contents" : [ { "name" : "Call ID", - "format" : "guint8" }, - { "name" : "Digit", - "format" : "guint8" } ] } ], + "input" : [ { "name" : "Data", + "id" : "0x01", + "type" : "TLV", + "since" : "1.32", + "format" : "sequence", + "contents" : [ { "name" : "Call ID", + "format" : "guint8" }, + { "name" : "Digit", + "format" : "guint8" } ], + "personal-info" : "true" } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Call ID", "id" : "0x10", "type" : "TLV", "since" : "1.32", "format" : "guint8", + "personal-info" : "true", "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, { "name" : "Stop Continuous DTMF", "type" : "Message", "service" : "VOICE", "id" : "0x002A", "since" : "1.32", - "input" : [ { "name" : "Data", - "id" : "0x01", - "type" : "TLV", - "since" : "1.32", - "format" : "sequence", - "contents" : [ { "name" : "Call ID", - "format" : "guint8" } ] } ], + "input" : [ { "name" : "Data", + "id" : "0x01", + "type" : "TLV", + "since" : "1.32", + "format" : "sequence", + "contents" : [ { "name" : "Call ID", + "format" : "guint8" } ], + "personal-info" : "true" } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Call ID", "id" : "0x10", "type" : "TLV", "since" : "1.32", "format" : "guint8", + "personal-info" : "true", "prerequisites" : [ { "common-ref" : "Success" } ] } ] } ] diff --git a/data/qmi-service-wds.json b/data/qmi-service-wds.json index 15e67577..39368477 100644 --- a/data/qmi-service-wds.json +++ b/data/qmi-service-wds.json @@ -195,13 +195,15 @@ "name" : "Username", "id" : "0x1B", "type" : "TLV", - "format" : "string" }, + "format" : "string", + "personal-info" : "true" }, { "common-ref" : "WDS Password", "name" : "Password", "id" : "0x1C", "type" : "TLV", - "format" : "string" }, + "format" : "string", + "personal-info" : "true" }, { "common-ref" : "WDS Authentication", "name" : "Authentication", @@ -793,12 +795,14 @@ "id" : "0x17", "type" : "TLV", "since" : "1.0", - "format" : "string" }, + "format" : "string", + "personal-info" : "true" }, { "name" : "Password", "id" : "0x18", "type" : "TLV", "since" : "1.0", - "format" : "string" }, + "format" : "string", + "personal-info" : "true" }, { "name" : "IP Family Preference", "id" : "0x19", "type" : "TLV", diff --git a/data/qmi-service-wms.json b/data/qmi-service-wms.json index 766dd047..3af6d0da 100644 --- a/data/qmi-service-wms.json +++ b/data/qmi-service-wms.json @@ -72,7 +72,8 @@ { "name" : "Raw Data", "format" : "array", "size-prefix-format" : "guint16", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "Message Mode", "id" : "0x12", "type" : "TLV", @@ -90,7 +91,8 @@ { "name" : "Raw Data", "format" : "array", "size-prefix-format" : "guint16", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "ETWS PLMN Information", "id" : "0x14", "type" : "TLV", @@ -145,7 +147,8 @@ { "name" : "Raw Data", "format" : "array", "size-prefix-format" : "guint16", - "array-element" : { "format" : "guint8" } } ] }, + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] }, { "name" : "CDMA Force On DC", "id" : "0x10", "type" : "TLV", @@ -258,7 +261,8 @@ { "name" : "Raw Data", "format" : "array", "size-prefix-format" : "guint16", - "array-element" : { "format" : "guint8" } } ] } ], + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ] } ], "output" : [ { "common-ref" : "Operation Result" }, { "name" : "Memory Index", "id" : "0x01", @@ -310,7 +314,8 @@ { "name" : "Raw Data", "format" : "array", "size-prefix-format" : "guint16", - "array-element" : { "format" : "guint8" } } ], + "array-element" : { "format" : "guint8" }, + "personal-info" : "true" } ], "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* diff --git a/docs/reference/libqmi-glib/libqmi-glib-common.sections b/docs/reference/libqmi-glib/libqmi-glib-common.sections index a1bb41ca..8d31ddeb 100644 --- a/docs/reference/libqmi-glib/libqmi-glib-common.sections +++ b/docs/reference/libqmi-glib/libqmi-glib-common.sections @@ -1705,6 +1705,8 @@ qmi_message_context_get_type <TITLE>Common utilities</TITLE> qmi_utils_get_traces_enabled qmi_utils_set_traces_enabled +qmi_utils_set_show_personal_info +qmi_utils_get_show_personal_info </SECTION> <SECTION> diff --git a/src/libqmi-glib/qmi-device.c b/src/libqmi-glib/qmi-device.c index 9689f103..69a9b448 100644 --- a/src/libqmi-glib/qmi-device.c +++ b/src/libqmi-glib/qmi-device.c @@ -19,6 +19,7 @@ * * Copyright (C) 2012 Lanedo GmbH * Copyright (C) 2012-2021 Aleksander Morgado <aleksander@aleksander.es> + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. */ #include <config.h> @@ -73,6 +74,10 @@ # include "qmi-net-port-manager-rmnet.h" #endif +/* maximum number of printed data bytes when personal info + * should be hidden */ +#define MAX_PRINTED_BYTES 12 + static void async_initable_iface_init (GAsyncInitableIface *iface); G_DEFINE_TYPE_EXTENDED (QmiDevice, qmi_device, G_TYPE_OBJECT, 0, @@ -1682,9 +1687,17 @@ trace_message (QmiDevice *self, action_str = "received"; } - printable = qmi_helpers_str_hex (((GByteArray *)message)->data, - ((GByteArray *)message)->len, - ':'); + if (qmi_utils_get_show_personal_info () || (((GByteArray *)message)->len < MAX_PRINTED_BYTES)) { + printable = qmi_helpers_str_hex (((GByteArray *)message)->data, + ((GByteArray *)message)->len, + ':'); + } else { + g_autofree gchar *tmp = NULL; + + tmp = qmi_helpers_str_hex (((GByteArray *)message)->data, MAX_PRINTED_BYTES, ':'); + printable = g_strdup_printf ("%s...", tmp); + } + g_debug ("[%s] %s message...\n" "%sRAW:\n" "%s length = %u\n" diff --git a/src/libqmi-glib/qmi-message.c b/src/libqmi-glib/qmi-message.c index d92a14bc..d2df0876 100644 --- a/src/libqmi-glib/qmi-message.c +++ b/src/libqmi-glib/qmi-message.c @@ -25,6 +25,7 @@ * Boston, MA 02110-1301 USA. * * Copyright (C) 2012-2019 Aleksander Morgado <aleksander@aleksander.es> + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. */ #include <glib.h> @@ -1546,7 +1547,11 @@ qmi_message_get_tlv_printable (QmiMessage *self, g_return_val_if_fail (line_prefix != NULL, NULL); g_return_val_if_fail (raw != NULL, NULL); - value_hex = qmi_helpers_str_hex (raw, raw_length, ':'); + if (qmi_utils_get_show_personal_info ()) + value_hex = qmi_helpers_str_hex (raw, raw_length, ':'); + else + value_hex = g_strdup ("###..."); + printable = g_strdup_printf ("%sTLV:\n" "%s type = 0x%02x\n" "%s length = %" G_GSIZE_FORMAT "\n" diff --git a/src/libqmi-glib/qmi-utils.c b/src/libqmi-glib/qmi-utils.c index 8b504668..ff81b733 100644 --- a/src/libqmi-glib/qmi-utils.c +++ b/src/libqmi-glib/qmi-utils.c @@ -20,6 +20,7 @@ * * Copyright (C) 2012-2020 Dan Williams <dcbw@redhat.com> * Copyright (C) 2012-2020 Aleksander Morgado <aleksander@aleksander.es> + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. */ #include <config.h> @@ -28,6 +29,7 @@ /*****************************************************************************/ static volatile gint __traces_enabled = FALSE; +static volatile gint __hide_personal_info = FALSE; gboolean qmi_utils_get_traces_enabled (void) @@ -40,3 +42,15 @@ qmi_utils_set_traces_enabled (gboolean enabled) { g_atomic_int_set (&__traces_enabled, enabled); } + +void +qmi_utils_set_show_personal_info (gboolean hide_personal_info) +{ + g_atomic_int_set (&__hide_personal_info, hide_personal_info); +} + +gboolean +qmi_utils_get_show_personal_info (void) +{ + return (gboolean) g_atomic_int_get (&__hide_personal_info); +}
\ No newline at end of file diff --git a/src/libqmi-glib/qmi-utils.h b/src/libqmi-glib/qmi-utils.h index 2982a6a3..97a6174c 100644 --- a/src/libqmi-glib/qmi-utils.h +++ b/src/libqmi-glib/qmi-utils.h @@ -23,7 +23,7 @@ * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> * Copyright (C) 2000 Wim Taymans <wtay@chello.be> * Copyright (C) 2002 Thomas Vander Stichele <thomas@apestaart.org> - + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. */ #ifndef _LIBQMI_GLIB_QMI_UTILS_H_ @@ -69,6 +69,27 @@ gboolean qmi_utils_get_traces_enabled (void); */ void qmi_utils_set_traces_enabled (gboolean enabled); +/** + * qmi_utils_set_show_personal_info: + * @show_personal_info: %TRUE to show personal info in traces, %FALSE otherwise. + * + * Sets whether personal info is printed when traces are enabled. + * + * Since: 1.32 + */ +void qmi_utils_set_show_personal_info (gboolean show_personal_info); + +/** + * qmi_utils_get_show_personal_info: + * + * Checks whether personal info should be hidden when traces are enabled. + * + * Returns: %TRUE to show personal info in trace, %FALSE otherwise. + * + * Since: 1.32 + */ +gboolean qmi_utils_get_show_personal_info (void); + G_END_DECLS #endif /* _LIBQMI_GLIB_QMI_UTILS_H_ */ diff --git a/src/qmicli/qmicli.c b/src/qmicli/qmicli.c index 76d0565e..76411865 100644 --- a/src/qmicli/qmicli.c +++ b/src/qmicli/qmicli.c @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Copyright (C) 2012-2017 Aleksander Morgado <aleksander@aleksander.es> + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. */ #include "config.h" @@ -68,6 +69,7 @@ static gboolean device_open_auto_flag; static gchar *client_cid_str; static gboolean client_no_release_cid_flag; static gboolean verbose_flag; +static gboolean verbose_full_flag; static gboolean silent_flag; static gboolean version_flag; @@ -129,6 +131,10 @@ static GOptionEntry main_entries[] = { "Run action with verbose logs, including the debug ones", NULL }, + { "verbose-full", 0, 0, G_OPTION_ARG_NONE, &verbose_full_flag, + "Run action with verbose logs, including the debug ones and personal info", + NULL + }, { "silent", 0, 0, G_OPTION_ARG_NONE, &silent_flag, "Run action with no logs; not even the error/warning ones", NULL @@ -210,7 +216,7 @@ log_handler (const gchar *log_domain, g_assert_not_reached (); } - if (!verbose_flag && !err) + if (!verbose_flag && !verbose_full_flag && !err) return; g_fprintf (err ? stderr : stdout, @@ -1018,14 +1024,28 @@ int main (int argc, char **argv) g_log_set_handler (NULL, G_LOG_LEVEL_MASK, log_handler, NULL); g_log_set_handler ("Qmi", G_LOG_LEVEL_MASK, log_handler, NULL); - if (verbose_flag) + + if (verbose_flag && verbose_full_flag) { + g_printerr ("error: cannot specify --verbose and --verbose-full at the same time\n"); + exit (EXIT_FAILURE); + } else if (verbose_flag) { qmi_utils_set_traces_enabled (TRUE); + qmi_utils_set_show_personal_info (FALSE); + } else if (verbose_full_flag) { + qmi_utils_set_traces_enabled (TRUE); + qmi_utils_set_show_personal_info (TRUE); + } #if QMI_MBIM_QMUX_SUPPORTED /* libmbim logging */ g_log_set_handler ("Mbim", G_LOG_LEVEL_MASK, log_handler, NULL); - if (verbose_flag) + if (verbose_flag) { mbim_utils_set_traces_enabled (TRUE); + mbim_utils_set_show_personal_info (FALSE); + } else if (verbose_full_flag) { + mbim_utils_set_traces_enabled (TRUE); + mbim_utils_set_show_personal_info (TRUE); + } #endif #if QMI_QRTR_SUPPORTED |