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