d8a5697361461941033221915b288343114b6139
[openwrt/staging/dedeckeh.git] / target / linux / ipq40xx / base-files / etc / board.d / 02_network
1 #!/bin/sh
2 #
3 # Copyright (c) 2015 The Linux Foundation. All rights reserved.
4 # Copyright (c) 2011-2015 OpenWrt.org
5 #
6
7 . /lib/functions/uci-defaults.sh
8 . /lib/functions/system.sh
9
10 ipq40xx_setup_interfaces()
11 {
12 local board="$1"
13
14 case "$board" in
15 8dev,jalapeno|\
16 alfa-network,ap120c-ac|\
17 engenius,ens620ext)
18 ucidef_set_interfaces_lan_wan "eth0" "eth1"
19 ;;
20 asus,map-ac2200|\
21 openmesh,a42|\
22 openmesh,a62)
23 ucidef_set_interfaces_lan_wan "eth1" "eth0"
24 ;;
25 asus,rt-ac58u|\
26 zyxel,nbg6617)
27 ucidef_set_interfaces_lan_wan "eth0" "eth1"
28 ucidef_add_switch "switch0" \
29 "0u@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
30 ;;
31 avm,fritzbox-4040|\
32 linksys,ea6350v3)
33 ucidef_set_interfaces_lan_wan "eth0" "eth1"
34 ucidef_add_switch "switch0" \
35 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
36 ;;
37 avm,fritzbox-7530)
38 ucidef_add_switch "switch0" \
39 "0u@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
40 ;;
41 avm,fritzrepeater-3000|\
42 compex,wpj428)
43 ucidef_set_interface_lan "eth0 eth1"
44 ;;
45 engenius,eap1300|\
46 meraki,mr33|\
47 netgear,ex6100v2|\
48 netgear,ex6150v2|\
49 zyxel,wre6606)
50 ucidef_set_interface_lan "eth0"
51 ;;
52 glinet,gl-b1300)
53 ucidef_set_interfaces_lan_wan "eth0" "eth1"
54 ucidef_add_switch "switch0" \
55 "0u@eth0" "3:lan" "4:lan"
56 ;;
57 qxwlan,e2600ac-c1 |\
58 qxwlan,e2600ac-c2)
59 ucidef_set_interfaces_lan_wan "eth0" "eth1"
60 ucidef_add_switch "switch0" \
61 "0u@eth0" "3:lan" "4:lan" "0u@eth1" "5:wan"
62 ;;
63 *)
64 echo "Unsupported hardware. Network interfaces not initialized"
65 ;;
66 esac
67 }
68
69 ipq40xx_setup_macs()
70 {
71 local board="$1"
72
73 case "$board" in
74 asus,rt-ac58u)
75 CI_UBIPART=UBI_DEV
76 wan_mac=$(mtd_get_mac_binary_ubi Factory 20486)
77 lan_mac=$(mtd_get_mac_binary_ubi Factory 4102)
78 ;;
79 engenius,ens620ext)
80 wan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
81 lan_mac=$(macaddr_add "$wan_mac" 1)
82 ;;
83 linksys,ea6350v3)
84 wan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr)
85 lan_mac=$(macaddr_add "$wan_mac" 1)
86 ;;
87 esac
88
89 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
90 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
91 }
92
93 board_config_update
94 board=$(board_name)
95 ipq40xx_setup_interfaces $board
96 ipq40xx_setup_macs $board
97 board_config_flush
98
99 exit 0