ramips: move "elx-header" to Makefile from mt7620.mk and mt7621.mk
[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-256m-16m|\
86 unielec,u7621-06-512m-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-128m-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-ac85p|\
238 dlink,dir-860l-b1|\
239 elecom,wrc-1167ghbk2-s|\
240 elecom,wrc-1900gst|\
241 elecom,wrc-2533gst|\
242 huawei,hg255d|\
243 iodata,wn-ax1167gr|\
244 iodata,wn-gx300gr|\
245 iptime,a604m)
246 ucidef_add_switch "switch0" \
247 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
248 ;;
249 asus,rt-n15|\
250 belkin,f9k1109v1|\
251 sitecom,wl-351)
252 ucidef_add_switch "switch0" \
253 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5@eth0"
254 ;;
255 asus,rt-n56u)
256 ucidef_add_switch "switch0" \
257 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "8@eth0"
258 ;;
259 asus,wl-330n|\
260 easyacc,wizard-8800|\
261 kingston,mlwg2)
262 ucidef_set_interface_lan "eth0.1"
263 ;;
264 aximcom,mr-102n|\
265 kingston,mlw221)
266 ucidef_set_interface_lan "eth0.2"
267 ;;
268 belkin,f5d8235-v1|\
269 belkin,f5d8235-v2|\
270 buffalo,wzr-agl300nh|\
271 ralink,v11st-fe|\
272 trendnet,tew-714tru)
273 ucidef_add_switch "switch0" \
274 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
275 ;;
276 buffalo,wcr-1166ds)
277 ucidef_add_switch "switch0" \
278 "3:lan" "4:wan" "6@eth0"
279 ;;
280 buffalo,whr-300hp2|\
281 buffalo,whr-600d|\
282 buffalo,wsr-1166dhp|\
283 buffalo,wsr-600dhp)
284 ucidef_add_switch "switch0" \
285 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:wan:5" "6@eth0"
286 ;;
287 buffalo,whr-1166d)
288 ucidef_add_switch "switch0" \
289 "0:lan" "1:lan" "2:lan" "3:lan" "5:wan" "6@eth0"
290 ;;
291 comfast,cf-wr800n|\
292 hnet,c108)
293 ucidef_add_switch "switch0" \
294 "4:lan" "6t@eth0"
295 ;;
296 cudy,wr1000)
297 ucidef_add_switch "switch0" \
298 "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
299 ;;
300 dlink,dir-510l|\
301 glinet,vixmini|\
302 netgear,ex6150|\
303 tplink,re350-v1|\
304 tplink,re650-v1)
305 ucidef_add_switch "switch0" \
306 "0:lan" "6@eth0"
307 ;;
308 dlink,dir-615-h1|\
309 d-team,newifi-d2|\
310 wevo,11acnas|\
311 wevo,w2914ns-v2|\
312 zbtlink,zbt-we2026)
313 ucidef_add_switch "switch0" \
314 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
315 ;;
316 dlink,dwr-118-a1)
317 ucidef_add_switch "switch0" \
318 "1:lan:2" "2:lan:3" "3:lan:1" "4:lan:0" "5:wan" "6@eth0"
319 ;;
320 dlink,dwr-118-a2)
321 ucidef_add_switch "switch0" \
322 "1:lan:2" "2:lan:1" "3:lan:3" "4:lan" "0:wan" "6@eth0"
323 ;;
324 duzun,dm06)
325 ucidef_add_switch "switch0" \
326 "1:lan" "0:wan" "6@eth0"
327 ;;
328 edimax,br-6475nd)
329 ucidef_add_switch "switch0" \
330 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
331 ;;
332 edimax,br-6478ac-v2|\
333 tplink,archer-c2-v1)
334 ucidef_add_switch "switch1" \
335 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
336 ;;
337 engenius,esr600)
338 ucidef_add_switch "switch0" \
339 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "0@eth0"
340 ;;
341 fon,fon2601)
342 ucidef_add_switch "switch0" \
343 "0:lan" "4:wan" "6@eth0"
344 ;;
345 edimax,rg21s)
346 ucidef_add_switch "switch0" \
347 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
348 ;;
349 gehua,ghl-r-001)
350 ucidef_add_switch "switch0" \
351 "0:lan" "1:lan" "2:lan" "4:wan" "6@eth0"
352 ;;
353 glinet,gl-mt300n-v2)
354 ucidef_add_switch "switch0" \
355 "1:lan" "0:wan" "6@eth0"
356 ;;
357 gnubee,gb-pc1|\
358 gnubee,gb-pc2)
359 ucidef_add_switch "switch0" \
360 "0:lan" "4:lan" "6@eth0"
361 ;;
362 head-weblink,hdrm200)
363 ucidef_add_switch "switch0" \
364 "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
365 ;;
366 hiwifi,hc5761)
367 ucidef_add_switch "switch0" \
368 "1:lan" "4:lan" "0:wan" "6@eth0"
369 ;;
370 hiwifi,hc5861)
371 ucidef_add_switch "switch0" \
372 "0:lan" "1:lan" "5:wan" "6@eth0"
373 ;;
374 iodata,wn-ac1167gr|\
375 iodata,wn-ac733gr3)
376 ucidef_add_switch "switch1" \
377 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
378 ;;
379 iptime,a3)
380 ucidef_add_switch "switch0" \
381 "2:lan:2" "3:lan:1" "0:wan" "6@eth0"
382 ;;
383 lava,lr-25g001|\
384 sitecom,wlr-6000|\
385 trendnet,tew-691gr|\
386 trendnet,tew-692gr)
387 ucidef_add_switch "switch0" \
388 "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
389 ;;
390 lenovo,newifi-d1)
391 ucidef_add_switch "switch0" \
392 "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
393 ;;
394 lenovo,newifi-y1|\
395 zbtlink,zbt-we1226)
396 ucidef_add_switch "switch0" \
397 "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
398 ;;
399 lenovo,newifi-y1s)
400 ucidef_add_switch "switch0" \
401 "1:lan:4" "2:lan:3" "4:lan:2" "5:lan:1" "0:wan" "6@eth0"
402 ;;
403 linksys,e1700|\
404 ralink,mt7620a-mt7530-evb)
405 ucidef_add_switch "switch1" \
406 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
407 ;;
408 linksys,re6500)
409 ucidef_add_switch "switch0" \
410 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
411 ;;
412 netgear,r6120|\
413 netgear,r6220|\
414 netgear,r6260|\
415 netgear,r6350|\
416 netgear,r6850|\
417 netgear,wndr3700-v5)
418 ucidef_add_switch "switch0" \
419 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
420 ;;
421 nexx,wt1520-4m|\
422 nexx,wt1520-8m|\
423 vonets,var11n-300)
424 ucidef_add_switch "switch0" \
425 "0:lan" "4:wan" "6@eth0"
426 ;;
427 nexx,wt3020-4m|\
428 nexx,wt3020-8m)
429 ucidef_add_switch "switch0" \
430 "4:lan" "0:wan" "6@eth0"
431 ;;
432 phicomm,k2g)
433 ucidef_add_switch "switch0" \
434 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5:wan" "6@eth0"
435 ;;
436 phicomm,psg1218b)
437 ucidef_add_switch "switch0" \
438 "0:lan:3" "1:lan:2" "2:lan:1" "3:wan" "6@eth0"
439 ;;
440 planex,mzk-dp150n|\
441 vocore,vocore-8m|\
442 vocore,vocore-16m)
443 ucidef_add_switch "switch0" \
444 "0:lan" "4:lan" "6t@eth0"
445 ;;
446 samsung,cy-swr1100)
447 ucidef_add_switch "switch0" \
448 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0"
449 ;;
450 sparklan,wcr-150gn|\
451 zbtlink,we1026-5g-16m)
452 ucidef_add_switch "switch0" \
453 "0:lan" "6t@eth0"
454 ;;
455 tplink,archer-c20-v1|\
456 tplink,archer-c50-v1)
457 ucidef_add_switch "switch0" \
458 "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0"
459 ;;
460 tplink,archer-mr200)
461 ucidef_add_switch "switch0" \
462 "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0"
463 ucidef_set_interface_wan "usb0"
464 ;;
465 tplink,tl-wr902ac-v3)
466 ucidef_add_switch "switch0" \
467 "4:lan" "6@eth0"
468 ;;
469 trendnet,tew-638apb-v2)
470 ucidef_add_switch "switch0" \
471 "4:lan" "6@eth0"
472 ;;
473 vocore,vocore2|\
474 vocore,vocore2-lite)
475 ucidef_add_switch "switch0" \
476 "0:lan" "2:lan" "6t@eth0"
477 ;;
478 wiznet,wizfi630a)
479 ucidef_add_switch "switch0" \
480 "0:lan" "1:lan" "2:wan" "6@eth0"
481 ;;
482 wiznet,wizfi630s)
483 ucidef_add_switch "switch0" \
484 "0:wan" "3:lan" "4:lan" "6@eth0"
485 ;;
486 xiaomi,mir3g)
487 ucidef_add_switch "switch0" \
488 "2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
489 ;;
490 xiaomi,mir3p)
491 ucidef_add_switch "switch0" \
492 "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
493 ;;
494 xiaomi,mir4a-100m)
495 ucidef_add_switch "switch0" \
496 "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
497 ;;
498 zyxel,keenetic-omni-ii)
499 ucidef_add_switch "switch0" \
500 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6@eth0"
501 ;;
502 zyxel,keenetic-start)
503 ucidef_add_switch "switch0" \
504 "0:lan:3" "1:lan:2" "2:lan:1" "3:lan:0" "4:wan" "6@eth0"
505 ;;
506 zyxel,keenetic-viva)
507 ucidef_add_switch "switch1" \
508 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "7t@eth0"
509 ;;
510 *)
511 RT3X5X=$(grep -E "(RT3.5|RT5350)" /proc/cpuinfo)
512 if [ -n "${RT3X5X}" ]; then
513 ramips_setup_rt3x5x_vlans
514 else
515 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
516 fi
517 ;;
518 esac
519 }
520
521 ramips_setup_macs()
522 {
523 local board="$1"
524 local lan_mac=""
525 local wan_mac=""
526
527 case $board in
528 8devices,carambola|\
529 alfa-network,w502u|\
530 arcwireless,freestation5|\
531 lenovo,newifi-y1|\
532 lenovo,newifi-y1s|\
533 netgear,wnce2001|\
534 ohyeah,oy-0001|\
535 phicomm,k2g|\
536 skylab,skw92a|\
537 totolink,lr1200)
538 wan_mac=$(mtd_get_mac_binary factory 0x2e)
539 ;;
540 dlink,dir-300-b7|\
541 dlink,dir-320-b1|\
542 dlink,dir-620-a1|\
543 engenius,esr-9753|\
544 hame,mpr-a1|\
545 hauppauge,broadway|\
546 huawei,d105|\
547 hilink,hlk-7628n|\
548 hilink,hlk-rm04|\
549 nexaira,bc2|\
550 petatel,psr-680w|\
551 skyline,sl-r7205)
552 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
553 wan_mac=$(macaddr_add "$lan_mac" 1)
554 ;;
555 asus,rt-ac57u|\
556 d-team,newifi-d2|\
557 d-team,pbr-m1|\
558 elecom,wrc-1167ghbk2-s|\
559 elecom,wrc-1900gst|\
560 elecom,wrc-2533gst|\
561 lenovo,newifi-d1|\
562 phicomm,k2p|\
563 planex,vr500|\
564 samknows,whitebox-v8|\
565 youku,yk-l2|\
566 zbtlink,zbt-we3526)
567 wan_mac=$(mtd_get_mac_binary factory 0xe006)
568 ;;
569 asus,rt-ac85p)
570 wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
571 ;;
572 asus,rt-n56u)
573 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
574 wan_mac=$(mtd_get_mac_binary factory 0x8004)
575 ;;
576 belkin,f9k1109v1)
577 wan_mac=$(mtd_get_mac_ascii uboot-env HW_WAN_MAC)
578 lan_mac=$(mtd_get_mac_ascii uboot-env HW_LAN_MAC)
579 label_mac=$wan_mac
580 ;;
581 buffalo,wcr-1166ds|\
582 buffalo,wsr-1166dhp)
583 local index="$(find_mtd_index "board_data")"
584 wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
585 lan_mac=$wan_mac
586 ;;
587 buffalo,whr-1166d|\
588 buffalo,whr-300hp2|\
589 buffalo,whr-600d|\
590 buffalo,whr-g300n|\
591 buffalo,wsr-600dhp|\
592 glinet,gl-mt300n-v2|\
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 iptime,a3|\
674 iptime,a604m)
675 wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40)
676 ;;
677 linksys,e1700)
678 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
679 ;;
680 mediatek,linkit-smart-7688|\
681 onion,omega2|\
682 onion,omega2p)
683 wan_mac=$(mtd_get_mac_binary factory 0x4)
684 lan_mac=$(mtd_get_mac_binary factory 0x2e)
685 ;;
686 mercury,mac1200r-v2)
687 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1)
688 ;;
689 poray,m3|\
690 poray,m4-4m|\
691 poray,m4-8m|\
692 poray,x5|\
693 poray,x8)
694 lan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" -2)
695 ;;
696 sitecom,wlr-6000)
697 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x8004)" 2)
698 ;;
699 sparklan,wcr-150gn|\
700 wiznet,wizfi630a|\
701 zyxel,keenetic-omni|\
702 zyxel,keenetic-omni-ii|\
703 zyxel,keenetic-viva)
704 wan_mac=$(mtd_get_mac_binary factory 0x28)
705 ;;
706 tenda,w306r-v2)
707 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 5)
708 ;;
709 trendnet,tew-691gr)
710 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 3)
711 ;;
712 vocore,vocore2|\
713 vocore,vocore2-lite)
714 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
715 ;;
716 xiaomi,mir3g)
717 lan_mac=$(mtd_get_mac_binary factory 0xe006)
718 ;;
719 xiaomi,mir3p)
720 lan_mac=$(mtd_get_mac_binary factory 0xe006)
721 label_mac=$lan_mac
722 ;;
723 xiaomi,miwifi-mini)
724 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
725 ;;
726 zbtlink,zbt-we1326)
727 wan_mac=$(mtd_get_mac_binary factory 0xe006)
728 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
729 ;;
730 *)
731 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
732 ;;
733 esac
734
735 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
736 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
737 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
738 }
739
740 board_config_update
741 board=$(board_name)
742 ramips_setup_interfaces $board
743 ramips_setup_macs $board
744 board_config_flush
745
746 exit 0