# Wireless connection support for netctl . "$SUBR_DIR/8021x" . "$SUBR_DIR/ip" . "$SUBR_DIR/rfkill" wireless_up() { local config_file if ! is_interface "$Interface"; then report_error "Interface '$Interface' does not exist" return 1 fi # Default settings : ${Security:=none} : ${WPADriver:=nl80211,wext} : ${TimeoutWPA:=15} if [[ $RFKill ]]; then enable_rf "$Interface" "$RFKill" || return 1 fi # Kill any lingering WPA supplicants WPAConfigFile= wpa_stop "$Interface" &> /dev/null if [[ $Security == "wpa-config" ]]; then : ${WPAConfigFile:=/etc/wpa_supplicant.conf} config_file=$WPAConfigFile else config_file=$(wpa_make_config_file "$Interface") if [[ -z $config_file ]]; then report_error "Could not create a wpa config file for interface '$Interface'" bring_interface_down "$Interface" return 1 fi printf "%s\n" "network={" "$(wpa_make_config_block)" "}" >> "$config_file" fi # Start the WPA supplicant if ! do_debug wpa_start "$Interface" "$WPADriver" "$config_file"; then report_error "The WPA supplicant did not start for interface '$Interface'" bring_interface_down "$Interface" return 1 fi if is_yes "${Scan:-no}"; then if ! wpa_wait_while_state "$TimeoutWPA" "$Interface" "DISCONNECTED" "SCANNING"; then report_error "Wireless network '$ESSID' (or access point) not present" wpa_stop "$Interface" bring_interface_down "$interface" return 1 fi fi # Bring interface up after starting wpa_supplicant # This is important since cards such as iwl3945 do not support # mode switching when they are already up. bring_interface_up "$Interface" || return 1 if ! wpa_wait_until_state "$TimeoutWPA" "$Interface" "COMPLETED"; then report_error "WPA association/authentication failed for interface '$Interface'" wpa_stop "$Interface" bring_interface_down "$Interface" return 1 fi if ! ip_set; then wpa_stop "$Interface" bring_interface_down "$Interface" return 1 fi } wireless_down() { ip_unset if [[ $Security == "wpa-config" ]]; then : ${WPAConfigFile:=/etc/wpa_supplicant.conf} fi wpa_stop "$Interface" bring_interface_down "$Interface" || return 1 if [[ $RFKill ]]; then disable_rf "$Interface" "$RFKill" fi } # vim: ft=sh ts=4 et sw=4 tw=0: