-
- ifconfig "$ifname" up
-
- [ "$mode" = "ap" ] || mac80211_start_vif "$vif" "$ifname"
-
- case "$mode" in
- adhoc)
- config_get bssid "$vif" bssid
- iw dev "$ifname" ibss join "$ssid" $freq ${fixed:+fixed-freq} $bssid
- ;;
- sta|mesh)
- config_get bssid "$vif" bssid
- case "$enc" in
- *wep*)
- if [ -z "$keymgmt" ]; then
- [ -n "$keystring" ] &&
- iw dev "$ifname" connect "$ssid" ${fixed:+$freq} $bssid key $keystring
- else
- if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
- wpa_supplicant_setup_vif "$vif" wext || {
- echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
- # make sure this wifi interface won't accidentally stay open without encryption
- ifconfig "$ifname" down
- continue
- }
- fi
- fi
- ;;
- *wpa*|*psk*)
- config_get key "$vif" key
- if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
- wpa_supplicant_setup_vif "$vif" wext || {
- echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
- # make sure this wifi interface won't accidentally stay open without encryption
- ifconfig "$ifname" down
- continue
- }
- fi
- ;;
- *)
- if [ -z "$keymgmt" ]; then
- iw dev "$ifname" connect "$ssid" ${fixed:+$freq} $bssid
- else
- if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
- wpa_supplicant_setup_vif "$vif" wext || {
- echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
- # make sure this wifi interface won't accidentally stay open without encryption
- ifconfig "$ifname" down
- continue
- }
- fi
- fi
- ;;
- esac
-
- ;;
- esac