parse the a/g mode setting in /etc/config/wireless when setting up hostapd (instead...
[openwrt/svn-archive/archive.git] / package / hostapd / files / hostapd.sh
index 660a90c3efaed7b446ded279207a612285f22ded..7a67cec949c03f72ac0cae27b7c57a2a6088f85a 100644 (file)
@@ -39,7 +39,11 @@ hostapd_setup_vif() {
        case "$enc" in
                *psk*|*PSK*)
                        config_get psk "$vif" key
-                       append hostapd_cfg "wpa_passphrase=$psk" "$N"
+                       if [ ${#psk} -eq 64 ]; then
+                               append hostapd_cfg "wpa_psk=$psk" "$N"
+                       else
+                               append hostapd_cfg "wpa_passphrase=$psk" "$N"
+                       fi
                ;;
                *wpa*|*WPA*)
                        # required fields? formats?
@@ -62,15 +66,26 @@ hostapd_setup_vif() {
                        append hostapd_cfg "wpa_gmk_rekey=640" "$N"
                ;;
                *)
-                       return 0;
+                       wpa=0
                ;;
        esac
        config_get ifname "$vif" ifname
        config_get bridge "$vif" bridge
        config_get ssid "$vif" ssid
+       config_get device "$vif" device
+       config_get channel "$device" channel
+       config_get agmode "$device" agmode
+       case "$agmode" in
+               11a) agmode=a;;
+               11b) agmode=b;;
+               11g) agmode=g;;
+               *) agmode=;;
+       esac
        cat > /var/run/hostapd-$ifname.conf <<EOF
 driver=$driver
 interface=$ifname
+hw_mode=${agmode:-g}
+channel=$channel
 ${bridge:+bridge=$bridge}
 ssid=$ssid
 debug=0