/[baselayout]/trunk/net.Linux/iwconfig.sh
Gentoo

Diff of /trunk/net.Linux/iwconfig.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2753 Revision 2754
306 # Sleep if required 306 # Sleep if required
307 eval x=\$sleep_scan_${IFVAR} 307 eval x=\$sleep_scan_${IFVAR}
308 [ -n "${x}" ] && sleep "${x}" 308 [ -n "${x}" ] && sleep "${x}"
309 309
310 while [ ${i} -lt 3 ] ; do 310 while [ ${i} -lt 3 ] ; do
311 scan="${scan} $(iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")" 311 local scan="${scan}${scan:+ }$(LC_ALL=C iwlist "${IFACE}" scan 2>/dev/null | sed -e "s/'/'\\\\''/g" -e "s/$/'/g" -e "s/^/'/g")"
312 # If this is the first pass and txpower as off and we have no results
313 # then we need to wait for at least 2 seconds whilst the interface
314 # does an initial scan.
315 if [ "${i}" = "0" -a "${txpowerwasoff}" = "0" ] ; then
316 case "${scan}" in
317 "'${IFACE} "*"No scan results"*)
318 sleep 2
319 txpowerwasoff=1
320 continue
321 ;;
322 esac
323 fi
312 i=$((${i} + 1)) 324 i=$((${i} + 1))
313 done 325 done
314 326
315 if [ -z "${scan}" ] ; then 327 if [ -z "${scan}" ] ; then
316 ewarn "${iface} does not support scanning" 328 ewarn "${iface} does not support scanning"
338 APS=-1 350 APS=-1
339 eval set -- ${scan} 351 eval set -- ${scan}
340 for line in "$@" ; do 352 for line in "$@" ; do
341 case "${line}" in 353 case "${line}" in
342 *Address:*) 354 *Address:*)
343 APS=$((${APS} + 1)) 355 APS=$((${APS} + 1))
344 eval MAC_${APS}=\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\" 356 eval MAC_${APS}=\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\"
345 eval QUALITY_${APS}=0 357 eval QUALITY_${APS}=0
346 ;; 358 ;;
347 *ESSID:*) 359 *ESSID:*)
348 x=${line#*\"} 360 x=${line#*\"}
410 # Strip any duplicates 422 # Strip any duplicates
411 local i=0 k=1 a= b= 423 local i=0 k=1 a= b=
412 while [ ${i} -lt ${APS} ] ; do 424 while [ ${i} -lt ${APS} ] ; do
413 k=$((${i} + 1)) 425 k=$((${i} + 1))
414 while [ ${k} -le ${APS} ] ; do 426 while [ ${k} -le ${APS} ] ; do
415 eval a=\$MAC_${i} 427 eval a=\$MAC_${i}
416 eval b=\$MAC_${k} 428 eval b=\$MAC_${k}
417 if [ "${a}" = "${b}" ] ; then 429 if [ "${a}" = "${b}" ] ; then
418 eval a=\$QUALITY_${i} 430 eval a=\$QUALITY_${i}
419 eval b=\$QUALITY_${k} 431 eval b=\$QUALITY_${k}
420 if [ -n "${a}" -a -n "${b}" ] ; then 432 local u=${k}
421 if [ ${a} -ge ${b} ] ; then 433 [ -n "${a}" -a -n "${b}" -a "${a}" -lt "${b}" ] && u=${i}
422 unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} ENC_${k}
423 else
424 unset MAC_${i} SSID_${i} CHAN_${i} QUALITY_${i} ENC_${i}
425 fi
426 else
427 unset MAC_${k} SSID_${k} CHAN_${k} QUALITY_${k} ENC_${k} 434 unset MAC_${u} SSID_${u} CHAN_${u} QUALITY_${u} ENC_${u}
428 fi
429 fi 435 fi
430 k=$((${k} + 1)) 436 k=$((${k} + 1))
431 done 437 done
432 i=$((${i} + 1)) 438 i=$((${i} + 1))
433 done 439 done
434 440
435 local i=0 e= m= black= s= 441 local i=0 e= m= black= s=
505 ewarn "Failed to associate with any preferred access points on ${IFACE}" 511 ewarn "Failed to associate with any preferred access points on ${IFACE}"
506 return 1 512 return 1
507} 513}
508 514
509iwconfig_connect_preferred() { 515iwconfig_connect_preferred() {
510 local ssid= i=0 mode= mac= enc= freq= chan= 516 local ssid= i= mode= mac= enc= freq= chan=
511 517
512 eval "$(_get_array preferred_aps)" 518 eval "$(_get_array preferred_aps)"
513 for ssid in "$@"; do 519 for ssid in "$@"; do
520 i=0
514 while [ ${i} -le ${APS} ] ; do 521 while [ ${i} -le ${APS} ] ; do
515 eval e=\$SSID_${i} 522 eval e=\$SSID_${i}
516 if [ "${e}" = "${ssid}" ] ; then 523 if [ "${e}" = "${ssid}" ] ; then
517 SSID=${e} 524 SSID=${e}
518 eval mode=\$MODE_${i} 525 eval mode=\$MODE_${i}
533iwconfig_connect_not_preferred() { 540iwconfig_connect_not_preferred() {
534 local ssid= i=0 mode= mac= enc= freq= chan= pref=false 541 local ssid= i=0 mode= mac= enc= freq= chan= pref=false
535 542
536 while [ ${i} -le ${APS} ] ; do 543 while [ ${i} -le ${APS} ] ; do
537 eval e=\$SSID_${i} 544 eval e=\$SSID_${i}
545 if [ -n "${e}" ] ; then
538 eval "$(_get_array preferred_aps)" 546 eval "$(_get_array preferred_aps)"
539 for ssid in "$@" ; do 547 for ssid in "$@" ; do
540 if [ "${e}" = "${ssid}" ] ; then 548 if [ "${e}" = "${ssid}" ] ; then
541 pref=true 549 pref=true
542 break 550 break
543 fi 551 fi
544 done 552 done
545 553
546 if ! ${pref} ; then 554 if ! ${pref} ; then
547 SSID=${e} 555 SSID=${e}
548 eval mode=\$MODE_${i} 556 eval mode=\$MODE_${i}
549 eval mac=\$MAC_${i} 557 eval mac=\$MAC_${i}
550 eval enc=\$ENC_${i} 558 eval enc=\$ENC_${i}
551 eval freq=\$FREQ_${i} 559 eval freq=\$FREQ_${i}
552 eval chan=\$CHAN_${i} 560 eval chan=\$CHAN_${i}
553 iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \ 561 iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \
554 "${chan}" && return 0 562 "${chan}" && return 0
563 fi
555 fi 564 fi
556 i=$((${i} + 1)) 565 i=$((${i} + 1))
557 done 566 done
558 567
559 return 1 568 return 1
666 ewarn "/etc/conf.d/wireless is deprecated" 675 ewarn "/etc/conf.d/wireless is deprecated"
667 ewarn "Please put all settings into /etc/conf.d/net" 676 ewarn "Please put all settings into /etc/conf.d/net"
668 . /etc/conf.d/wireless 677 . /etc/conf.d/wireless
669 fi 678 fi
670 679
680 # Store the fact that tx-power was off so we default to a longer
681 # wait if our scan returns nothing
682 LC_ALL=C iwconfig iwi0 | sed -e '1d' | grep -q "Tx-Power=off"
683 local txpowerwasoff=$?
684
671 iwconfig_defaults 685 iwconfig_defaults
672 iwconfig_user_config 686 iwconfig_user_config
673 687
674 # Set the base metric to be 2000 688 # Set the base metric to be 2000
675 metric=2000 689 metric=2000
676 690
677 # Check for rf_kill - only ipw supports this at present, but other 691 # Check for rf_kill - only ipw supports this at present, but other

Legend:
Removed from v.2753  
changed lines
  Added in v.2754

  ViewVC Help
Powered by ViewVC 1.1.20