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