ramips: fix Omnima models, images and profiles names
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/ramips.sh
5 . /lib/functions/uci-defaults-new.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 a5-v11)
41 ucidef_set_interface_lan "eth0.1"
42 ucidef_add_switch "switch0" "1" "1"
43 ucidef_add_switch_vlan "switch0" "1" "0 6t"
44 ;;
45
46 3g150b | \
47 3g300m | \
48 microwrt | \
49 w150m | \
50 zte-q7 | \
51 all0256n | \
52 all5002 | \
53 all5003 | \
54 broadway | \
55 dcs-930| \
56 dcs-930l-b1| \
57 ht-tm02| \
58 ncs601w | \
59 wnce2001)
60 ucidef_add_switch "switch0" "1" "0"
61 ucidef_set_interface_lan "eth0"
62 ;;
63
64 3g-6200nl | \
65 mlw221 | \
66 mr-102n)
67 ucidef_set_interface_lan "eth0.2"
68 ;;
69 mlwg2)
70 ucidef_set_interface_lan "eth0.1"
71 ;;
72
73 m2m)
74 ucidef_add_switch "switch0" "4"
75 ucidef_set_interface_lan "eth0"
76 ;;
77
78 wizard8800 | \
79 wl-330n | \
80 wmr300)
81 ucidef_set_interface_lan "eth0.1"
82 ;;
83
84 b2c | \
85 nw718 | \
86 psr-680w | \
87 sl-r7205 | \
88 w502u | \
89 wr6202)
90 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
91 ;;
92
93 awapn2403)
94 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
95 ucidef_add_switch "switch0" "1" "1"
96 ucidef_add_switch_vlan "switch0" "1" "0 6t"
97 ucidef_add_switch_vlan "switch0" "2" "1 6t"
98 ;;
99
100 br-6475nd)
101 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
102 ucidef_add_switch "switch0" "1" "1"
103 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
104 ucidef_add_switch_vlan "switch0" "2" "0 9t"
105 ;;
106
107 re6500 | \
108 asl26555)
109 ucidef_set_interface_lan "eth0.1"
110 ucidef_add_switch "switch0" "1" "1"
111 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
112 ;;
113
114 cf-wr800n)
115 ucidef_set_interface_lan "eth0.1"
116 ucidef_add_switch "switch0" "1" "1"
117 ucidef_add_switch_vlan "switch0" "1" "4 6t"
118 ;;
119
120 cy-swr1100)
121 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
122 ucidef_add_switch "switch0" "1" "1"
123 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 9t"
124 ucidef_add_switch_vlan "switch0" "2" "4 9t"
125 ;;
126
127 3g-6200n | \
128 ai-br100 | \
129 dir-610-a1 | \
130 dir-300-b7 | \
131 dir-320-b1 | \
132 dir-615-h1 | \
133 firewrt | \
134 pbr-m1 | \
135 hlk-rm04 | \
136 mt7621 | \
137 mt7628 | \
138 mzk-w300nh2 | \
139 mzk-750dhp | \
140 whr-300hp2 | \
141 whr-600d | \
142 oy-0001 | \
143 sap-g3200u3 | \
144 wsr-600 | \
145 wsr-1166 | \
146 wt1520 | \
147 miwifi-mini |\
148 y1)
149 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
150 ucidef_add_switch "switch0" "1" "1"
151 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
152 ucidef_add_switch_vlan "switch0" "2" "4 6t"
153 ;;
154
155 whr-1166d)
156 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
157 ucidef_add_switch "switch0" "1" "1"
158 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"
159 ucidef_add_switch_vlan "switch0" "2" "5 6t"
160 ;;
161
162 awm002-evb | \
163 awm003-evb | \
164 atp-52b | \
165 dir-645 | \
166 dir-860l-b1 | \
167 f5d8235-v1 | \
168 f5d8235-v2 | \
169 hg255d | \
170 rt-n14u | \
171 wrtnode | \
172 wt3020 | \
173 ur-326n4g | \
174 zbt-wa05)
175 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
176 ucidef_add_switch "switch0" "1" "1"
177 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 6t"
178 ucidef_add_switch_vlan "switch0" "2" "0 6t"
179 ;;
180
181 ur-336un)
182 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
183 ;;
184
185 br6524n | \
186 v11st-fe)
187 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
188 ucidef_add_switch "switch0" "1" "1"
189 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
190 ucidef_add_switch_vlan "switch0" "2" "0 5t"
191 ;;
192
193 ar670w | \
194 ar725w | \
195 rt-n15 | \
196 wl-351)
197 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
198 ucidef_add_switch "switch0" "1" "1"
199 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
200 ucidef_add_switch_vlan "switch0" "2" "4 5t"
201 ;;
202
203 rt-n56u)
204 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
205 ucidef_add_switch "switch0" "1" "1"
206 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 8t"
207 ucidef_add_switch_vlan "switch0" "2" "4 8t"
208 ;;
209
210 tew-691gr|\
211 tew-692gr)
212 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
213 ucidef_add_switch "switch0" "1" "1"
214 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
215 ucidef_add_switch_vlan "switch0" "2" "0t 5"
216 ;;
217
218 vocore)
219 ucidef_set_interface_lan "eth0.1"
220 ucidef_add_switch "switch0" "1" "1"
221 ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
222 ;;
223
224 wcr-150gn)
225 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
226 ucidef_add_switch "switch0" "1" "1"
227 ucidef_add_switch_vlan "switch0" "1" "0 6t"
228 ucidef_add_switch_vlan "switch0" "2" "6t"
229 ;;
230
231 zbt-wr8305rt)
232 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
233 ucidef_add_switch "switch0" "1" "1"
234 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 6t"
235 ucidef_add_switch_vlan "switch0" "2" "4 6t"
236 ;;
237
238 y1s)
239 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
240 ucidef_add_switch "switch0" "1" "1"
241 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5 6t"
242 ucidef_add_switch_vlan "switch0" "2" "0 6t"
243 ;;
244 d105 | \
245 na930 | \
246 hpm|\
247 wli-tx4-ag300n)
248 ucidef_set_interface_lan "eth0"
249 ;;
250
251 e1700 | \
252 mt7620a_mt7530)
253 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
254 ucidef_add_switch "switch1" "1" "1"
255 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 6t"
256 ucidef_add_switch_vlan "switch1" "2" "4 6t"
257 ;;
258
259 wzr-agl300nh)
260 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
261 ucidef_add_switch "switch0" "1" "1"
262 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
263 ucidef_add_switch_vlan "switch0" "2" "0 5t"
264 ;;
265
266 mzk-dp150n)
267 ucidef_set_interface_lan "eth0.1"
268 ucidef_add_switch "switch0" "1" "1"
269 ucidef_add_switch_vlan "switch0" "1" "0 4 6t"
270 ;;
271
272 *)
273 RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"`
274 if [ -n "${RT3X5X}" ]; then
275 ramips_setup_rt3x5x_vlans
276 else
277 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
278 fi
279 ;;
280 esac
281 }
282
283 ramips_setup_macs()
284 {
285 local board="$1"
286 local lan_mac=""
287 local wan_mac=""
288
289 case $board in
290 br-6475nd)
291 lan_mac=$(cat /sys/class/net/eth0/address)
292 wan_mac=$(mtd_get_mac_binary devdata 7)
293 ;;
294
295 oy-0001)
296 lan_mac=$(mtd_get_mac_binary factory 40)
297 wan_mac=$(mtd_get_mac_binary factory 46)
298 ;;
299
300 w306r-v20)
301 lan_mac=$(cat /sys/class/net/eth0/address)
302 wan_mac=$(macaddr_add "$lan_mac" 5)
303 ;;
304
305 tew-691gr)
306 lan_mac=$(cat /sys/class/net/eth0/address)
307 wan_mac=$(macaddr_add "$lan_mac" 3)
308 ;;
309
310 tew-692gr)
311 lan_mac=$(cat /sys/class/net/eth0/address)
312 wan_mac=$(macaddr_add "$lan_mac" 4)
313 ;;
314
315 m3 |\
316 m4 |\
317 x5 |\
318 x8)
319 lan_mac=$(cat /sys/class/net/eth0/address)
320 lan_mac=$(macaddr_add "$lan_mac" -2)
321 ;;
322
323 a5-v11 |\
324 bc2 |\
325 broadway |\
326 d105 |\
327 dir-620-a1 |\
328 esr-9753 |\
329 freestation5 |\
330 hlk-rm04 | \
331 mpr-a1 | \
332 mpr-a2 | \
333 dir-300-b7 | \
334 dir-320-b1 | \
335 psr-680w |\
336 sl-r7205 |\
337 y1 |\
338 y1s)
339 lan_mac=$(cat /sys/class/net/eth0/address)
340 lan_mac=$(macaddr_setbit_la "$lan_mac")
341 wan_mac=$(macaddr_add "$lan_mac" 1)
342 ;;
343
344 ht-tm02)
345 lan_mac=$(cat /sys/class/net/eth0/address)
346 ;;
347
348 cy-swr1100 | \
349 dir-645)
350 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
351 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
352 ;;
353
354 e1700)
355 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
356 ;;
357
358 wcr-150gn)
359 wan_mac=$(mtd_get_mac_binary factory 40)
360 ;;
361
362 rt-n56u)
363 lan_mac=$(cat /sys/class/net/eth0/address)
364 lan_mac=$(macaddr_setbit_la "$lan_mac")
365 wan_mac=$(mtd_get_mac_binary factory 32772)
366 ;;
367
368 all0239-3g | \
369 carambola | \
370 freestation5 | \
371 w502u | \
372 wnce2001)
373 wan_mac=$(mtd_get_mac_binary factory 46)
374 ;;
375
376 wsr-600|whr-300hp2|whr-600d|whr-1166d)
377 wan_mac=$(mtd_get_mac_binary factory 4)
378 lan_mac=$wan_mac
379 ;;
380 wsr-1166)
381 local index="$(find_mtd_index "board_data")"
382 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
383 lan_mac=$wan_mac
384 ;;
385 *)
386 lan_mac=$(cat /sys/class/net/eth0/address)
387 wan_mac=$(macaddr_add "$lan_mac" 1)
388 ;;
389
390 esac
391
392 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr lan $lan_mac
393 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr wan $wan_mac
394 }
395
396 board_config_update
397 board=$(ramips_board_name)
398 ramips_setup_interfaces $board
399 ramips_setup_macs $board
400 board_config_flush
401
402 exit 0