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