Commit 5372956a authored by Jakob Olsson's avatar Jakob Olsson
Browse files

map-agent: multiap: func to sync mapcontroller from wireless

To accomodate datamodel
parent bf0ddc53
......@@ -7,6 +7,7 @@
# write_credentials - write bBSS credentials to fBSS
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
. /lib/wifi/traffic_separation
diff=0
......@@ -409,6 +410,97 @@ brcm_bsta_to_wireless() {
}
sync_mapcontroller_from_wireless() {
ubus -t 5 wait_for wifi
[ "$?" != "0" ] && return
[ ! -f "/etc/config/wireless" ] && return
status=$(ubus -S call wifi status)
device_to_band() {
local ifname=$1
json_load "$status"
json_select "radios"
json_get_keys keys
for key in $keys; do
json_select $key
json_get_var name name
if [ "$name" != "$ifname" ]; then
json_select ..
continue
fi
json_get_var band band
if [ "$band" == "5GHz" ]; then
echo "5"
elif [ "$band" == "2.4GHz" ]; then
echo "2"
fi
break
done
json_cleanup
}
wireless_process_iface() {
local section=$1
local type="ap"
local enabled="1"
config_get multi_ap $section multi_ap 0
[ "$multi_ap" != "1" ] && [ "$multi_ap" != "2" ] && return
config_get mode $section mode "ap"
[ "$mode" != "ap" ] && return
config_get device $section device
band=$(device_to_band $device)
[ "$band" == "" ] && return
config_get ssid $section ssid
config_get key $section key
config_get encryption $section encryption
config_get start_disabled $section start_disabled "0"
config_get network $section network
cntlr_section=$(uci add mapcontroller ${type})
uci set mapcontroller.${cntlr_section}.ssid="$ssid"
uci set mapcontroller.${cntlr_section}.key="$key"
uci set mapcontroller.${cntlr_section}.encryption="$encryption"
uci set mapcontroller.${cntlr_section}.band="$band"
uci set mapcontroller.${cntlr_section}.vid="1"
uci set mapcontroller.${cntlr_section}.network="$network"
[ "$multi_ap" == "1" ] && map_type="backhaul" || map_type="fronthaul"
uci set mapcontroller.${cntlr_section}.type="$map_type"
[ "$start_disabled" == "1" ] && enabled="0"
uci set mapcontroller.${cntlr_section}.enabled="$enabled"
}
mapcontroller_teardown() {
local section=$1
uci delete mapcontroller.$1
}
config_load mapcontroller
config_foreach mapcontroller_teardown ap
config_load wireless
config_foreach wireless_process_iface wifi-iface
uci commit mapcontroller
}
func=$1
shift
......@@ -423,6 +515,7 @@ case "$func" in
write_bsta_config) write_bsta_config $@;;
teardown_iface) brcm_teardown_iface $@;;
bsta_to_wireless) brcm_bsta_to_wireless $@;;
sync_mapcontroller_from_wireless) sync_mapcontroller_from_wireless $@;;
ts) ts_sub $@;;
--help|help) usage;;
*) usage; exit 1;;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment