modemmanager: improve 'simple connection' option handling
authorFlorian Eckert <fe@dev.tdt.de>
Mon, 24 Jul 2023 11:41:12 +0000 (13:41 +0200)
committerFlorian Eckert <fe@dev.tdt.de>
Mon, 24 Jul 2023 11:46:39 +0000 (13:46 +0200)
The line to generate the argument list for 'simple connect' is quite
long and is not maintainable. To improve the handling a function
'append_param' was added for appending the 'simple connect' options.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
net/modemmanager/Makefile
net/modemmanager/files/modemmanager.proto

index 996f1885d50ffed7a5f457e5346e8202134f1fb6..8a4958404362143d39780c73a71019bfd40387ed 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=modemmanager
 PKG_SOURCE_VERSION:=1.20.6
-PKG_RELEASE:=7
+PKG_RELEASE:=8
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git
index a0f6c357e3ac186a90c5f0bbb59e75161b854c94..b8ebce924026a95e53777f24ca8bdb149833b198 100755 (executable)
@@ -350,6 +350,15 @@ proto_modemmanager_init_config() {
        proto_config_add_defaults
 }
 
+# Append param to the global 'connectargs' variable.
+append_param() {
+       local param="$1"
+
+       [ -z "$param" ] && return
+       [ -z "$connectargs" ] || connectargs="${connectargs},"
+       connectargs="${connectargs}${param}"
+}
+
 proto_modemmanager_setup() {
        local interface="$1"
 
@@ -401,7 +410,16 @@ proto_modemmanager_setup() {
                # allowed unless a user set the opposite
                allow_roaming="yes"
        fi
-       connectargs="apn=${apn},allow-roaming=${allow_roaming}${iptype:+,ip-type=${iptype}}${plmn:+,operator-id=${plmn}}${cliauth:+,allowed-auth=${cliauth}}${username:+,user=${username}}${password:+,password=${password}}${pincode:+,pin=${pincode}}"
+
+       # Append options to 'connectargs' variable
+       append_param "apn=${apn}"
+       append_param "allow-roaming=${allow_roaming}"
+       append_param "${iptype:+ip-type=${iptype}}"
+       append_param "${plmn:+operator-id=${plmn}}"
+       append_param "${cliauth:+allowed-auth=${cliauth}}"
+       append_param "${username:+user=${username}}"
+       append_param "${password:+password=${password}}"
+       append_param "${pincode:+pin=${pincode}}"
 
        mmcli --modem="${device}" --timeout 120 --simple-connect="${connectargs}" || {
                proto_notify_error "${interface}" MM_CONNECT_FAILED