X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/78a4e88e7631e101b3917c58d9de741768598e7a..f806cc2b9fd39352dad6f5edae3ab61010dcce17:/package/madwifi/files/lib/wifi/madwifi.sh?ds=sidebyside diff --git a/package/madwifi/files/lib/wifi/madwifi.sh b/package/madwifi/files/lib/wifi/madwifi.sh index 8b4751ef7..69874b5c1 100755 --- a/package/madwifi/files/lib/wifi/madwifi.sh +++ b/package/madwifi/files/lib/wifi/madwifi.sh @@ -99,12 +99,13 @@ enable_atheros() { *bg) agmode=11g;; *g) agmode=11g; pureg=1;; *a) agmode=11a;; - *) agmode=11g;; + *) agmode=auto;; esac - iwconfig "$ifname" channel 0 + iwconfig "$ifname" channel 0 >/dev/null 2>/dev/null + ifconfig "$ifname" up iwpriv "$ifname" mode "$agmode" iwpriv "$ifname" pureg "$pureg" - iwconfig "$ifname" channel "$channel" + iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null } config_get_bool hidden "$vif" hidden @@ -125,7 +126,11 @@ enable_atheros() { iwconfig "$ifname" enc "[$idx]" "${key:-off}" done config_get key "$vif" key - iwconfig "$ifname" enc "${key:-1}" + key="${key:-1}" + case "$key" in + [1234]) iwconfig "$ifname" enc "[$key]";; + *) iwconfig "$ifname" enc "$key";; + esac ;; PSK|psk|PSK2|psk2) config_get key "$vif" key @@ -177,6 +182,7 @@ enable_atheros() { fi ifconfig "$ifname" up + iwconfig "$ifname" channel "$channel" >/dev/null 2>/dev/null local net_cfg bridge net_cfg="$(find_net_config "$vif")" @@ -188,13 +194,15 @@ enable_atheros() { iwconfig "$ifname" essid "$ssid" case "$mode" in ap) - hostapd_setup_vif "$vif" madwifi || { - echo "enable_atheros($device): Failed to set up wpa for interface $ifname" >&2 - # make sure this wifi interface won't accidentally stay open without encryption - ifconfig "$ifname" down - wlanconfig "$ifname" destroy - continue - } + if eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then + hostapd_setup_vif "$vif" madwifi || { + echo "enable_atheros($device): Failed to set up wpa for interface $ifname" >&2 + # make sure this wifi interface won't accidentally stay open without encryption + ifconfig "$ifname" down + wlanconfig "$ifname" destroy + continue + } + fi ;; wds|sta) case "$enc" in @@ -220,7 +228,7 @@ EOF #add wpa_supplicant calls here ;; esac - wpa_supplicant ${bridge:+ -b $bridge} -Bw -D wext -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf + [ -z "$proto" ] || wpa_supplicant ${bridge:+ -b $bridge} -Bw -D wext -i "$ifname" -c /var/run/wpa_supplicant-$ifname.conf ;; esac first=0 @@ -231,7 +239,7 @@ EOF detect_atheros() { cd /proc/sys/dev [ -d ath ] || return - for dev in $(ls wifi* 2>&-); do + for dev in $(ls -d wifi* 2>&-); do config_get type "$dev" type [ "$type" = atheros ] && return cat <