From patchwork Sun Nov 4 21:08:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 992796 X-Patchwork-Delegate: koen.vandeputte@ncentric.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZsucGJyt"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42p7hl5vkmzB6NY for ; Mon, 5 Nov 2018 08:08:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-ID:To:From :Date: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=SXIMXuuJX7oGTAc44HrS06hDeYfRIsaFWE0mJ6YIWVI=; b=ZsucGJytYkXAQ2 Ec7WJR43LHkopsm7b3MlzkZQPcIVWmU5ClVnV/pbqpHJhCYR4o4Bn/S5T4SOsoKLKIBo6rTapqYgE +F0hJ4WdvVT1+7mtyVk+mXq4NXNkM4537aFqvN21rNL6WtIGdKP5Zzuvq5vIvyifRZ1kihDhMU02v hZXIF3EgoWoO5/44zysutG1JAAgByY6p5TPgr5pRcOaX4+mx6EgtIajrGJ6ne++C1bbQ4LxkIRxQ0 v0I90i5TWwIrWM0oxf0Retthn89zVuSEwVvuFRiOagFzUAWIKrulLeeZ9BgfJ1btVzxcjglfZDU19 wxHhbcXxFif6xdlpLF0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJPdR-0008V6-BR; Sun, 04 Nov 2018 21:08:41 +0000 Received: from fudo.makrotopia.org ([2a07:2ec0:3002::71]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJPdO-0008UD-EH for openwrt-devel@lists.openwrt.org; Sun, 04 Nov 2018 21:08:39 +0000 Received: from local by fudo.makrotopia.org with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gJPd3-00059G-ME; Sun, 04 Nov 2018 22:08:17 +0100 Date: Sun, 4 Nov 2018 22:08:11 +0100 From: Daniel Golle To: openwrt-devel@lists.openwrt.org Message-ID: <20181104210804.GA5482@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181104_130838_479659_A92300D8 X-CRM114-Status: GOOD ( 11.94 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH/RFC] uqmi: allow matching IMSI for qmi networks X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Koen Vandeputte , Florian Eckert , Matti Laakso Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Introduce 'imsi' configuration option for proto 'qmi' network interfaces. Setting it makes sure the configuration only gets used on the intended SIM card. In this way, one could have configuration for different SIM cards selected automatically when the card was either swapped physically or in software (as possible on the APU3 board). Signed-off-by: Daniel Golle --- .../utils/uqmi/files/lib/netifd/proto/qmi.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh index 9b2f69f009..ec1b936177 100755 --- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh +++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh @@ -28,12 +28,12 @@ proto_qmi_init_config() { proto_qmi_setup() { local interface="$1" - local dataformat connstat - local device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS + local dataformat connstat imsi_actual + local device imsi apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS local ip4table ip6table local cid_4 pdh_4 cid_6 pdh_6 local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6 - json_get_vars device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout $PROTO_DEFAULT_OPTIONS + json_get_vars device imsi apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout $PROTO_DEFAULT_OPTIONS [ "$timeout" = "" ] && timeout="10" @@ -68,6 +68,14 @@ proto_qmi_setup() { return 1 } + imsi_actual="$(uqmi -s -d "$device" --get-imsi | cut -d'"' -f2)" + [ -n "$imsi" -a "$imsi" != "$imsi_actual" ] && { + echo "Configured IMSI doesn't match SIM card." + proto_notify_error "$interface" NO_IFACE + proto_set_available "$interface" 0 + return 1 + } + echo "Waiting for SIM initialization" local uninitialized_timeout=0 while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do