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