umbim: allow forcing DHCP/DHCPv6 configuration
[openwrt/staging/hauke.git] / package / network / utils / umbim / files / lib / netifd / proto / mbim.sh
index bf07137fc4e79db99230548de6689d0b3cb5276c..50913e7fa0461e2732583dd1499dffaba6de5964 100755 (executable)
@@ -20,8 +20,8 @@ proto_mbim_init_config() {
        proto_config_add_string username
        proto_config_add_string password
        [ -e /proc/sys/net/ipv6 ] && proto_config_add_string ipv6
-       proto_config_add_boolean dhcp
-       proto_config_add_boolean dhcpv6
+       proto_config_add_string dhcp
+       proto_config_add_string dhcpv6
        proto_config_add_string pdptype
        proto_config_add_int mtu
        proto_config_add_defaults
@@ -199,15 +199,15 @@ _proto_mbim_setup() {
        proto_init_update "$ifname" 1
        proto_send_update "$interface"
 
-       [ -z "$dhcp" ] && dhcp=1
-       [ -z "$dhcpv6" ] && dhcpv6=1
+       [ -z "$dhcp" ] && dhcp="auto"
+       [ -z "$dhcpv6" ] && dhcpv6="auto"
 
        [ "$iptype" != "ipv6" ] && {
                json_init
                json_add_string name "${interface}_4"
                json_add_string ifname "@$interface"
                ipv4address=$(_proto_mbim_get_field ipv4address "$mbimconfig")
-               if [ -n "$ipv4address" ]; then
+               if [ -n "$ipv4address" -a "$dhcp" != 1 ]; then
                        json_add_string proto "static"
 
                        json_add_array ipaddr
@@ -222,7 +222,7 @@ _proto_mbim_setup() {
                        json_add_string proto "dhcp"
                fi
 
-               [ "$peerdns" = 0 ] || {
+               [ "$peerdns" = 0 -a "$dhcp" != 1 ] || {
                        json_add_array dns
                        for server in $(_proto_mbim_get_field ipv4dnsserver "$mbimconfig"); do
                                json_add_string "" "$server"
@@ -242,7 +242,7 @@ _proto_mbim_setup() {
                json_add_string name "${interface}_6"
                json_add_string ifname "@$interface"
                ipv6address=$(_proto_mbim_get_field ipv6address "$mbimconfig")
-               if [ -n "$ipv6address" ]; then
+               if [ -n "$ipv6address" -a "$dhcpv6" != 1 ]; then
                        json_add_string proto "static"
 
                        json_add_array ip6addr
@@ -265,7 +265,7 @@ _proto_mbim_setup() {
                        json_add_string extendprefix 1
                fi
 
-               [ "$peerdns" = 0 ] || {
+               [ "$peerdns" = 0 -a "$dhcpv6" != 1 ] || {
                        json_add_array dns
                        for server in $(_proto_mbim_get_field ipv6dnsserver "$mbimconfig"); do
                                json_add_string "" "$server"