mountd: update to latest git HEAD
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6 . /lib/functions/system.sh
7
8 ramips_setup_rt3x5x_vlans()
9 {
10 if [ ! -x /sbin/swconfig ]; then
11 # legacy default
12 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
13 return
14 fi
15 local wanports=""
16 local lanports=""
17 for port in 5 4 3 2 1 0; do
18 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
19 continue
20 fi
21 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
22 wanports="$port:wan $wanports"
23 else
24 lanports="$port:lan $lanports"
25 fi
26 done
27 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28 ucidef_add_switch "rt305x" $lanports $wanports "6@eth0"
29 }
30
31 ramips_setup_interfaces()
32 {
33 local board="$1"
34
35 case $board in
36 3g150b|\
37 3g300m|\
38 a5-v11|\
39 all0256n|\
40 all5002|\
41 all5003|\
42 broadway|\
43 dcs-930|\
44 dcs-930l-b1|\
45 ht-tm02|\
46 linkits7688 | \
47 linkits7688d | \
48 m2m|\
49 microwrt|\
50 mpr-a2|\
51 ncs601w|\
52 w150m|\
53 widora-neo|\
54 wnce2001|\
55 zte-q7)
56 ucidef_add_switch "switch0"
57 ucidef_add_switch_attr "switch0" "enable" "false"
58 ucidef_set_interface_lan "eth0"
59 ;;
60 3g-6200nl|\
61 mlw221|\
62 mr-102n)
63 ucidef_set_interface_lan "eth0.2"
64 ;;
65 3g-6200n|\
66 ai-br100|\
67 db-wrt01|\
68 dir-300-b7|\
69 dir-320-b1|\
70 dir-610-a1|\
71 dir-615-h1|\
72 firewrt|\
73 hlk-rm04|\
74 miwifi-mini|\
75 miwifi-nano|\
76 mt7621|\
77 mt7628|\
78 mzk-750dhp|\
79 mzk-w300nh2|\
80 oy-0001|\
81 pbr-m1|\
82 psg1208|\
83 sap-g3200u3|\
84 sk-wb8|\
85 wf-2881|\
86 whr-300hp2|\
87 whr-600d|\
88 witi|\
89 wndr3700v5|\
90 wsr-1166|\
91 wsr-600|\
92 wt1520|\
93 y1|\
94 zbt-wg2626|\
95 zbt-wg3526|\
96 youku-yk1)
97 ucidef_add_switch "switch0" \
98 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
99 ;;
100 ar670w|\
101 ar725w|\
102 rt-n15|\
103 wl-351)
104 ucidef_add_switch "switch0" \
105 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
106 ;;
107 asl26555|\
108 re6500|\
109 rp-n53)
110 ucidef_add_switch "switch0" \
111 "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
112 ;;
113 atp-52b|\
114 awm002-evb|\
115 awm003-evb|\
116 c50|\
117 dir-645|\
118 dir-860l-b1|\
119 f5d8235-v1|\
120 f5d8235-v2|\
121 gl-mt300a|\
122 gl-mt300n|\
123 gl-mt750|\
124 hg255d|\
125 mzk-wdpr|\
126 jhr-n805r|\
127 jhr-n825r|\
128 jhr-n926r|\
129 rt-n14u|\
130 ubnt-erx|\
131 ur-326n4g|\
132 wrtnode|\
133 wrtnode2p | \
134 wrtnode2r | \
135 wt3020|\
136 zbt-wa05)
137 ucidef_add_switch "switch0" \
138 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
139 ;;
140 awapn2403)
141 ucidef_add_switch "switch0" \
142 "0:lan" "1:wan" "6@eth0"
143 ;;
144 b2c|\
145 nw718|\
146 psr-680w|\
147 sl-r7205|\
148 ur-336un|\
149 w502u|\
150 wr6202)
151 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
152 ;;
153 br-6475nd)
154 ucidef_add_switch "switch0" \
155 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
156 ;;
157 cf-wr800n|\
158 ex2700)
159 ucidef_add_switch "switch0" \
160 "4:lan" "6t@eth0"
161 ;;
162 cy-swr1100)
163 ucidef_add_switch "switch0" \
164 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0"
165 ;;
166 cs-qr10|\
167 d105|\
168 hpm|\
169 mzk-ex300np|\
170 mzk-ex750np|\
171 na930|\
172 wli-tx4-ag300n|\
173 wrh-300cr)
174 ucidef_set_interface_lan "eth0"
175 ;;
176 duzun-dm06)
177 ucidef_add_switch "switch0" \
178 "1:lan" "0:wan" "6@eth0"
179 ;;
180 e1700|\
181 mt7620a_mt7530)
182 ucidef_add_switch "switch1" \
183 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
184 ;;
185 hc5*61|\
186 y1s)
187 ucidef_add_switch "switch0" \
188 "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
189 ;;
190 mlwg2|\
191 wizard8800|\
192 wl-330n|\
193 wmr-300)
194 ucidef_set_interface_lan "eth0.1"
195 ;;
196 mzk-dp150n|\
197 vocore)
198 ucidef_add_switch "switch0" \
199 "0:lan" "4:lan" "6t@eth0"
200 ;;
201 rt-n56u)
202 ucidef_add_switch "switch0" \
203 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "8@eth0"
204 ;;
205 tew-691gr|\
206 tew-692gr)
207 ucidef_add_switch "switch0" \
208 "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
209 ;;
210 v11st-fe|\
211 wzr-agl300nh)
212 ucidef_add_switch "switch0" \
213 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
214 ;;
215 wcr-150gn)
216 ucidef_add_switch "switch0" \
217 "0:lan" "6t@eth0"
218 ;;
219 whr-1166d)
220 ucidef_add_switch "switch0" \
221 "0:lan" "1:lan" "2:lan" "3:lan" "5:wan" "6@eth0"
222 ;;
223 wizfi630a)
224 ucidef_add_switch "switch0" \
225 "1:lan" "2:lan" "0:wan" "6@eth0"
226 ;;
227 zbt-we826|\
228 zbt-wr8305rt)
229 ucidef_add_switch "switch0" \
230 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
231 ;;
232 *)
233 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
234 if [ -n "${RT3X5X}" ]; then
235 ramips_setup_rt3x5x_vlans
236 else
237 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
238 fi
239 ;;
240 esac
241 }
242
243 ramips_setup_macs()
244 {
245 local board="$1"
246 local lan_mac=""
247 local wan_mac=""
248
249 case $board in
250 a5-v11|\
251 ht-tm02)
252 lan_mac=$(cat /sys/class/net/eth0/address)
253 ;;
254 all0239-3g|\
255 carambola|\
256 freestation5|\
257 w502u|\
258 wnce2001)
259 wan_mac=$(mtd_get_mac_binary factory 46)
260 ;;
261 bc2|\
262 broadway|\
263 d105|\
264 dir-300-b7|\
265 dir-320-b1|\
266 dir-620-a1|\
267 esr-9753|\
268 freestation5|\
269 hlk-rm04|\
270 mpr-a1|\
271 psr-680w|\
272 sl-r7205|\
273 y1|\
274 y1s)
275 lan_mac=$(cat /sys/class/net/eth0/address)
276 lan_mac=$(macaddr_setbit_la "$lan_mac")
277 wan_mac=$(macaddr_add "$lan_mac" 1)
278 ;;
279 br-6475nd)
280 lan_mac=$(cat /sys/class/net/eth0/address)
281 wan_mac=$(mtd_get_mac_binary devdata 7)
282 ;;
283 cy-swr1100|\
284 dir-645)
285 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
286 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
287 ;;
288 e1700)
289 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
290 ;;
291 hc5*61)
292 lan_mac=`mtd_get_mac_ascii bdinfo "Vfac_mac "`
293 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
294 wan_mac=$(macaddr_add "$lan_mac" 1)
295 ;;
296 linkits7688 | \
297 linkits7688d)
298 wan_mac=$(mtd_get_mac_binary factory 4)
299 lan_mac=$(mtd_get_mac_binary factory 46)
300 ;;
301 m3|\
302 m4|\
303 x5|\
304 x8)
305 lan_mac=$(cat /sys/class/net/eth0/address)
306 lan_mac=$(macaddr_add "$lan_mac" -2)
307 ;;
308 oy-0001)
309 lan_mac=$(mtd_get_mac_binary factory 40)
310 wan_mac=$(mtd_get_mac_binary factory 46)
311 ;;
312 rt-n56u)
313 lan_mac=$(cat /sys/class/net/eth0/address)
314 lan_mac=$(macaddr_setbit_la "$lan_mac")
315 wan_mac=$(mtd_get_mac_binary factory 32772)
316 ;;
317 sk-wb8)
318 wan_mac=$(mtd_get_mac_binary factory 57350)
319 ;;
320 tew-691gr)
321 lan_mac=$(cat /sys/class/net/eth0/address)
322 wan_mac=$(macaddr_add "$lan_mac" 3)
323 ;;
324 tew-692gr)
325 lan_mac=$(cat /sys/class/net/eth0/address)
326 wan_mac=$(macaddr_add "$lan_mac" 4)
327 ;;
328 tiny-ac)
329 lan_mac=$(mtd_get_mac_ascii u-boot-env LAN_MAC_ADDR)
330 wan_mac=$(mtd_get_mac_ascii u-boot-env WAN_MAC_ADDR)
331 ;;
332 w306r-v20)
333 lan_mac=$(cat /sys/class/net/eth0/address)
334 wan_mac=$(macaddr_add "$lan_mac" 5)
335 ;;
336 wcr-150gn)
337 wan_mac=$(mtd_get_mac_binary factory 40)
338 ;;
339 whr-1166d|\
340 whr-300hp2|\
341 whr-600d|\
342 wsr-600)
343 wan_mac=$(mtd_get_mac_binary factory 4)
344 lan_mac=$wan_mac
345 ;;
346 wizfi630a)
347 lan_mac=$(mtd_get_mac_binary factory 4)
348 wan_mac=$(mtd_get_mac_binary factory 40)
349 ;;
350 wsr-1166)
351 local index="$(find_mtd_index "board_data")"
352 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
353 lan_mac=$wan_mac
354 ;;
355 *)
356 lan_mac=$(cat /sys/class/net/eth0/address)
357 wan_mac=$(macaddr_add "$lan_mac" 1)
358 ;;
359 esac
360
361 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
362 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
363 }
364
365 board_config_update
366 board=$(ramips_board_name)
367 ramips_setup_interfaces $board
368 ramips_setup_macs $board
369 board_config_flush
370
371 exit 0