ramips: add support for easyacc wizard8800
[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 . /lib/functions/system.sh
7
8 ramips_setup_rt3x5x_vlans()
9 {
10 if [ ! -x /sbin/swconfig ]; then
11 # legacy default
12 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
13 return
14 fi
15 local wanports=""
16 local lanports=""
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 all5003 | \
45 broadway | \
46 dcs-930| \
47 ncs601w | \
48 wnce2001)
49 ucidef_add_switch "switch0" "1" "0"
50 ucidef_set_interface_lan "eth0"
51 ;;
52
53 3g-6200nl | \
54 mlw221)
55 ucidef_set_interface_lan "eth0.2"
56 ;;
57
58 wizard8800 | \
59 wl-330n | \
60 wmr300)
61 ucidef_set_interface_lan "eth0.1"
62 ;;
63
64 3g-6200n | \
65 b2c | \
66 nw718 | \
67 psr-680w | \
68 sl-r7205 | \
69 w502u | \
70 wr6202)
71 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
72 ;;
73
74 awapn2403)
75 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
76 ucidef_add_switch "switch0" "1" "1"
77 ucidef_add_switch_vlan "switch0" "1" "0 6t"
78 ucidef_add_switch_vlan "switch0" "2" "1 6t"
79 ;;
80
81 br-6475nd)
82 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
83 ucidef_add_switch "switch0" "1" "1"
84 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
85 ucidef_add_switch_vlan "switch0" "2" "0 9t"
86 ;;
87
88 asl26555)
89 ucidef_set_interface_lan "eth0.1"
90 ucidef_add_switch "switch0" "1" "1"
91 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
92 ;;
93
94 cy-swr1100)
95 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
96 ucidef_add_switch "switch0" "1" "1"
97 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
98 ucidef_add_switch_vlan "switch0" "2" "4 9t"
99 ;;
100
101 dir-610-a1 | \
102 dir-300-b7 | \
103 dir-320-b1 | \
104 dir-615-h1 | \
105 hlk-rm04 | \
106 mzk-w300nh2 | \
107 mzk-750dhp)
108 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
109 ucidef_add_switch "switch0" "1" "1"
110 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
111 ucidef_add_switch_vlan "switch0" "2" "4 6t"
112 ;;
113
114 awm002-evb | \
115 awm003-evb | \
116 argus-atp52b | \
117 dir-645 | \
118 f5d8235-v1 | \
119 f5d8235-v2 | \
120 hg255d | \
121 rt-n14u | \
122 wrtnode | \
123 ur-326n4g | \
124 zbt-wa05)
125 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
126 ucidef_add_switch "switch0" "1" "1"
127 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
128 ucidef_add_switch_vlan "switch0" "2" "0 6t"
129 ;;
130
131 ur-336un)
132 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
133 ;;
134
135 br6524n | \
136 v11st-fe)
137 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
138 ucidef_add_switch "switch0" "1" "1"
139 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
140 ucidef_add_switch_vlan "switch0" "2" "0 5t"
141 ;;
142
143 ar725w | \
144 rt-n15 | \
145 wl-351)
146 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
147 ucidef_add_switch "switch0" "1" "1"
148 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
149 ucidef_add_switch_vlan "switch0" "2" "4 5t"
150 ;;
151
152 rt-n56u)
153 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
154 ucidef_add_switch "switch0" "1" "1"
155 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
156 ucidef_add_switch_vlan "switch0" "2" "4 8t"
157 ;;
158
159 tew-691gr|\
160 tew-692gr)
161 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
162 ucidef_add_switch "switch0" "1" "1"
163 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
164 ucidef_add_switch_vlan "switch0" "2" "0t 5"
165 ;;
166
167 wcr-150gn)
168 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
169 ucidef_add_switch "switch0" "1" "1"
170 ucidef_add_switch_vlan "switch0" "1" "0 6t"
171 ucidef_add_switch_vlan "switch0" "2" "6t"
172 ;;
173
174 wr8305rt)
175 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
176 ucidef_add_switch "switch0" "1" "1"
177 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
178 ucidef_add_switch_vlan "switch0" "2" "4 6t"
179 ;;
180
181 d105 | \
182 na930 | \
183 omni-emb-hpm|\
184 wli-tx4-ag300n)
185 ucidef_set_interface_lan "eth0"
186 ;;
187
188 *)
189 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
190 if [ -n "${RT3X5X}" ]; then
191 ramips_setup_rt3x5x_vlans
192 else
193 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
194 fi
195 ;;
196 esac
197 }
198
199 ramips_setup_macs()
200 {
201 local board="$1"
202 local lan_mac=""
203 local wan_mac=""
204
205 case $board in
206 br-6475nd)
207 lan_mac=$(cat /sys/class/net/eth0/address)
208 wan_mac=$(mtd_get_mac_binary devdata 7)
209 ;;
210
211 w306r-v20)
212 lan_mac=$(cat /sys/class/net/eth0/address)
213 wan_mac=$(macaddr_add "$lan_mac" 5)
214 ;;
215
216 tew-691gr)
217 lan_mac=$(cat /sys/class/net/eth0/address)
218 wan_mac=$(macaddr_add "$lan_mac" 3)
219 ;;
220
221 tew-692gr)
222 lan_mac=$(cat /sys/class/net/eth0/address)
223 wan_mac=$(macaddr_add "$lan_mac" 4)
224 ;;
225
226 m3 |\
227 m4 |\
228 x5 |\
229 x8)
230 lan_mac=$(cat /sys/class/net/eth0/address)
231 lan_mac=$(macaddr_add "$lan_mac" -2)
232 ;;
233
234 bc2 |\
235 broadway |\
236 d105 |\
237 dir-620-a1 |\
238 esr-9753 |\
239 freestation5 |\
240 hlk-rm04 | \
241 mpr-a1 | \
242 mpr-a2 | \
243 dir-300-b7 | \
244 dir-320-b1 | \
245 psr-680w |\
246 sl-r7205)
247 lan_mac=$(cat /sys/class/net/eth0/address)
248 lan_mac=$(macaddr_setbit_la "$lan_mac")
249 wan_mac=$(macaddr_add "$lan_mac" 1)
250 ;;
251
252 cy-swr1100 | \
253 dir-645)
254 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
255 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
256 ;;
257
258 wcr-150gn)
259 wan_mac=$(mtd_get_mac_binary factory 40)
260 ;;
261
262 rt-n56u)
263 lan_mac=$(cat /sys/class/net/eth0/address)
264 lan_mac=$(macaddr_setbit_la "$lan_mac")
265 wan_mac=$(mtd_get_mac_binary factory 32772)
266 ;;
267
268 all0239-3g | \
269 carambola | \
270 freestation5 | \
271 w502u | \
272 wnce2001)
273 wan_mac=$(mtd_get_mac_binary factory 46)
274 ;;
275
276 *)
277 lan_mac=$(cat /sys/class/net/eth0/address)
278 wan_mac=$(macaddr_add "$lan_mac" 1)
279 ;;
280
281 esac
282
283 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
284 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
285 }
286
287 [ -e /etc/config/network ] && exit 0
288
289 touch /etc/config/network
290
291 board=$(ramips_board_name)
292
293 ramips_setup_interfaces $board
294 ramips_setup_macs $board
295
296 uci commit network
297
298 exit 0