base-files: wifi: add random MAC support for wifi-iface
[openwrt/openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index 5d6ca7c0e311860f59532aaa6998ad3243aa15ba..62afd9e6a0fb6c4b047432ac8b1e8b97e42fc72b 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/sh
 . /lib/netifd/netifd-wireless.sh
 . /lib/netifd/hostapd.sh
+. /lib/functions/system.sh
 
 init_wireless_driver "$@"
 
@@ -667,10 +668,12 @@ mac80211_prepare_vif() {
 
        json_select ..
 
-       [ -n "$macaddr" ] || {
+       if [ -z "$macaddr" ]; then
                macaddr="$(mac80211_generate_mac $phy)"
                macidx="$(($macidx + 1))"
-       }
+       elif [ "$macaddr" = 'random' ]; then
+               macaddr="$(macaddr_random)"
+       fi
 
        json_add_object data
        json_add_string ifname "$ifname"