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