f7e43addc1abd0434c2068e96fd1a0b95b540ee8
[openwrt/openwrt.git] / target / linux / ath79 / nand / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/functions/uci-defaults.sh
5
6 ath79_setup_interfaces()
7 {
8 local board="$1"
9
10 case "$board" in
11 aerohive,hiveap-121)
12 ucidef_set_interface_lan "eth0"
13 ;;
14 glinet,gl-ar750s-nor|\
15 glinet,gl-ar750s-nor-nand)
16 ucidef_add_switch "switch0" \
17 "0@eth0" "2:lan:2" "3:lan:1" "1:wan"
18 ;;
19 netgear,wndr3700-v4|\
20 netgear,wndr4300)
21 ucidef_add_switch "switch0" \
22 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
23 ;;
24 zyxel,nbg6716)
25 ucidef_add_switch "switch0" \
26 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
27 ;;
28 *)
29 ucidef_set_interfaces_lan_wan "eth0" "eth1"
30 ;;
31 esac
32 }
33
34 ath79_setup_macs()
35 {
36 local board="$1"
37
38 case "$board" in
39 netgear,wndr3700-v4|\
40 netgear,wndr4300)
41 wan_mac=$(mtd_get_mac_binary caldata 0x6)
42 ;;
43 zyxel,nbg6716)
44 lan_mac=$(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +2)
45 wan_mac=$(macaddr_add $(mtd_get_mac_ascii u-boot-env ethaddr) +3)
46 ;;
47 esac
48
49 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
50 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
51 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
52 }
53
54 board_config_update
55 board=$(board_name)
56 ath79_setup_interfaces $board
57 ath79_setup_macs $board
58 board_config_flush
59
60 exit 0