Fix iproute handling of -host and improve iwconfig scanning
This commit is contained in:
		| @@ -118,9 +118,8 @@ _add_route() { | |||||||
| 		case "$1" in | 		case "$1" in | ||||||
| 			metric) cmd="${cmd} $1"; have_metric=true ;; | 			metric) cmd="${cmd} $1"; have_metric=true ;; | ||||||
| 			netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift ;; | 			netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift ;; | ||||||
| 			-net) ;; | 			-host|-net) ;; | ||||||
| 			-A)	[ "$2" = "inet6" ] && shift ;; | 			-A)	[ "$2" = "inet6" ] && shift ;; | ||||||
| 			-host) cmd="${cmd} scope host" ;; |  | ||||||
| 			*) cmd="${cmd} $1" ;; | 			*) cmd="${cmd} $1" ;; | ||||||
| 		esac | 		esac | ||||||
| 		shift | 		shift | ||||||
|   | |||||||
| @@ -308,7 +308,19 @@ iwconfig_scan() { | |||||||
| 	[ -n "${x}" ] && sleep "${x}" | 	[ -n "${x}" ] && sleep "${x}" | ||||||
|  |  | ||||||
| 	while [ ${i} -lt 3 ] ; do | 	while [ ${i} -lt 3 ] ; do | ||||||
| 	    scan="${scan} $(iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")" | 	    local scan="${scan}${scan:+ }$(LC_ALL=C iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")" | ||||||
|  | 		# If this is the first pass and txpower as off and we have no results | ||||||
|  | 		# then we need to wait for at least 2 seconds whilst the interface | ||||||
|  | 		# does an initial scan. | ||||||
|  | 		if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ] ; then | ||||||
|  | 			case "${scan}" in | ||||||
|  | 				"'${IFACE} "*"No scan results"*) | ||||||
|  | 					sleep 2 | ||||||
|  | 					txpowerwasoff=1 | ||||||
|  | 					continue | ||||||
|  | 					;; | ||||||
|  | 			esac | ||||||
|  | 		fi | ||||||
| 	    i=$((${i} + 1)) | 	    i=$((${i} + 1)) | ||||||
| 	done | 	done | ||||||
|  |  | ||||||
| @@ -417,15 +429,9 @@ iwconfig_scan() { | |||||||
| 			if [ "${a}" = "${b}" ] ; then | 			if [ "${a}" = "${b}" ] ; then | ||||||
| 		    	eval a=\$QUALITY_${i} | 		    	eval a=\$QUALITY_${i} | ||||||
| 		    	eval b=\$QUALITY_${k} | 		    	eval b=\$QUALITY_${k} | ||||||
| 		    if [ -n "${a}" -a -n "${b}" ] ; then | 				local u=${k} | ||||||
| 			if [ ${a} -ge ${b} ] ; then | 		    	[ -n "${a}" -a -n "${b}" -a "${a}" -lt "${b}" ] && u=${i} | ||||||
| 			    unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} ENC_${k} | 				unset MAC_${u} SSID_${u} CHAN_${u} QUALITY_${u} ENC_${u} | ||||||
| 			else |  | ||||||
| 			    unset MAC_${i} SSID_${i} CHAN_${i} QUALITY_${i} ENC_${i} |  | ||||||
| 			fi |  | ||||||
| 		    else |  | ||||||
| 			unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} ENC_${k} |  | ||||||
| 		    fi |  | ||||||
| 			fi | 			fi | ||||||
| 			k=$((${k} + 1)) | 			k=$((${k} + 1)) | ||||||
| 	    done | 	    done | ||||||
| @@ -507,10 +513,11 @@ iwconfig_force_preferred() { | |||||||
| } | } | ||||||
|  |  | ||||||
| iwconfig_connect_preferred() { | iwconfig_connect_preferred() { | ||||||
| 	local ssid= i=0 mode= mac= enc= freq= chan= | 	local ssid= i= mode= mac= enc= freq= chan= | ||||||
|  |  | ||||||
| 	eval "$(_get_array preferred_aps)" | 	eval "$(_get_array preferred_aps)" | ||||||
| 	for ssid in "$@"; do | 	for ssid in "$@"; do | ||||||
|  | 		i=0 | ||||||
| 		while [ ${i} -le ${APS} ]  ; do | 		while [ ${i} -le ${APS} ]  ; do | ||||||
| 			eval e=\$SSID_${i} | 			eval e=\$SSID_${i} | ||||||
| 			if [ "${e}" = "${ssid}" ] ; then | 			if [ "${e}" = "${ssid}" ] ; then | ||||||
| @@ -535,6 +542,7 @@ iwconfig_connect_not_preferred() { | |||||||
|  |  | ||||||
| 	while [ ${i} -le ${APS} ] ; do | 	while [ ${i} -le ${APS} ] ; do | ||||||
| 		eval e=\$SSID_${i} | 		eval e=\$SSID_${i} | ||||||
|  | 		if [ -n "${e}" ] ; then | ||||||
| 			eval "$(_get_array preferred_aps)" | 			eval "$(_get_array preferred_aps)" | ||||||
| 			for ssid in "$@" ; do | 			for ssid in "$@" ; do | ||||||
| 				if [ "${e}" = "${ssid}" ] ; then | 				if [ "${e}" = "${ssid}" ] ; then | ||||||
| @@ -553,6 +561,7 @@ iwconfig_connect_not_preferred() { | |||||||
| 				iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \ | 				iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \ | ||||||
| 					"${chan}" && return 0 | 					"${chan}" && return 0 | ||||||
| 			fi | 			fi | ||||||
|  | 		fi | ||||||
| 		i=$((${i} + 1)) | 		i=$((${i} + 1)) | ||||||
| 	done | 	done | ||||||
|  |  | ||||||
| @@ -668,6 +677,11 @@ iwconfig_pre_start() { | |||||||
| 		. /etc/conf.d/wireless | 		. /etc/conf.d/wireless | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
|  | 	# Store the fact that tx-power was off so we default to a longer | ||||||
|  | 	# wait if our scan returns nothing | ||||||
|  | 	LC_ALL=C iwconfig iwi0 | sed -e '1d' | grep -q "Tx-Power=off" | ||||||
|  | 	local txpowerwasoff=$? | ||||||
|  | 	 | ||||||
| 	iwconfig_defaults | 	iwconfig_defaults | ||||||
| 	iwconfig_user_config | 	iwconfig_user_config | ||||||
| 	 | 	 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user