-#!/bin/ash
-
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
[ -n "$opt" -a -n "$val" ] || break
- json_add_string "$opt" "$val"
+ [ "$opt" = "device" -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
}
ucidef_set_interface_lan() {
- ucidef_set_interface "lan" ifname "$1" protocol "${2:-static}"
+ ucidef_set_interface "lan" device "$1" protocol "${2:-static}"
}
ucidef_set_interface_wan() {
- ucidef_set_interface "wan" ifname "$1" protocol "${2:-dhcp}"
+ ucidef_set_interface "wan" device "$1" protocol "${2:-dhcp}"
}
ucidef_set_interfaces_lan_wan() {
ucidef_set_bridge_device() {
json_select_object bridge
- json_add_string name "${1:switch0}"
+ json_add_string name "${1:-switch0}"
json_select ..
}
}
ucidef_set_network_device_mac() {
- json_select_object "network-device"
+ json_select_object "network_device"
json_select_object "${1}"
json_add_string macaddr "${2}"
json_select ..
json_select ..
}
+ucidef_set_network_device_path() {
+ json_select_object "network_device"
+ json_select_object "$1"
+ json_add_string path "$2"
+ json_select ..
+ json_select ..
+}
+
_ucidef_add_switch_port() {
# inherited: $num $device $need_tag $want_untag $role $index $prev_role
# inherited: $n_cpu $n_ports $n_vlan $cpu0 $cpu1 $cpu2 $cpu3 $cpu4 $cpu5
json_select_object "$role"
# attach previous interfaces (for multi-switch devices)
- json_get_var devices ifname
+ json_get_var devices device
if ! list_contains devices "$device"; then
devices="${devices:+$devices }$device"
fi
json_select ..
json_select ..
- ucidef_set_interface "$role" ifname "$devices"
+ ucidef_set_interface "$role" device "$devices"
done
}
json_select ..
}
+ucidef_set_led_heartbeat() {
+ _ucidef_set_led_common "$1" "$2" "$3"
+
+ json_add_string trigger heartbeat
+ json_select ..
+
+ json_select ..
+}
+
ucidef_set_led_gpio() {
local gpio="$4"
local inverted="$5"
json_select ..
}
+ucidef_add_wlan() {
+ local path="$1"; shift
+
+ ucidef_wlan_idx=${ucidef_wlan_idx:-0}
+
+ json_select_object wlan
+ json_select_object "wl$ucidef_wlan_idx"
+ json_add_string path "$path"
+ json_add_fields "$@"
+ json_select ..
+ json_select ..
+
+ ucidef_wlan_idx="$((ucidef_wlan_idx + 1))"
+}
+
board_config_update() {
json_init
[ -f ${CFG} ] && json_load "$(cat ${CFG})"