480726a870e1a155d6b8857a3ed4a3a619987169
[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 xiaomi,mir3g-v2)
302 ucidef_add_switch "switch0" \
303 "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
304 ;;
305 dlink,dir-510l|\
306 glinet,vixmini|\
307 netgear,ex6150|\
308 tplink,re350-v1|\
309 tplink,re650-v1)
310 ucidef_add_switch "switch0" \
311 "0:lan" "6@eth0"
312 ;;
313 dlink,dir-615-h1|\
314 d-team,newifi-d2|\
315 wevo,11acnas|\
316 wevo,w2914ns-v2|\
317 zbtlink,zbt-we2026)
318 ucidef_add_switch "switch0" \
319 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0"
320 ;;
321 dlink,dwr-118-a1)
322 ucidef_add_switch "switch0" \
323 "1:lan:2" "2:lan:3" "3:lan:1" "4:lan:0" "5:wan" "6@eth0"
324 ;;
325 dlink,dwr-118-a2)
326 ucidef_add_switch "switch0" \
327 "1:lan:2" "2:lan:1" "3:lan:3" "4:lan" "0:wan" "6@eth0"
328 ;;
329 duzun,dm06)
330 ucidef_add_switch "switch0" \
331 "1:lan" "0:wan" "6@eth0"
332 ;;
333 edimax,br-6475nd)
334 ucidef_add_switch "switch0" \
335 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
336 ;;
337 edimax,br-6478ac-v2|\
338 tplink,archer-c2-v1)
339 ucidef_add_switch "switch1" \
340 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0"
341 ;;
342 engenius,esr600)
343 ucidef_add_switch "switch0" \
344 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "0@eth0"
345 ;;
346 fon,fon2601)
347 ucidef_add_switch "switch0" \
348 "0:lan" "4:wan" "6@eth0"
349 ;;
350 edimax,rg21s)
351 ucidef_add_switch "switch0" \
352 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
353 ;;
354 gehua,ghl-r-001)
355 ucidef_add_switch "switch0" \
356 "0:lan" "1:lan" "2:lan" "4:wan" "6@eth0"
357 ;;
358 glinet,gl-mt300n-v2)
359 ucidef_add_switch "switch0" \
360 "1:lan" "0:wan" "6@eth0"
361 ;;
362 gnubee,gb-pc1|\
363 gnubee,gb-pc2)
364 ucidef_add_switch "switch0" \
365 "0:lan" "4:lan" "6@eth0"
366 ;;
367 head-weblink,hdrm200)
368 ucidef_add_switch "switch0" \
369 "1:lan" "2:lan" "3:lan" "4:lan" "5:lan" "0:wan" "6@eth0"
370 ;;
371 hiwifi,hc5761)
372 ucidef_add_switch "switch0" \
373 "1:lan" "4:lan" "0:wan" "6@eth0"
374 ;;
375 hiwifi,hc5861)
376 ucidef_add_switch "switch0" \
377 "0:lan" "1:lan" "5:wan" "6@eth0"
378 ;;
379 iodata,wn-ac1167gr|\
380 iodata,wn-ac733gr3)
381 ucidef_add_switch "switch1" \
382 "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "6@eth0"
383 ;;
384 iptime,a3)
385 ucidef_add_switch "switch0" \
386 "2:lan:2" "3:lan:1" "0:wan" "6@eth0"
387 ;;
388 lava,lr-25g001|\
389 sitecom,wlr-6000|\
390 trendnet,tew-691gr|\
391 trendnet,tew-692gr)
392 ucidef_add_switch "switch0" \
393 "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "0@eth0"
394 ;;
395 lenovo,newifi-d1)
396 ucidef_add_switch "switch0" \
397 "1:lan:2" "2:lan:1" "4:wan" "6@eth0"
398 ;;
399 lenovo,newifi-y1|\
400 zbtlink,zbt-we1226)
401 ucidef_add_switch "switch0" \
402 "0:lan:2" "1:lan:1" "4:wan" "6@eth0"
403 ;;
404 lenovo,newifi-y1s)
405 ucidef_add_switch "switch0" \
406 "1:lan:4" "2:lan:3" "4:lan:2" "5:lan:1" "0:wan" "6@eth0"
407 ;;
408 linksys,e1700|\
409 ralink,mt7620a-mt7530-evb)
410 ucidef_add_switch "switch1" \
411 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0"
412 ;;
413 linksys,re6500)
414 ucidef_add_switch "switch0" \
415 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "6@eth0"
416 ;;
417 netgear,r6120|\
418 netgear,r6220|\
419 netgear,r6260|\
420 netgear,r6350|\
421 netgear,r6850|\
422 netgear,wndr3700-v5)
423 ucidef_add_switch "switch0" \
424 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
425 ;;
426 nexx,wt1520-4m|\
427 nexx,wt1520-8m|\
428 vonets,var11n-300)
429 ucidef_add_switch "switch0" \
430 "0:lan" "4:wan" "6@eth0"
431 ;;
432 nexx,wt3020-4m|\
433 nexx,wt3020-8m)
434 ucidef_add_switch "switch0" \
435 "4:lan" "0:wan" "6@eth0"
436 ;;
437 phicomm,k2g)
438 ucidef_add_switch "switch0" \
439 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5:wan" "6@eth0"
440 ;;
441 phicomm,psg1218b)
442 ucidef_add_switch "switch0" \
443 "0:lan:3" "1:lan:2" "2:lan:1" "3:wan" "6@eth0"
444 ;;
445 planex,mzk-dp150n|\
446 vocore,vocore-8m|\
447 vocore,vocore-16m)
448 ucidef_add_switch "switch0" \
449 "0:lan" "4:lan" "6t@eth0"
450 ;;
451 samsung,cy-swr1100)
452 ucidef_add_switch "switch0" \
453 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "9@eth0"
454 ;;
455 sparklan,wcr-150gn|\
456 zbtlink,zbt-we1026-5g-16m)
457 ucidef_add_switch "switch0" \
458 "0:lan" "6t@eth0"
459 ;;
460 tplink,archer-c20-v1|\
461 tplink,archer-c50-v1)
462 ucidef_add_switch "switch0" \
463 "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0"
464 ;;
465 tplink,archer-mr200)
466 ucidef_add_switch "switch0" \
467 "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0"
468 ucidef_set_interface_wan "usb0"
469 ;;
470 vocore,vocore2|\
471 vocore,vocore2-lite)
472 ucidef_add_switch "switch0" \
473 "0:lan" "2:lan" "6t@eth0"
474 ;;
475 wiznet,wizfi630a)
476 ucidef_add_switch "switch0" \
477 "0:lan" "1:lan" "2:wan" "6@eth0"
478 ;;
479 wiznet,wizfi630s)
480 ucidef_add_switch "switch0" \
481 "0:wan" "3:lan" "4:lan" "6@eth0"
482 ;;
483 xiaomi,mir3g)
484 ucidef_add_switch "switch0" \
485 "2:lan:2" "3:lan:1" "1:wan" "6t@eth0"
486 ;;
487 xiaomi,mir3p)
488 ucidef_add_switch "switch0" \
489 "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0"
490 ;;
491 xiaomi,mir4a-100m)
492 ucidef_add_switch "switch0" \
493 "4:lan:1" "2:lan:2" "0:wan" "6@eth0"
494 ;;
495 zyxel,keenetic-omni-ii)
496 ucidef_add_switch "switch0" \
497 "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6@eth0"
498 ;;
499 zyxel,keenetic-start)
500 ucidef_add_switch "switch0" \
501 "0:lan:3" "1:lan:2" "2:lan:1" "3:lan:0" "4:wan" "6@eth0"
502 ;;
503 zyxel,keenetic-viva)
504 ucidef_add_switch "switch1" \
505 "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "7t@eth0"
506 ;;
507 *)
508 RT3X5X=$(grep -E "(RT3.5|RT5350)" /proc/cpuinfo)
509 if [ -n "${RT3X5X}" ]; then
510 ramips_setup_rt3x5x_vlans
511 else
512 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
513 fi
514 ;;
515 esac
516 }
517
518 ramips_setup_macs()
519 {
520 local board="$1"
521 local lan_mac=""
522 local wan_mac=""
523
524 case $board in
525 8devices,carambola|\
526 alfa-network,w502u|\
527 arcwireless,freestation5|\
528 lenovo,newifi-y1|\
529 lenovo,newifi-y1s|\
530 netgear,wnce2001|\
531 ohyeah,oy-0001|\
532 phicomm,k2g|\
533 skylab,skw92a|\
534 totolink,lr1200)
535 wan_mac=$(mtd_get_mac_binary factory 0x2e)
536 ;;
537 dlink,dir-300-b7|\
538 dlink,dir-320-b1|\
539 dlink,dir-620-a1|\
540 engenius,esr-9753|\
541 hame,mpr-a1|\
542 hauppauge,broadway|\
543 huawei,d105|\
544 hilink,hlk-7628n|\
545 hilink,hlk-rm04|\
546 nexaira,bc2|\
547 petatel,psr-680w|\
548 skyline,sl-r7205)
549 lan_mac=$(macaddr_setbit_la "$(cat /sys/class/net/eth0/address)")
550 wan_mac=$(macaddr_add "$lan_mac" 1)
551 ;;
552 asus,rt-ac57u|\
553 d-team,newifi-d2|\
554 d-team,pbr-m1|\
555 elecom,wrc-1167ghbk2-s|\
556 elecom,wrc-1900gst|\
557 elecom,wrc-2533gst|\
558 lenovo,newifi-d1|\
559 phicomm,k2p|\
560 planex,vr500|\
561 samknows,whitebox-v8|\
562 youhua,wr1200js|\
563 youku,yk-l2|\
564 zbtlink,zbt-we3526)
565 wan_mac=$(mtd_get_mac_binary factory 0xe006)
566 ;;
567 asus,rt-ac65p|\
568 asus,rt-ac85p)
569 wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr)
570 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
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 xiaomi,miwifi-mini|\
594 zyxel,keenetic-start)
595 # This empty case has to be kept for devices without any MAC address adjustments
596 ;;
597 cudy,wr1000)
598 wan_mac=$(mtd_get_mac_binary factory 0x2e)
599 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
600 ;;
601 dlink,dch-m225|\
602 samsung,cy-swr1100)
603 lan_mac=$(mtd_get_mac_ascii factory lanmac)
604 ;;
605 dlink,dir-510l|\
606 dlink,dwr-116-a1|\
607 dlink,dwr-118-a1|\
608 dlink,dwr-118-a2|\
609 dlink,dwr-921-c1|\
610 dlink,dwr-922-e2|\
611 lava,lr-25g001)
612 wan_mac=$(jboot_config_read -m -i $(find_mtd_part "config") -o 0xE000)
613 lan_mac=$(macaddr_add "$wan_mac" 1)
614 label_mac=$wan_mac
615 ;;
616 dlink,dir-615-d|\
617 dlink,dir-615-h1|\
618 glinet,gl-mt300a|\
619 glinet,gl-mt300n|\
620 glinet,gl-mt750|\
621 zbtlink,zbt-wg3526-16m|\
622 zbtlink,zbt-wg3526-32m)
623 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
624 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
625 ;;
626 dlink,dir-645)
627 lan_mac=$(mtd_get_mac_ascii nvram lanmac)
628 wan_mac=$(mtd_get_mac_ascii nvram wanmac)
629 ;;
630 dlink,dir-860l-b1)
631 lan_mac=$(mtd_get_mac_ascii factory lanmac)
632 wan_mac=$(mtd_get_mac_ascii factory wanmac)
633 label_mac=$(cat /sys/class/ieee80211/phy1/macaddress)
634 ;;
635 dovado,tiny-ac)
636 lan_mac=$(mtd_get_mac_ascii u-boot-env LAN_MAC_ADDR)
637 wan_mac=$(mtd_get_mac_ascii u-boot-env WAN_MAC_ADDR)
638 ;;
639 edimax,br-6475nd)
640 wan_mac=$(mtd_get_mac_binary devdata 0x7)
641 ;;
642 edimax,br-6478ac-v2|\
643 netgear,r6260|\
644 netgear,r6350|\
645 netgear,r6850)
646 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 2)
647 ;;
648 edimax,rg21s|\
649 engenius,esr600)
650 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
651 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
652 ;;
653 hiwifi,hc5661|\
654 hiwifi,hc5661a|\
655 hiwifi,hc5761|\
656 hiwifi,hc5761a|\
657 hiwifi,hc5861|\
658 hiwifi,hc5861b|\
659 hiwifi,hc5962)
660 lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ")
661 label_mac=$lan_mac
662 [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address)
663 wan_mac=$(macaddr_add "$lan_mac" 1)
664 ;;
665 iodata,wn-ac1167gr|\
666 iodata,wn-ac733gr3)
667 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
668 ;;
669 iodata,wn-ax1167gr|\
670 iodata,wn-gx300gr|\
671 trendnet,tew-692gr)
672 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1)
673 ;;
674 iodata,wnpr2600g)
675 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
676 label_mac=$wan_mac
677 ;;
678 iptime,a3|\
679 iptime,a604m)
680 wan_mac=$(mtd_get_mac_binary u-boot 0x1fc40)
681 ;;
682 linksys,e1700)
683 wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
684 ;;
685 mediatek,linkit-smart-7688|\
686 onion,omega2|\
687 onion,omega2p)
688 wan_mac=$(mtd_get_mac_binary factory 0x4)
689 lan_mac=$(mtd_get_mac_binary factory 0x2e)
690 ;;
691 mercury,mac1200r-v2)
692 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory_info 0xd)" 1)
693 ;;
694 poray,m3|\
695 poray,m4-4m|\
696 poray,m4-8m|\
697 poray,x5|\
698 poray,x8)
699 lan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" -2)
700 ;;
701 sitecom,wlr-6000)
702 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x8004)" 2)
703 ;;
704 sparklan,wcr-150gn|\
705 wiznet,wizfi630a|\
706 zyxel,keenetic-omni|\
707 zyxel,keenetic-omni-ii|\
708 zyxel,keenetic-viva)
709 wan_mac=$(mtd_get_mac_binary factory 0x28)
710 ;;
711 tenda,w306r-v2)
712 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 5)
713 ;;
714 trendnet,tew-691gr)
715 wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x4)" 3)
716 ;;
717 vocore,vocore2|\
718 vocore,vocore2-lite)
719 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
720 ;;
721 xiaomi,mir3g)
722 lan_mac=$(mtd_get_mac_binary factory 0xe006)
723 ;;
724 xiaomi,mir3g-v2)
725 wan_mac=$(mtd_get_mac_binary factory 0xe006)
726 label_mac=$wan_mac
727 ;;
728 xiaomi,mir3p)
729 lan_mac=$(mtd_get_mac_binary factory 0xe006)
730 label_mac=$lan_mac
731 ;;
732 zbtlink,zbt-we1326)
733 wan_mac=$(mtd_get_mac_binary factory 0xe006)
734 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
735 ;;
736 *)
737 wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1)
738 ;;
739 esac
740
741 [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
742 [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
743 [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
744 }
745
746 board_config_update
747 board=$(board_name)
748 ramips_setup_interfaces $board
749 ramips_setup_macs $board
750 board_config_flush
751
752 exit 0