ath79: ubnt-xm: disable WAN on (rocket|bullet)-m
[openwrt/openwrt.git] / target / linux / ath79 / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions/system.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/k2t.sh
6
7 ath79_setup_interfaces()
8 {
9 local board="$1"
10
11 case "$board" in
12 avm,fritz300e|\
13 ocedo,koala|\
14 ocedo,raccoon|\
15 pcs,cap324|\
16 pisen,wmm003n|\
17 tplink,re450-v2|\
18 tplink,tl-mr10u|\
19 tplink,tl-mr3020-v1|\
20 tplink,tl-mr3040-v2|\
21 tplink,tl-wr703n|\
22 ubnt,bullet-m|\
23 ubnt,rocket-m|\
24 ubnt,unifiac-lite|\
25 ubnt,unifiac-mesh|\
26 ubnt,unifi)
27 ucidef_set_interface_lan "eth0"
28 ;;
29 buffalo,wzr-hp-g450h)
30 ucidef_add_switch "switch0" \
31 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
32 ;;
33 buffalo,bhr-4grv2)
34 ucidef_add_switch "switch0" \
35 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
36 ;;
37 dlink,dir-825-b1)
38 ucidef_set_interface_wan "eth1"
39 ucidef_add_switch "switch0" \
40 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
41 ;;
42 embeddedwireless,dorin)
43 ucidef_add_switch "switch0" \
44 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
45 ;;
46 etactica,eg200)
47 ucidef_set_interface_lan "eth0" "dhcp"
48 ;;
49 avm,fritz4020|\
50 glinet,ar150|\
51 glinet,ar300m)
52 ucidef_set_interfaces_lan_wan "eth1" "eth0"
53 ;;
54 iodata,etg3-r|\
55 iodata,wn-ac1167dgr|\
56 iodata,wn-ac1600dgr2|\
57 pcs,cr5000)
58 ucidef_add_switch "switch0" \
59 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
60 ;;
61 netgear,wndr3700|\
62 netgear,wndr3700v2|\
63 netgear,wndr3800)
64 ucidef_set_interfaces_lan_wan "eth0" "eth1"
65 ucidef_add_switch "switch0" \
66 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
67 ucidef_add_switch_attr "switch0" "blinkrate" 2
68 ucidef_add_switch_port_attr "switch0" 1 led 6
69 ucidef_add_switch_port_attr "switch0" 2 led 9
70 ucidef_add_switch_port_attr "switch0" 5 led 2
71 ;;
72 netgear,wnr612-v2|\
73 on,n150r)
74 ucidef_set_interface_wan "eth0"
75 ucidef_add_switch "switch0" \
76 "0@eth1" "1:lan" "2:lan" "3:lan:3" "4:lan:4"
77 ;;
78 pcs,cr3000)
79 ucidef_add_switch "switch0" \
80 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
81 ucidef_set_interface_wan "eth0"
82 ;;
83 phicomm,k2t)
84 ucidef_add_switch "switch0" \
85 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
86 ;;
87 tplink,archer-c7-v1|\
88 tplink,archer-c7-v2|\
89 tplink,tl-wdr4900-v2)
90 ucidef_add_switch "switch0" \
91 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
92 ;;
93 buffalo,whr-g301n|\
94 tplink,tl-mr3220-v1|\
95 tplink,tl-mr3420-v1|\
96 tplink,tl-wr841-v7)
97 ucidef_set_interface_wan "eth0"
98 ucidef_add_switch "switch0" \
99 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
100 ;;
101 tplink,tl-wdr3600|\
102 tplink,tl-wdr4300)
103 ucidef_add_switch "switch0" \
104 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
105 ;;
106 tplink,tl-wr1043nd-v1)
107 ucidef_add_switch "switch0" \
108 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
109 ;;
110 tplink,tl-wr1043nd-v2|\
111 tplink,tl-wr1043nd-v3)
112 ucidef_add_switch "switch0" \
113 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
114 ;;
115 tplink,tl-wr1043nd-v4)
116 ucidef_add_switch "switch0" \
117 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
118 ;;
119 tplink,tl-wr2543-v1)
120 ucidef_add_switch "switch0" \
121 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
122 ;;
123 tplink,tl-wr740n-v1|\
124 tplink,tl-wr740n-v3|\
125 tplink,tl-wr741-v1|\
126 tplink,tl-wr743nd-v1|\
127 tplink,tl-wr841-v5|\
128 tplink,tl-wr941-v4)
129 ucidef_set_interface_wan "eth0"
130 ucidef_add_switch "switch0" \
131 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
132 ;;
133 tplink,tl-wr740nd-v4|\
134 tplink,tl-wr741nd-v4|\
135 tplink,tl-wr841-v9|\
136 tplink,tl-wr841-v11)
137 ucidef_set_interface_wan "eth0"
138 ucidef_add_switch "switch0" \
139 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
140 ;;
141 tplink,tl-wr941-v2)
142 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
143 ;;
144 ubnt,unifiac-mesh-pro|\
145 ubnt,unifiac-pro)
146 ucidef_add_switch "switch0" \
147 "0@eth0" "2:lan" "3:wan"
148 ;;
149 *)
150 ucidef_set_interfaces_lan_wan "eth0" "eth1"
151 ;;
152 esac
153 }
154
155 ath79_setup_macs()
156 {
157 local board="$1"
158
159 case "$board" in
160 avm,fritz300e)
161 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
162 ;;
163 avm,fritz4020)
164 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
165 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
166 ;;
167 dlink,dir-825-b1)
168 lan_mac=$(mtd_get_mac_text "caldata" 65440)
169 wan_mac=$(mtd_get_mac_text "caldata" 65460)
170 ;;
171 iodata,etg3-r)
172 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
173 wan_mac=$(macaddr_add "$lan_mac" -1)
174 ;;
175 iodata,wn-ac1167dgr|\
176 iodata,wn-ac1600dgr2)
177 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
178 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
179 ;;
180 netgear,wndr3700|\
181 netgear,wndr3700v2|\
182 netgear,wndr3800)
183 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0)")
184 ;;
185 phicomm,k2t)
186 lan_mac=$(k2t_get_mac "lan_mac")
187 wan_mac=$(k2t_get_mac "wan_mac")
188 ;;
189 tplink,tl-wr1043nd-v4)
190 base_mac=$(mtd_get_mac_binary product-info 8)
191 wan_mac=$(macaddr_add "$base_mac" 1)
192 ;;
193 tplink,tl-wr941-v2)
194 base_mac=$(mtd_get_mac_binary u-boot 130048)
195 wan_mac=$(macaddr_add "$base_mac" 1)
196 ;;
197 esac
198
199 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
200 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
201 }
202
203 board_config_update
204 board=$(board_name)
205 ath79_setup_interfaces $board
206 ath79_setup_macs $board
207 board_config_flush
208
209 exit 0