From b57c0e5af68a65b97aa02b3fc754f40462f2ad80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C5=82awomir=20Demeszko?= Date: Wed, 17 Dec 2014 15:56:32 +0100 Subject: [PATCH] Added commands to change PIN code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: SÅ‚awomir Demeszko --- commands-dms.c | 36 ++++++++++++++++++++++++++++++++++++ commands-dms.h | 8 ++++++++ 2 files changed, 44 insertions(+) diff --git a/commands-dms.c b/commands-dms.c index 15cf829..a677052 100644 --- a/commands-dms.c +++ b/commands-dms.c @@ -136,6 +136,42 @@ cmd_dms_set_pin2_protection_prepare(struct qmi_dev *qmi, struct qmi_request *req return cmd_dms_set_pin_protection_prepare(msg, arg); } +static enum qmi_cmd_result +cmd_dms_change_pin_prepare(struct qmi_msg *msg, char *arg) +{ + if (!dms_req_data.pin || !dms_req_data.new_pin) { + uqmi_add_error("Missing argument"); + return QMI_CMD_EXIT; + } + + struct qmi_dms_uim_change_pin_request dms_change_pin_req = { + QMI_INIT_SEQUENCE(info, + .pin_id = dms_req_data.pin_id + ), + QMI_INIT_PTR(info.old_pin, dms_req_data.pin), + QMI_INIT_PTR(info.new_pin, dms_req_data.new_pin) + }; + + qmi_set_dms_uim_change_pin_request(msg, &dms_change_pin_req); + return QMI_CMD_REQUEST; +} + +#define cmd_dms_change_pin1_cb no_cb +static enum qmi_cmd_result +cmd_dms_change_pin1_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + dms_req_data.pin_id = QMI_DMS_UIM_PIN_ID_PIN; + return cmd_dms_change_pin_prepare(msg, arg); +} + +#define cmd_dms_change_pin2_cb no_cb +static enum qmi_cmd_result +cmd_dms_change_pin2_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + dms_req_data.pin_id = QMI_DMS_UIM_PIN_ID_PIN2; + return cmd_dms_change_pin_prepare(msg, arg); +} + #define cmd_dms_set_new_pin_cb no_cb static enum qmi_cmd_result cmd_dms_set_new_pin_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) diff --git a/commands-dms.h b/commands-dms.h index e214975..925aea3 100644 --- a/commands-dms.h +++ b/commands-dms.h @@ -5,6 +5,8 @@ __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_change_pin1, change-pin1, no, QMI_SERVICE_DMS), \ + __uqmi_command(dms_change_pin2, change-pin2, no, QMI_SERVICE_DMS), \ __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), \ @@ -23,6 +25,12 @@ " --pin : PIN1 needed to change state\n" \ " --set-pin2-protection : Set PIN2 protection state (disabled, enabled)\n" \ " --pin : PIN2 needed to change state\n" \ + " --change-pin1: Change PIN1\n" \ + " --pin : Current PIN1\n" \ + " --new-pin : New pin\n" \ + " --change-pin2: Change PIN2\n" \ + " --pin : Current PIN2\n" \ + " --new-pin : New pin\n" \ " --unblock-pin1: Unblock PIN1\n" \ " --puk : PUK needed to unblock\n" \ " --new-pin : New pin\n" \ -- 2.11.0