+ if [ -z "$dhcp" ]; then
+ echo "Setting up $ifname"
+ [ -n "$ipv4" ] && {
+ json_load "$(uqmi -s -d $device --set-client-id wds,$cid_4 --get-current-settings)"
+ json_select ipv4
+ json_get_vars ip subnet gateway dns1 dns2
+
+ proto_init_update "$ifname" 1
+ proto_set_keep 1
+ proto_add_ipv4_address "$ip" "$subnet"
+ proto_add_dns_server "$dns1"
+ proto_add_dns_server "$dns2"
+ proto_add_ipv4_route "0.0.0.0" 0 "$gateway"
+ proto_add_data
+ json_add_string "cid_4" "$cid_4"
+ json_add_string "pdh_4" "$pdh_4"
+ proto_close_data
+ proto_send_update "$interface"
+ }
+
+ [ -n "$ipv6" ] && {
+ json_load "$(uqmi -s -d $device --set-client-id wds,$cid_6 --get-current-settings)"
+ json_select ipv6
+ json_get_var ip_6 ip
+ json_get_var gateway_6 gateway
+ json_get_var dns1_6 dns1
+ json_get_var dns2_6 dns2
+ json_get_var ip_prefix_length ip-prefix-length
+
+ proto_init_update "$ifname" 1
+ proto_set_keep 1
+ # RFC 7278: Extend an IPv6 /64 Prefix to LAN
+ proto_add_ipv6_address "$ip_6" "128"
+ proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}"
+ proto_add_ipv6_route "$gateway_6" "128"
+ proto_add_ipv6_route "::0" 0 "$gateway_6" "" "" "${ip_6}/${ip_prefix_length}"
+ proto_add_dns_server "$dns1_6"
+ proto_add_dns_server "$dns2_6"
+ proto_add_data
+ json_add_string "cid_6" "$cid_6"
+ json_add_string "pdh_6" "$pdh_6"
+ proto_close_data
+ proto_send_update "$interface"
+ }
+ else
+ echo "Starting DHCP on $ifname"
+ proto_init_update "$ifname" 1
+ proto_add_data
+ [ -n "$ipv4" ] && {
+ json_add_string "cid_4" "$cid_4"
+ json_add_string "pdh_4" "$pdh_4"
+ }
+ [ -n "$ipv6" ] && {
+ json_add_string "cid_6" "$cid_6"
+ json_add_string "pdh_6" "$pdh_6"
+ }
+ proto_close_data
+ proto_send_update "$interface"
+
+ [ -n "$ipv4" ] && {
+ json_init
+ json_add_string name "${interface}_4"
+ json_add_string ifname "@$interface"
+ json_add_string proto "dhcp"
+ json_close_object
+ ubus call network add_dynamic "$(json_dump)"
+ }
+
+ [ -n "$ipv6" ] && {
+ json_init
+ json_add_string name "${interface}_6"
+ json_add_string ifname "@$interface"
+ json_add_string proto "dhcpv6"
+ # RFC 7278: Extend an IPv6 /64 Prefix to LAN
+ json_add_string extendprefix 1
+ json_close_object
+ ubus call network add_dynamic "$(json_dump)"
+ }
+ fi