d9c3fe7440a0902d0a613cf46e54591c1e4ea487
[openwrt/openwrt.git] / target / linux / ath79 / base-files / etc / hotplug.d / ieee80211 / 10_fix_wifi_mac
1 #!/bin/ash
2
3 [ "$ACTION" = "add" ] || exit 0
4
5 PHYNBR=${DEVPATH##*/phy}
6
7 [ -n $PHYNBR ] || exit 0
8
9 . /lib/functions.sh
10 . /lib/functions/system.sh
11 . /lib/functions/k2t.sh
12
13 board=$(board_name)
14
15 case "$board" in
16 adtran,bsap1800-v2|\
17 adtran,bsap1840)
18 macaddr_add "$(mtd_get_mac_binary 'Board data' 2)" $(($PHYNBR * 8 + 1)) > /sys${DEVPATH}/macaddress
19 ;;
20 iodata,wn-ag300dgr)
21 # There is no eeprom data for 5 GHz wlan in "art" partition
22 # which would allow to patch the macaddress
23 [ "$PHYNBR" -eq 1 ] && \
24 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
25 ;;
26 iodata,wn-ac1600dgr)
27 # There is no eeprom data for 5 GHz wlan in "art" partition
28 # which would allow to patch the macaddress
29 [ "$PHYNBR" -eq 0 ] && \
30 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
31 ;;
32 phicomm,k2t)
33 # The K2T factory firmware does use LAN mac address as the 2.4G wifi mac address
34 [ "$PHYNBR" -eq 1 ] && \
35 k2t_get_mac "lan_mac" > /sys${DEVPATH}/macaddress
36 ;;
37 trendnet,tew-823dru)
38 # set the 2.4G interface mac address to LAN MAC
39 [ "$PHYNBR" -eq 1 ] && \
40 mtd_get_mac_text mac 4 > /sys${DEVPATH}/macaddress
41 # set the 5G interface mac address to WAN MAC + 1
42 [ "$PHYNBR" -eq 0 ] && \
43 macaddr_add "$(mtd_get_mac_text mac 24)" 1 > /sys${DEVPATH}/macaddress
44 ;;
45 *)
46 ;;
47 esac
48