f814bd46ad2e6f1d0596d377d02c8ac24f986d21
[openwrt/openwrt.git] / target / linux / ath79 / generic / 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-ac1600dgr)
21 # There is no eeprom data for 5 GHz wlan in "art" partition
22 # which would allow to patch the macaddress
23 [ "$PHYNBR" -eq 0 ] && \
24 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
25 ;;
26 iodata,wn-ag300dgr)
27 # There is no eeprom data for 5 GHz wlan in "art" partition
28 # which would allow to patch the macaddress
29 [ "$PHYNBR" -eq 1 ] && \
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 siemens,ws-ap3610)
38 mtd_get_mac_ascii cfg1 RADIOADDR${PHYNBR} > /sys${DEVPATH}/macaddress
39 ;;
40 trendnet,tew-823dru)
41 # set the 2.4G interface mac address to LAN MAC
42 [ "$PHYNBR" -eq 1 ] && \
43 mtd_get_mac_text mac 4 > /sys${DEVPATH}/macaddress
44 # set the 5G interface mac address to WAN MAC + 1
45 [ "$PHYNBR" -eq 0 ] && \
46 macaddr_add "$(mtd_get_mac_text mac 0x18)" 1 > /sys${DEVPATH}/macaddress
47 ;;
48 esac