From patchwork Tue Oct 10 13:58:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Bauer X-Patchwork-Id: 1845925 X-Patchwork-Delegate: mail@david-bauer.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=vW56Fghu; dkim=fail reason="key not found in DNS" header.d=david-bauer.net header.i=@david-bauer.net header.a=rsa-sha256 header.s=uberspace header.b=HD87M8hT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S4czH73KMz1yq7 for ; Wed, 11 Oct 2023 01:02:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=rswjhp7Jy2z/A36TxqGkabbcDITNtgfWtiiUyHcZih0=; b=vW56FghuHuw6t0 d0aSdY1wFWihujvLdqXO/FFFJPy+WaUiWyF8dyx0VKkgzHbSpSdrboXjvky8D9KaPtXMbMmgAaBAL bUHlAuropKdNErk8ECj6gE6RToQSegh5eX8/AvzXk7vQzu4t/QW9UNztkhAqtdy/FvueT76aT0LWT 5WHoeyY/+YEttF4LVTgOy9C07xhJPZMz9neWnlxdaqtGw9gK8wpMcTLXO5+vTntbXicft3n5dLeKo mwfV6garykM638CO1jvwo83cNyQc//gf8Mncv0fdX6tJeVpXM8LStBboalV8nGtcxulkq4gYZ2kSV ShBYO/BQz6YlXbohcZ6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqDGS-00DVJk-32; Tue, 10 Oct 2023 13:59:12 +0000 Received: from perseus.uberspace.de ([95.143.172.134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqDGN-00DVI1-13 for openwrt-devel@lists.openwrt.org; Tue, 10 Oct 2023 13:59:10 +0000 Received: (qmail 23305 invoked by uid 988); 10 Oct 2023 13:58:54 -0000 Authentication-Results: perseus.uberspace.de; auth=pass (plain) From: David Bauer To: openwrt-devel@lists.openwrt.org Subject: [PATCH uqmi 1/3] uim: add application state to SIM status Date: Tue, 10 Oct 2023 15:58:43 +0200 Message-ID: <20231010135845.183016-1-mail@david-bauer.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Bar: - X-Rspamd-Report: MID_CONTAINS_FROM(1) BAYES_HAM(-3) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -1.6 Received: from unknown (HELO unkown) (::1) by perseus.uberspace.de (Haraka/3.0.1) with ESMTPSA; Tue, 10 Oct 2023 15:58:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=david-bauer.net; s=uberspace; h=from; bh=/NXaZi2ZEvoddnRikNfd9BFTQnYOURuLI6xYKpCeh/w=; b=HD87M8hTso8u1VE4jBAL1gZ9sHPmzV9Vp6M6YHWzw5VriActgyF9NqhRvKn07RrMfAP2wfkmoX 5k51O7ZANhbNmExmtp9aWZN5oFQSuH5F38txrzzY47JsP/GxpUDss0H/o/NXqpy7uvgiV6ZXOZf1 gq2z9MXXTmKy+0ae9owMG0bRVj3zsRw3/UGtQE/GdgEjAum8H4qd6Zjn37YloPmfxt/RJE+TB8hG e3bQG/MYUYf/UoVVGdIdFY10ZViNlVILW6qAenu4Y03vHP89ZECR64zoGU005cJM9bD4fky5685O EIFBiX8gnmuBTCIN+XkZL/Qd1ykzceLTFAQUZ1emUKr3+sE61/0MgmqnrRFRXxt/nf6QUHQR9vs2 YLt1cU08yt/TIs+dBSQ2xGl6BoUk5sWxRD4glQX1Mta5jnPeg+OgLSr/1g4tWNSsqXte4D5jy1zz PQIk82oFrJdTRAbvTniynbIvcGWahc5TesiZO3FCftwS9fZ+Lx46QJXLnSszjglj2Meqq+LsXKmH e5hXhQo7LzqqJRIktAAut0KG1GG6UnEKBrC8ew3r2No6NYCLc2gKWXRR1L9WKjaDBONKeHA1I1ij +mdFGs3wboYsXqZW2UmPM7CSVJVSOn1w6LkwUrZfHrGn0k7AEzjsFV/n/yrenk1iVgBCA3asNujC s= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231010_065908_207632_15341FDC X-CRM114-Status: UNSURE ( 7.90 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.5 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Parse the card application state and report it to the SIM card status output object. This is required to detect a card application which is in the failed (illegal) state. Signed-off-by: David Bauer --- commands-uim.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) Content analysis details: (-0.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [95.143.172.134 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay 0.1 DKIM_INVALID DKIM or DK signature exists, but is not valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Parse the card application state and report it to the SIM card status output object. This is required to detect a card application which is in the failed (illegal) state. Signed-off-by: David Bauer --- commands-uim.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/commands-uim.c b/commands-uim.c index 3bd8a74..68803b4 100644 --- a/commands-uim.c +++ b/commands-uim.c @@ -59,6 +59,16 @@ static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct qmi_request *re { struct qmi_uim_get_card_status_response res; void * const card_table = blobmsg_open_table(&status, NULL); + static const char *card_application_states[] = { + [QMI_UIM_CARD_APPLICATION_STATE_UNKNOWN] = "unknown", + [QMI_UIM_CARD_APPLICATION_STATE_DETECTED] = "detected", + [QMI_UIM_CARD_APPLICATION_STATE_PIN1_OR_UPIN_PIN_REQUIRED] = "pin-required", + [QMI_UIM_CARD_APPLICATION_STATE_PUK1_OR_UPIN_PUK_REQUIRED] = "puk-required", + [QMI_UIM_CARD_APPLICATION_STATE_CHECK_PERSONALIZATION_STATE] = "check-personalization-state", + [QMI_UIM_CARD_APPLICATION_STATE_PIN1_BLOCKED] = "pin1-blocked", + [QMI_UIM_CARD_APPLICATION_STATE_ILLEGAL] = "illegal", + [QMI_UIM_CARD_APPLICATION_STATE_READY] = "ready", + }; qmi_parse_uim_get_card_status_response(msg, &res); @@ -66,6 +76,7 @@ static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct qmi_request *re if (res.data.card_status.cards[i].card_state != QMI_UIM_CARD_STATE_PRESENT) continue; + uint8_t card_application_state; uint8_t pin1_state = res.data.card_status.cards[i].upin_state; uint8_t pin1_retries = res.data.card_status.cards[i].upin_retries; uint8_t puk1_retries = res.data.card_status.cards[i].upuk_retries; @@ -78,6 +89,8 @@ static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct qmi_request *re if (res.data.card_status.cards[i].applications[j].type == QMI_UIM_CARD_APPLICATION_TYPE_UNKNOWN) continue; + card_application_state = pin1_state = res.data.card_status.cards[i].applications[j].state; + if (!res.data.card_status.cards[i].applications[j].upin_replaces_pin1) { pin1_state = res.data.card_status.cards[i].applications[j].pin1_state; pin1_retries = res.data.card_status.cards[i].applications[j].pin1_retries; @@ -92,6 +105,10 @@ static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct qmi_request *re break; /* handle first application only for now */ } + if (card_application_state > QMI_UIM_CARD_APPLICATION_STATE_READY) + card_application_state = QMI_UIM_CARD_APPLICATION_STATE_UNKNOWN; + + blobmsg_add_string(&status, "card_application_state", card_application_states[card_application_state]); blobmsg_add_string(&status, "pin1_status", get_pin_status(pin1_state)); blobmsg_add_u32(&status, "pin1_verify_tries", pin1_retries); blobmsg_add_u32(&status, "pin1_unlock_tries", puk1_retries);