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