From 1a6ba499592fa05e16ac49104f2f5fce67277b06 Mon Sep 17 00:00:00 2001 From: XT-Martinez <32611135+XT-Martinez@users.noreply.github.com> Date: Mon, 15 Jul 2024 22:15:53 +0800 Subject: [PATCH] Update quectel proto script to support dual-stack IP via QMAP multiplexing Update quectel proto script to support dual-stack IP via QMAP multiplexing --- wwan/app/quectel-cm/files/quectel.sh | 29 +++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/wwan/app/quectel-cm/files/quectel.sh b/wwan/app/quectel-cm/files/quectel.sh index 8b724d0..d8b905a 100644 --- a/wwan/app/quectel-cm/files/quectel.sh +++ b/wwan/app/quectel-cm/files/quectel.sh @@ -11,6 +11,7 @@ proto_quectel_init_config() { no_device=1 proto_config_add_string "device:device" proto_config_add_string "apn" + proto_config_add_string "apnv6" proto_config_add_string "auth" proto_config_add_string "username" proto_config_add_string "password" @@ -27,12 +28,12 @@ proto_quectel_init_config() { proto_quectel_setup() { local interface="$1" - local device apn auth username password pincode delay pdptype + local device apn apnv6 auth username password pincode delay pdptype local dhcp dhcpv6 sourcefilter delegate mtu $PROTO_DEFAULT_OPTIONS local ip4table ip6table local pid zone - json_get_vars device apn auth username password pincode delay + json_get_vars device apn apnv6 auth username password pincode delay json_get_vars pdptype dhcp dhcpv6 sourcefilter delegate ip4table json_get_vars ip6table mtu $PROTO_DEFAULT_OPTIONS @@ -71,15 +72,25 @@ proto_quectel_setup() { [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && ipv6opt="-6" [ -n "$auth" ] || auth="none" - eval "proto_run_command '$interface' /usr/bin/quectel-cm -i '$ifname' $ipv4opt $ipv6opt ${pincode:+-p $pincode} -s '$apn' '$username' '$password' '$auth'" + quectel-qmi-proxy & + sleep 3 + + if [ -n "$ipv4opt" ]; then + quectel-cm -i "$ifname" $ipv4opt -n 1 -m 1 ${pincode:+-p $pincode} -s "$apn" "$username" "$password" "$auth" & + fi + if [ -n "$ipv6opt" ]; then + quectel-cm -i "$ifname" $ipv6opt -n 4 -m 2 ${pincode:+-p $pincode} -s "$apnv6" "$username" "$password" "$auth" & + fi sleep 5 ifconfig "$ifname" up - ifconfig "${ifname}_1" &>"/dev/null" && ifname="${ifname}_1" + ifconfig "${ifname}_1" &>"/dev/null" && ifname4="${ifname}_1" + ifconfig "${ifname}_2" &>"/dev/null" && ifname6="${ifname}_2" if [ -n "$mtu" ]; then echo "Setting MTU to $mtu" - /sbin/ip link set dev "$ifname" mtu "$mtu" + /sbin/ip link set dev "$ifname4" mtu "$mtu" + /sbin/ip link set dev "$ifname6" mtu "$mtu" fi echo "Setting up $ifname" @@ -92,7 +103,7 @@ proto_quectel_setup() { if [ "$pdptype" = "ipv6" ] || [ "$pdptype" = "ipv4v6" ]; then json_init json_add_string name "${interface}_6" - json_add_string ifname "@$interface" + json_add_string device "$ifname6" [ "$pdptype" = "ipv4v6" ] && json_add_string iface_464xlat "0" json_add_string proto "dhcpv6" proto_add_dynamic_defaults @@ -109,7 +120,7 @@ proto_quectel_setup() { if [ "$pdptype" = "ipv4" ] || [ "$pdptype" = "ipv4v6" ]; then json_init json_add_string name "${interface}_4" - json_add_string ifname "@$interface" + json_add_string device "$ifname4" json_add_string proto "dhcp" [ -z "$ip4table" ] || json_add_string ip4table "$ip4table" proto_add_dynamic_defaults @@ -128,10 +139,10 @@ proto_quectel_teardown() { echo "Stopping network $interface" - proto_kill_command "$interface" - proto_init_update "*" 0 proto_send_update "$interface" + killall quectel-cm + killall quectel-qmi-proxy } [ -n "$INCLUDE_ONLY" ] || {