8ea23a8ac6b9d872db1718a19d7b821710355df7
[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 dlink,dap-1330-a1|\
21 dlink,dap-1365-a1|\
22 dlink,dch-g020-a1)
23 mtd_get_mac_text "mp" 0x13 > /sys${DEVPATH}/macaddress
24 ;;
25 iodata,wn-ac1600dgr)
26 # There is no eeprom data for 5 GHz wlan in "art" partition
27 # which would allow to patch the macaddress
28 [ "$PHYNBR" -eq 0 ] && \
29 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
30 ;;
31 iodata,wn-ag300dgr)
32 # There is no eeprom data for 5 GHz wlan in "art" partition
33 # which would allow to patch the macaddress
34 [ "$PHYNBR" -eq 1 ] && \
35 macaddr_add "$(mtd_get_mac_ascii u-boot-env ethaddr)" 1 > /sys${DEVPATH}/macaddress
36 ;;
37 phicomm,k2t)
38 # The K2T factory firmware does use LAN mac address as the 2.4G wifi mac address
39 [ "$PHYNBR" -eq 1 ] && \
40 k2t_get_mac "lan_mac" > /sys${DEVPATH}/macaddress
41 ;;
42 siemens,ws-ap3610)
43 mtd_get_mac_ascii cfg1 RADIOADDR${PHYNBR} > /sys${DEVPATH}/macaddress
44 ;;
45 trendnet,tew-823dru)
46 # set the 2.4G interface mac address to LAN MAC
47 [ "$PHYNBR" -eq 1 ] && \
48 mtd_get_mac_text mac 4 > /sys${DEVPATH}/macaddress
49 # set the 5G interface mac address to WAN MAC + 1
50 [ "$PHYNBR" -eq 0 ] && \
51 macaddr_add "$(mtd_get_mac_text mac 0x18)" 1 > /sys${DEVPATH}/macaddress
52 ;;
53 esac