ar71xx: base-files: rework etc/board.d/02_network

Convert etc/board.d/02_network in ar71xx target to the same shape
as we have in ramips target. Split code into two new functions:

- interface/s setup in ar71xx_setup_interfaces()
- MAC/s setup in ar71xx_setup_macs()

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
This commit is contained in:
Piotr Dymacz 2016-09-27 23:41:12 +02:00 committed by John Crispin
parent 4ef1144958
commit 4fa90c49c1

View file

@ -7,10 +7,9 @@
. /lib/functions/uci-defaults.sh
. /lib/ar71xx.sh
board_config_update
board=$(ar71xx_board_name)
ar71xx_setup_interfaces()
{
local board="$1"
case "$board" in
all0315n |\
@ -270,19 +269,13 @@ cr3000)
dgl-5500-a1 |\
dir-825-c1)
local mac
ucidef_add_switch "switch0" \
"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
mac=$(mtd_get_mac_ascii nvram "wan_mac")
[ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
;;
mynet-n750)
local mac
ucidef_add_switch "switch0" \
"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
mac=$(mtd_get_mac_ascii devdata "wanmac")
[ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
;;
onion-omega)
@ -295,18 +288,11 @@ wndr3700v4 | \
wndr4300)
ucidef_add_switch "switch0" \
"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
mac_lan=$(mtd_get_mac_binary caldata 0)
[ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
mac_wan=$(mtd_get_mac_binary caldata 6)
[ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
;;
esr900)
local mac
ucidef_add_switch "switch0" \
"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
[ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
;;
dlan-hotspot |\
@ -548,7 +534,42 @@ z1)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
esac
}
ar71xx_setup_macs()
{
local board="$1"
local lan_mac=""
local wan_mac=""
case $board in
dgl-5500-a1|\
dir-825-c1)
wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
;;
dhp-1565-a1|\
dir-835-a1|\
wndr3700v4|\
wndr4300)
lan_mac=$(mtd_get_mac_binary caldata 0)
wan_mac=$(mtd_get_mac_binary caldata 6)
;;
esr900)
wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
;;
mynet-n750)
wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
}
board_config_update
board=$(ar71xx_board_name)
ar71xx_setup_interfaces $board
ar71xx_setup_macs $board
board_config_flush
exit 0