aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-12-03 17:30:24 +0000
committerJo-Philipp Wich <jow@openwrt.org>2015-12-03 17:30:24 +0000
commit9b02e73188158829d48835906edbb8702fd95e28 (patch)
treef7592cc1db8ad3aac0040b011b106c73048acb97 /package/base-files/files/lib
parentd17a64c7c01e2f0bb79123250ec6ea5f4fb8ec6e (diff)
downloadupstream-9b02e73188158829d48835906edbb8702fd95e28.tar.gz
upstream-9b02e73188158829d48835906edbb8702fd95e28.tar.bz2
upstream-9b02e73188158829d48835906edbb8702fd95e28.zip
board.d: merge ucidef_add_switch() and ucidef_add_switch_ports()
This changes uci-defaults-new.sh, config_generate and all relevant board.d files in order combine ucidef_add_switch() and ucidef_add_switch_ports() into a single function. Also removes now superfluous enable and reset arguments. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> SVN-Revision: 47721
Diffstat (limited to 'package/base-files/files/lib')
-rwxr-xr-xpackage/base-files/files/lib/functions/uci-defaults-new.sh110
1 files changed, 50 insertions, 60 deletions
diff --git a/package/base-files/files/lib/functions/uci-defaults-new.sh b/package/base-files/files/lib/functions/uci-defaults-new.sh
index e652a8b521..f025cb696e 100755
--- a/package/base-files/files/lib/functions/uci-defaults-new.sh
+++ b/package/base-files/files/lib/functions/uci-defaults-new.sh
@@ -82,35 +82,6 @@ ucidef_set_interfaces_lan_wan() {
json_select ..
}
-ucidef_add_switch() {
- local name="$1"
-
- json_select_object switch
- json_select_object "$name"
- json_add_boolean enable 1
- json_add_boolean reset 1
- json_select ..
- json_select ..
-}
-
-ucidef_add_switch_attr() {
- local name="$1"
- local key="$2"
- local val="$3"
-
- json_select_object switch
- json_select_object "$name"
-
- case "$val" in
- true|false) [ "$val" != "true" ]; json_add_boolean "$key" $? ;;
- [0-9]) json_add_int "$key" "$val" ;;
- *) json_add_string "$key" "$val" ;;
- esac
-
- json_select ..
- json_select ..
-}
-
_ucidef_add_switch_port() {
# inherited: $num $device $need_tag $role $index $prev_role
# inherited: $n_cpu $n_ports $n_vlan $cpu0 $cpu1 $cpu2 $cpu3 $cpu4 $cpu5
@@ -205,50 +176,69 @@ _ucidef_finish_switch_roles() {
done
}
-ucidef_add_switch_ports() {
+ucidef_add_switch() {
local name="$1"; shift
local port num role device index need_tag prev_role
local cpu0 cpu1 cpu2 cpu3 cpu4 cpu5
local n_cpu=0 n_vlan=0 n_ports=0
json_select_object switch
- json_select_object "$name"
-
- for port in "$@"; do
- case "$port" in
- [0-9]*@*)
- num="${port%%@*}"
- device="${port##*@}"
- need_tag=0
- [ "${num%t}" != "$num" ] && {
- num="${num%t}"
- need_tag=1
- }
- ;;
- [0-9]*:*:[0-9]*)
- num="${port%%:*}"
- index="${port##*:}"
- role="${port#[0-9]*:}"; role="${role%:*}"
- ;;
- [0-9]*:*)
- num="${port%%:*}"
- role="${port##*:}"
- ;;
- esac
-
- if [ -n "$num" ] && [ -n "$device$role" ]; then
- _ucidef_add_switch_port
- fi
+ json_select_object "$name"
+ json_add_boolean enable 1
+ json_add_boolean reset 1
- unset num device role index need_tag
- done
+ for port in "$@"; do
+ case "$port" in
+ [0-9]*@*)
+ num="${port%%@*}"
+ device="${port##*@}"
+ need_tag=0
+ [ "${num%t}" != "$num" ] && {
+ num="${num%t}"
+ need_tag=1
+ }
+ ;;
+ [0-9]*:*:[0-9]*)
+ num="${port%%:*}"
+ index="${port##*:}"
+ role="${port#[0-9]*:}"; role="${role%:*}"
+ ;;
+ [0-9]*:*)
+ num="${port%%:*}"
+ role="${port##*:}"
+ ;;
+ esac
+
+ if [ -n "$num" ] && [ -n "$device$role" ]; then
+ _ucidef_add_switch_port
+ fi
- json_select ..
+ unset num device role index need_tag
+ done
+ json_select ..
json_select ..
_ucidef_finish_switch_roles
}
+ucidef_add_switch_attr() {
+ local name="$1"
+ local key="$2"
+ local val="$3"
+
+ json_select_object switch
+ json_select_object "$name"
+
+ case "$val" in
+ true|false) [ "$val" != "true" ]; json_add_boolean "$key" $? ;;
+ [0-9]) json_add_int "$key" "$val" ;;
+ *) json_add_string "$key" "$val" ;;
+ esac
+
+ json_select ..
+ json_select ..
+}
+
ucidef_add_switch_port_attr() {
local name="$1"
local port="$2"