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