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