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