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