[ramips] add profile for tenda w150m 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 swconfig dev rt305x set reset 1
17 for port in 5 4 3 2 1 0; do
18 if [ `swconfig dev rt305x port $port get disable` = "1" ]; then
19 continue
20 fi
21 if [ `swconfig dev rt305x port $port get lan` = "0" ]; then
22 wanports="$port $wanports"
23 else
24 lanports="$port $lanports"
25 fi
26 done
27 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28 ucidef_add_switch "rt305x" "1" "1"
29 ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"
30 ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t"
31 }
32
33 ramips_setup_interfaces()
34 {
35 local board="$1"
36
37 ucidef_set_interface_loopback
38
39 case $board in
40 3g300m | \
41 w150m | \
42 all0256n | \
43 all5002 | \
44 broadway)
45 ucidef_add_switch "switch0" "1" "0"
46 ucidef_set_interface_lan "eth0"
47 ;;
48
49 dir-615-h1 | \
50 3g-6200nl | \
51 wl-330n)
52 ucidef_set_interface_lan "eth0.1"
53 ;;
54
55 3g-6200n | \
56 argus-atp52b | \
57 b2c | \
58 nw718 | \
59 psr-680w | \
60 sl-r7205 | \
61 w502u | \
62 wr6202)
63 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
64 ;;
65
66 dir-645)
67 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
68 ucidef_add_switch "switch0" "1" "1"
69 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
70 ucidef_add_switch_vlan "switch0" "2" "0 6t"
71 ;;
72
73 mzk-w300nh2)
74 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
75 ucidef_add_switch "switch0" "1" "1"
76 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
77 ucidef_add_switch_vlan "switch0" "2" "4 6t"
78 ;;
79
80 f5d8235-v1 | \
81 f5d8235-v2 | \
82 ur-326n4g)
83 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
84 ucidef_add_switch "switch0" "1" "1"
85 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
86 ucidef_add_switch_vlan "switch0" "2" "0 6t"
87 ;;
88
89 ur-336un)
90 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
91 ;;
92
93 br6524n | \
94 v11st-fe)
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 5t"
98 ucidef_add_switch_vlan "switch0" "2" "0 5t"
99 ;;
100
101 rt-n15 | \
102 wl-351)
103 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
104 ucidef_add_switch "switch0" "1" "1"
105 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
106 ucidef_add_switch_vlan "switch0" "2" "4 5t"
107 ;;
108
109 rt-n56u)
110 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
111 ucidef_add_switch "switch0" "1" "1"
112 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
113 ucidef_add_switch_vlan "switch0" "2" "4 8t"
114 ;;
115
116 tew-691gr|\
117 tew-692gr)
118 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
119 ucidef_add_switch "switch0" "1" "1"
120 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
121 ucidef_add_switch_vlan "switch0" "2" "0t 5"
122 ;;
123
124 freestation5 | \
125 wcr-150gn)
126 ucidef_set_interfaces_lan_wan "eth0.2" "eth0.1"
127 ;;
128
129 d105 | \
130 omni-emb-hpm|\
131 wli-tx4-ag300n)
132 ucidef_set_interface_lan "eth0"
133 ;;
134
135 *)
136 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
137 if [ -n "${RT3X5X}" ]; then
138 ramips_setup_rt3x5x_vlans
139 else
140 ucidef_set_interfaces_lan_wan "eth0" "eth1"
141 fi
142 ;;
143 esac
144 }
145
146 ramips_setup_macs()
147 {
148 local board="$1"
149 local lan_mac=""
150 local wan_mac=""
151
152 case $board in
153 all0256n | \
154 all5002 | \
155 dir-615-h1)
156 lan_mac=$(mtd_get_mac_binary factory 40)
157 ;;
158 3g-6200n | \
159 3g300m | \
160 w150m | \
161 air3gii | \
162 argus-atp52b | \
163 bc2 | \
164 br6425 | \
165 broadway | \
166 f5d8235-v1 | \
167 mzk-w300nh2 | \
168 nw718 | \
169 psr-680w | \
170 rt-n15 | \
171 sl-r7205 | \
172 wl-351)
173 lan_mac=$(mtd_get_mac_binary factory 4)
174 wan_mac=$(macaddr_add "$lan_mac" 1)
175 ;;
176
177 w306r-v20)
178 lan_mac=$(mtd_get_mac_binary factory 4)
179 wan_mac=$(macaddr_add "$lan_mac" 5)
180 ;;
181
182 rt-n13u | \
183 fonera20n)
184 lan_mac=$(mtd_get_mac_binary factory 40)
185 wan_mac=$(macaddr_add "$lan_mac" 1)
186 ;;
187
188 dir-300-b1 |\
189 dir-300-b2 |\
190 dir-600-b1)
191 lan_mac=$(mtd_get_mac_binary devdata 16388)
192 wan_mac=$(macaddr_add "$lan_mac" 1)
193 ;;
194
195 dir-620-a1)
196 lan_mac=$(mtd_get_mac_binary factory 4)
197 lan_mac=$(macaddr_setbit_la "$lan_mac")
198 wan_mac=$(macaddr_add "$lan_mac" 1)
199 ;;
200
201 dir-645)
202 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
203 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
204 ;;
205
206 esr-9753 | \
207 ur-326n4g | \
208 ur-336un)
209 lan_mac=$(mtd_get_mac_binary devdata 16388)
210 wan_mac=$(macaddr_add "$lan_mac" 1)
211 ;;
212
213 nbg-419n | \
214 wcr-150gn)
215 lan_mac=$(mtd_get_mac_binary factory 4)
216 wan_mac=$(mtd_get_mac_binary factory 40)
217 ;;
218
219 omni-emb-hpm)
220 lan_mac=$(mtd_get_mac_binary factory 40)
221 ;;
222
223 f5d8235-v2)
224 lan_mac=$(mtd_get_mac_binary "u-boot" 262148)
225 wan_mac=$(macaddr_add "$lan_mac" 1)
226 ;;
227
228 rt-n56u)
229 lan_mac=$(mtd_get_mac_binary factory 4)
230 wan_mac=$(mtd_get_mac_binary factory 32772)
231 ;;
232
233 tew-691gr)
234 lan_mac=$(mtd_get_mac_binary factory 40)
235 wan_mac=$(macaddr_add "$lan_mac" 3)
236 ;;
237
238 tew-692gr)
239 lan_mac=$(mtd_get_mac_binary factory 40)
240 wan_mac=$(macaddr_add "$lan_mac" 4)
241 ;;
242
243 all0239-3g | \
244 carambola | \
245 w502u)
246 lan_mac=$(mtd_get_mac_binary factory 40)
247 wan_mac=$(mtd_get_mac_binary factory 46)
248 ;;
249
250 wl341v3)
251 lan_mac=$(mtd_get_mac_binary board-nvram 65440)
252 wan_mac=$(macaddr_add "$lan_mac" 1)
253 ;;
254
255 d105 | \
256 wli-tx4-ag300n)
257 lan_mac=$(mtd_get_mac_binary factory 4)
258 ;;
259
260 esac
261
262 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
263 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
264 }
265
266 [ -e /etc/config/network ] && exit 0
267
268 touch /etc/config/network
269
270 board=$(ramips_board_name)
271
272 ramips_setup_interfaces $board
273 ramips_setup_macs $board
274
275 uci commit network
276
277 exit 0