Merge pull request #105 from wigyori/chaos_calmer
[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 dir-615-i1 |\
225 tl-mr3420-v2 |\
226 tl-wr841n-v8 |\
227 tl-wr842n-v2 |\
228 tl-wr941nd-v5 |\
229 tl-wr941nd-v6 |\
230 wnr2000-v3 |\
231 wnr2000-v4 |\
232 wnr2200 |\
233 wnr612-v2 |\
234 wnr1000-v2 |\
235 wpn824n)
236         ucidef_set_interfaces_lan_wan "eth1" "eth0"
237         ucidef_add_switch "switch0" "1" "1"
238         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
239         ;;
240
241 uap-pro)
242         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
243         ucidef_add_switch "switch0" "1" "1"
244         ucidef_add_switch_vlan "switch0" "1" "0t 1"
245         ucidef_add_switch_vlan "switch0" "2" "0t 2"
246         ;;
247
248 nanostation-m-xw)
249         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
250         ucidef_add_switch "switch0" "1" "1"
251         ucidef_add_switch_vlan "switch0" "1" "0t 5"
252         ucidef_add_switch_vlan "switch0" "2" "0t 1"
253         ;;
254
255 wrt160nl)
256         ucidef_set_interfaces_lan_wan "eth0" "eth1"
257         ucidef_add_switch "switch0" "1" "1"
258         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 5"
259         ;;
260
261 wzr-hp-g300nh)
262         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
263         ucidef_add_switch "switch0" "1" "1"
264         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
265         ;;
266
267 dgl-5500-a1 |\
268 dir-825-c1)
269         local mac
270         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
271         ucidef_add_switch "switch0" "1" "1"
272         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
273         ucidef_add_switch_vlan "switch0" "2" "0t 5"
274         mac=$(mtd_get_mac_ascii nvram "wan_mac")
275         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
276         ;;
277
278 mynet-n750)
279         local mac
280         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
281         ucidef_add_switch "switch0" "1" "1"
282         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
283         ucidef_add_switch_vlan "switch0" "2" "0t 5"
284         mac=$(mtd_get_mac_ascii devdata "wanmac")
285         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
286         ;;
287
288 onion-omega)
289         ucidef_set_interface_lan "wlan0"
290         ;;
291
292 dhp-1565-a1 |\
293 dir-835-a1 |\
294 wndr3700v4 | \
295 wndr4300)
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_lan=$(mtd_get_mac_binary caldata 0)
301         [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
302         mac_wan=$(mtd_get_mac_binary caldata 6)
303         [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
304         ;;
305
306 esr900)
307         local mac
308         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
309         ucidef_add_switch "switch0" "1" "1"
310         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
311         ucidef_add_switch_vlan "switch0" "2" "0t 5"
312         mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
313         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
314         ;;
315
316 dlan-pro-500-wp)
317         ucidef_set_interface_lan "eth0 eth1"
318         ;;
319
320 dlan-pro-1200-ac)
321         ucidef_set_interface_lan "eth0"
322         ucidef_add_switch "switch0" "1" "0"
323         ucidef_add_switch_vlan "switch0" "0" "0 2 3 4"
324         ;;
325
326 alfa-ap120c |\
327 all0305 |\
328 antminer-s1 |\
329 antminer-s3 |\
330 aw-nr580 |\
331 bullet-m |\
332 cap4200ag |\
333 eap300v2 |\
334 eap7660d |\
335 el-mini |\
336 loco-m-xw |\
337 mr1750 |\
338 mr1750v2 |\
339 mr600 |\
340 mr600v2 |\
341 mr900 |\
342 mr900v2 |\
343 rb-411 |\
344 rb-911g-2hpnd |\
345 rb-911g-5hpacd |\
346 rb-911g-5hpnd |\
347 rb-912uag-2hpnd |\
348 rb-912uag-5hpnd |\
349 rb-sxt2n |\
350 rb-sxt5n |\
351 rocket-m-xw |\
352 tl-mr10u |\
353 tl-mr11u |\
354 tl-mr12u |\
355 tl-mr13u |\
356 tl-mr3020 |\
357 tl-mr3040 |\
358 tl-mr3040-v2 |\
359 tl-wa701nd-v2 |\
360 tl-wa7210n-v2 |\
361 tl-wa750re |\
362 tl-wa850re |\
363 tl-wa830re-v2 |\
364 tl-wa801nd-v2 |\
365 tl-wa901nd |\
366 tl-wa901nd-v2 |\
367 tl-wa901nd-v3 |\
368 tl-wa901nd-v4 |\
369 tl-wr703n |\
370 tube2h |\
371 wndap360 |\
372 mynet-rext |\
373 wp543)
374         ucidef_set_interface_lan "eth0"
375         ;;
376
377 dir-505-a1)
378         ucidef_set_interface_lan "eth1"
379         ;;
380
381 alfa-ap96 |\
382 alfa-nx |\
383 ap83 |\
384 gl-inet |\
385 jwap003 |\
386 pb42 |\
387 pb44 |\
388 routerstation|\
389 tl-wr710n |\
390 tl-wr720n-v3|\
391 wpe72)
392         ucidef_set_interfaces_lan_wan "eth1" "eth0"
393         ;;
394
395 wpj344)
396         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
397         ucidef_add_switch "switch0" "1" "1"
398         ucidef_add_switch_vlan "switch0" "1" "0t 3"
399         ucidef_add_switch_vlan "switch0" "2" "0t 2"
400         ;;
401
402 wpj531)
403         ucidef_set_interfaces_lan_wan "eth0" "eth1"
404         ;;
405
406 wpj558)
407         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
408         ucidef_add_switch "switch0" "1" "1"
409         ucidef_add_switch_vlan "switch0" "1" "5 6t"
410         ucidef_add_switch_vlan "switch0" "2" "1 6t"
411         ;;
412
413 ap121 |\
414 ap121-mini |\
415 ap96 |\
416 airrouter |\
417 dir-600-a1 |\
418 dir-615-c1 |\
419 dir-615-e1 |\
420 dir-615-e4 |\
421 hiwifi-hc6361 |\
422 ja76pf |\
423 mc-mac1200r|\
424 minibox-v1 |\
425 mynet-n600 |\
426 oolite |\
427 qihoo-c301 |\
428 rb-750 |\
429 rb-751 |\
430 tew-632brp |\
431 tew-712br |\
432 tew-732br |\
433 tl-mr3220 |\
434 tl-mr3220-v2 |\
435 tl-mr3420 |\
436 tl-wdr3500 |\
437 tl-wr741nd |\
438 tl-wr741nd-v4 |\
439 tl-wr841n-v7 |\
440 tl-wr841n-v9 |\
441 whr-g301n |\
442 whr-hp-g300n |\
443 whr-hp-gn |\
444 wzr-hp-ag300h)
445         ucidef_set_interfaces_lan_wan "eth0" "eth1"
446         ucidef_add_switch "switch0" "1" "1"
447         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
448         ;;
449
450 wzr-hp-g450h)
451         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
452         ucidef_add_switch "switch0" "1" "1"
453         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
454         ucidef_add_switch_vlan "switch0" "2" "0t 1"
455         ;;
456
457 ew-dorin)
458         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
459         ucidef_add_switch "switch0" "1" "1"
460         ucidef_add_switch_vlan "switch0" "1" "0t 1 2"
461         ucidef_add_switch_vlan "switch0" "2" "0t 3"
462         ;;
463
464 ew-dorin-router)
465         ucidef_set_interfaces_lan_wan "eth0" "eth1"
466         ucidef_add_switch "switch0" "1" "1"
467         ucidef_add_switch_vlan "switch0" "1" "0 2 3"
468         ;;
469
470 wndr3700)
471         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
472         ucidef_add_switch "switch0" "1" "1"
473         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
474         # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
475         uci set network.@switch[-1].blinkrate='2'
476
477         ucidef_add_switch_port "switch0" "1"
478         # Port 1 controls the GREEN configuration of LEDs for
479         # the switch and the section does not correspond to a real
480         # switch port.
481         #
482         # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
483         # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
484         # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
485         # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
486         # 14: Link (master); 15: separate register
487         uci set network.@switch_port[-1].led='6'
488
489         ucidef_add_switch_port "switch0" "2"
490         # Port 2 controls the ORANGE configuration of LEDs for
491         # the switch and the section does not correspond to a real
492         # switch port.
493         #
494         # See the key above for switch port 1 for the meaning of the
495         # 'led' setting below.
496         uci set network.@switch_port[-1].led='9'
497
498         ucidef_add_switch_port "switch0" "5"
499         # Port 5 controls the configuration of the WAN LED and the
500         # section does not correspond to a real switch port.
501         #
502         # To toggle the use of green or orange LEDs for the WAN port,
503         # see the LED setting for wndr3700:green:wan in /etc/config/system.
504         #
505         # See the key above for switch port 1 for the meaning of the
506         # 'led' setting below.
507         uci set network.@switch_port[-1].led='2'
508         ;;
509
510 *)
511         ucidef_set_interfaces_lan_wan "eth0" "eth1"
512         ;;
513 esac
514
515 uci commit network
516
517 exit 0