hostapd: move mac address allocation from mac80211.sh to wdev.uc
[openwrt/openwrt.git] / package / kernel / mac80211 / files / lib / netifd / wireless / mac80211.sh
index db1ba231f3a33a2f9782fbe36d37d67113d74842..1d7f733cadfbfebf95d66b04b1e50207d7395abd 100644 (file)
@@ -533,47 +533,7 @@ mac80211_generate_mac() {
        local phy="$1"
        local id="${macidx:-0}"
 
-       local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
-       local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)"
-
-       [ "$mask" = "00:00:00:00:00:00" ] && {
-               mask="ff:ff:ff:ff:ff:ff";
-
-               [ "$(wc -l < /sys/class/ieee80211/${phy}/addresses)" -gt $id ] && {
-                       addr="$(mac80211_get_addr "$phy" "$id")"
-                       [ -n "$addr" ] && {
-                               echo "$addr"
-                               return
-                       }
-               }
-       }
-
-       local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS"
-
-       local mask1=$1
-       local mask6=$6
-
-       local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS"
-
-       macidx=$(($id + 1))
-       [ "$((0x$mask1))" -gt 0 ] && {
-               b1="0x$1"
-               [ "$id" -gt 0 ] && \
-                       b1=$(($b1 ^ ((($id - !($b1 & 2)) << 2)) | 0x2))
-               printf "%02x:%s:%s:%s:%s:%s" $b1 $2 $3 $4 $5 $6
-               return
-       }
-
-       [ "$((0x$mask6))" -lt 255 ] && {
-               printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $(( 0x$6 ^ $id ))
-               return
-       }
-
-       off2=$(( (0x$6 + $id) / 0x100 ))
-       printf "%s:%s:%s:%s:%02x:%02x" \
-               $1 $2 $3 $4 \
-               $(( (0x$5 + $off2) % 0x100 )) \
-               $(( (0x$6 + $id) % 0x100 ))
+       wdev_tool "$phy" get_macaddr id=$id
 }
 
 get_board_phy_name() (
@@ -889,7 +849,6 @@ wpa_supplicant_init_config() {
 wpa_supplicant_add_interface() {
        local ifname="$1"
        local mode="$2"
-       local hostapd_ctrl="$3"
        local prev
 
        _wpa_supplicant_common "$ifname"
@@ -903,7 +862,6 @@ wpa_supplicant_add_interface() {
        json_add_string config "$_config"
        json_add_string macaddr "$macaddr"
        [ -n "$network_bridge" ] && json_add_string bridge "$network_bridge"
-       [ -n "$hostapd_ctrl" ] && json_add_string hostapd_ctrl "$hostapd_ctrl"
        [ -n "$wds" ] && json_add_boolean 4addr "$wds"
        json_add_boolean powersave "$powersave"
        [ "$mode" = "mesh" ] && mac80211_add_mesh_params
@@ -978,7 +936,7 @@ mac80211_setup_supplicant() {
                wpa_supplicant_add_network "$ifname" "$freq" "$htmode" "$noscan"
        fi
 
-       wpa_supplicant_add_interface "$ifname" "$mode" "$hostapd_ctrl"
+       wpa_supplicant_add_interface "$ifname" "$mode"
 
        return 0
 }
@@ -1072,7 +1030,7 @@ mac80211_reset_config() {
        hostapd_conf_file="/var/run/hostapd-$phy.conf"
        ubus call hostapd config_set '{ "phy": "'"$phy"'", "config": "", "prev_config": "'"$hostapd_conf_file"'" }' > /dev/null
        ubus call wpa_supplicant config_set '{ "phy": "'"$phy"'", "config": [] }' > /dev/null
-       wdev_tool "$phy" '{}'
+       wdev_tool "$phy" set_config '{}'
 }
 
 drv_mac80211_setup() {
@@ -1176,7 +1134,7 @@ drv_mac80211_setup() {
        [ -x /usr/sbin/wpa_supplicant ] && wpa_supplicant_start "$phy"
 
        json_set_namespace wdev_uc prev
-       wdev_tool "$phy" "$(json_dump)" $active_ifnames
+       wdev_tool "$phy" set_config "$(json_dump)" $active_ifnames
        json_set_namespace "$prev"
 
        for_each_interface "ap sta adhoc mesh monitor" mac80211_set_vif_txpower