Change OpenWRT network config to support cvd-wifiap-XX am: e88e3d78f5 am: 579901a7c5 am: bf3e3260b6 am: d770550efb

Original change: https://android-review.googlesource.com/c/platform/external/openwrt-prebuilts/+/2433267

Change-Id: Ia343c4f5bc2914d8a55f1d89ce1367b353f23d77
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/shared/config/network b/shared/config/network
index 3760c8c..4f15042 100644
--- a/shared/config/network
+++ b/shared/config/network
@@ -39,9 +39,11 @@
 config interface 'wifi0'
 	option device 'br-wifi0'
 	option proto 'static'
-	option netmask '255.255.255.192'
+	option netmask '255.255.255.128'
+	option ipaddr '192.168.99.1'
 
 config interface 'wifi1'
 	option device 'br-wifi1'
 	option proto 'static'
-	option netmask '255.255.255.192'
+	option netmask '255.255.255.128'
+	option ipaddr '192.168.99.129'
diff --git a/shared/uci-defaults/0_default_config b/shared/uci-defaults/0_default_config
index baf5650..deeac1f 100644
--- a/shared/uci-defaults/0_default_config
+++ b/shared/uci-defaults/0_default_config
@@ -3,17 +3,21 @@
 opkg install /ipks/*
 ip link set eth0 mtu 1460
 
-# Extract instance_num of CF instance. The default value is 1.
-instance_num=1
-bridged_host_network=false
+rule_name=$(uci add network rule)
+
+# Extract configs from /proc/cmdline
+bridged_wifi_tap=false
 words=$(cat /proc/cmdline)
 while
     word=${words%%" "*}
-    if echo "$word" | grep "instance_num"; then
-        instance_num=${word#*"="}
-    fi
-    if echo "$word" | grep "bridged_host_network=true"; then
-        bridged_host_network=true
+    if [ "$word" = "bridged_wifi_tap=true" ]; then
+        bridged_wifi_tap=true
+    elif echo "$word" | grep "^wan_gateway="; then
+        uci set network.wan.gateway=${word#*"="}
+    elif echo "$word" | grep "^wan_ipaddr="; then
+        uci set network.wan.ipaddr=${word#*"="}
+    elif echo "$word" | grep "^wan_broadcast="; then
+        uci set network.wan.broadcast=${word#*"="}
     fi
     next=${words#*" "}
     [ "$words" != "$next" ]
@@ -21,29 +25,11 @@
     words=$next
 done
 
-rule_name=$(uci add network rule)
-
-# Setup wan based on instance_num. Interface wan will occupy 192.168.96.X.
-if $bridged_host_network; then
-    uci set network.wan.gateway="192.168.96.1"
+if $bridged_wifi_tap; then
     uci set network.wan.netmask="255.255.255.0"
 else
-    d_class_wan_gateway=$(expr $instance_num \* 4 - 3);
-    uci set network.wan.gateway="192.168.96."$d_class_wan_gateway
     uci set network.wan.netmask="255.255.255.252"
 fi
-d_class_wan_ipaddr=$(expr $instance_num \* 4 - 2);
-d_class_wan_broadcast=$(expr $instance_num \* 4 - 1);
-uci set network.wan.ipaddr="192.168.96."$d_class_wan_ipaddr
-uci set network.wan.broadcast="192.168.96."$d_class_wan_broadcast
-
-# Setup wifi0 and wifi1 based on instance_num.
-# Interfaces wifi0 and wifi1 will occupy 192.168.2.X - 192.168.33.X.
-c_class_wifi=$(expr \( $instance_num + 3 \) / 2)
-d_class_wifi0=$(expr \( $instance_num % 2 \* 128 \) + 1)
-d_class_wifi1=$(expr \( $instance_num % 2 \* 128 \) + 65)
-uci set network.wifi0.ipaddr="192.168."$c_class_wifi"."$d_class_wifi0
-uci set network.wifi1.ipaddr="192.168."$c_class_wifi"."$d_class_wifi1
 
 uci commit