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