Fix iproute handling of -host and improve iwconfig scanning

This commit is contained in:
Roy Marples 2007-07-09 09:14:19 +00:00
parent 87d1a3be19
commit e03844fd26
2 changed files with 51 additions and 38 deletions

View File

@ -118,9 +118,8 @@ _add_route() {
case "$1" in
metric) cmd="${cmd} $1"; have_metric=true ;;
netmask) cmd="${cmd}/$(_netmask2cidr "$2")"; shift ;;
-net) ;;
-host|-net) ;;
-A) [ "$2" = "inet6" ] && shift ;;
-host) cmd="${cmd} scope host" ;;
*) cmd="${cmd} $1" ;;
esac
shift

View File

@ -308,7 +308,19 @@ iwconfig_scan() {
[ -n "${x}" ] && sleep "${x}"
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))
done
@ -417,15 +429,9 @@ iwconfig_scan() {
if [ "${a}" = "${b}" ] ; then
eval a=\$QUALITY_${i}
eval b=\$QUALITY_${k}
if [ -n "${a}" -a -n "${b}" ] ; then
if [ ${a} -ge ${b} ] ; then
unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} ENC_${k}
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
local u=${k}
[ -n "${a}" -a -n "${b}" -a "${a}" -lt "${b}" ] && u=${i}
unset MAC_${u} SSID_${u} CHAN_${u} QUALITY_${u} ENC_${u}
fi
k=$((${k} + 1))
done
@ -507,10 +513,11 @@ iwconfig_force_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)"
for ssid in "$@"; do
i=0
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
if [ "${e}" = "${ssid}" ] ; then
@ -535,6 +542,7 @@ iwconfig_connect_not_preferred() {
while [ ${i} -le ${APS} ] ; do
eval e=\$SSID_${i}
if [ -n "${e}" ] ; then
eval "$(_get_array preferred_aps)"
for ssid in "$@" ; do
if [ "${e}" = "${ssid}" ] ; then
@ -553,6 +561,7 @@ iwconfig_connect_not_preferred() {
iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \
"${chan}" && return 0
fi
fi
i=$((${i} + 1))
done
@ -668,6 +677,11 @@ iwconfig_pre_start() {
. /etc/conf.d/wireless
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_user_config