diff options
author | Lech Perczak <lech.perczak@gmail.com> | 2022-02-15 01:44:32 +0100 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2023-04-29 21:33:04 +0200 |
commit | 0be14c622b809e7d3551c21e7ac6dbae6b0403f8 (patch) | |
tree | 715ab0f5249295e8e55b91d9a4e29cbc39f4278b /package | |
parent | 512bb17f3e2a15d52191bb45d63c8d8739f85584 (diff) | |
download | upstream-0be14c622b809e7d3551c21e7ac6dbae6b0403f8.tar.gz upstream-0be14c622b809e7d3551c21e7ac6dbae6b0403f8.tar.bz2 upstream-0be14c622b809e7d3551c21e7ac6dbae6b0403f8.zip |
umbim: connect session for only the selected PDP type
Previous implementation automatically set up connections for both IPv4
and IPv6, even if one of them isn't supported. Respect the "pdptype"
option in the same way, as it is done for QMI or NCM, and only start the
respective PDN sessions, if set.
Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
Diffstat (limited to 'package')
-rwxr-xr-x | package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 108 |
1 files changed, 60 insertions, 48 deletions
diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 492e06829d..08f95ddc6f 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -20,6 +20,7 @@ proto_mbim_init_config() { proto_config_add_string username proto_config_add_string password proto_config_add_boolean dhcp + proto_config_add_string pdptype proto_config_add_defaults } @@ -28,8 +29,8 @@ _proto_mbim_setup() { local tid=2 local ret - local device apn pincode delay allow_roaming allow_partner dhcp $PROTO_DEFAULT_OPTIONS - json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp $PROTO_DEFAULT_OPTIONS + local device apn pincode delay allow_roaming allow_partner dhcp pdptype $PROTO_DEFAULT_OPTIONS + json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp pdptype $PROTO_DEFAULT_OPTIONS [ -n "$ctl_device" ] && device=$ctl_device @@ -147,8 +148,11 @@ _proto_mbim_setup() { } tid=$((tid + 1)) + pdptype=$(echo "$pdptype" | awk '{print tolower($0)}') + [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] || pdptype="ipv4v6" + echo "mbim[$$]" "Connect to network" - while ! umbim $DBG -n -t $tid -d $device connect "$apn" "$auth" "$username" "$password"; do + while ! umbim $DBG -n -t $tid -d $device connect "$pdptype:$apn" "$auth" "$username" "$password"; do tid=$((tid + 1)) sleep 1; done @@ -164,56 +168,64 @@ _proto_mbim_setup() { proto_init_update "$ifname" 1 proto_send_update "$interface" - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" - json_add_string proto "static" - json_add_array ipaddr - json_add_string "" "$ipv4address" - json_close_array - json_add_string gateway "$ipv4gateway" - json_add_array dns - json_add_string "" "$ipv4dnsserver" - json_close_array - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" - - json_init - json_add_string name "${interface}_6" - json_add_string ifname "@$interface" - json_add_string proto "static" - json_add_array ip6addr - json_add_string "" "$ipv6address" - json_close_array - json_add_string ip6gw "$ipv6gateway" - json_add_array dns - json_add_string "" "$ipv6dnsserver" - json_close_array - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" + [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "static" + json_add_array ipaddr + json_add_string "" "$ipv4address" + json_close_array + json_add_string gateway "$ipv4gateway" + json_add_array dns + json_add_string "" "$ipv4dnsserver" + json_close_array + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } + + [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "static" + json_add_array ip6addr + json_add_string "" "$ipv6address" + json_close_array + json_add_string ip6gw "$ipv6gateway" + json_add_array dns + json_add_string "" "$ipv6dnsserver" + json_close_array + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } else echo "mbim[$$]" "Starting DHCP on $ifname" proto_init_update "$ifname" 1 proto_send_update "$interface" - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" - json_add_string proto "dhcp" - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" - - json_init - json_add_string name "${interface}_6" - json_add_string ifname "@$interface" - json_add_string proto "dhcpv6" - json_add_string extendprefix 1 - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" + [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } + + [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "dhcpv6" + json_add_string extendprefix 1 + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } fi uci_set_state network $interface tid "$tid" |