From patchwork Sat May 8 00:02:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun AK X-Patchwork-Id: 1475693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=Pd23ckTA; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=GzCY5uf1; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FcSK86JYLz9sVb for ; Sat, 8 May 2021 10:06:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=5/QoG+hreHIxAF8bRNwuwgpQroZpI4Ye2CURHZUoL7I=; b=Pd23ckTA9KUSTXWqxTLNjhZjeS nc/W0IlMjz2PSvxwiADo0YxxyiyWPivH19HXOSP4Mw8/QWzQz+WQzu8YSvXLZ/PCRlatnLF6JdRMf SHC+tETLXEGMdwQrv0/OsU/T6zoZH/mOoG0Vz1K74rHREIfWQjoRUJ/3XX55BnSTxOb3eTVk33Kvq LdEAiPcjZd/65n5/U1o21nrQOx1ZWrpJlPJMrME/GNeIFrwUNwGBGBgSXrbFrmXud7vBE/q4l4eDX 6fVl1foimcgN5YNMkZ/LSA0IKiff79bcFEhpZCObKDE1lcx+ChDKMxapS2JH6In7upOoLKqRHtCEZ etchNVlw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lfAST-008LDf-Rn; Sat, 08 May 2021 00:04:38 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfASO-008LD1-8u for openwrt-devel@lists.openwrt.org; Sat, 08 May 2021 00:04:35 +0000 Received: by mail-pf1-x42f.google.com with SMTP id i13so9129539pfu.2 for ; Fri, 07 May 2021 17:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DaDZ3g/44dqOPPuKVXe80YRG9tQNPZmGOToL+vgKrT4=; b=GzCY5uf1bb3yVSWdcxUmn06vy0zG9AR81PbR2pSNguh9tXwGK0ioWyymjNvbCuGCbp BeoFVrLJ1f+qfiJUhnEuNu9j2zQNq077FNcx4r3XXqyuV9KxeUNiaIfj18SKzNXqbvV7 jbXGdql+qqSRmWYpQu71aTYUjuQCW3Ms4OlM1BO79Spqqgb9AmsIkDLBe0mf8iESAfYp It+jw1FOJnzH4yfTVKH9CUWSTgoeF63vBJp72RjXUnChwZUm42+iCGJ+czJN6ptouICh RgcmsdvWXgZzB2XwU3nvhOjYE6J/XAAbtnzB0NThHFUgR2HxaMIYiahb/T0NIi5fmdOf M86A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DaDZ3g/44dqOPPuKVXe80YRG9tQNPZmGOToL+vgKrT4=; b=PY7peaqRBQCZEvSTQ2JjkzHjA17jFHsvR2V6s85yZ3QEq+gVk4G6FgBL2UkeeQDkr3 9kWnM5kjg5ZfhkuV1pQE/g8NdFjncFLkR7wdYXHawSut/K9Sa43vsMqflvFvHKelwEFu uznP/zo1ZJeGvZEA8OKKSTvxQGb3d9RrAVg9CDuXfQPPI0eunqkupyp2MQX3XqCCiYI/ FDG4juoiikNQopV24qpCdRF288i6fSmAHODjMHLt4i6cVqJl3UT8OvUfUUpem3xGPFKw 2hbjdVBGffk80rrMB6vRirvenue8aSB8zECreojgYAIZ//grM9CsfvPGxaRIxWSK6xXN NYrQ== X-Gm-Message-State: AOAM530NuKBUxPiwx+RK5q6CwA/jkS1khzZqyTIh1BttjErLQQRGgfTf 1TC4+JxyMaLq9pp7DAgFqQ1//L6u/Rs= X-Google-Smtp-Source: ABdhPJwWu877v19DMxAh/A6wXI3MqiRV9OllIKAHjvU0qQxrfoUN0GEWrNpxwusAG+i/XTlN5HAGJA== X-Received: by 2002:a63:e242:: with SMTP id y2mr13064258pgj.298.1620432268657; Fri, 07 May 2021 17:04:28 -0700 (PDT) Received: from debian.lan ([49.206.15.4]) by smtp.gmail.com with ESMTPSA id k7sm5560916pfc.16.2021.05.07.17.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 17:04:28 -0700 (PDT) From: Arjun AK To: openwrt-devel@lists.openwrt.org Cc: Arjun Subject: [PATCH] uim: add --uim-get-sim-state Date: Sat, 8 May 2021 05:32:57 +0530 Message-Id: <20210508000257.17188-1-arjunak234@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210508_010432_481879_8011D0ED X-CRM114-Status: UNSURE ( 9.68 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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: From: Arjun This command will show whether a SIM card has been inserted and whether a pin is required. Signed-off-by: Arjun --- commands-uim.c | 26 ++++++++++++++++++++++++++ commands-uim.h | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42f listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [arjunak234[at]gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [arjunak234[at]gmail.com] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily 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 From: Arjun This command will show whether a SIM card has been inserted and whether a pin is required. Signed-off-by: Arjun --- commands-uim.c | 26 ++++++++++++++++++++++++++ commands-uim.h | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/commands-uim.c b/commands-uim.c index 859da68..03166a2 100644 --- a/commands-uim.c +++ b/commands-uim.c @@ -54,3 +54,29 @@ cmd_uim_verify_pin2_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_set_uim_verify_pin_request(msg, &data); return QMI_CMD_REQUEST; } + + +static void cmd_uim_get_sim_state_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) +{ + struct qmi_uim_get_card_status_response res; + qmi_parse_uim_get_card_status_response(msg, &res); + + void * const array = blobmsg_open_array(&status, "sim_cards"); + if (res.data.card_status.cards_n > 0){ + void * const table = blobmsg_open_table(&status, NULL); + + for (int i = 0; i < res.data.card_status.cards_n;i++){ + blobmsg_add_u32(&status, "state", res.data.card_status.cards[i].card_state); + blobmsg_add_u32(&status, "upin_state", res.data.card_status.cards[i].upin_state); + } + blobmsg_close_table(&status, table); + } + blobmsg_close_array(&status, array); +} + +static enum qmi_cmd_result +cmd_uim_get_sim_state_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + qmi_set_uim_get_card_status_request(msg); + return QMI_CMD_REQUEST; +} diff --git a/commands-uim.h b/commands-uim.h index 86ebae4..02a49b1 100644 --- a/commands-uim.h +++ b/commands-uim.h @@ -21,10 +21,12 @@ #define __uqmi_uim_commands \ __uqmi_command(uim_verify_pin1, uim-verify-pin1, required, QMI_SERVICE_UIM), \ - __uqmi_command(uim_verify_pin2, uim-verify-pin2, required, QMI_SERVICE_UIM) \ + __uqmi_command(uim_verify_pin2, uim-verify-pin2, required, QMI_SERVICE_UIM), \ + __uqmi_command(uim_get_sim_state, uim-get-sim-state, no, QMI_SERVICE_UIM) \ #define uim_helptext \ " --uim-verify-pin1 : Verify PIN1 (new devices)\n" \ " --uim-verify-pin2 : Verify PIN2 (new devices)\n" \ + " --uim-get-sim-state: Get current SIM state\n" \