-mac80211_prepare_vif() {
- json_select config
-
- json_get_vars ifname mode ssid wds powersave macaddr enable wpa_psk_file vlan_file
-
- [ -n "$ifname" ] || {
- local prefix;
-
- case "$mode" in
- ap|sta|mesh) prefix=$mode;;
- adhoc) prefix=ibss;;
- monitor) prefix=mon;;
- esac
-
- mac80211_set_ifname "$phy" "$prefix"
- }
-
- append active_ifnames "$ifname"
- set_default wds 0
- set_default powersave 0
- json_add_string _ifname "$ifname"
-
- default_macaddr=
- if [ -z "$macaddr" ]; then
- macaddr="$(mac80211_generate_mac $phy)"
- macidx="$(($macidx + 1))"
- default_macaddr=1
- elif [ "$macaddr" = 'random' ]; then
- macaddr="$(macaddr_random)"
- fi
- json_add_string _macaddr "$macaddr"
- json_add_string _default_macaddr "$default_macaddr"
- json_select ..
-
-
- [ "$mode" == "ap" ] && {
- [ -z "$wpa_psk_file" ] && hostapd_set_psk "$ifname"
- [ -z "$vlan_file" ] && hostapd_set_vlan "$ifname"
- }
-
- json_select config
-
- # It is far easier to delete and create the desired interface
- case "$mode" in
- ap)
- # Hostapd will handle recreating the interface and
- # subsequent virtual APs belonging to the same PHY
- if [ -n "$hostapd_ctrl" ]; then
- type=bss
- else
- type=interface
- fi
-
- mac80211_hostapd_setup_bss "$phy" "$ifname" "$macaddr" "$type" || return
-
- [ -n "$hostapd_ctrl" ] || {
- ap_ifname="${ifname}"
- hostapd_ctrl="${hostapd_ctrl:-/var/run/hostapd/$ifname}"
- }
- ;;
- esac
-
- json_select ..
-}
-