237d0264b39ef055a90e03c3544647ccb9489ece
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / etc / board.d / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011-2015 OpenWrt.org
4 #
5
6 . /lib/functions/system.sh
7 . /lib/functions/uci-defaults.sh
8 . /lib/ar71xx.sh
9
10 ar71xx_setup_interfaces()
11 {
12 local board="$1"
13
14 case "$board" in
15 airgatewaypro)
16 ucidef_add_switch "switch0" \
17 "0@eth0" "4:lan" "5:wan"
18 ;;
19 airrouter|\
20 ap121|\
21 ap121-mini|\
22 ap96|\
23 dir-600-a1|\
24 dir-615-c1|\
25 dir-615-e1|\
26 dir-615-e4|\
27 hiwifi-hc6361|\
28 ja76pf|\
29 mc-mac1200r|\
30 minibox-v1|\
31 mynet-n600|\
32 oolite|\
33 qihoo-c301|\
34 r602n|\
35 rb-750|\
36 rb-751|\
37 som9331|\
38 tew-632brp|\
39 tew-712br|\
40 tew-732br|\
41 tl-mr3220|\
42 tl-mr3220-v2|\
43 tl-mr3420|\
44 tl-wdr3320-v2|\
45 tl-wdr3500|\
46 tl-wr740n-v6|\
47 tl-wr741nd|\
48 tl-wr741nd-v4|\
49 tl-wr840n-v2|\
50 tl-wr840n-v3|\
51 tl-wr841n-v11|\
52 tl-wr841n-v9|\
53 tl-wr842n-v3|\
54 whr-g301n|\
55 whr-hp-g300n|\
56 whr-hp-gn|\
57 wzr-hp-ag300h|\
58 zbt-we1526)
59 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
60 ucidef_add_switch "switch0" \
61 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
62 ;;
63 alfa-ap120c|\
64 all0305|\
65 antminer-s1|\
66 antminer-s3|\
67 antrouter-r1|\
68 aw-nr580|\
69 bullet-m|\
70 c-55|\
71 cap4200ag|\
72 cf-e380ac-v1|\
73 cf-e380ac-v2|\
74 eap120|\
75 eap300v2|\
76 eap7660d|\
77 el-mini|\
78 hiveap-121|\
79 loco-m-xw|\
80 mr12|\
81 mr16|\
82 mr1750|\
83 mr1750v2|\
84 mr18|\
85 mr600|\
86 mr600v2|\
87 mr900|\
88 mr900v2|\
89 mynet-rext|\
90 pqi-air-pen|\
91 rb-411|\
92 rb-411u|\
93 rb-911g-2hpnd|\
94 rb-911g-5hpacd|\
95 rb-911g-5hpnd|\
96 rb-912uag-2hpnd|\
97 rb-912uag-5hpnd|\
98 rb-lhg-5nd|\
99 rb-mapl-2nd|\
100 rb-sxt2n|\
101 rb-sxt5n|\
102 re450|\
103 rocket-m-xw|\
104 sc300m |\
105 tl-mr10u|\
106 tl-mr11u|\
107 tl-mr12u|\
108 tl-mr13u|\
109 tl-mr3020|\
110 tl-mr3040|\
111 tl-mr3040-v2|\
112 tl-wa701nd-v2|\
113 tl-wa7210n-v2|\
114 tl-wa750re|\
115 tl-wa801nd-v2|\
116 tl-wa830re-v2|\
117 tl-wa850re|\
118 tl-wa850re-v2|\
119 tl-wa901nd|\
120 tl-wa901nd-v2|\
121 tl-wa901nd-v3|\
122 tl-wa901nd-v4|\
123 tl-wr703n|\
124 tl-wr802n-v1|\
125 tl-wr802n-v2|\
126 tube2h|\
127 unifiac-lite|\
128 wndap360|\
129 wp543)
130 ucidef_set_interface_lan "eth0"
131 ;;
132 a40|\
133 a60|\
134 alfa-ap96|\
135 alfa-nx|\
136 gl-ar150|\
137 gl-ar300m|\
138 gl-domino|\
139 gl-inet|\
140 gl-mifi|\
141 jwap003|\
142 om2pv4|\
143 om2p-hsv4|\
144 pb42|\
145 pb44|\
146 rb-750-r2|\
147 rb-750up-r2|\
148 rb-951ui-2hnd|\
149 rb-951ui-2nd|\
150 rb-952ui-5ac2nd|\
151 routerstation|\
152 tl-wr710n|\
153 tl-wr720n-v3|\
154 tl-wr810n|\
155 wpe72|\
156 wrtnode2q)
157 ucidef_set_interfaces_lan_wan "eth1" "eth0"
158 ;;
159 all0258n|\
160 all0315n|\
161 dlan-hotspot|\
162 dlan-pro-500-wp|\
163 dr344|\
164 ja76pf2|\
165 rocket-m-ti|\
166 ubnt-unifi-outdoor)
167 ucidef_set_interface_lan "eth0 eth1"
168 ;;
169 wzr-hp-g300nh2)
170 ucidef_add_switch "switch0" \
171 "0@eth0" "1:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "2:wan"
172 ;;
173 ap132|\
174 ap136|\
175 ap152|\
176 rb-750gl|\
177 rb-751g|\
178 rb-951g-2hnd|\
179 rb-962uigs-5hact2hnt|\
180 wlr8100|\
181 wzr-hp-g450h)
182 ucidef_add_switch "switch0" \
183 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
184 ;;
185 ap135-020|\
186 ap136-020|\
187 bhr-4grv2|\
188 tew-823dru|\
189 tl-wr1043nd-v2|\
190 wzr-450hp2)
191 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
192 ucidef_add_switch "switch0" \
193 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
194 ;;
195 ap136-010|\
196 ap147-010|\
197 nbg6616|\
198 nbg6716)
199 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
200 ucidef_add_switch "switch0" \
201 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
202 ;;
203 ap143|\
204 rb-433|\
205 rb-433u)
206 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
207 ucidef_add_switch "switch0" \
208 "1:lan" "2:lan" "5@eth1"
209 ;;
210 archer-c5|\
211 archer-c7|\
212 tl-wdr4900-v2)
213 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
214 ucidef_add_switch "switch0" \
215 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
216 ;;
217 archer-c59-v1|\
218 rb-450g)
219 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
220 ucidef_add_switch "switch0" \
221 "0@eth1" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
222 ;;
223 archer-c60-v1)
224 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
225 ucidef_add_switch "switch0" \
226 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
227 ;;
228 arduino-yun|\
229 dir-505-a1|\
230 tl-wa801nd-v3)
231 ucidef_set_interface_lan "eth1"
232 ;;
233 bsb)
234 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
235 ucidef_add_switch "switch0" \
236 "0@eth1" "1:lan" "3:lan"
237 ;;
238 c-60)
239 ucidef_add_switch "switch0" \
240 "0@eth0" "3:wan" "4:lan"
241 ;;
242 cap324)
243 ucidef_set_interface_lan "eth0" "dhcp"
244 ;;
245 cpe210|\
246 cpe510|\
247 wbs210|\
248 wbs510)
249 ucidef_add_switch "switch0" \
250 "0@eth0" "5:lan" "4:wan"
251 ;;
252 cr3000)
253 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
254 ucidef_add_switch "switch0" \
255 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
256 ;;
257 cr5000|\
258 dgl-5500-a1|\
259 dhp-1565-a1|\
260 dir-825-c1|\
261 dir-835-a1|\
262 esr900|\
263 mynet-n750|\
264 sr3200|\
265 wndr3700v4)
266 ucidef_add_switch "switch0" \
267 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
268 ;;
269 dap-2695-a1)
270 ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1"
271 ;;
272 rb-941-2nd)
273 ucidef_add_switch "switch0" \
274 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:wan:1"
275 ;;
276 db120|\
277 rb-2011il|\
278 rb-2011l|\
279 rb-2011uas|\
280 rb-2011uas-2hnd|\
281 rb-2011uias|\
282 rb-2011uias-2hnd)
283 case "$board" in
284 rb-2011uas*|\
285 rb-2011uias|\
286 rb-2011uias-2hnd)
287 ucidef_add_switch "switch0" \
288 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan" "6:sfp"
289 ;;
290 *)
291 ucidef_add_switch "switch0" \
292 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
293 ;;
294 esac
295
296 ucidef_add_switch "switch1" \
297 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
298 ;;
299 dir-615-i1|\
300 omy-g1|\
301 r6100|\
302 smart-300|\
303 tl-wdr6500-v2|\
304 tl-wr940n-v4|\
305 tl-wr941nd-v6|\
306 wnr1000-v2|\
307 wnr2000-v4|\
308 wnr2200|\
309 wnr612-v2|\
310 wpn824n)
311 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
312 ucidef_add_switch "switch0" \
313 "0@eth1" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
314 ;;
315 tl-mr6400)
316 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "usb0"
317 ucidef_add_switch "switch0" \
318 "0@eth0" "1:lan" "2:lan" "3:lan"
319 ;;
320 dir-825-b1|\
321 nbg460n_550n_550nh|\
322 tew-673gru|\
323 wzr-hp-g300nh)
324 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
325 ucidef_add_switch "switch0" \
326 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
327 ;;
328 dlan-pro-1200-ac)
329 ucidef_set_interface_lan "eth0"
330 ucidef_add_switch "switch0" \
331 "0u@eth0" "2:lan" "3:lan" "4:lan"
332 ucidef_add_switch_attr "switch0" "enable" "false"
333 ;;
334 ebr-2310-c1)
335 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
336 ucidef_add_switch "switch0" \
337 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
338 ;;
339 el-m150)
340 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
341 ucidef_add_switch "switch0" \
342 "0:lan" "1:lan" "3@eth1"
343 ;;
344 dir-869-a1|\
345 epg5000|\
346 esr1750|\
347 tl-wr1043nd-v4|\
348 wndr4300)
349 ucidef_add_switch "switch0" \
350 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
351 ;;
352 ew-dorin)
353 ucidef_add_switch "switch0" \
354 "0@eth0" "1:lan" "2:lan" "3:wan"
355 ;;
356 ew-dorin-router)
357 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
358 ucidef_add_switch "switch0" \
359 "0@eth0" "2:lan" "3:lan"
360 ;;
361 dw33d|\
362 f9k1115v2)
363 ucidef_set_interfaces_lan_wan "eth1.1" "eth0.2"
364 ucidef_add_switch "switch0" \
365 "2:lan" "3:lan" "4:lan" "5:lan" "6@eth1" "0@eth0" "1:wan"
366 ;;
367 gl-ar300|\
368 wnr2000-v3)
369 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
370 ucidef_add_switch "switch0" \
371 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
372 ;;
373 jwap230)
374 ucidef_set_interfaces_lan_wan "eth0.1" "eth1.2"
375 ucidef_add_switch "switch0" \
376 "0@eth0" "1:lan" "5:wan" "6@eth1"
377 ;;
378 nanostation-m-xw)
379 ucidef_add_switch "switch0" \
380 "0@eth0" "5:lan" "1:wan"
381 ;;
382 onion-omega)
383 ucidef_set_interface_lan "wlan0"
384 ;;
385 rb-435g)
386 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
387 ucidef_add_switch "switch0" \
388 "0@eth1" "1:lan" "2:lan"
389 ;;
390 rb-450)
391 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
392 ucidef_add_switch "switch0" \
393 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth1"
394 ;;
395 routerstation-pro)
396 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
397 ucidef_add_switch "switch0" \
398 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
399 ;;
400 rb-493g)
401 ucidef_set_interfaces_lan_wan "eth0.1 eth1.1" "eth1.2"
402 ucidef_add_switch "switch0" \
403 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
404 ucidef_add_switch "switch1" \
405 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
406 ;;
407 tellstick-znet-lite)
408 ucidef_set_interface_wan "eth0"
409 ucidef_set_interface_raw "wlan" "wlan0" "dhcp"
410 ;;
411 tl-mr3420-v2|\
412 tl-wr841n-v8|\
413 tl-wr842n-v2|\
414 tl-wr941nd-v5)
415 ucidef_set_interfaces_lan_wan "eth1.1" "eth0"
416 ucidef_add_switch "switch0" \
417 "0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
418 ;;
419 tl-wdr4300|\
420 tl-wr1041n-v2)
421 ucidef_add_switch "switch0" \
422 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
423 ;;
424 tl-wpa8630)
425 ucidef_add_switch "switch0" \
426 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
427 ;;
428 tl-wr1043nd)
429 ucidef_add_switch "switch0" \
430 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
431 ;;
432 tl-wr2543n)
433 ucidef_add_switch "switch0" \
434 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
435 ;;
436 tl-wr841n-v1|\
437 tl-wr941nd)
438 ucidef_set_interface_raw "eth" "eth0"
439 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
440 ;;
441 tl-wr841n-v7)
442 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
443 ucidef_add_switch "switch0" \
444 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4"
445 ;;
446 uap-pro|\
447 wpj342)
448 ucidef_add_switch "switch0" \
449 "0@eth0" "1:lan" "2:wan"
450 ;;
451 unifiac-pro|\
452 xd3200)
453 ucidef_add_switch "switch0" \
454 "0@eth0" "2:lan" "3:wan"
455 ;;
456 wndr3700|\
457 wndr3700v2|\
458 wndr3800|\
459 wndr3800ch)
460 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
461 ucidef_add_switch "switch0" \
462 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5@eth0"
463
464 ucidef_add_switch_attr "switch0" "blinkrate" 2
465 ucidef_add_switch_port_attr "switch0" 1 led 6
466 ucidef_add_switch_port_attr "switch0" 2 led 9
467 ucidef_add_switch_port_attr "switch0" 5 led 2
468 ;;
469 wpj344)
470 ucidef_add_switch "switch0" \
471 "0@eth0" "3:lan" "2:wan"
472 ;;
473 wpj558)
474 ucidef_add_switch "switch0" \
475 "5:lan" "1:wan" "6@eth0"
476 ;;
477 wpj563)
478 ucidef_add_switch "switch0" \
479 "0@eth0" "2:lan" "3:wan"
480 ;;
481 wrt160nl)
482 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
483 ucidef_add_switch "switch0" \
484 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4@eth0"
485 ;;
486 wzr-hp-g450h)
487 ucidef_add_switch "switch0" \
488 "0@eth0" "2:lan:1 3:lan:2 4:lan:3 5:lan:4" "1:wan"
489 ;;
490 z1)
491 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
492 ucidef_add_switch "switch0" \
493 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan"
494 ;;
495 *)
496 ucidef_set_interfaces_lan_wan "eth0" "eth1"
497 ;;
498 esac
499 }
500
501 ar71xx_setup_macs()
502 {
503 local board="$1"
504 local lan_mac=""
505 local wan_mac=""
506
507 case $board in
508 dgl-5500-a1|\
509 dir-825-c1)
510 wan_mac=$(mtd_get_mac_ascii nvram "wan_mac")
511 ;;
512 dhp-1565-a1|\
513 dir-835-a1|\
514 wndr3700v4|\
515 wndr4300)
516 lan_mac=$(mtd_get_mac_binary caldata 0)
517 wan_mac=$(mtd_get_mac_binary caldata 6)
518 ;;
519 tl-wr1043nd-v4)
520 wan_mac=$(mtd_get_mac_binary config 0x1017c)
521 ;;
522 esr900)
523 wan_mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
524 ;;
525 dir-869-a1|\
526 mynet-n750)
527 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
528 ;;
529 esac
530
531 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
532 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
533 }
534
535 board_config_update
536 board=$(ar71xx_board_name)
537 ar71xx_setup_interfaces $board
538 ar71xx_setup_macs $board
539 board_config_flush
540
541 exit 0