summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSławomir Demeszko <s.demeszko@wireless-instruments.com>2014-12-17 13:35:32 +0100
committerFelix Fietkau <nbd@openwrt.org>2014-12-18 12:45:44 +0100
commit695ac858744ee1321582b76d8faaecbe00f79ab7 (patch)
treeab9b40a7f7f996d93293f3d875be74e892fb92a6
parentcba2f469ffbe99f9fb181faeadc22d62e6c89185 (diff)
Added option for enabling and disabling protection of simcard by PIN
Signed-off-by: SÅ‚awomir Demeszko <s.demeszko@wireless-instruments.com>
-rw-r--r--commands-dms.c53
-rw-r--r--commands-dms.h7
2 files changed, 60 insertions, 0 deletions
diff --git a/commands-dms.c b/commands-dms.c
index ad5c89d..3a3c394 100644
--- a/commands-dms.c
+++ b/commands-dms.c
@@ -75,6 +75,59 @@ cmd_dms_verify_pin2_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct
return QMI_CMD_REQUEST;
}
+static struct qmi_dms_uim_set_pin_protection_request dms_pin_protection_req = {
+ QMI_INIT_SEQUENCE(info,
+ .pin_id = QMI_DMS_UIM_PIN_ID_PIN
+ )
+};
+
+#define cmd_dms_set_pin_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_set_pin_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+ qmi_set_ptr(&dms_pin_protection_req, info.pin, arg);
+ return QMI_CMD_DONE;
+}
+
+static enum qmi_cmd_result
+cmd_dms_set_pin_protection_prepare(struct qmi_msg *msg, char *arg)
+{
+ if (!dms_pin_protection_req.data.info.pin) {
+ uqmi_add_error("Missing argument");
+ return QMI_CMD_EXIT;
+ }
+
+ int is_enabled;
+ if (strcasecmp(arg, "disabled") == 0)
+ is_enabled = false;
+ else if (strcasecmp(arg, "enabled") == 0)
+ is_enabled = true;
+ else {
+ uqmi_add_error("Invalid value (valid: disabled, enabled)");
+ return QMI_CMD_EXIT;
+ }
+
+ qmi_set_ptr(&dms_pin_protection_req, info.protection_enabled, is_enabled);
+ qmi_set_dms_uim_set_pin_protection_request(msg, &dms_pin_protection_req);
+ return QMI_CMD_REQUEST;
+}
+
+#define cmd_dms_set_pin1_protection_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_set_pin1_protection_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+ qmi_set_ptr(&dms_pin_protection_req, info.pin_id, QMI_DMS_UIM_PIN_ID_PIN);
+ return cmd_dms_set_pin_protection_prepare(msg, arg);
+}
+
+#define cmd_dms_set_pin2_protection_cb no_cb
+static enum qmi_cmd_result
+cmd_dms_set_pin2_protection_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+ qmi_set_ptr(&dms_pin_protection_req, info.pin_id, QMI_DMS_UIM_PIN_ID_PIN2);
+ return cmd_dms_set_pin_protection_prepare(msg, arg);
+}
+
static struct qmi_dms_uim_unblock_pin_request dms_unlock_pin_req = {
QMI_INIT_SEQUENCE(info,
.pin_id = QMI_DMS_UIM_PIN_ID_PIN
diff --git a/commands-dms.h b/commands-dms.h
index 703b9f7..e214975 100644
--- a/commands-dms.h
+++ b/commands-dms.h
@@ -2,6 +2,9 @@
__uqmi_command(dms_get_pin_status, get-pin-status, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin1, verify-pin1, required, QMI_SERVICE_DMS), \
__uqmi_command(dms_verify_pin2, verify-pin2, required, QMI_SERVICE_DMS), \
+ __uqmi_command(dms_set_pin1_protection, set-pin1-protection, required, QMI_SERVICE_DMS), \
+ __uqmi_command(dms_set_pin2_protection, set-pin2-protection, required, QMI_SERVICE_DMS), \
+ __uqmi_command(dms_set_pin, pin, required, CMD_TYPE_OPTION), \
__uqmi_command(dms_unblock_pin1, unblock-pin1, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_unblock_pin2, unblock-pin2, no, QMI_SERVICE_DMS), \
__uqmi_command(dms_set_puk, puk, required, CMD_TYPE_OPTION), \
@@ -16,6 +19,10 @@
" --get-pin-status: Get PIN verification status\n" \
" --verify-pin1 <pin>: Verify PIN1\n" \
" --verify-pin2 <pin>: Verify PIN2\n" \
+ " --set-pin1-protection <state>: Set PIN1 protection state (disabled, enabled)\n" \
+ " --pin <pin>: PIN1 needed to change state\n" \
+ " --set-pin2-protection <state>: Set PIN2 protection state (disabled, enabled)\n" \
+ " --pin <pin2>: PIN2 needed to change state\n" \
" --unblock-pin1: Unblock PIN1\n" \
" --puk <puk>: PUK needed to unblock\n" \
" --new-pin <new pin>: New pin\n" \