+ [ "$pdptype" = "ip" -o "$pdptype" = "ipv4v6" ] && {
+ cid_4=$(uqmi -s -d "$device" --get-client-id wds)
+ if ! [ "$cid_4" -eq "$cid_4" ] 2> /dev/null; then
+ echo "Unable to obtain client ID"
+ proto_notify_error "$interface" NO_CID
+ return 1
+ fi
+
+ uqmi -s -d "$device" --set-client-id wds,"$cid_4" --set-ip-family ipv4 > /dev/null
+
+ pdh_4=$(uqmi -s -d "$device" --set-client-id wds,"$cid_4" \
+ --start-network \
+ ${apn:+--apn $apn} \
+ ${profile:+--profile $profile} \
+ ${auth:+--auth-type $auth} \
+ ${username:+--username $username} \
+ ${password:+--password $password} \
+ ${autoconnect:+--autoconnect})
+
+ # pdh_4 is a numeric value on success
+ if ! [ "$pdh_4" -eq "$pdh_4" ] 2> /dev/null; then
+ echo "Unable to connect IPv4"
+ uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds
+ proto_notify_error "$interface" CALL_FAILED
+ return 1
+ fi
+
+ # Check data connection state
+ connstat=$(uqmi -s -d "$device" --get-data-status)
+ [ "$connstat" == '"connected"' ] || {
+ echo "No data link!"
+ uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds
+ proto_notify_error "$interface" CALL_FAILED
+ return 1
+ }
+ }
+
+ [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && {
+ cid_6=$(uqmi -s -d "$device" --get-client-id wds)
+ if ! [ "$cid_6" -eq "$cid_6" ] 2> /dev/null; then
+ echo "Unable to obtain client ID"
+ proto_notify_error "$interface" NO_CID
+ return 1
+ fi
+
+ uqmi -s -d "$device" --set-client-id wds,"$cid_6" --set-ip-family ipv6 > /dev/null
+
+ pdh_6=$(uqmi -s -d "$device" --set-client-id wds,"$cid_6" \
+ --start-network \
+ ${apn:+--apn $apn} \
+ ${profile:+--profile $profile} \
+ ${auth:+--auth-type $auth} \
+ ${username:+--username $username} \
+ ${password:+--password $password} \
+ ${autoconnect:+--autoconnect})
+
+ # pdh_6 is a numeric value on success
+ if ! [ "$pdh_6" -eq "$pdh_6" ] 2> /dev/null; then
+ echo "Unable to connect IPv6"
+ uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds
+ proto_notify_error "$interface" CALL_FAILED
+ return 1
+ fi
+
+ # Check data connection state
+ connstat=$(uqmi -s -d "$device" --get-data-status)
+ [ "$connstat" == '"connected"' ] || {
+ echo "No data link!"
+ uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds
+ proto_notify_error "$interface" CALL_FAILED
+ return 1
+ }
+ }
+
+ echo "Setting up $ifname"