3c73a63aaeae088cad1146531079092ea624b997
[openwrt/openwrt.git] / target / linux / ramips / base-files / etc / board.d / 02_network
1 #!/bin/sh
2
3 . /lib/functions.sh
4 . /lib/functions/uci-defaults.sh
5 . /lib/functions/system.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:wan $wanports"
22 else
23 lanports="$port:lan $lanports"
24 fi
25 done
26 ucidef_add_switch "rt305x" $lanports $wanports "6t@eth0"
27 }
28
29 ramips_setup_interfaces()
30 {
31 local board="$1"
32
33 case $board in
34 accton,wr6202|\
35 alfa-network,w502u|\
36 netcore,nw718|\
37 petatel,psr-680w|\
38 skyline,sl-r7205|\
39 upvel,ur-336un)
40 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
41 ;;
42 adslr,g7|\
43 afoundry,ew1200|\
44 aigale,ai-br100|\
45 alfa-network,ac1200rm|\
46 asus,rt-n12p|\
47 buffalo,whr-g300n|\
48 d-team,pbr-m1|\
49 dlink,dir-300-b7|\
50 dlink,dir-320-b1|\
51 dlink,dir-610-a1|\
52 dlink,dir-810l|\
53 dlink,dwr-116-a1|\
54 dlink,dwr-921-c1|\
55 dlink,dwr-922-e2|\
56 edimax,3g-6200n|\
57 firefly,firewrt|\
58 hilink,hlk-rm04|\
59 hiwifi,hc5661a|\
60 hiwifi,hc5761a|\
61 hiwifi,hc5962|\
62 mediatek,ap-mt7621a-v60|\
63 mediatek,mt7621-eval-board|\
64 mediatek,mt7628an-eval-board|\
65 mercury,mac1200r-v2|\
66 mqmaker,witi|\
67 mtc,wr1201|\
68 netis,wf-2881|\
69 nixcore,x1-16m|\
70 nixcore,x1-8m|\
71 ohyeah,oy-0001|\
72 phicomm,k2p|\
73 phicomm,psg1208|\
74 phicomm,psg1218a|\
75 planex,db-wrt01|\
76 planex,mzk-750dhp|\
77 planex,mzk-w300nh2|\
78 planex,vr500|\
79 samknows,whitebox-v8|\
80 sanlinking,d240|\
81 storylink,sap-g3200u3|\
82 telco-electronics,x1|\
83 totolink,a7000r|\
84 totolink,lr1200|\
85 unielec,u7621-06-16m|\
86 unielec,u7621-06-64m|\
87 wavlink,wl-wn570ha1|\
88 wavlink,wl-wn575a3|\
89 xiaomi,miwifi-mini|\
90 xiaomi,miwifi-nano|\
91 xiaoyu,xy-c5|\
92 xzwifi,creativebox-v1|\
93 youku,yk-l2|\
94 youku,yk1|\
95 zbtlink,zbt-ape522ii|\
96 zbtlink,zbt-we1326|\
97 zbtlink,zbt-we3526|\
98 zbtlink,zbt-we826-16m|\
99 zbtlink,zbt-we826-32m|\
100 zbtlink,zbt-we826-e|\
101 zbtlink,zbt-wg2626|\
102 zbtlink,zbt-wg3526-16m|\
103 zbtlink,zbt-wg3526-32m|\
104 zbtlink,zbt-wr8305rt|\
105 zyxel,keenetic|\
106 zyxel,keenetic-omni)
107 ucidef_add_switch "switch0" \
108 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
109 ;;
110 airlink101,ar670w|\
111 airlink101,ar725w|\
112 asus,rt-ac51u|\
113 rakwireless,rak633)
114 ucidef_add_switch "switch0" \
115 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
116 ;;
117 alfa-network,awusfree1|\
118 alfa-network,tube-e4g|\
119 buffalo,wli-tx4-ag300n|\
120 buffalo,wmr-300|\
121 dlink,dap-1522-a1|\
122 dlink,dch-m225|\
123 d-team,pbr-d1|\
124 elecom,wrh-300cr|\
125 huawei,d105|\
126 kimax,u25awf-h1|\
127 loewe,wmdr-143n|\
128 netgear,ex2700|\
129 netgear,ex3700|\
130 netgear,wn3000rp-v3|\
131 omnima,hpm|\
132 planex,cs-qr10|\
133 planex,mzk-ex300np|\
134 planex,mzk-ex750np|\
135 ravpower,wd03|\
136 sercomm,na930|\
137 tama,w06|\
138 tplink,tl-mr3020-v3|\
139 tplink,tl-wr802n-v4)
140 ucidef_set_interface_lan "eth0"
141 ;;
142 allnet,all0256n-4m|\
143 allnet,all0256n-8m|\
144 allnet,all5002|\
145 allnet,all5003|\
146 dlink,dcs-930l-b1|\
147 dlink,dcs-930|\
148 edimax,ew-7476rpc|\
149 edimax,ew-7478ac|\
150 hame,mpr-a2|\
151 hauppauge,broadway|\
152 hootoo,ht-tm02|\
153 intenso,memory2move|\
154 kimax,u35wf|\
155 mediatek,linkit-smart-7688|\
156 microduino,microwrt|\
157 mikrotik,rbm11g|\
158 netgear,wnce2001|\
159 onion,omega2p|\
160 onion,omega2|\
161 tenda,3g150b|\
162 tenda,3g300m|\
163 tenda,w150m|\
164 thunder,timecloud|\
165 tplink,tl-wa801nd-v5|\
166 unbranded,a5-v11|\
167 wansview,ncs601w|\
168 widora,neo-16m|\
169 widora,neo-32m|\
170 yukai,bocco|\
171 zbtlink,zbt-cpe102|\
172 zorlik,zl5900v2|\
173 zte,q7)
174 ucidef_add_switch "switch0"
175 ucidef_add_switch_attr "switch0" "enable" "false"
176 ucidef_set_interface_lan "eth0"
177 ;;
178 alphanetworks,asl26555-8m|\
179 alphanetworks,asl26555-16m|\
180 asus,rp-n53)
181 ucidef_add_switch "switch0" \
182 "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0"
183 ;;
184 argus,atp-52b|\
185 asiarf,awm002-evb-4m|\
186 asiarf,awm002-evb-8m|\
187 asus,rt-ac57u|\
188 asus,rt-n14u|\
189 bdcom,wap2100-sk|\
190 dlink,dir-645|\
191 glinet,gl-mt300a|\
192 glinet,gl-mt300n|\
193 glinet,gl-mt750|\
194 hilink,hlk-7628n|\
195 hiwifi,hc5661|\
196 hiwifi,hc5861b|\
197 jcg,jhr-n805r|\
198 jcg,jhr-n825r|\
199 jcg,jhr-n926r|\
200 mikrotik,rb750gr3|\
201 mikrotik,rbm33g|\
202 planex,mzk-wdpr|\
203 skylab,skw92a|\
204 tplink,archer-c20-v4|\
205 tplink,archer-c20i|\
206 tplink,archer-c50-v3|\
207 tplink,archer-c50-v4|\
208 tplink,tl-mr3420-v5|\
209 tplink,tl-wr840n-v4|\
210 tplink,tl-wr840n-v5|\
211 tplink,tl-wr841n-v13|\
212 tplink,tl-wr841n-v14|\
213 tplink,tl-wr842n-v5|\
214 unielec,u7628-01-16m|\
215 ubiquiti,edgerouterx|\
216 ubiquiti,edgerouterx-sfp|\
217 upvel,ur-326n4g|\
218 wrtnode,wrtnode|\
219 wrtnode,wrtnode2p|\
220 wrtnode,wrtnode2r|\
221 youhua,wr1200js|\
222 zbtlink,zbt-wa05|\
223 zyxel,keenetic-extra-ii)
224 ucidef_add_switch "switch0" \
225 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
226 ;;
227 asiarf,ap7621-001)
228 ucidef_add_switch "switch0" "0:lan" "4:wan" "6@eth0"
229 ;;
230 asiarf,ap7621-nv1)
231 ucidef_add_switch "switch0" "0:wan" "2:lan" "3:lan" "6@eth0"
232 ;;
233 asiarf,awapn2403)
234 ucidef_add_switch "switch0" \
235 "0:lan" "1:wan" "6@eth0"
236 ;;
237 asus,rt-ac65p|\
238 asus,rt-ac85p|\
239 dlink,dir-860l-b1|\
240 elecom,wrc-1167ghbk2-s|\
241 elecom,wrc-1900gst|\
242 elecom,wrc-2533gst|\
243 huawei,hg255d|\
244 iodata,wn-ax1167gr|\
245 iodata,wn-gx300gr|\
246 iodata,wnpr2600g|\
247 iptime,a604m)
248 ucidef_add_switch "switch0" \
249 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
250 ;;
251 asus,rt-n15|\
252 belkin,f9k1109v1|\
253 sitecom,wl-351)
254 ucidef_add_switch "switch0" \
255 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
256 ;;
257 asus,rt-n56u)
258 ucidef_add_switch "switch0" \
259 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "8@eth0"
260 ;;
261 asus,wl-330n|\
262 easyacc,wizard-8800|\
263 kingston,mlwg2)
264 ucidef_set_interface_lan "eth0.1"
265 ;;
266 aximcom,mr-102n|\
267 kingston,mlw221)
268 ucidef_set_interface_lan "eth0.2"
269 ;;
270 belkin,f5d8235-v1|\
271 belkin,f5d8235-v2|\
272 buffalo,wzr-agl300nh|\
273 ralink,v11st-fe|\
274 trendnet,tew-714tru)
275 ucidef_add_switch "switch0" \
276 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
277 ;;
278 buffalo,wcr-1166ds)
279 ucidef_add_switch "switch0" \
280 "3:lan" "4:wan" "6@eth0"
281 ;;
282 buffalo,whr-300hp2|\
283 buffalo,whr-600d|\
284 buffalo,wsr-1166dhp|\
285 buffalo,wsr-600dhp)
286 ucidef_add_switch "switch0" \
287 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
288 ;;
289 buffalo,whr-1166d)
290 ucidef_add_switch "switch0" \
291 "0:lan" "1:lan" "2:lan" "3:lan" "5:wan" "6@eth0"
292 ;;
293 comfast,cf-wr800n|\
294 hnet,c108|\
295 tplink,tl-wr902ac-v3|\
296 trendnet,tew-638apb-v2)
297 ucidef_add_switch "switch0" \
298 "4:lan" "6@eth0"
299 ;;
300 cudy,wr1000)
301 ucidef_add_switch "switch0" \
302 "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
303 ;;
304 dlink,dir-510l|\
305 glinet,vixmini|\
306 netgear,ex6150|\
307 tplink,re350-v1|\
308 tplink,re650-v1)
309 ucidef_add_switch "switch0" \
310 "0:lan" "6@eth0"
311 ;;
312 dlink,dir-615-h1|\
313 d-team,newifi-d2|\
314 wevo,11acnas|\
315 wevo,w2914ns-v2|\
316 zbtlink,zbt-we2026)
317 ucidef_add_switch "switch0" \
318 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
319 ;;
320 dlink,dwr-118-a1)
321 ucidef_add_switch "switch0" \
322 "1:lan:2" "2:lan:3" "3:lan:1" "4:lan:0" "5:wan" "6@eth0"
323 ;;
324 dlink,dwr-118-a2)
325 ucidef_add_switch "switch0" \
326 "1:lan:2" "2:lan:1" "3:lan:3" "4:lan" "0:wan" "6@eth0"
327 ;;
328 duzun,dm06)
329 ucidef_add_switch "switch0" \
330 "1:lan" "0:wan" "6@eth0"
331 ;;
332 edimax,br-6475nd)
333 ucidef_add_switch "switch0" \
334 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
335 ;;
336 edimax,br-6478ac-v2|\
337 tplink,archer-c2-v1)
338 ucidef_add_switch "switch1" \
339 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
340 ;;
341 engenius,esr600)
342 ucidef_add_switch "switch0" \
343 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "0@eth0"
344 ;;
345 fon,fon2601)
346 ucidef_add_switch "switch0" \
347 "0:lan" "4:wan" "6@eth0"
348 ;;
349 edimax,rg21s)
350 ucidef_add_switch "switch0" \
351 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
352 ;;
353 gehua,ghl-r-001)
354 ucidef_add_switch "switch0" \
355 "0:lan" "1:lan" "2:lan" "4:wan" "6@eth0"
356 ;;
357 glinet,gl-mt300n-v2)
358 ucidef_add_switch "switch0" \
359 "1:lan" "0:wan" "6@eth0"
360 ;;
361 gnubee,gb-pc1|\
362 gnubee,gb-pc2)
363 ucidef_add_switch "switch0" \
364 "0:lan" "4:lan" "6@eth0"
365 ;;
366 head-weblink,hdrm200)
367 ucidef_add_switch "switch0" \
368 "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
369 ;;
370 hiwifi,hc5761)
371 ucidef_add_switch "switch0" \
372 "1:lan" "4:lan" "0:wan" "6@eth0"
373 ;;
374 hiwifi,hc5861)
375 ucidef_add_switch "switch0" \
376 "0:lan" "1:lan" "5:wan" "6@eth0"
377 ;;
378 iodata,wn-ac1167gr|\
379 iodata,wn-ac733gr3)
380 ucidef_add_switch "switch1" \
381 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
382 ;;
383 iptime,a3)
384 ucidef_add_switch "switch0" \
385 "2:lan:2" "3:lan:1" "0:wan" "6@eth0"
386 ;;
387 lava,lr-25g001|\
388 sitecom,wlr-6000|\
389 trendnet,tew-691gr|\
390 trendnet,tew-692gr)
391 ucidef_add_switch "switch0" \
392 "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
393 ;;
394 lenovo,newifi-d1)
395 ucidef_add_switch "switch0" \
396 "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
397 ;;
398 lenovo,newifi-y1|\
399 zbtlink,zbt-we1226)
400 ucidef_add_switch "switch0" \
401 "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
402 ;;
403 lenovo,newifi-y1s)
404 ucidef_add_switch "switch0" \
405 "1:lan:4" "2:lan:3" "4:lan:2" "5:lan:1" "0:wan" "6@eth0"
406 ;;
407 linksys,e1700|\
408 ralink,mt7620a-mt7530-evb)
409 ucidef_add_switch "switch1" \
410 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
411 ;;
412 linksys,re6500)
413 ucidef_add_switch "switch0" \
414 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
415 ;;
416 netgear,r6120|\
417 netgear,r6220|\
418 netgear,r6260|\
419 netgear,r6350|\
420 netgear,r6850|\
421 netgear,wndr3700-v5)
422 ucidef_add_switch "switch0" \
423 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
424 ;;
425 nexx,wt1520-4m|\
426 nexx,wt1520-8m|\
427 vonets,var11n-300)
428 ucidef_add_switch "switch0" \
429 "0:lan" "4:wan" "6@eth0"
430 ;;
431 nexx,wt3020-4m|\
432 nexx,wt3020-8m)
433 ucidef_add_switch "switch0" \
434 "4:lan" "0:wan" "6@eth0"
435 ;;
436 phicomm,k2g)
437 ucidef_add_switch "switch0" \
438 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5:wan" "6@eth0"
439 ;;
440 phicomm,psg1218b)
441 ucidef_add_switch "switch0" \
442 "0:lan:3" "1:lan:2" "2:lan:1" "3:wan" "6@eth0"
443 ;;
444 planex,mzk-dp150n|\
445 vocore,vocore-8m|\
446 vocore,vocore-16m)
447 ucidef_add_switch "switch0" \
448 "0:lan" "4:lan" "6t@eth0"
449 ;;
450 samsung,cy-swr1100)
451 ucidef_add_switch "switch0" \
452 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0"
453 ;;
454 sparklan,wcr-150gn|\
455 zbtlink,zbt-we1026-5g-16m)
456 ucidef_add_switch "switch0" \
457 "0:lan" "6t@eth0"
458 ;;
459 tplink,archer-c20-v1|\
460 tplink,archer-c50-v1)
461 ucidef_add_switch "switch0" \
462 "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0"
463 ;;
464 tplink,archer-mr200)
465 ucidef_add_switch "switch0" \
466 "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0"
467 ucidef_set_interface_wan "usb0"
468 ;;
469 vocore,vocore2|\
470 vocore,vocore2-lite)
471 ucidef_add_switch "switch0" \
472 "0:lan" "2:lan" "6t@eth0"
473 ;;
474 wiznet,wizfi630a)
475 ucidef_add_switch "switch0" \
476 "0:lan" "1:lan" "2:wan" "6@eth0"
477 ;;
478 wiznet,wizfi630s)
479 ucidef_add_switch "switch0" \
480 "0:wan" "3:lan" "4:lan" "6@eth0"
481 ;;
482 xiaomi,mir3g)
483 ucidef_add_switch "switch0" \
484 "2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
485 ;;
486 xiaomi,mir3p)
487 ucidef_add_switch "switch0" \
488 "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
489 ;;
490 xiaomi,mir4a-100m)
491 ucidef_add_switch "switch0" \
492 "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
493 ;;
494 zyxel,keenetic-omni-ii)
495 ucidef_add_switch "switch0" \
496 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6@eth0"
497 ;;
498 zyxel,keenetic-start)
499 ucidef_add_switch "switch0" \
500 "0:lan:3" "1:lan:2" "2:lan:1" "3:lan:0" "4:wan" "6@eth0"
501 ;;
502 zyxel,keenetic-viva)
503 ucidef_add_switch "switch1" \
504 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "7t@eth0"
505 ;;
506 *)
507 RT3X5X=$(grep -E "(RT3.5|RT5350)" /proc/cpuinfo)
508 if [ -n "${RT3X5X}" ]; then
509 ramips_setup_rt3x5x_vlans
510 else
511 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
512 fi
513 ;;
514 esac
515 }
516
517 ramips_setup_macs()
518 {
519 local board="$1"
520 local lan_mac=""
521 local wan_mac=""
522
523 case $board in
524 8devices,carambola|\
525 alfa-network,w502u|\
526 arcwireless,freestation5|\
527 lenovo,newifi-y1|\
528 lenovo,newifi-y1s|\
529 netgear,wnce2001|\
530 ohyeah,oy-0001|\
531 phicomm,k2g|\
532 skylab,skw92a|\
533 totolink,lr1200)
534 wan_mac=$(mtd_get_mac_binary factory 0x2e)
535 ;;
536 dlink,dir-300-b7|\
537 dlink,dir-320-b1|\
538 dlink,dir-620-a1|\
539 engenius,esr-9753|\
540 hame,mpr-a1|\
541 hauppauge,broadway|\
542 huawei,d105|\
543 hilink,hlk-7628n|\
544 hilink,hlk-rm04|\
545 nexaira,bc2|\
546 petatel,psr-680w|\
547 skyline,sl-r7205)
548 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
549 wan_mac=$(macaddr_add "$lan_mac" 1)
550 ;;
551 asus,rt-ac57u|\
552 d-team,newifi-d2|\
553 d-team,pbr-m1|\
554 elecom,wrc-1167ghbk2-s|\
555 elecom,wrc-1900gst|\
556 elecom,wrc-2533gst|\
557 lenovo,newifi-d1|\
558 phicomm,k2p|\
559 planex,vr500|\
560 samknows,whitebox-v8|\
561 youhua,wr1200js|\
562 youku,yk-l2|\
563 zbtlink,zbt-we3526)
564 wan_mac=$(mtd_get_mac_binary factory 0xe006)
565 ;;
566 asus,rt-ac65p|\
567 asus,rt-ac85p)
568 wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
569 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
570 ;;
571 asus,rt-n56u)
572 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
573 wan_mac=$(mtd_get_mac_binary factory 0x8004)
574 ;;
575 belkin,f9k1109v1)
576 wan_mac=$(mtd_get_mac_ascii uboot-env HW_WAN_MAC)
577 lan_mac=$(mtd_get_mac_ascii uboot-env HW_LAN_MAC)
578 label_mac=$wan_mac
579 ;;
580 buffalo,wcr-1166ds|\
581 buffalo,wsr-1166dhp)
582 local index="$(find_mtd_index "board_data")"
583 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
584 lan_mac=$wan_mac
585 ;;
586 buffalo,whr-1166d|\
587 buffalo,whr-300hp2|\
588 buffalo,whr-600d|\
589 buffalo,whr-g300n|\
590 buffalo,wsr-600dhp|\
591 glinet,gl-mt300n-v2|\
592 xiaomi,miwifi-mini|\
593 zyxel,keenetic-start)
594 # This empty case has to be kept for devices without any MAC address adjustments
595 ;;
596 cudy,wr1000)
597 wan_mac=$(mtd_get_mac_binary factory 0x2e)
598 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
599 ;;
600 dlink,dch-m225|\
601 samsung,cy-swr1100)
602 lan_mac=$(mtd_get_mac_ascii factory lanmac)
603 ;;
604 dlink,dir-510l|\
605 dlink,dwr-116-a1|\
606 dlink,dwr-118-a1|\
607 dlink,dwr-118-a2|\
608 dlink,dwr-921-c1|\
609 dlink,dwr-922-e2|\
610 lava,lr-25g001)
611 wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
612 lan_mac=$(macaddr_add "$wan_mac" 1)
613 label_mac=$wan_mac
614 ;;
615 dlink,dir-615-d|\
616 dlink,dir-615-h1|\
617 glinet,gl-mt300a|\
618 glinet,gl-mt300n|\
619 glinet,gl-mt750|\
620 zbtlink,zbt-wg3526-16m|\
621 zbtlink,zbt-wg3526-32m)
622 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
623 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
624 ;;
625 dlink,dir-645)
626 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
627 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
628 ;;
629 dlink,dir-860l-b1)
630 lan_mac=$(mtd_get_mac_ascii factory lanmac)
631 wan_mac=$(mtd_get_mac_ascii factory wanmac)
632 label_mac=$(cat /sys/class/ieee80211/phy1/macaddress)
633 ;;
634 dovado,tiny-ac)
635 lan_mac=$(mtd_get_mac_ascii u-boot-env LAN_MAC_ADDR)
636 wan_mac=$(mtd_get_mac_ascii u-boot-env WAN_MAC_ADDR)
637 ;;
638 edimax,br-6475nd)
639 wan_mac=$(mtd_get_mac_binary devdata 0x7)
640 ;;
641 edimax,br-6478ac-v2|\
642 netgear,r6260|\
643 netgear,r6350|\
644 netgear,r6850)
645 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
646 ;;
647 edimax,rg21s|\
648 engenius,esr600)
649 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
650 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
651 ;;
652 hiwifi,hc5661|\
653 hiwifi,hc5661a|\
654 hiwifi,hc5761|\
655 hiwifi,hc5761a|\
656 hiwifi,hc5861|\
657 hiwifi,hc5861b|\
658 hiwifi,hc5962)
659 lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
660 label_mac=$lan_mac
661 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
662 wan_mac=$(macaddr_add "$lan_mac" 1)
663 ;;
664 iodata,wn-ac1167gr|\
665 iodata,wn-ac733gr3)
666 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
667 ;;
668 iodata,wn-ax1167gr|\
669 iodata,wn-gx300gr|\
670 trendnet,tew-692gr)
671 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
672 ;;
673 iodata,wnpr2600g)
674 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
675 label_mac=$wan_mac
676 ;;
677 iptime,a3|\
678 iptime,a604m)
679 wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40)
680 ;;
681 linksys,e1700)
682 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
683 ;;
684 mediatek,linkit-smart-7688|\
685 onion,omega2|\
686 onion,omega2p)
687 wan_mac=$(mtd_get_mac_binary factory 0x4)
688 lan_mac=$(mtd_get_mac_binary factory 0x2e)
689 ;;
690 mercury,mac1200r-v2)
691 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1)
692 ;;
693 poray,m3|\
694 poray,m4-4m|\
695 poray,m4-8m|\
696 poray,x5|\
697 poray,x8)
698 lan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" -2)
699 ;;
700 sitecom,wlr-6000)
701 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x8004)" 2)
702 ;;
703 sparklan,wcr-150gn|\
704 wiznet,wizfi630a|\
705 zyxel,keenetic-omni|\
706 zyxel,keenetic-omni-ii|\
707 zyxel,keenetic-viva)
708 wan_mac=$(mtd_get_mac_binary factory 0x28)
709 ;;
710 tenda,w306r-v2)
711 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 5)
712 ;;
713 trendnet,tew-691gr)
714 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 3)
715 ;;
716 vocore,vocore2|\
717 vocore,vocore2-lite)
718 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
719 ;;
720 xiaomi,mir3g)
721 lan_mac=$(mtd_get_mac_binary factory 0xe006)
722 ;;
723 xiaomi,mir3p)
724 lan_mac=$(mtd_get_mac_binary factory 0xe006)
725 label_mac=$lan_mac
726 ;;
727 zbtlink,zbt-we1326)
728 wan_mac=$(mtd_get_mac_binary factory 0xe006)
729 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
730 ;;
731 *)
732 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
733 ;;
734 esac
735
736 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
737 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
738 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
739 }
740
741 board_config_update
742 board=$(board_name)
743 ramips_setup_interfaces $board
744 ramips_setup_macs $board
745 board_config_flush
746
747 exit 0