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