From patchwork Sat May 8 01:21:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun AK X-Patchwork-Id: 1475698 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=NZglG4Qu; 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=gxBQRqjj; 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 4FcV6F6HNxz9sCD for ; Sat, 8 May 2021 11:27:01 +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:References:In-Reply-To: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:List-Owner; bh=TdIAEPsF3+qLmNjaKbHcJ3nkfZHHLSFKX3uXvkxByfQ=; b=NZglG4QuXdyKwvpn/x85QPvi1 x02qaSJ43PdWFCleiL21RnAfNcPyC/At0D51i+o0mmVWviZFidwSY5Iva+lqGwL5lyoWK5V1Sq96u C4Y1MZfnyypTFkkk6lZTUqBwFvu++nAFwD2CDRGCOf4G7KZ0Zw2ivJNLtvdqttB4VzXpfm/M/RyU+ llcjNuf0mZzbRICbRC3xrZ3aHqwZfGRiHblMlqyB8u2dyAuu7LEYnc9zo3E69FAsW6Awg6+FSieIr NsaqtTCfy+ntOnqNdBx0c9wpg4o4EvN17hoNlQ6GQWeXDuQvvTYvkpeXFzIvaFoPpgTQ2wbcT68ar NZbYAgD7g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lfBhz-008TCX-Ih; Sat, 08 May 2021 01:24:43 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lfBfM-008T4G-9N for openwrt-devel@lists.openwrt.org; Sat, 08 May 2021 01:22:28 +0000 Received: by mail-pj1-x102f.google.com with SMTP id gc22-20020a17090b3116b02901558435aec1so6527513pjb.4 for ; Fri, 07 May 2021 18:21:58 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=StUI7yNqEATHgcOJGPK0P+PsIVuo0UytLcxT4/WyyWw=; b=gxBQRqjjz2DvpLgqvt7d59WHePZaPTKuCqIjXkHg5pJxlBMJsKZsr2TSLwDMSEd/jH f4ShvXpEHU6jalsyYPqh05eUkzr9I8swBSKgU6ruGhAxkfVMIOd+yOuLkfmloz1salNS Y53hLZnJJZBZs6gH0HxpAOJXYkxiTVrkvZ05d97e9CWGe63hkV8smnoeVOwXoxw57Ur7 tf6VtyASJzEV/RgJi7xa5NyNuN7e1/CLYcj1U4W+0l6ZMoLCJbdokvx4BIK0zWxgcYAO bLYSzslYoD0LJhhWINh/8jC9FnfSqlZAJA//Il67C15wf+EEH+nxT1i+rpEEdy9ltFbB NRFQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=StUI7yNqEATHgcOJGPK0P+PsIVuo0UytLcxT4/WyyWw=; b=eyP0vsq52Rozn72eqEBF635AZad3Y3zcob6f8R1mq/P2U9nII2+IKeBYej7KUklWOr eplWuvN07yfVXcS5t+I0C0atRw95/5g/QmYNizwd5fY2Gzf0ymGN84ZuVeZR7HSgyXIt c8yX7HhqOucUlwENINqqKF4qTDlcYVCs6//nJV7lGBugZ1zUaPStsoQ1VPuWxTeNUkvW VoScFXq7frqRmto1cBqVtRBf2/vlC0rEfidkjwNWUeZ8hTr1iLMjvkx2AfCQt5M+utU/ zt+gO1caaiZpLD0U7uHa6DnlsvyBFz4bSZocpZKUHN2z02pPyjFha+NU9HrFCcHuN682 fNvg== X-Gm-Message-State: AOAM530PUhDsfL4ew56sGzsP+bqbZVKiU+YwBvmTcTmyYQnjo46Xw4wl +rwDXw1WfkyKyVnFAL6DAp8PpsYQqLI= X-Google-Smtp-Source: ABdhPJxuD6G7b0J3DrLrc9TmmoVHpn+ccSKDHVDoZfhQvyhRPMCtSNXohTnQl6wwGV0upthNr1xGFw== X-Received: by 2002:a17:90a:e54a:: with SMTP id ei10mr8230152pjb.235.1620436916841; Fri, 07 May 2021 18:21:56 -0700 (PDT) Received: from debian.lan ([49.206.15.4]) by smtp.gmail.com with ESMTPSA id n203sm5777285pfd.31.2021.05.07.18.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 18:21:56 -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 06:51:44 +0530 Message-Id: <20210508012144.24045-1-arjunak234@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210508_022225_328185_07EDCAA9 X-CRM114-Status: GOOD ( 11.64 ) 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 AK --- 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 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:102f 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.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 AK --- 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..e6cdd6d 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" \