From 3ebb0264531012a070e0b16c5de9ca42e13b79fa Mon Sep 17 00:00:00 2001 From: Jakob Olsson Date: Thu, 9 Jun 2022 15:34:51 +0200 Subject: [PATCH] map-agent: multiap: manage wpa_supplicant bssid_ignore --- map-agent/files/lib/wifi/multiap | 39 ++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/map-agent/files/lib/wifi/multiap b/map-agent/files/lib/wifi/multiap index 5e060fc1e..6f0dd19e1 100755 --- a/map-agent/files/lib/wifi/multiap +++ b/map-agent/files/lib/wifi/multiap @@ -356,7 +356,7 @@ write_bsta_config() { #echo result diff = $diff > /dev/console [ "$diff" == "1" ] && { - config_foreach mapagent_apply_bssid_same_band bsta + (config_foreach mapagent_apply_bssid_same_band bsta) #ubus call uci commit '{"config":"wireless"}' #echo reloading wireless > /dev/console } @@ -488,10 +488,12 @@ bsta_to_wireless() { mapagent_find_other_creds() { #echo "trying to find other creds for $2" > /dev/console + local other_section="$2" + config_get band $1 band config_get onboarded $1 onboarded "0" - [ "$3" != "$band" -o "$onboarded" = "0" ] && return + [ "$4" != "$band" -o "$onboarded" = "0" ] && return config_get ssid $1 ssid config_get key $1 key @@ -499,7 +501,12 @@ bsta_to_wireless() { config_get enabled $1 enabled "0" config_get bssid $1 bssid - (mapagent_apply_wl_bsta $2 "$ssid" "$key" $encryption $4 "$bssid") + uci -q set mapagent.${other_section}.ssid="$ssid" + uci -q set mapagent.${other_section}.key="$key" + uci -q set mapagent.${other_section}.encryption=$encryption + uci -q set mapagent.${other_section}.bssid="$bssid" + uci commit mapagent + (mapagent_apply_wl_bsta "$3" "$ssid" "$key" $encryption "$5" "$bssid") } config_get band $1 band @@ -508,7 +515,7 @@ bsta_to_wireless() { config_get enabled $1 enabled "0" if [ "$onboarded" = "0" ]; then - config_foreach mapagent_find_other_creds bsta $ifname $band $enabled + config_foreach mapagent_find_other_creds bsta $1 $ifname $band $enabled else config_get ssid $1 ssid config_get key $1 key @@ -700,8 +707,28 @@ bsta_clear_all_bssid() { config_load wireless config_foreach wireless_remove_bssid wifi-iface uci commit wireless +} - bsta_scan_on_enabled +# arg1 = ifname arg2 = bssid +bsta_blacklist_bssid_set() { + local ifname="$1" + shift + local bssid="$@" + + wpa_cli -i "$ifname" set_network 0 bssid_ignore "$bssid" > /dev/null 2>&1 + wpa_cli -i "$ifname" save_config > /dev/null 2>&1 +} + +bsta_blacklist_bssid_clear() { + mapagent_blacklist_by_band() { + config_get ifname $1 ifname + + wpa_cli -i "$ifname" set_network 0 bssid_ignore "" > /dev/null 2>&1 + wpa_cli -i "$ifname" save_config > /dev/null 2>&1 + } + + config_load mapagent + config_foreach mapagent_blacklist_by_band bsta } bsta_disable_lower_priority() { @@ -878,6 +905,8 @@ case "$func" in ts) ts_sub $@;; bsta_enable_all) bsta_enable_all $@;; bsta_clear_all_bssid) bsta_clear_all_bssid $@;; + bsta_blacklist_bssid_set) bsta_blacklist_bssid_set $@;; + bsta_blacklist_bssid_clear) bsta_blacklist_bssid_clear $@;; bsta_disable_lower_priority) bsta_disable_lower_priority $@;; bsta_scan_on_enabled) bsta_scan_on_enabled $@;; bsta_use_link) bsta_use_link $@;;