diff options
Diffstat (limited to 'src/connections')
-rw-r--r-- | src/connections/ethernet | 10 | ||||
-rw-r--r-- | src/connections/wireless | 75 |
2 files changed, 42 insertions, 43 deletions
diff --git a/src/connections/ethernet b/src/connections/ethernet index ad9e870..9ec27fb 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -11,13 +11,19 @@ ethernet_up() { fi fi + # Connection check if ip link show "$INTERFACE"|grep -q "NO-CARRIER"; then err_append "no connection available" return 1 fi ifconfig "$INTERFACE" up - + + # Some hardware is not immediately ready after ifconfig up + while ip link show $INTERFACE|grep -q "state UNKNOWN"; do + sleep 0.5 + done + if checkyesno "${AUTH8021X:-no}"; then . "${SUBR_DIR}"/8021x [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" @@ -116,7 +122,7 @@ ethernet_down() { esac ifconfig $INTERFACE 0.0.0.0 - case "$CONNECTION" in + case "$CONNECTION" in # Keep interface up for wireless ethernet|ethernet-old) quirk "nodown" || ifconfig $INTERFACE down ;; diff --git a/src/connections/wireless b/src/connections/wireless index 27df7ca..c614c6f 100644 --- a/src/connections/wireless +++ b/src/connections/wireless @@ -7,28 +7,33 @@ wireless_up() { . ${SUBR_DIR}/wireless - if [[ ! -d /sys/class/net/$INTERFACE/wireless ]]; then + if [[ ! -d /sys/class/net/$INTERFACE/phy80211 ]]; then err_append "$INTERFACE is not a valid wireless interface." return 1 fi - - # Required by atheros and others (mac80211?) to enable device - ifconfig $INTERFACE up - - # Hack that has been required by some broadcom - quirk "prescan" && iwlist $INTERFACE scan &> /dev/null - - # Required by ipw3945 to properly re-associate - quirk "preessid" && eval "iwconfig $INTERFACE mode managed essid \"$ESSID\"" # Kill any lingering wpa_supplicants. if [[ -f /var/run/wpa_supplicant_$INTERFACE.pid ]]; then kill $(cat /var/run/wpa_supplicant_$INTERFACE.pid) fi - # Default scan off as it won't see hidden networks and some hardware's scanning is dodgy - [[ ! "$SCAN" ]] && SCAN="no" - if checkyesno $SCAN; then + # Most drivers (mac80211) need mode set before device is brought up + # Drivers generally default to managed, but set this to be sure. + if [[ "$(iwgetid -sm $INTERFACE)" -ne "Managed" ]]; then + iwconfig $INTERFACE mode managed + fi + + ifconfig $INTERFACE up + + # Some hardware is not immediately ready after ifconfig up + while ip link show $INTERFACE|grep -q "state UNKNOWN"; do + sleep 0.5 + done + + quirk "prescan" && iwlist $INTERFACE scan &> /dev/null # bcm43xx + quirk "preessid" && eval "iwconfig $INTERFACE mode managed essid \"$ESSID\"" # ipw3945 + + if checkyesno ${SCAN-no}; then if ! find_essid $INTERFACE "$ESSID"; then err_append "Network not present." return 1 @@ -36,44 +41,33 @@ wireless_up() { fi # Manually set iwconfig options - if [[ "$IWCONFIG" ]]; then - iwconfig $INTERFACE $IWCONFIG - fi + [[ "$IWCONFIG" ]] && iwconfig $INTERFACE $IWCONFIG case $SECURITY in wep|none) - # 'none' security uses iwconfig, like wep, so use same code, minus keysetting. - # Use sane default if no alternative is specified - if [[ "$SECURITY" = "wep" && "$WEP_OPTS" = "" ]]; then - WEP_OPTS="mode managed essid \"$ESSID\" key $KEY" - elif [[ "$SECURITY" = "none" && "$WEP_OPTS" = "" ]]; then - WEP_OPTS="mode managed essid \"$ESSID\"" + # 'none' uses iwconfig like wep. Use sane default if WEP_OPTS="" + if [[ "$SECURITY" = "wep" ]]; then + WEP_OPTS="essid \"$ESSID\" key $KEY" + elif [[ "$SECURITY" = "none" ]]; then + WEP_OPTS="essid \"$ESSID\"" fi - - # Add wierd quirk for some Atheros in response to FS#10585 - quirk "predown" && ifconfig $INTERFACE down + + quirk "predown" && ifconfig $INTERFACE down # madwifi FS#10585 if ! eval iwconfig $INTERFACE $WEP_OPTS; then err_append "Could not set wireless configuration." return 1 fi - quirk "postsleep" && sleep 1 - quirk "postscan" && sleep 1 && iwlist $INTERFACE scan &>/dev/null - quirk "predown" && ifconfig $INTERFACE up - - # Many devices appear to not associate until DHCP is run. - if quirk "acheck"; then - wep_check $INTERFACE $TIMEOUT|| return 1 - else - sleep ${TIMEOUT:-15} - fi + quirk "predown" && ifconfig $INTERFACE up # madwifi FS#10585 + + wep_check $INTERFACE $TIMEOUT||return 1 ;; wpa) . ${SUBR_DIR}/8021x # Quirk for broken drivers... http://bbs.archlinux.org/viewtopic.php?id=36384 - quirk "wpaessid" && eval iwconfig $INTERFACE mode managed essid "\"$ESSID\"" + quirk "wpaessid" && eval iwconfig $INTERFACE essid "\"$ESSID\"" local WPA_CONF="/tmp/wpa.${1// /}" # substitute spaces out echo "ctrl_interface=/var/run/wpa_supplicant" >> $WPA_CONF @@ -89,15 +83,14 @@ wireless_up() { fi # Connect! - [[ "$WPA_OPTS" == "" ]] && WPA_OPTS="-Dwext" + [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext" start_wpa $INTERFACE $WPA_CONF $WPA_OPTS || return 1 wpa_check $INTERFACE $TIMEOUT || return 1 ;; wpa-config) - . ${SUBR_DIR}/8021x - # If user hasnt defined one, use stock config. - [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" - [[ "$WPA_OPTS" == "" ]] && WPA_OPTS="-Dwext" + . ${SUBR_DIR}/8021x + [[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults + [[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext" start_wpa $INTERFACE $WPA_CONF $WPA_OPTS || return 1 wpa_check $INTERFACE $TIMEOUT || return 1 ;; |