/[vps]/baselayout-vserver/trunk/net-scripts/net.modules.d/iwconfig
Gentoo

Diff of /baselayout-vserver/trunk/net-scripts/net.modules.d/iwconfig

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

Revision 235 Revision 236
61# char* iwconfig_get_wep_status(char *interface) 61# char* iwconfig_get_wep_status(char *interface)
62# 62#
63# Echos a string showing whether WEP is enabled or disabled 63# Echos a string showing whether WEP is enabled or disabled
64# for the given interface 64# for the given interface
65iwconfig_get_wep_status() { 65iwconfig_get_wep_status() {
66 local key=$( iwconfig "$1" | grep -i -o "Encryption key:[0-9,A-F]" ) 66 local key="$( iwconfig "$1" | grep -i -o "Encryption key:[0-9,A-F]" )"
67 local mode status="disabled" 67 local mode status="disabled"
68 68
69 if [[ -n ${key} ]]; then 69 if [[ -n ${key} ]]; then
70 status="enabled" 70 status="enabled"
71 mode="$( iwconfig $1 | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p' )" 71 mode="$( iwconfig "$1" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p' )"
72 [[ -n ${mode} ]] && mode=" - ${mode}" 72 [[ -n ${mode} ]] && mode=" - ${mode}"
73 fi 73 fi
74 74
75 echo "(WEP ${status}${mode})" 75 echo "(WEP ${status}${mode})"
76} 76}
80# Gets the current ESSID of the iface 80# Gets the current ESSID of the iface
81iwconfig_get_essid() { 81iwconfig_get_essid() {
82 local i essid 82 local i essid
83 83
84 for (( i=0; i<5; i++ )); do 84 for (( i=0; i<5; i++ )); do
85 essid="$( iwgetid $1 2>/dev/null | sed -n -e 's/^.*ESSID:"\(.*\)"$/\1/p' )" 85 essid="$( iwgetid "$1" 2>/dev/null | sed -n -e 's/^.*ESSID:"\(.*\)"$/\1/p' )"
86 if [[ -n ${essid} ]]; then 86 if [[ -n ${essid} ]]; then
87 echo "${essid}" 87 echo "${essid}"
88 return 0 88 return 0
89 fi 89 fi
90 sleep 1 90 sleep 1
119# 119#
120# Output how our wireless interface has been configured 120# Output how our wireless interface has been configured
121iwconfig_report() { 121iwconfig_report() {
122 local iface="$1" essid mac m="to" 122 local iface="$1" essid mac m="to"
123 123
124 essid=$( iwconfig_get_essid "${iface}" ) 124 essid="$( iwconfig_get_essid "${iface}" )"
125 125
126 local wep_status=$( iwconfig_get_wep_status "${iface}" ) 126 local wep_status="$( iwconfig_get_wep_status "${iface}" )"
127 local channel=$( iwgetid --channel "${iface}" 2>/dev/null | cut -d: -f2 ) 127 local channel="$( iwgetid --channel "${iface}" 2>/dev/null | cut -d: -f2 )"
128 [[ -n ${channel} ]] && channel="on channel ${channel} " 128 [[ -n ${channel} ]] && channel="on channel ${channel} "
129 129
130 essid="${essid//\\\\/\\\\}" 130 essid="${essid//\\\\/\\\\}"
131 local mode=$( iwconfig_get_mode "${iface}" ) 131 local mode="$( iwconfig_get_mode "${iface}" )"
132 if [[ ${mode} == "master" ]]; then 132 if [[ ${mode} == "master" ]]; then
133 m="as" 133 m="as"
134 elif [[ ${mode} != "ad-hoc" ]]; then 134 elif [[ ${mode} != "ad-hoc" ]]; then
135 mac=$( iwconfig_get_ap_mac_address "${iface}" ) 135 mac="$( iwconfig_get_ap_mac_address "${iface}" )"
136 [[ -n ${mac} ]] && mac=" at ${mac}" 136 [[ -n ${mac} ]] && mac=" at ${mac}"
137 fi 137 fi
138 138
139 eindent 139 eindent
140 einfo "${iface} connected ${m} \"${essid}\"${mac}" 140 einfo "${iface} connected ${m} \"${essid}\"${mac}"
156# void iwconfig_user_config(char *iface, char *ifvar) 156# void iwconfig_user_config(char *iface, char *ifvar)
157# 157#
158# Applies the user configuration to the interface 158# Applies the user configuration to the interface
159iwconfig_user_config() { 159iwconfig_user_config() {
160 local iface="$1" conf aconf ifvar="$2" 160 local iface="$1" conf aconf ifvar="$2"
161 [[ -z ${ifvar} ]] && ifvar=$( bash_variable "$1" ) 161 [[ -z ${ifvar} ]] && ifvar="$( bash_variable "$1" )"
162 162
163 # Apply the user configuration 163 # Apply the user configuration
164 conf="iwconfig_${ifvar}" 164 conf="iwconfig_${ifvar}"
165 if [[ -n ${!conf} ]]; then 165 if [[ -n ${!conf} ]]; then
166 aconf=( "${!conf}" ) 166 aconf=( "${!conf}" )
187# bool iwconfig_setup_specific(char *iface) 187# bool iwconfig_setup_specific(char *iface)
188# 188#
189# Sets up our wireless interface to operate in ad-hoc or master mode 189# Sets up our wireless interface to operate in ad-hoc or master mode
190iwconfig_setup_specific() { 190iwconfig_setup_specific() {
191 local iface="$1" mode="$2" channel key dessid 191 local iface="$1" mode="$2" channel key dessid
192 local ifvar=$( bash_variable "$1" ) 192 local ifvar="$( bash_variable "$1" )"
193 193
194 if [[ -z ${ESSID} ]]; then 194 if [[ -z ${ESSID} ]]; then
195 eerror "${iface} requires an ESSID to be set to operate in ${mode} mode" 195 eerror "${iface} requires an ESSID to be set to operate in ${mode} mode"
196 eerror "adjust the essid_${iface} setting in /etc/conf.d/wireless" 196 eerror "adjust the essid_${iface} setting in /etc/conf.d/wireless"
197 return 1 197 return 1
198 fi 198 fi
199 dessid="${ESSID//\\\\/\\\\}" 199 dessid="${ESSID//\\\\/\\\\}"
200 ESSIDVAR=$( bash_variable "${ESSID}" ) 200 ESSIDVAR="$( bash_variable "${ESSID}" )"
201 key=$( iwconfig_get_wep_key ) 201 key="$( iwconfig_get_wep_key )"
202 202
203 # We only change the mode if it's not the same 203 # We only change the mode if it's not the same
204 local cur_mode=$( iwconfig_get_mode "${iface}" ) 204 local cur_mode="$( iwconfig_get_mode "${iface}" )"
205 if [[ ${cur_mode} != "${mode}" ]]; then 205 if [[ ${cur_mode} != "${mode}" ]]; then
206 if ! iwconfig "${iface}" mode "${mode}" ; then 206 if ! iwconfig "${iface}" mode "${mode}" ; then
207 eerror "${iface} does not support setting the mode to \"${mode}\"" 207 eerror "${iface} does not support setting the mode to \"${mode}\""
208 return 1 208 return 1
209 fi 209 fi
216 ewarn "${iface} does not support setting the channel to \"${channel}\"" 216 ewarn "${iface} does not support setting the channel to \"${channel}\""
217 return 1 217 return 1
218 fi 218 fi
219 219
220 # Now set the key 220 # Now set the key
221 if ! eval iwconfig "${iface}" key "${key}" ; then 221 if ! iwconfig "${iface}" key ${key} ; then
222 if [[ ${key} != "off" ]]; then 222 if [[ ${key} != "off" ]]; then
223 ewarn "${iface} does not support setting keys" 223 ewarn "${iface} does not support setting keys"
224 ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect" 224 ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect"
225 fi 225 fi
226 fi 226 fi
228 # Then set the ESSID 228 # Then set the ESSID
229 if ! iwconfig "${iface}" essid "${ESSID}" ; then 229 if ! iwconfig "${iface}" essid "${ESSID}" ; then
230 eerror "${iface} does not support setting ESSID to \"${dessid}\"" 230 eerror "${iface} does not support setting ESSID to \"${dessid}\""
231 return 1 231 return 1
232 fi 232 fi
233 iwconfig "${iface}" nick "${ESSID}" 2>/dev/null
234 233
235 # Finally apply the user Config 234 # Finally apply the user Config
236 iwconfig_user_config "${iface}" "${ESSIDVAR}" 235 iwconfig_user_config "${iface}" "${ESSIDVAR}"
237 236
238 iwconfig_report "${iface}" 237 iwconfig_report "${iface}"
243# bool iwconfig_associate_mac(char *iface) 242# bool iwconfig_associate_mac(char *iface)
244# 243#
245# Returns true if the AP MAC address is valid or not 244# Returns true if the AP MAC address is valid or not
246iwconfig_associate_mac() { 245iwconfig_associate_mac() {
247 # Checks if a MAC address has been assigned 246 # Checks if a MAC address has been assigned
248 local mac="$( iwconfig_get_ap_mac_address $1 )" i 247 local mac="$( iwconfig_get_ap_mac_address "$1" )" i
249 local -a invalid_macs=( 248 local -a invalid_macs=(
250 "00:00:00:00:00:00" 249 "00:00:00:00:00:00"
251 "44:44:44:44:44:44" 250 "44:44:44:44:44:44"
252 "FF:00:00:00:00:00" 251 "FF:00:00:00:00:00"
253 "FF:FF:FF:FF:FF:FF" 252 "FF:FF:FF:FF:FF:FF"
262 261
263# bool iwconfig_associate_quality(char *iface) 262# bool iwconfig_associate_quality(char *iface)
264# 263#
265# Returns true if the link quality is not 0 or 0. 264# Returns true if the link quality is not 0 or 0.
266iwconfig_associate_quality() { 265iwconfig_associate_quality() {
267 local quality=$( \ 266 local quality="$( \
268 sed -n -e 's/^.*'"$1"': *[0-9]* *\([0-9]*\).*/\1/p' \ 267 sed -n -e 's/^.*'"$1"': *[0-9]* *\([0-9]*\).*/\1/p' \
269 /proc/net/wireless 268 /proc/net/wireless
270 ) 269 )"
271 [[ ${quality} != "0" ]] 270 [[ ${quality} != "0" ]]
272 return "$?" 271 return "$?"
273} 272}
274 273
275# bool iwconfig_test_associated(char *iface) 274# bool iwconfig_test_associated(char *iface)
276# 275#
277# Returns true if the interface has associated with an Access Point 276# Returns true if the interface has associated with an Access Point
278iwconfig_test_associated() { 277iwconfig_test_associated() {
279 local iface="$1" ttype ifvar=$( bash_variable "$1" ) x 278 local iface="$1" ttype ifvar="$( bash_variable "$1" )" x
280 # Some drivers don't set MAC to a bogus value when assocation is lost/fails 279 # Some drivers don't set MAC to a bogus value when assocation is lost/fails
281 # whereas they do set link quality to 0 280 # whereas they do set link quality to 0
282 281
283 x="associate_test_${ifvar}" 282 x="associate_test_${ifvar}"
284 ttype=$( echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]' ) 283 ttype="$( echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]' )"
285 if [[ ${ttype} != "mac" && ${ttype} != "quality" && ${ttype} != "all" ]]; then 284 if [[ ${ttype} != "mac" && ${ttype} != "quality" && ${ttype} != "all" ]]; then
286 ewarn " associate_test_${iface} is not set to mac, quality or all" 285 ewarn " associate_test_${iface} is not set to mac, quality or all"
287 ewarn " defaulting to \"mac\"" 286 ewarn " defaulting to \"mac\""
288 test="mac" 287 test="mac"
289 fi 288 fi
301# bool iwconfig_wait_for_association(char *iface) 300# bool iwconfig_wait_for_association(char *iface)
302# 301#
303# Waits for a configured ammount of time until 302# Waits for a configured ammount of time until
304# we are assocaited with an Access Point 303# we are assocaited with an Access Point
305iwconfig_wait_for_association() { 304iwconfig_wait_for_association() {
306 local iface="$1" i=0 timeout ifvar=$( bash_variable "$1" ) 305 local iface="$1" i=0 timeout ifvar="$( bash_variable "$1" )"
307 timeout="associate_timeout_${ifvar}" 306 timeout="associate_timeout_${ifvar}"
308 [[ -z ${!timeout} ]] && timeout="sleep_associate_${ifvar}" 307 [[ -z ${!timeout} ]] && timeout="sleep_associate_${ifvar}"
309 timeout="${!timeout:-10}" 308 timeout="${!timeout:-10}"
310 309
311 [[ ${timeout} == "0" ]] \ 310 [[ ${timeout} == "0" ]] \
336 if [[ ${ESSID} == "any" ]]; then 335 if [[ ${ESSID} == "any" ]]; then
337 iwconfig "${iface}" ap any 2>/dev/null 336 iwconfig "${iface}" ap any 2>/dev/null
338 dessid="any" 337 dessid="any"
339 unset ESSIDVAR 338 unset ESSIDVAR
340 else 339 else
341 ESSIDVAR=$( bash_variable "${ESSID}" ) 340 ESSIDVAR="$( bash_variable "${ESSID}" )"
342 key=$( iwconfig_get_wep_key "${mac}" ) 341 key="$( iwconfig_get_wep_key "${mac}" )"
343 if [[ ${wep_required} == "on" && ${key} == "off" ]]; then 342 if [[ ${wep_required} == "on" && ${key} == "off" ]]; then
344 eerror "WEP key is not set for \"${dessid}\" - not connecting" 343 eerror "WEP key is not set for \"${dessid}\" - not connecting"
345 return 1 344 return 1
346 fi 345 fi
347 if [[ ${wep_required} == "off" && ${key} != "off" ]]; then 346 if [[ ${wep_required} == "off" && ${key} != "off" ]]; then
348 key="off" 347 key="off"
349 ewarn "\"${dessid}\" is not WEP enabled - ignoring setting" 348 ewarn "\"${dessid}\" is not WEP enabled - ignoring setting"
350 fi 349 fi
351 350
352 if ! eval iwconfig "${iface}" key "${key}" ; then 351 if ! iwconfig "${iface}" key ${key} ; then
353 if [[ ${key} != "off" ]]; then 352 if [[ ${key} != "off" ]]; then
354 ewarn "${iface} does not support setting keys" 353 ewarn "${iface} does not support setting keys"
355 ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect" 354 ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect"
356 return 1 355 return 1
357 fi 356 fi
358 fi 357 fi
359 [[ ${key} != "off" ]] && w=$( iwconfig_get_wep_status "${iface}" ) 358 [[ ${key} != "off" ]] && w="$( iwconfig_get_wep_status "${iface}" )"
360 fi 359 fi
361 360
362 if ! iwconfig "${iface}" essid "${ESSID}" ; then 361 if ! iwconfig "${iface}" essid "${ESSID}" ; then
363 if [[ ${ESSID} != "any" ]]; then 362 if [[ ${ESSID} != "any" ]]; then
364 ewarn "${iface} does not support setting ESSID to \"${dessid}\"" 363 ewarn "${iface} does not support setting ESSID to \"${dessid}\""
365 fi 364 fi
366 fi 365 fi
367 iwconfig "${iface}" nick "${ESSID}" 2>/dev/null
368 366
369 # Finally apply the user Config 367 # Finally apply the user Config
370 iwconfig_user_config "${iface}" "${ESSIDVAR}" 368 iwconfig_user_config "${iface}" "${ESSIDVAR}"
371 369
372 vebegin "Connecting to \"${dessid}\" ${w}" 370 vebegin "Connecting to \"${dessid}\" ${w}"
388 return 1 386 return 1
389 fi 387 fi
390 veend 0 388 veend 0
391 389
392 if [[ ${ESSID} == "any" ]]; then 390 if [[ ${ESSID} == "any" ]]; then
393 ESSID=$( iwconfig_get_essid "${iface}" ) 391 ESSID="$( iwconfig_get_essid "${iface}" )"
394 iwconfig_associate "${iface}" 392 iwconfig_associate "${iface}"
395 return $? 393 return $?
396 fi 394 fi
397 395
398 iwconfig_report "${iface}" 396 iwconfig_report "${iface}"
409 407
410# bool iwconfig_scan(char *iface) 408# bool iwconfig_scan(char *iface)
411# 409#
412# Fills 3 arrays with information from a wireless scan 410# Fills 3 arrays with information from a wireless scan
413iwconfig_scan() { 411iwconfig_scan() {
414 local iface="$1" mode x ifvar=$( bash_variable "$1" ) 412 local iface="$1" mode x ifvar="$( bash_variable "$1" )"
415 413
416 # First, we may need to change mode to scan in 414 # First, we may need to change mode to scan in
417 x="scan_mode_${ifvar}" 415 x="scan_mode_${ifvar}"
418 mode=$( echo "${!x}" | tr '[:upper:]' '[:lower:]' ) 416 mode="$( echo "${!x}" | tr '[:upper:]' '[:lower:]' )"
419 if [[ -n ${mode} ]]; then 417 if [[ -n ${mode} ]]; then
420 if ! iwconfig "${iface}" mode "${mode}" ; then 418 if ! iwconfig "${iface}" mode "${mode}" ; then
421 ewarn "${iface} does not support setting the mode to \"${mode}\"" 419 ewarn "${iface} does not support setting the mode to \"${mode}\""
422 fi 420 fi
423 fi 421 fi
446 while read line; do 444 while read line; do
447 error=false 445 error=false
448 case "${line}" in 446 case "${line}" in
449 *Address:*) 447 *Address:*)
450 (( i++ )) 448 (( i++ ))
451 mac[i]=$( echo "${line#*: }" | tr '[:lower:]' '[:upper:]' ) 449 mac[i]="$( echo "${line#*: }" | tr '[:lower:]' '[:upper:]' )"
452 ;; 450 ;;
453 *ESSID:*) 451 *ESSID:*)
454 essid[i]="${line#*\"}" 452 essid[i]="${line#*\"}"
455 essid[i]="${essid[i]%*\"}" 453 essid[i]="${essid[i]%*\"}"
456 ;; 454 ;;
457 *Mode:*) 455 *Mode:*)
458 mode[i]=$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]' ) 456 mode[i]="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]' )"
459 [[ ${mode[i]} == "master" ]] && mode[i]="managed" 457 [[ ${mode[i]} == "master" ]] && mode[i]="managed"
460 ;; 458 ;;
461 *'Encryption key:'*) 459 *'Encryption key:'*)
462 enc[i]="${line#*:}" 460 enc[i]="${line#*:}"
463 ;; 461 ;;
500 fi 498 fi
501 fi 499 fi
502 500
503 # Change back mode if needed 501 # Change back mode if needed
504 x="mode_${ifvar}" 502 x="mode_${ifvar}"
505 x=$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' ) 503 x="$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' )"
506 [[ ${mode} != "${x}" ]] && iwconfig "${iface}" mode "${x}" 504 [[ ${mode} != "${x}" ]] && iwconfig "${iface}" mode "${x}"
507 505
508 for (( i=0; i<${#mac[@]}; i++ )); do 506 for (( i=0; i<${#mac[@]}; i++ )); do
509 # Don't like ad-hoc nodes by default 507 # Don't like ad-hoc nodes by default
510 [[ ${mode[i]} == "ad-hoc" ]] && (( qual[i]-=10000 )) 508 [[ ${mode[i]} == "ad-hoc" ]] && (( qual[i]-=10000 ))
679iwconfig_defaults() { 677iwconfig_defaults() {
680 local iface="$1" 678 local iface="$1"
681 679
682 # Set some defaults 680 # Set some defaults
683 iwconfig "${iface}" rate auto &>/dev/null 681 iwconfig "${iface}" rate auto &>/dev/null
684 iwconfig "${iface}" rts off &>/dev/null 682 iwconfig "${iface}" rts auto &>/dev/null
685 iwconfig "${iface}" frag off &>/dev/null 683 iwconfig "${iface}" frag auto &>/dev/null
686 iwconfig "${iface}" power off &>/dev/null
687 iwconfig "${iface}" txpower auto &>/dev/null 684 iwconfig "${iface}" txpower auto &>/dev/null
688 iwconfig "${iface}" key [1] off &>/dev/null 685 iwconfig "${iface}" key [1] off &>/dev/null
689 iwconfig "${iface}" mode managed &>/dev/null 686 iwconfig "${iface}" mode managed &>/dev/null
687 iwconfig "${iface}" essid -- off &>/dev/null
688 iwconfig "${iface}" ap off &>/dev/null
690} 689}
691 690
692# void iwconfig_strip_associated(char *iface) 691# void iwconfig_strip_associated(char *iface)
693# 692#
694# We check to see which ifaces have associated AP's except for the iface 693# We check to see which ifaces have associated AP's except for the iface
695# given and remove those AP's from the scan list 694# given and remove those AP's from the scan list
696# We also remove from the preferred list 695# We also remove from the preferred list
697iwconfig_strip_associated() { 696iwconfig_strip_associated() {
698 local iface="$1" e a j 697 local iface="$1" e a j
699 local essid=$( iwconfig_get_essid "${iface}" ) 698 local essid="$( iwconfig_get_essid "${iface}" )"
700 local -a ifaces=( $( iwconfig 2>/dev/null | grep -o "^\w*" ) ) 699 local -a ifaces=( $( iwconfig 2>/dev/null | grep -o "^\w*" ) )
701 700
702 for i in "${ifaces[@]}"; do 701 for i in "${ifaces[@]}"; do
703 [[ ${i} == ${iface} ]] && continue 702 [[ ${i} == ${iface} ]] && continue
704 interface_is_up "${i}" || continue 703 interface_is_up "${i}" || continue
705 iwconfig_test_associated "${i}" || continue 704 iwconfig_test_associated "${i}" || continue
706 e=$( iwconfig_get_essid "${i}" ) 705 e="$( iwconfig_get_essid "${i}" )"
707 u=() 706 local -a u=()
708 for ((j=0; j<${#mac_APs[@]}; j++)); do 707 for ((j=0; j<${#mac_APs[@]}; j++)); do
709 if [[ ${essid_APs[j]} == "${e}" ]]; then 708 if [[ ${essid_APs[j]} == "${e}" ]]; then
710 ewarn "${e} has already been associated with ${i}" 709 ewarn "${e} has already been associated with ${i}"
711 unset essid_APs[j] 710 unset essid_APs[j]
712 unset mode_Aps[j] 711 unset mode_Aps[j]
737# Then we test to see if ad-hoc mode has been requested and branch if needed 736# Then we test to see if ad-hoc mode has been requested and branch if needed
738# Then we scan for access points and try to connect to them in a predetermined order 737# Then we scan for access points and try to connect to them in a predetermined order
739# Once we're connected we show a report and then configure any interface 738# Once we're connected we show a report and then configure any interface
740# variables for the ESSID 739# variables for the ESSID
741iwconfig_configure() { 740iwconfig_configure() {
742 local iface="$1" test x e ifvar=$( bash_variable "$1" ) 741 local iface="$1" test x e ifvar="$( bash_variable "$1" )"
743 local -a essid_APs mac_APs mode_APs enc_APs 742 local -a essid_APs mac_APs mode_APs enc_APs
744 743
745 iwconfig_defaults "${iface}" 744 iwconfig_defaults "${iface}"
746 iwconfig_user_config "${iface}" 745 iwconfig_user_config "${iface}"
747 746
748 ESSID="essid_${ifvar}" 747 ESSID="essid_${ifvar}"
749 ESSID="${!ESSID}" 748 ESSID="${!ESSID}"
750 749
751 # Setup ad-hoc mode? 750 # Setup ad-hoc mode?
752 x="mode_${ifvar}" 751 x="mode_${ifvar}"
753 x=$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' ) 752 x="$( echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]' )"
754 if [[ ${x} == "ad-hoc" || ${x} == "master" ]]; then 753 if [[ ${x} == "ad-hoc" || ${x} == "master" ]]; then
755 iwconfig_setup_specific "${iface}" "${x}" 754 iwconfig_setup_specific "${iface}" "${x}"
756 return $? 755 return $?
757 fi 756 fi
758 757
761 return 1 760 return 1
762 fi 761 fi
763 762
764 # We only change the mode if it's not the same as some drivers 763 # We only change the mode if it's not the same as some drivers
765 # only do managed and throw an error changing to managed 764 # only do managed and throw an error changing to managed
766 local cur_mode=$( iwconfig_get_mode "${iface}" ) 765 local cur_mode="$( iwconfig_get_mode "${iface}" )"
767 if [[ ${cur_mode} != "${x}" ]]; then 766 if [[ ${cur_mode} != "${x}" ]]; then
768 if ! iwconfig "${iface}" mode "${x}" ; then 767 if ! iwconfig "${iface}" mode "${x}" ; then
769 eerror "${iface} does not support setting the mode to \"${x}\"" 768 eerror "${iface} does not support setting the mode to \"${x}\""
770 return 1 769 return 1
771 fi 770 fi
797 [[ -n ${!x} ]] && blacklist_aps=( "${!x}" ) 796 [[ -n ${!x} ]] && blacklist_aps=( "${!x}" )
798 797
799 # Are we forcing preferred only? 798 # Are we forcing preferred only?
800 x="associate_order_${ifvar}" 799 x="associate_order_${ifvar}"
801 [[ -n ${!x} ]] && associate_order="${!x}" 800 [[ -n ${!x} ]] && associate_order="${!x}"
802 associate_order=$( 801 associate_order="$(
803 echo "${associate_order:-any}" \ 802 echo "${associate_order:-any}" \
804 | tr '[:upper:]' '[:lower:]' 803 | tr '[:upper:]' '[:lower:]'
805 ) 804 )"
806 805
807 if [[ ${associate_order} == "forcepreferredonly" ]]; then 806 if [[ ${associate_order} == "forcepreferredonly" ]]; then
808 iwconfig_force_preferred "${iface}" && return 0 807 iwconfig_force_preferred "${iface}" && return 0
809 else 808 else
810 iwconfig_scan "${iface}" || return 1 809 iwconfig_scan "${iface}" || return 1
812 811
813 # Strip AP's from the list that have already been associated with 812 # Strip AP's from the list that have already been associated with
814 # other wireless cards in the system if requested 813 # other wireless cards in the system if requested
815 x="unique_ap_${ifvar}" 814 x="unique_ap_${ifvar}"
816 [[ -n ${!x} ]] && unique_ap="${!x}" 815 [[ -n ${!x} ]] && unique_ap="${!x}"
817 unique_ap=$( echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]' ) 816 unique_ap="$( echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]' )"
818 [[ ${unique_ap} != "no" ]] && iwconfig_strip_associated "${iface}" 817 [[ ${unique_ap} != "no" ]] && iwconfig_strip_associated "${iface}"
819 818
820 iwconfig_connect_preferred "${iface}" && return 0 819 iwconfig_connect_preferred "${iface}" && return 0
821 [[ ${associate_order} == "forcepreferred" \ 820 [[ ${associate_order} == "forcepreferred" \
822 || ${associate_order} == "forceany" ]] \ 821 || ${associate_order} == "forceany" ]] \
881 # Are we a proper IEEE device? 880 # Are we a proper IEEE device?
882 # Most devices reutrn IEEE 802.11b/g - but intel cards return IEEE in lower case 881 # Most devices reutrn IEEE 802.11b/g - but intel cards return IEEE in lower case
883 # and RA cards return RAPCI or similar which really sucks :( 882 # and RA cards return RAPCI or similar which really sucks :(
884 # For the time being, we will test prism54 not loading firmware which reports 883 # For the time being, we will test prism54 not loading firmware which reports
885 # NOT READY! 884 # NOT READY!
886 x=$( iwconfig_get_type "${iface}" ) 885 x="$( iwconfig_get_type "${iface}" )"
887 if [[ ${x} == "NOT READY!" ]]; then 886 if [[ ${x} == "NOT READY!" ]]; then
888 eerror "Looks like there was a probem loading the firmware for ${iface}" 887 eerror "Looks like there was a probem loading the firmware for ${iface}"
889 return 1 888 return 1
890 fi 889 fi
891 890

Legend:
Removed from v.235  
changed lines
  Added in v.236

  ViewVC Help
Powered by ViewVC 1.1.20