ralink: revert 38348 as it breaks network on the hame-mpr
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults.sh
6
7 ramips_setup_rt3x5x_vlans()
8 {
9 if [ ! -x /sbin/swconfig ]; then
10 # legacy default
11 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
12 return
13 fi
14 local wanports=""
15 local lanports=""
16 for port in 5 4 3 2 1 0; do
17 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
18 continue
19 fi
20 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
21 wanports="$port $wanports"
22 else
23 lanports="$port $lanports"
24 fi
25 done
26 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
27 ucidef_add_switch "rt305x" "1" "1"
28 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
29 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
30 }
31
32 ramips_setup_interfaces()
33 {
34 local board="$1"
35
36 ucidef_set_interface_loopback
37
38 case $board in
39 3g300m | \
40 w150m | \
41 all0256n | \
42 all5002 | \
43 all5003 | \
44 awm002-evb | \
45 broadway | \
46 dcs-930| \
47 wnce2001)
48 ucidef_add_switch "switch0" "1" "0"
49 ucidef_set_interface_lan "eth0"
50 ;;
51
52 3g-6200nl | \
53 wl-330n)
54 ucidef_set_interface_lan "eth0.1"
55 ;;
56
57 3g-6200n | \
58 argus-atp52b | \
59 b2c | \
60 nw718 | \
61 psr-680w | \
62 sl-r7205 | \
63 w502u | \
64 wr6202)
65 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
66 ;;
67
68 asl26555)
69 ucidef_set_interface_lan "eth0.1"
70 ucidef_add_switch "switch0" "1" "1"
71 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
72 ;;
73
74 dir-645)
75 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
76 ucidef_add_switch "switch0" "1" "1"
77 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
78 ucidef_add_switch_vlan "switch0" "2" "0 6t"
79 ;;
80
81 dir-610-a1 | \
82 dir-300-b7 | \
83 dir-320-b1 | \
84 dir-615-h1 | \
85 mzk-w300nh2)
86 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
87 ucidef_add_switch "switch0" "1" "1"
88 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
89 ucidef_add_switch_vlan "switch0" "2" "4 6t"
90 ;;
91
92 f5d8235-v1 | \
93 f5d8235-v2 | \
94 hg255d | \
95 ur-326n4g)
96 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
97 ucidef_add_switch "switch0" "1" "1"
98 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
99 ucidef_add_switch_vlan "switch0" "2" "0 6t"
100 ;;
101
102 ur-336un)
103 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
104 ;;
105
106 br6524n | \
107 v11st-fe)
108 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
109 ucidef_add_switch "switch0" "1" "1"
110 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
111 ucidef_add_switch_vlan "switch0" "2" "0 5t"
112 ;;
113
114 rt-n15 | \
115 wl-351)
116 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
117 ucidef_add_switch "switch0" "1" "1"
118 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
119 ucidef_add_switch_vlan "switch0" "2" "4 5t"
120 ;;
121
122 rt-n56u)
123 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
124 ucidef_add_switch "switch0" "1" "1"
125 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
126 ucidef_add_switch_vlan "switch0" "2" "4 8t"
127 ;;
128
129 tew-691gr|\
130 tew-692gr)
131 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
132 ucidef_add_switch "switch0" "1" "1"
133 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
134 ucidef_add_switch_vlan "switch0" "2" "0t 5"
135 ;;
136
137 wcr-150gn)
138 ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
139 ;;
140
141 d105 | \
142 omni-emb-hpm|\
143 wli-tx4-ag300n)
144 ucidef_set_interface_lan "eth0"
145 ;;
146
147 whr-300hp2 |\
148 whr-600d)
149 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
150 ;;
151
152 *)
153 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
154 if [ -n "${RT3X5X}" ]; then
155 ramips_setup_rt3x5x_vlans
156 else
157 ucidef_set_interfaces_lan_wan "eth0" "eth1"
158 fi
159 ;;
160 esac
161 }
162
163 ramips_setup_macs()
164 {
165 local board="$1"
166 local lan_mac=""
167 local wan_mac=""
168
169 case $board in
170 all0256n | \
171 all5002 | \
172 dir-615-h1)
173 lan_mac=$(mtd_get_mac_binary factory 40)
174 ;;
175 3g-6200n | \
176 3g300m | \
177 w150m | \
178 air3gii | \
179 argus-atp52b | \
180 bc2 | \
181 br6425 | \
182 broadway | \
183 dir-620-d1 | \
184 f5d8235-v1 | \
185 ip2202 | \
186 mpr-a1 | \
187 mpr-a2 | \
188 dir-300-b7 | \
189 dir-320-b1 | \
190 mzk-w300nh2 | \
191 nw718 | \
192 psr-680w | \
193 rt-n15 | \
194 sl-r7205 | \
195 wl-351)
196 lan_mac=$(mtd_get_mac_binary factory 4)
197 wan_mac=$(macaddr_add "$lan_mac" 1)
198 ;;
199
200 asl26555)
201 lan_mac=$(mtd_get_mac_binary devdata 16388)
202 ;;
203
204 w306r-v20)
205 lan_mac=$(mtd_get_mac_binary factory 4)
206 wan_mac=$(macaddr_add "$lan_mac" 5)
207 ;;
208
209 rt-n13u | \
210 hg255d | \
211 fonera20n | \
212 dir-810l)
213 lan_mac=$(mtd_get_mac_binary factory 40)
214 wan_mac=$(macaddr_add "$lan_mac" 1)
215 ;;
216
217 dir-300-b1 |\
218 dir-300-b2 |\
219 dir-600-b1 |\
220 dir-610-a1)
221 lan_mac=$(mtd_get_mac_binary devdata 16388)
222 wan_mac=$(macaddr_add "$lan_mac" 1)
223 ;;
224
225 dir-620-a1)
226 lan_mac=$(mtd_get_mac_binary factory 4)
227 lan_mac=$(macaddr_setbit_la "$lan_mac")
228 wan_mac=$(macaddr_add "$lan_mac" 1)
229 ;;
230
231 dir-645)
232 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
233 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
234 ;;
235
236 esr-9753 | \
237 ur-326n4g | \
238 ur-336un)
239 lan_mac=$(mtd_get_mac_binary devdata 16388)
240 wan_mac=$(macaddr_add "$lan_mac" 1)
241 ;;
242
243 m3 |\
244 m4 |\
245 x5 |\
246 x8)
247 lan_mac=$(mtd_get_mac_binary factory 4)
248 lan_mac=$(macaddr_add "$lan_mac" -1)
249 ;;
250
251 nbg-419n | \
252 wcr-150gn)
253 lan_mac=$(mtd_get_mac_binary factory 4)
254 wan_mac=$(mtd_get_mac_binary factory 40)
255 ;;
256
257 omni-emb-hpm)
258 lan_mac=$(mtd_get_mac_binary factory 40)
259 ;;
260
261 f5d8235-v2)
262 lan_mac=$(mtd_get_mac_binary "u-boot" 262148)
263 wan_mac=$(macaddr_add "$lan_mac" 1)
264 ;;
265
266 rt-n56u)
267 lan_mac=$(mtd_get_mac_binary factory 4)
268 wan_mac=$(mtd_get_mac_binary factory 32772)
269 ;;
270
271 tew-691gr)
272 lan_mac=$(mtd_get_mac_binary factory 40)
273 wan_mac=$(macaddr_add "$lan_mac" 3)
274 ;;
275
276 tew-692gr)
277 lan_mac=$(mtd_get_mac_binary factory 40)
278 wan_mac=$(macaddr_add "$lan_mac" 4)
279 ;;
280
281 all0239-3g | \
282 carambola | \
283 freestation5 | \
284 w502u | \
285 wnce2001)
286 lan_mac=$(mtd_get_mac_binary factory 40)
287 wan_mac=$(mtd_get_mac_binary factory 46)
288 ;;
289
290 wl341v3)
291 lan_mac=$(mtd_get_mac_binary board-nvram 65440)
292 wan_mac=$(macaddr_add "$lan_mac" 1)
293 ;;
294
295 d105 | \
296 wli-tx4-ag300n)
297 lan_mac=$(mtd_get_mac_binary factory 4)
298 ;;
299
300 esac
301
302 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
303 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
304 }
305
306 [ -e /etc/config/network ] && exit 0
307
308 touch /etc/config/network
309
310 board=$(ramips_board_name)
311
312 ramips_setup_interfaces $board
313 ramips_setup_macs $board
314
315 uci commit network
316
317 exit 0