mkimage: fix validation of legacy images with custom magic
[openwrt/openwrt.git] / target / linux / ath79 / generic / base-files / etc / board.d / 02_network
1
2 . /lib/functions/system.sh
3 . /lib/functions/uci-defaults.sh
4 . /lib/functions/k2t.sh
5
6 ath79_setup_interfaces()
7 {
8 local board="$1"
9
10 case "$board" in
11 adtran,bsap1800-v2|\
12 adtran,bsap1840|\
13 allnet,all-wap02860ac|\
14 alfa-network,ap121f|\
15 alfa-network,pi-wifi4|\
16 alfa-network,tube-2hq|\
17 araknis,an-300-ap-i-n|\
18 araknis,an-500-ap-i-ac|\
19 araknis,an-700-ap-i-ac|\
20 arduino,yun|\
21 aruba,ap-105|\
22 asus,rp-ac51|\
23 asus,rp-ac66|\
24 avm,fritz1750e|\
25 avm,fritz300e|\
26 avm,fritzdvbc|\
27 comfast,cf-wr752ac-v1|\
28 comfast,cf-e130n-v2|\
29 devolo,dvl1200i|\
30 devolo,dvl1750c|\
31 devolo,dvl1750i|\
32 devolo,dvl1750x|\
33 dlink,dap-1330-a1|\
34 dlink,dap-1365-a1|\
35 dlink,dap-2230-a1|\
36 dlink,dap-2660-a1|\
37 dlink,dap-2680-a1|\
38 dlink,dap-3320-a1|\
39 dlink,dir-505|\
40 engenius,eap1200h|\
41 engenius,eap600|\
42 engenius,ecb1200|\
43 engenius,ecb1750|\
44 engenius,ecb600|\
45 enterasys,ws-ap3705i|\
46 glinet,gl-ar300m-lite|\
47 glinet,gl-usb150|\
48 hak5,wifi-pineapple-nano|\
49 meraki,mr16|\
50 netgear,ex6400|\
51 netgear,ex7300|\
52 netgear,ex7300-v2|\
53 netgear,wndap360|\
54 ocedo,koala|\
55 ocedo,raccoon|\
56 onion,omega|\
57 openmesh,mr600-v1|\
58 openmesh,mr600-v2|\
59 openmesh,mr900-v1|\
60 openmesh,mr900-v2|\
61 openmesh,mr1750-v1|\
62 openmesh,mr1750-v2|\
63 pcs,cap324|\
64 pisen,ts-d084|\
65 pisen,wmb001n|\
66 pisen,wmm003n|\
67 siemens,ws-ap3610|\
68 sophos,ap55|\
69 sophos,ap55c|\
70 sophos,ap100|\
71 sophos,ap100c|\
72 tplink,cpe210-v2|\
73 tplink,cpe210-v3|\
74 tplink,cpe510-v2|\
75 tplink,cpe510-v3|\
76 tplink,cpe610-v1|\
77 tplink,cpe610-v2|\
78 tplink,cpe710-v1|\
79 tplink,eap225-outdoor-v1|\
80 tplink,eap225-outdoor-v3|\
81 tplink,eap225-v1|\
82 tplink,eap225-v3|\
83 tplink,eap225-v4|\
84 tplink,eap245-v1|\
85 tplink,re350k-v1|\
86 tplink,re355-v1|\
87 tplink,re450-v1|\
88 tplink,re450-v2|\
89 tplink,re450-v3|\
90 tplink,re455-v1|\
91 tplink,tl-wa1201-v2|\
92 tplink,tl-wr902ac-v1|\
93 ubnt,bullet-ac|\
94 ubnt,bullet-m-xw|\
95 ubnt,lap-120|\
96 ubnt,litebeam-ac-gen2|\
97 ubnt,nanobeam-ac|\
98 ubnt,nanobeam-ac-xc|\
99 ubnt,nanostation-ac-loco|\
100 ubnt,nanostation-loco-m-xw|\
101 ubnt,powerbeam-5ac-500|\
102 ubnt,powerbeam-5ac-gen2|\
103 ubnt,powerbeam-m2-xw|\
104 ubnt,powerbeam-m5-xw|\
105 ubnt,rocket-5ac-lite|\
106 ubnt,unifiac-lite|\
107 ubnt,unifiac-lr|\
108 ubnt,unifiac-mesh|\
109 ubnt,unifi|\
110 wd,mynet-wifi-rangeextender|\
111 winchannel,wb2000)
112 ucidef_set_interface_lan "eth0"
113 ;;
114 airtight,c-75)
115 ucidef_add_switch "switch0" \
116 "0@eth0" "2:wan" "3:lan" "6@eth1"
117 ;;
118 alfa-network,ap121fe)
119 ucidef_set_interface_lan "eth0 usb0"
120 ;;
121 alfa-network,n2q|\
122 alfa-network,n5q|\
123 devolo,dvl1200e|\
124 devolo,dvl1750e|\
125 engenius,enstationac-v1|\
126 engenius,ews511ap|\
127 ocedo,ursus|\
128 ubnt,unifi-ap-outdoor-plus)
129 ucidef_set_interface_lan "eth0 eth1"
130 ;;
131 asus,pl-ac56)
132 # port 6 (internal) is the power-line port
133 ucidef_add_switch "switch0" \
134 "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "6:lan:4"
135 ;;
136 atheros,db120)
137 ucidef_add_switch "switch0" \
138 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
139 ucidef_add_switch "switch1" \
140 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
141 ;;
142 avm,fritz4020|\
143 pcs,cr3000|\
144 tplink,archer-c58-v1|\
145 tplink,archer-c59-v1|\
146 tplink,archer-c59-v2|\
147 wd,mynet-n600)
148 ucidef_set_interface_wan "eth1"
149 ucidef_add_switch "switch0" \
150 "0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
151 ;;
152 belkin,f9j1108-v2|\
153 belkin,f9k1115-v2|\
154 tplink,archer-c5-v1|\
155 tplink,archer-c7-v1|\
156 tplink,archer-c7-v2|\
157 tplink,tl-wdr4900-v2|\
158 tplink,tl-wdr7500-v3)
159 ucidef_add_switch "switch0" \
160 "0@eth1" "2:lan" "3:lan" "4:lan" "5:lan" "6@eth0" "1:wan"
161 ;;
162 buffalo,bhr-4grv|\
163 buffalo,wzr-hp-g450h)
164 ucidef_add_switch "switch0" \
165 "0@eth0" "2:lan" "3:lan" "4:lan" "5:lan" "1:wan"
166 ;;
167 buffalo,bhr-4grv2|\
168 trendnet,tew-823dru)
169 ucidef_add_switch "switch0" \
170 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth0"
171 ;;
172 buffalo,wzr-600dhp|\
173 buffalo,wzr-hp-ag300h|\
174 tplink,archer-c25-v1|\
175 tplink,archer-c60-v1|\
176 tplink,archer-c60-v2|\
177 tplink,archer-c60-v3|\
178 tplink,tl-wdr3500-v1|\
179 tplink,tl-wr842n-v1|\
180 tplink,tl-wr842n-v3)
181 ucidef_set_interface_wan "eth1"
182 ucidef_add_switch "switch0" \
183 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
184 ;;
185 buffalo,wzr-hp-g300nh-rb|\
186 buffalo,wzr-hp-g300nh-s|\
187 dlink,dir-825-b1)
188 ucidef_set_interface_wan "eth1"
189 ucidef_add_switch "switch0" \
190 "0:lan" "1:lan" "2:lan" "3:lan" "5@eth0"
191 ;;
192 buffalo,wzr-hp-g302h-a1a0)
193 ucidef_add_switch "switch0" \
194 "0@eth0" "1:lan:1" "3:lan:4" "4:lan:3" "5:lan:2" "2:wan"
195 ;;
196 comfast,cf-e110n-v2|\
197 comfast,cf-e120a-v3|\
198 comfast,cf-e314n-v2|\
199 compex,wpj531-16m|\
200 openmesh,a40|\
201 openmesh,a60|\
202 openmesh,om2p-v1|\
203 openmesh,om2p-v4|\
204 openmesh,om2p-hs-v4|\
205 plasmacloud,pa300|\
206 plasmacloud,pa300e|\
207 tplink,cpe210-v1|\
208 tplink,cpe220-v2|\
209 tplink,cpe220-v3|\
210 tplink,cpe510-v1|\
211 tplink,wbs210-v1|\
212 tplink,wbs210-v2|\
213 tplink,wbs510-v1|\
214 tplink,wbs510-v2|\
215 ubnt,routerstation)
216 ucidef_set_interfaces_lan_wan "eth1" "eth0"
217 ;;
218 comfast,cf-e375ac)
219 ucidef_add_switch "switch0" \
220 "0@eth0" "1:wan" "2:lan"
221 ;;
222 comfast,cf-e560ac|\
223 qca,ap143-8m|\
224 qca,ap143-16m|\
225 tplink,tl-wr841hp-v3)
226 ucidef_set_interface_wan "eth1"
227 ucidef_add_switch "switch0" \
228 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
229 ;;
230 comfast,cf-wr650ac-v1|\
231 comfast,cf-wr650ac-v2|\
232 zyxel,nbg6616)
233 ucidef_add_switch "switch0" \
234 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
235 ;;
236 compex,wpj344-16m|\
237 compex,wpj563)
238 ucidef_add_switch "switch0" \
239 "0@eth0" "3:lan" "2:wan"
240 ;;
241 compex,wpj558-16m)
242 ucidef_add_switch "switch0" \
243 "1:wan" "5:lan" "6@eth0"
244 ;;
245 devolo,dlan-pro-1200plus-ac|\
246 devolo,magic-2-wifi)
247 ucidef_add_switch "switch0" \
248 "0@eth0" "2:wan" "3:lan" "4:lan"
249 ;;
250 dlink,dap-2695-a1)
251 ucidef_add_switch "switch0" \
252 "0@eth0" "2:lan" "3:wan" "6@eth1"
253 ;;
254 dlink,dap-3662-a1)
255 ucidef_add_switch "switch0" \
256 "0@eth0" "1:lan:2" "2:lan:1" "6@eth1"
257 ;;
258 dlink,dch-g020-a1)
259 ucidef_add_switch "switch0" \
260 "0@eth0" "1:lan:2" "2:lan:1"
261 ;;
262 dlink,dir-825-c1|\
263 dlink,dir-835-a1|\
264 dlink,dir-842-c1|\
265 dlink,dir-842-c2|\
266 dlink,dir-842-c3|\
267 dlink,dir-859-a1|\
268 engenius,epg5000|\
269 sitecom,wlr-7100|\
270 tplink,archer-c2-v3|\
271 tplink,tl-wr1043nd-v4|\
272 tplink,tl-wr1043n-v5)
273 ucidef_add_switch "switch0" \
274 "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
275 ;;
276 elecom,wrc-1750ghbk2-i|\
277 elecom,wrc-300ghbk2-i|\
278 sitecom,wlr-8100)
279 ucidef_add_switch "switch0" \
280 "0@eth0" "2:lan:4" "3:lan:3" "4:lan:2" "5:lan:1" "1:wan"
281 ;;
282 embeddedwireless,balin)
283 ucidef_add_switch "switch0" \
284 "0@eth0" "5:lan:1" "4:lan:2" "3:wan"
285 ;;
286 embeddedwireless,dorin)
287 ucidef_add_switch "switch0" \
288 "0@eth0" "1:wan" "2:lan:3" "3:lan:2"
289 ;;
290 engenius,eap300-v2)
291 ucidef_add_switch "switch0" \
292 "0@eth0" "1:lan"
293 ;;
294 engenius,ens202ext-v1)
295 ucidef_set_interface_lan "eth1"
296 ucidef_add_switch "switch0" \
297 "0@eth0" "1:lan"
298 ;;
299 etactica,eg200)
300 ucidef_set_interface_lan "eth0" "dhcp"
301 ;;
302 glinet,gl-ar750)
303 ucidef_set_interface_wan "eth1"
304 ucidef_add_switch "switch0" \
305 "0@eth0" "1:lan" "2:lan"
306 ;;
307 glinet,gl-x300b)
308 ucidef_set_interface_wan "eth1"
309 ucidef_add_switch "switch0" \
310 "0@eth0" "4:lan"
311 ;;
312 iodata,etg3-r|\
313 iodata,wn-ac1167dgr|\
314 iodata,wn-ac1600dgr|\
315 iodata,wn-ac1600dgr2|\
316 iodata,wn-ag300dgr|\
317 pcs,cr5000|\
318 wd,mynet-n750)
319 ucidef_add_switch "switch0" \
320 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
321 ;;
322 jjplus,jwap230)
323 ucidef_add_switch "switch0" \
324 "0@eth0" "5:wan:1" "1:lan:2" "6@eth1"
325 ;;
326 joyit,jt-or750i)
327 ucidef_set_interface_wan "eth1"
328 ucidef_add_switch "switch0" \
329 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
330 ;;
331 letv,lba-047-ch)
332 ucidef_set_interface_wan "eth0"
333 ucidef_add_switch "switch0" \
334 "0@eth1" "3:lan:2" "4:lan:1"
335 ;;
336 librerouter,librerouter-v1)
337 ucidef_add_switch "switch0" \
338 "0@eth0" "5:wan" "6@eth1" "4:lan"
339 ;;
340 meraki,mr12)
341 ucidef_set_interface_lan "eth0"
342 ucidef_add_switch "switch0" \
343 "0@eth1" "1:lan"
344 ;;
345 mercury,mw4530r-v1|\
346 tplink,archer-a7-v5|\
347 tplink,archer-a9-v6|\
348 tplink,archer-c6-v2|\
349 tplink,archer-c6-v2-us|\
350 tplink,archer-c7-v4|\
351 tplink,archer-c7-v5|\
352 tplink,tl-wdr3600-v1|\
353 tplink,tl-wdr4300-v1|\
354 tplink,tl-wdr4300-v1-il|\
355 tplink,tl-wdr4310-v1)
356 ucidef_add_switch "switch0" \
357 "0@eth0" "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "1:wan"
358 ;;
359 nec,wf1200cr)
360 ucidef_set_interface_wan "eth1"
361 ucidef_add_switch "switch0" \
362 "0@eth0" "1:lan"
363 ;;
364 nec,wg1200cr|\
365 qxwlan,e1700ac-v2-8m|\
366 qxwlan,e1700ac-v2-16m|\
367 qxwlan,e750g-v8-8m|\
368 qxwlan,e750g-v8-16m|\
369 ubnt,nanobeam-ac-gen2|\
370 ubnt,nanostation-ac|\
371 yuncore,a782|\
372 yuncore,xd3200|\
373 yuncore,xd4200)
374 ucidef_add_switch "switch0" \
375 "0@eth0" "2:lan" "3:wan"
376 ;;
377 nec,wg800hp|\
378 xiaomi,aiot-ac2350)
379 ucidef_add_switch "switch0" \
380 "0@eth0" "2:lan" "3:lan" "4:lan" "1:wan"
381 ;;
382 netgear,wndr3700|\
383 netgear,wndr3700-v2|\
384 netgear,wndr3800|\
385 netgear,wndr3800ch|\
386 netgear,wndrmac-v1|\
387 netgear,wndrmac-v2)
388 ucidef_set_interface_wan "eth1"
389 ucidef_add_switch "switch0" \
390 "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "5u@eth0"
391 ucidef_add_switch_attr "switch0" "blinkrate" 2
392 ucidef_add_switch_port_attr "switch0" 1 led 6
393 ucidef_add_switch_port_attr "switch0" 2 led 9
394 ucidef_add_switch_port_attr "switch0" 5 led 2
395 ;;
396 netgear,wnr2200-8m|\
397 netgear,wnr2200-16m)
398 ucidef_set_interface_wan "eth0"
399 ucidef_add_switch "switch0" \
400 "0@eth1" "1:lan" "2:lan" "3:lan" "4:lan"
401 ;;
402 phicomm,k2t)
403 ucidef_add_switch "switch0" \
404 "0@eth0" "3:lan:1" "5:lan:2" "4:wan"
405 ;;
406 qihoo,c301)
407 ucidef_set_interface_wan "eth1"
408 ucidef_add_switch "switch0" \
409 "0@eth0" "2:lan" "3:lan"
410 ;;
411 qxwlan,e558-v2-8m|\
412 qxwlan,e558-v2-16m)
413 ucidef_add_switch "switch0" \
414 "0@eth1" "4:lan" "5:lan" "6@eth0" "3:wan"
415 ;;
416 rosinson,wr818)
417 ucidef_add_switch "switch0" \
418 "0@eth0" "1:lan" "2:lan" "3:wan"
419 ;;
420 teltonika,rut955|\
421 teltonika,rut955-h7v3c0)
422 ucidef_set_interface_wan "eth1"
423 ucidef_add_switch "switch0" \
424 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1"
425 ;;
426 tplink,archer-d50-v1)
427 ucidef_add_switch "switch0" \
428 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "1:wan"
429 ;;
430 tplink,archer-d7-v1|\
431 tplink,archer-d7b-v1)
432 ucidef_add_switch "switch0" \
433 "0@eth1" "3:lan:3" "4:lan:2" "5:lan:1" "6@eth0" "2:wan:4" "1:wan:5"
434 ;;
435 tplink,eap225-wall-v2)
436 ucidef_add_switch "switch0" \
437 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan"
438 ;;
439 tplink,eap245-v3)
440 ucidef_add_switch "switch0" \
441 "0@eth0" "2:lan:1" "5:lan:2"
442 ;;
443 tplink,tl-mr6400-v1)
444 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "usb0"
445 ucidef_add_switch "switch0" \
446 "0@eth0" "1:lan:1" "2:lan:3" "3:lan:2"
447 ;;
448 tplink,tl-wpa8630-v1)
449 # port 5 (internal) is the power-line port
450 ucidef_add_switch "switch0" \
451 "0@eth0" "2:lan:3" "3:lan:2" "4:lan:1" "5:lan:4"
452 ;;
453 tplink,tl-wr841hp-v2|\
454 tplink,tl-wr842n-v2|\
455 tplink,tl-wr941hp-v1)
456 ucidef_set_interface_wan "eth1"
457 ucidef_add_switch "switch0" \
458 "0@eth0" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
459 ;;
460 tplink,tl-wr1043nd-v1)
461 ucidef_add_switch "switch0" \
462 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "5@eth0"
463 ;;
464 tplink,tl-wr1043nd-v2|\
465 tplink,tl-wr1043nd-v3|\
466 tplink,tl-wr1045nd-v2)
467 ucidef_add_switch "switch0" \
468 "0@eth1" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan" "6@eth0"
469 ;;
470 tplink,tl-wr2543-v1)
471 ucidef_add_switch "switch0" \
472 "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "9@eth0"
473 ;;
474 ubnt,aircube-ac)
475 ucidef_add_switch "switch0" \
476 "0@eth0" "2:lan:1" "3:lan:2" "5:lan:3" "4:wan"
477 ;;
478 ubnt,aircube-isp)
479 ucidef_set_interface_wan "eth1"
480 ucidef_add_switch "switch0" \
481 "0@eth0" "2:lan:1" "3:lan:3" "4:lan:2"
482 ;;
483 ubnt,edgeswitch-5xp)
484 ucidef_set_interface_wan "eth1"
485 ucidef_add_switch "switch0" \
486 "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:lan"
487 ;;
488 ubnt,edgeswitch-8xp)
489 ucidef_set_interface_wan "eth1"
490 ucidef_add_switch "switch0" \
491 "0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "4:lan:5" "5:lan:6" "6:lan:7" "7:lan:8" "8@eth0"
492 ;;
493 ubnt,routerstation-pro)
494 ucidef_set_interface_wan "eth0"
495 ucidef_add_switch "switch0" \
496 "0@eth1" "2:lan:3" "3:lan:2" "4:lan:1"
497 ;;
498 ubnt,nanostation-m-xw)
499 ucidef_add_switch "switch0" \
500 "0@eth0" "5:lan" "1:wan"
501 ;;
502 ubnt,unifiac-mesh-pro|\
503 ubnt,unifiac-pro)
504 ucidef_add_switch "switch0" \
505 "0@eth0" "2:lan:1" "3:lan:2"
506 ;;
507 ubnt,unifi-ap-pro)
508 ucidef_add_switch "switch0" \
509 "0@eth0" "1:lan" "2:lan"
510 ;;
511 tplink,deco-m4r-v1)
512 ucidef_add_switch "switch0" \
513 "0@eth0" "3:lan:1" "5:lan:2"
514 ;;
515 hiwifi,hc6361|\
516 xiaomi,mi-router-4q|\
517 zbtlink,zbt-wd323)
518 ucidef_set_interface_wan "eth1"
519 ucidef_add_switch "switch0" \
520 "0@eth0" "3:lan:1" "4:lan:2"
521 ;;
522 *)
523 ucidef_set_interfaces_lan_wan "eth0" "eth1"
524 ;;
525 esac
526 }
527
528 ath79_setup_macs()
529 {
530 local board="$1"
531
532 case "$board" in
533 adtran,bsap1800-v2|\
534 adtran,bsap1840)
535 lan_mac=$(mtd_get_mac_binary "Board data" 2)
536 label_mac=$lan_mac
537 ;;
538 alfa-network,ap121f|\
539 alfa-network,ap121fe|\
540 alfa-network,n2q|\
541 alfa-network,n5q|\
542 alfa-network,pi-wifi4|\
543 alfa-network,r36a|\
544 alfa-network,tube-2hq|\
545 engenius,eap300-v2|\
546 engenius,ens202ext-v1)
547 label_mac=$(mtd_get_mac_binary art 0x1002)
548 ;;
549 arduino,yun)
550 base_mac=$(mtd_get_mac_binary art 0x1002)
551 lan_mac=$(macaddr_setbit $base_mac 29)
552 [ $lan_mac = $base_mac ] && lan_mac=$(macaddr_unsetbit $base_mac 29)
553 ;;
554 avm,fritz1750e|\
555 avm,fritz450e|\
556 avm,fritzdvbc)
557 label_mac=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))
558 ;;
559 avm,fritz300e)
560 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
561 label_mac=$(fritz_tffs -n macwlan -i $(find_mtd_part "tffs (1)"))
562 ;;
563 avm,fritz4020)
564 lan_mac=$(fritz_tffs -n maca -i $(find_mtd_part "tffs (1)"))
565 wan_mac=$(fritz_tffs -n macb -i $(find_mtd_part "tffs (1)"))
566 ;;
567 comfast,cf-e375ac)
568 wan_mac=$(macaddr_add $(mtd_get_mac_binary art 0x0) 1)
569 ;;
570 compex,wpj344-16m|\
571 compex,wpj558-16m|\
572 compex,wpj563)
573 wan_mac=$(mtd_get_mac_binary u-boot 0x2e018)
574 ;;
575 devolo,dlan-pro-1200plus-ac|\
576 devolo,magic-2-wifi)
577 label_mac=$(macaddr_add "$(mtd_get_mac_binary art 0x1002)" 3)
578 ;;
579 dlink,dap-1330-a1|\
580 dlink,dap-1365-a1|\
581 dlink,dch-g020-a1)
582 lan_mac=$(mtd_get_mac_text "mp" 0x1)
583 label_mac=$lan_mac
584 ;;
585 dlink,dap-2230-a1|\
586 dlink,dap-2660-a1|\
587 dlink,dap-2680-a1|\
588 dlink,dap-3320-a1)
589 lan_mac=$(mtd_get_mac_ascii bdcfg "lanmac")
590 label_mac=$lan_mac
591 ;;
592 dlink,dap-2695-a1|\
593 dlink,dap-3662-a1)
594 label_mac=$(mtd_get_mac_ascii bdcfg "wlanmac")
595 ;;
596 dlink,dir-825-b1)
597 lan_mac=$(mtd_get_mac_text "caldata" 0xffa0)
598 wan_mac=$(mtd_get_mac_text "caldata" 0xffb4)
599 label_mac=$wan_mac
600 ;;
601 dlink,dir-505)
602 lan_mac=$(mtd_get_mac_text "mac" 0x4)
603 ;;
604 dlink,dir-825-c1|\
605 dlink,dir-835-a1)
606 lan_mac=$(mtd_get_mac_text "mac" 0x4)
607 wan_mac=$(mtd_get_mac_text "mac" 0x18)
608 ;;
609 dlink,dir-842-c1|\
610 dlink,dir-842-c2|\
611 dlink,dir-842-c3)
612 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
613 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
614 label_mac=$lan_mac
615 ;;
616 dlink,dir-859-a1|\
617 qihoo,c301|\
618 wd,mynet-n600|\
619 wd,mynet-n750)
620 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
621 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
622 ;;
623 elecom,wrc-1750ghbk2-i|\
624 elecom,wrc-300ghbk2-i)
625 wan_mac=$(macaddr_add "$(mtd_get_mac_binary art 0x1002)" -2)
626 ;;
627 engenius,ecb1200|\
628 engenius,ecb1750)
629 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
630 label_mac=$lan_mac
631 ;;
632 engenius,epg5000)
633 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
634 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
635 ;;
636 engenius,ews511ap)
637 lan_mac=$(mtd_get_mac_text "u-boot-env" 0xe9)
638 eth1_mac=$(macaddr_add "$lan_mac" 1)
639 ucidef_set_interface "eth0" ifname "eth0" protocol "none" macaddr "$lan_mac"
640 ucidef_set_interface "eth1" ifname "eth1" protocol "none" macaddr "$eth1_mac"
641 ;;
642 enterasys,ws-ap3705i)
643 label_mac=$(mtd_get_mac_ascii u-boot-env0 ethaddr)
644 ;;
645 hak5,lan-turtle|\
646 hak5,packet-squirrel)
647 label_mac=$(mtd_get_mac_binary u-boot 0x1fc00)
648 ;;
649 iodata,etg3-r)
650 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
651 wan_mac=$(macaddr_add "$lan_mac" -1)
652 label_mac=$wan_mac
653 ;;
654 iodata,wn-ac1167dgr|\
655 iodata,wn-ac1600dgr|\
656 iodata,wn-ac1600dgr2|\
657 iodata,wn-ag300dgr)
658 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
659 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
660 label_mac=$wan_mac
661 ;;
662 mercury,mw4530r-v1|\
663 tplink,tl-wdr3600-v1|\
664 tplink,tl-wdr4300-v1|\
665 tplink,tl-wdr4300-v1-il)
666 base_mac=$(mtd_get_mac_binary u-boot 0x1fc00)
667 wan_mac=$(macaddr_add "$base_mac" 1)
668 ;;
669 nec,wf1200cr|\
670 nec,wg1200cr)
671 lan_mac=$(mtd_get_mac_ascii devdata "lanmac")
672 wan_mac=$(mtd_get_mac_ascii devdata "wanmac")
673 label_mac=$wan_mac
674 ;;
675 nec,wg800hp)
676 lan_mac=$(mtd_get_mac_text board_data 0x280)
677 wan_mac=$(mtd_get_mac_text board_data 0x480)
678 label_mac=$wan_mac
679 ;;
680 netgear,wndr3700|\
681 netgear,wndr3700-v2|\
682 netgear,wndr3800|\
683 netgear,wndrmac-v1|\
684 netgear,wndrmac-v2)
685 lan_mac=$(macaddr_setbit_la "$(mtd_get_mac_binary art 0x0)")
686 ;;
687 phicomm,k2t)
688 lan_mac=$(k2t_get_mac "lan_mac")
689 wan_mac=$(k2t_get_mac "wan_mac")
690 ;;
691 rosinson,wr818)
692 wan_mac=$(mtd_get_mac_binary factory 0x0)
693 lan_mac=$(macaddr_setbit_la "$wan_mac")
694 ;;
695 sitecom,wlr-7100|\
696 sitecom,wlr-8100)
697 lan_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
698 wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
699 label_mac=$lan_mac
700 ;;
701 tplink,archer-a7-v5|\
702 tplink,archer-a9-v6|\
703 tplink,archer-c7-v4|\
704 tplink,archer-c7-v5|\
705 tplink,tl-wr1043nd-v4|\
706 tplink,tl-wr1043n-v5)
707 base_mac=$(mtd_get_mac_binary info 0x8)
708 wan_mac=$(macaddr_add "$base_mac" 1)
709 ;;
710 trendnet,tew-823dru)
711 lan_mac=$(mtd_get_mac_text mac 0x4)
712 wan_mac=$(mtd_get_mac_text mac 0x18)
713 label_mac=$wan_mac
714 ;;
715 ubnt,unifi)
716 label_mac=$(cat /sys/class/ieee80211/phy0/macaddress)
717 ;;
718 ubnt,litebeam-ac-gen2|\
719 ubnt,nanobeam-ac-gen2|\
720 ubnt,nanobeam-ac-xc|\
721 ubnt,powerbeam-5ac-500|\
722 ubnt,powerbeam-5ac-gen2)
723 label_mac=$(mtd_get_mac_binary art 0x5006)
724 ;;
725 ubnt,routerstation|\
726 ubnt,routerstation-pro)
727 wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n ar7100_esa)
728 lan_mac=$(macaddr_add "$wan_mac" 1)
729 ;;
730 wd,mynet-wifi-rangeextender)
731 lan_mac=$(nvram get et0macaddr)
732 ;;
733 xiaomi,aiot-ac2350)
734 lan_mac=$(mtd_get_mac_binary art 0x1002)
735 ;;
736 zyxel,nbg6616)
737 label_mac=$(mtd_get_mac_ascii u-boot-env ethaddr)
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 ath79_setup_interfaces $board
749 ath79_setup_macs $board
750 board_config_flush
751
752 exit 0