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