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