base-files: use "ports" array in board.json network for bridges
[openwrt/openwrt.git] / package / base-files / files / lib / functions / uci-defaults.sh
old mode 100755 (executable)
new mode 100644 (file)
index 39bbeda..407a9c7
@@ -1,5 +1,3 @@
-#!/bin/ash
-
 . /lib/functions.sh
 . /usr/share/libubox/jshn.sh
 
@@ -41,7 +39,13 @@ ucidef_set_interface() {
 
                [ -n "$opt" -a -n "$val" ] || break
 
-               json_add_string "$opt" "$val"
+               [ "$opt" = "ifname" -a "$val" != "${val/ //}" ] && {
+                       json_select_array "ports"
+                       for e in $val; do json_add_string "" "$e"; done
+                       json_close_array
+               } || {
+                       json_add_string "$opt" "$val"
+               }
        done
 
        if ! json_is_a protocol string; then
@@ -91,7 +95,23 @@ ucidef_set_interfaces_lan_wan() {
 }
 
 ucidef_set_bridge_device() {
-       json_add_string bridge "${1:switch0}"
+       json_select_object bridge
+       json_add_string name "${1:switch0}"
+       json_select ..
+}
+
+ucidef_set_bridge_mac() {
+       json_select_object bridge
+       json_add_string macaddr "${1}"
+       json_select ..
+}
+
+ucidef_set_network_device_mac() {
+       json_select_object "network-device"
+       json_select_object "${1}"
+       json_add_string macaddr "${2}"
+       json_select ..
+       json_select ..
 }
 
 _ucidef_add_switch_port() {