63422daa3019d498976ab5c0e32af600d6b3e999
[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 gl-inet |\
293 jwap003 |\
294 pb42 |\
295 pb44 |\
296 routerstation|\
297 tl-wr710n |\
298 tl-wr720n-v3|\
299 wpe72)
300         ucidef_set_interfaces_lan_wan "eth1" "eth0"
301         ;;
302
303 ap121 |\
304 ap121-mini |\
305 ap96 |\
306 airrouter |\
307 dir-600-a1 |\
308 dir-615-c1 |\
309 dir-615-e1 |\
310 dir-615-e4 |\
311 hiwifi-hc6361 |\
312 ja76pf |\
313 mynet-n600 |\
314 oolite |\
315 rb-750 |\
316 rb-751 |\
317 tew-632brp |\
318 tew-712br |\
319 tl-mr3220 |\
320 tl-mr3220-v2 |\
321 tl-mr3420 |\
322 tl-wdr3500 |\
323 tl-wr741nd |\
324 tl-wr741nd-v4 |\
325 tl-wr841n-v7 |\
326 tl-wr841n-v9 |\
327 whr-g301n |\
328 whr-hp-g300n |\
329 whr-hp-gn |\
330 wzr-hp-ag300h)
331         ucidef_set_interfaces_lan_wan "eth0" "eth1"
332         ucidef_add_switch "switch0" "1" "1"
333         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
334         ;;
335
336 wzr-hp-g450h)
337         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
338         ucidef_add_switch "switch0" "1" "1"
339         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
340         ucidef_add_switch_vlan "switch0" "2" "0t 1"
341         ;;
342
343 ew-dorin)
344         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
345         ucidef_add_switch "switch0" "1" "1"
346         ucidef_add_switch_vlan "switch0" "1" "0t 1 2"
347         ucidef_add_switch_vlan "switch0" "2" "0t 3"
348         ;;
349
350 ew-dorin-router)
351         ucidef_set_interfaces_lan_wan "eth0" "eth1"
352         ucidef_add_switch "switch0" "1" "1"
353         ucidef_add_switch_vlan "switch0" "1" "0 2 3"
354         ;;
355
356 wndr3700)
357         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
358         ucidef_add_switch "switch0" "1" "1"
359         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
360         # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
361         uci set network.@switch[-1].blinkrate='2'
362
363         ucidef_add_switch_port "switch0" "1"
364         # Port 1 controls the GREEN configuration of LEDs for
365         # the switch and the section does not correspond to a real
366         # switch port.
367         #
368         # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
369         # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
370         # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
371         # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
372         # 14: Link (master); 15: separate register
373         uci set network.@switch_port[-1].led='6'
374
375         ucidef_add_switch_port "switch0" "2"
376         # Port 2 controls the ORANGE configuration of LEDs for
377         # the switch and the section does not correspond to a real
378         # switch port.
379         #
380         # See the key above for switch port 1 for the meaning of the
381         # 'led' setting below.
382         uci set network.@switch_port[-1].led='9'
383
384         ucidef_add_switch_port "switch0" "5"
385         # Port 5 controls the configuration of the WAN LED and the
386         # section does not correspond to a real switch port.
387         #
388         # To toggle the use of green or orange LEDs for the WAN port,
389         # see the LED setting for wndr3700:green:wan in /etc/config/system.
390         #
391         # See the key above for switch port 1 for the meaning of the
392         # 'led' setting below.
393         uci set network.@switch_port[-1].led='2'
394         ;;
395
396 *)
397         ucidef_set_interfaces_lan_wan "eth0" "eth1"
398         ;;
399 esac
400
401 uci commit network
402
403 exit 0