. /lib/functions.sh

handle_interface() {
	local config="${1}"
	local prefix="${2}"

	config_get ifname "${config}" ifname
	config_get mode ${config} mode

	if [ "$mode" = "ap" ] ; then
		echo "Get assoc list for ${ifname}"
		ubus call "${prefix}.${ifname}" assoclist
		echo "Get station info for ${ifname}"
		ubus call "${prefix}.${ifname}" stations
	fi
}

handle_wifi_interface() {
	handle_interface "$1" "wifi.ap"
}

handle_mld_interface() {
	handle_interface "$1" "wifi.apmld"
}

config_load wireless
echo "Get associated stations information for non-MLD interfaces"
config_foreach handle_wifi_interface wifi-iface
echo "Get associated stations information for MLD interfaces"
config_foreach handle_mld_interface wifi-mld
