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