[OpenWrt-Devel] [PATCH/RFC] uqmi: allow matching IMSI for qmi networks

Daniel Golle daniel at makrotopia.org
Sun Nov 4 16:08:11 EST 2018


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 <daniel at makrotopia.org>
---
 .../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
-- 
2.19.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list