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