mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-28 01:11:52 +02:00
mac80211: always use wpa_supplicant for client connections (patch by Stijn Tintel)
Since client mode in mac80211is unreliable without using wpa_supplicant, it would be better to enable wpa_supplicant by default. With this patch, wpa_supplicant will always be used for mac80211-based drivers in client mode. This will break client mode for images that don't include wpa_supplicant or wpad, so maybe I need to add a check somewhere to see if wpa_supplicant is available, and show the user a warning if he tries client mode without wpa_supplicant. Suggestions on where to add this check are welcome. Tested with ath5k in client mode on open and wpa2-psk network, and tested on my ath9k based AP as well to make sure it doesn't break AP mode. git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19718 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
b52c399411
commit
c0a4b957c5
@ -6,7 +6,10 @@ wpa_supplicant_setup_vif() {
|
|||||||
# wpa_supplicant should use wext for mac80211 cards
|
# wpa_supplicant should use wext for mac80211 cards
|
||||||
[ "$driver" = "mac80211" ] && driver='wext'
|
[ "$driver" = "mac80211" ] && driver='wext'
|
||||||
|
|
||||||
# make sure we have the psk
|
# make sure we have the encryption type and the psk
|
||||||
|
[ -n "$enc" ] || {
|
||||||
|
config_get enc "$vif" encryption
|
||||||
|
}
|
||||||
[ -n "$key" ] || {
|
[ -n "$key" ] || {
|
||||||
config_get key "$vif" key
|
config_get key "$vif" key
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,6 @@ enable_mac80211() {
|
|||||||
}
|
}
|
||||||
config_set "$vif" ifname "$ifname"
|
config_set "$vif" ifname "$ifname"
|
||||||
|
|
||||||
config_get enc "$vif" encryption
|
|
||||||
config_get mode "$vif" mode
|
config_get mode "$vif" mode
|
||||||
config_get ssid "$vif" ssid
|
config_get ssid "$vif" ssid
|
||||||
|
|
||||||
@ -288,60 +287,19 @@ enable_mac80211() {
|
|||||||
[ "$mode" = "ap" ] || ifconfig "$ifname" hw ether "$vif_mac"
|
[ "$mode" = "ap" ] || ifconfig "$ifname" hw ether "$vif_mac"
|
||||||
config_set "$vif" macaddr "$vif_mac"
|
config_set "$vif" macaddr "$vif_mac"
|
||||||
|
|
||||||
# Valid values are:
|
|
||||||
# wpa / wep / none
|
|
||||||
#
|
|
||||||
# !! ap !!
|
# !! ap !!
|
||||||
#
|
#
|
||||||
# ALL ap functionality will be passed to hostapd
|
# ALL ap functionality will be passed to hostapd
|
||||||
#
|
#
|
||||||
# !! mesh / adhoc / station !!
|
# !! station !!
|
||||||
# none -> NO encryption
|
|
||||||
#
|
#
|
||||||
# wep + keymgmt = '' -> we use iw to connect to the
|
# ALL station functionality will be passed to wpa_supplicant
|
||||||
# network.
|
|
||||||
#
|
#
|
||||||
# wep + keymgmt = 'NONE' -> wpa_supplicant will be
|
|
||||||
# configured to handle the wep connection
|
|
||||||
if [ ! "$mode" = "ap" ]; then
|
if [ ! "$mode" = "ap" ]; then
|
||||||
# We attempt to set the channel for all interfaces, although
|
# We attempt to set the channel for all interfaces, although
|
||||||
# mac80211 may not support it or the driver might not yet
|
# mac80211 may not support it or the driver might not yet
|
||||||
# for ap mode this is handled by hostapd
|
# for ap mode this is handled by hostapd
|
||||||
[ -n "$fixed" -a -n "$channel" ] && iw dev "$ifname" set channel "$channel"
|
[ -n "$fixed" -a -n "$channel" ] && iw dev "$ifname" set channel "$channel"
|
||||||
|
|
||||||
local key keystring
|
|
||||||
|
|
||||||
case "$enc" in
|
|
||||||
*none*)
|
|
||||||
config_get keymgmt "$vif" keymgmt
|
|
||||||
;;
|
|
||||||
*wep*)
|
|
||||||
config_get keymgmt "$vif" keymgmt
|
|
||||||
if [ -z "$keymgmt" ]; then
|
|
||||||
config_get key "$vif" key
|
|
||||||
key="${key:-1}"
|
|
||||||
case "$key" in
|
|
||||||
[1234])
|
|
||||||
for idx in 1 2 3 4; do
|
|
||||||
local zidx
|
|
||||||
zidx=$(($idx - 1))
|
|
||||||
config_get ckey "$vif" "key${idx}"
|
|
||||||
if [ -n "$ckey" ]; then
|
|
||||||
[ $idx -eq $key ] && zidx="d:${zidx}"
|
|
||||||
append keystring "${zidx}:$(prepare_key_wep "$ckey")"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
keystring="d:0:$(prepare_key_wep "$key")"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*psk*|*wpa*)
|
|
||||||
config_get key "$vif" key
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# txpower is not yet implemented in iw
|
# txpower is not yet implemented in iw
|
||||||
@ -363,21 +321,15 @@ enable_mac80211() {
|
|||||||
|
|
||||||
ifconfig "$ifname" up
|
ifconfig "$ifname" up
|
||||||
|
|
||||||
[ "$mode" = "ap" ] || mac80211_start_vif "$vif" "$ifname"
|
if [ ! "$mode" = "ap" ]; then
|
||||||
|
mac80211_start_vif "$vif" "$ifname"
|
||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
adhoc)
|
adhoc)
|
||||||
config_get bssid "$vif" bssid
|
config_get bssid "$vif" bssid
|
||||||
iw dev "$ifname" ibss join "$ssid" $freq ${fixed:+fixed-freq} $bssid
|
iw dev "$ifname" ibss join "$ssid" $freq ${fixed:+fixed-freq} $bssid
|
||||||
;;
|
;;
|
||||||
sta|mesh)
|
sta)
|
||||||
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
|
if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
|
||||||
wpa_supplicant_setup_vif "$vif" wext || {
|
wpa_supplicant_setup_vif "$vif" wext || {
|
||||||
echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
|
echo "enable_mac80211($device): Failed to set up wpa_supplicant for interface $ifname" >&2
|
||||||
@ -386,37 +338,9 @@ enable_mac80211() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fi
|
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
|
esac
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
local start_hostapd=
|
local start_hostapd=
|
||||||
|
Loading…
Reference in New Issue
Block a user