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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2754 - (show annotations) (download) (as text)
Mon Jul 9 09:14:19 2007 UTC (6 years, 9 months ago) by uberlord
File MIME type: text/x-sh
File size: 17841 byte(s)
Fix iproute handling of -host and improve iwconfig scanning
1 # Copyright 2004-2007 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # Many thanks to all the people in the Gentoo forums for their ideas and
4 # motivation for me to make this and keep on improving it
5
6 _config_vars="$_config_vars ssid mode associate_timeout sleep_scan preferred_aps blacklist_aps"
7
8 iwconfig_depend() {
9 program /sbin/iwconfig
10 after plug
11 before interface
12 provide wireless
13 }
14
15 iwconfig_get_wep_status() {
16 local mode= status="disabled"
17
18 # No easy way of doing this grep in bash regex :/
19 if LC_ALL=C iwconfig "${IFACE}" | grep -qE "^ +Encryption key:[*0-9,A-F]" ; then
20 status="enabled"
21 mode=$(LC_ALL=C iwconfig "${IFACE}" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p')
22 [ -n "${mode}" ] && mode=" - ${mode}"
23 fi
24
25 echo "(WEP ${status}${mode})"
26 }
27
28 _get_ssid() {
29 local i=5 ssid=
30
31 while [ ${i} -gt 0 ] ; do
32 ssid=$(iwgetid --raw "${IFACE}")
33 if [ -n "${ssid}" ] ; then
34 echo "${ssid}"
35 return 0
36 fi
37 sleep 1
38 i=$((${i} + 1))
39 done
40
41 return 1
42 }
43
44 _get_ap_mac_address() {
45 local mac="$(iwgetid --raw --ap "${IFACE}")"
46 case "${mac}" in
47 "00:00:00:00:00:00") return 1 ;;
48 "44:44:44:44:44:44") return 1 ;;
49 "FF:00:00:00:00:00") return 1 ;;
50 "FF:FF:FF:FF:FF:FF") return 1 ;;
51 *) echo "${mac}" ;;
52 esac
53 }
54
55 iwconfig_get_mode() {
56 LC_ALL=C iwgetid --mode "${IFACE}" | \
57 sed -n -e 's/^.*Mode:\(.*\)/\1/p' | \
58 tr '[:upper:]' '[:lower:]'
59 }
60
61 iwconfig_set_mode() {
62 local mode="$1"
63 [ "${mode}" = "$(iwconfig_get_mode)" ] && return 0
64
65 # Devicescape stack requires the interface to be down
66 _down
67 iwconfig "${IFACE}" mode "${mode}" || return 1
68 _up
69 }
70
71 iwconfig_get_type() {
72 LC_ALL=C iwconfig "${IFACE}" | sed -n -e 's/^'"$1"' *\([^ ]* [^ ]*\).*/\1/p'
73 }
74
75 iwconfig_report() {
76 local mac= m="connected to"
77 local ssid="$(_get_ssid)"
78 local wep_status="$(iwconfig_get_wep_status)"
79 local channel="$(iwgetid --raw --channel "${iface}")"
80 [ -n "${channel}" ] && channel="on channel ${channel} "
81 local mode="$(iwconfig_get_mode)"
82 if [ "${mode}" = "master" ]; then
83 m="configured as"
84 else
85 mac="$(_get_ap_mac_address)"
86 [ -n "${mac}" ] && mac=" at ${mac}"
87 fi
88
89 eindent
90 einfo "${IFACE} ${m} SSID \"${SSID}\"${mac}"
91 einfo "in ${mode} mode ${channel}${wep_status}"
92 eoutdent
93 }
94
95 iwconfig_get_wep_key() {
96 local mac="$1" key=
97 [ -n "${mac}" ] && mac="$(echo "${mac}" | sed -e 's/://g')"
98 eval key=\$mac_key_${mac}
99 [ -z "${key}" ] && eval key=\$key_${SSIDVAR}
100 if [ -z "${key}" ] ; then
101 echo "off"
102 else
103 set -- ${key}
104 local x= e=false
105 for x in "$@" ; do
106 if [ "${x}" = "enc" ] ; then
107 e=true
108 break
109 fi
110 done
111 ${e} || key="${key} enc open"
112 echo "${key}"
113 fi
114 }
115
116 iwconfig_user_config() {
117 local conf= var=${SSIDVAR}
118 [ -z "${var}" ] && var=${IFVAR}
119
120 eval "$(_get_array "iwconfig_${var}")"
121 for conf in "$@" ; do
122 if ! eval iwconfig "${IFACE}" "${conf}" ; then
123 ewarn "${IFACE} does not support the following configuration commands"
124 ewarn " ${conf}"
125 fi
126 done
127
128 eval "$(_get_array "iwpriv_${var}")"
129 for conf in "$@" ; do
130 if ! eval iwpriv "${IFACE}" "${conf}" ; then
131 ewarn "${IFACE} does not support the following private ioctls"
132 ewarn " ${conf}"
133 fi
134 done
135 }
136
137 iwconfig_setup_specific() {
138 local mode="$1" channel=
139 if [ -z "${SSID}" ]; then
140 eerror "${IFACE} requires an SSID to be set to operate in ${mode} mode"
141 eerror "adjust the ssid_${IFVAR} setting in /etc/conf.d/net"
142 return 1
143 fi
144 SSIDVAR=$(_shell_var "${SSID}")
145 local key=$(iwconfig_get_wep_key)
146
147 iwconfig_set_mode "${mode}"
148
149 # Now set the key
150 if ! eval iwconfig "${IFACE}" key "${key}" ; then
151 if [ "${key}" != "off" ]; then
152 ewarn "${IFACE} does not support setting keys"
153 ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
154 fi
155 fi
156
157 # Then set the SSID
158 if ! iwconfig "${IFACE}" essid "${SSID}" ; then
159 eerror "${IFACE} does not support setting SSID to \"${SSID}\""
160 return 1
161 fi
162
163 eval channel=\$channel_${SSIDVAR}
164 [ -z "${channel}" ] && eval channel=\$channel_${IFVAR}
165 # We default the channel to 3
166 if ! iwconfig "${IFACE}" channel "${channel:-3}" ; then
167 ewarn "${IFACE} does not support setting the channel to \"${channel:-3}\""
168 return 1
169 fi
170
171 # Finally apply the user Config
172 iwconfig_user_config
173
174 iwconfig_report
175 return 0
176 }
177
178 iwconfig_wait_for_association() {
179 local timeout= i=0
180 eval timeout=\$associate_timeout_${IFVAR}
181 timeout=${timeout:-10}
182
183 [ ${timeout} -eq 0 ] \
184 && vewarn "WARNING: infinite timeout set for association on ${IFACE}"
185
186 while true; do
187 # Use sysfs if we can
188 if [ -e /sys/class/net/"${IFACE}"/carrier ] ; then
189 if [ "$(cat /sys/class/net/"${IFACE}"/carrier)" = "1" ] ; then
190 # Double check we have an ssid. This is mainly for buggy
191 # prism54 drivers that always set their carrier on :/
192 [ -n "$(iwgetid --raw "${IFACE}")" ] && return 0
193 fi
194 else
195 local atest=
196 eval atest=\$associate_test_${IFVAR}
197 atest=${atest:-mac}
198 if [ "${atest}" = "mac" -o "${atest}" = "all" ] ; then
199 [ -n "$(_get_ap_mac_address)" ] && return 0
200 fi
201 if [ "${atest}" = "quality" -o "${atest}" = "all" ] ; then
202 [ "$(sed -n -e 's/^.*'"${IFACE}"': *[0-9]* *\([0-9]*\).*/\1/p' \
203 /proc/net/wireless)" != "0" ] && return 0
204 fi
205 fi
206
207 sleep 1
208 [ ${timeout} -eq 0 ] && continue
209 i=$((${i} + 1))
210 [ ${i} -ge ${timeout} ] && return 1
211 done
212 return 1
213 }
214
215 iwconfig_associate() {
216 local mode="${1:-managed}" mac="$2" wep_required="$3" freq="$4" chan="$5"
217 local w="(WEP Disabled)" key=
218
219 iwconfig_set_mode "${mode}"
220
221 if [ "${SSID}" = "any" ]; then
222 iwconfig "${IFACE}" ap any 2>/dev/null
223 unset SSIDVAR
224 else
225 SSIDVAR=$(_shell_var "${SSID}")
226 key="$(iwconfig_get_wep_key "${mac}")"
227 if [ "${wep_required}" = "on" -a "${key}" = "off" ] ; then
228 ewarn "WEP key is not set for \"${SSID}\" - not connecting"
229 return 1
230 fi
231 if [ "${wep_required}" = "off" -a "${key}" != "off" ] ; then
232 key="off"
233 ewarn "\"${SSID}\" is not WEP enabled - ignoring setting"
234 fi
235
236 if ! eval iwconfig "${IFACE}" key "${key}" ; then
237 if [ "${key}" != "off" ] ; then
238 ewarn "${IFACE} does not support setting keys"
239 ewarn "or the parameter \"mac_key_${SSIDVAR}\" or \"key_${SSIDVAR}\" is incorrect"
240 return 1
241 fi
242 fi
243 [ "${key}" != "off" ] && w="$(iwconfig_get_wep_status "${iface}")"
244 fi
245
246 if ! iwconfig "${IFACE}" essid "${SSID}" ; then
247 if [ "${SSID}" != "any" ] ; then
248 ewarn "${IFACE} does not support setting SSID to \"${SSID}\""
249 fi
250 fi
251
252 # Only use channel or frequency
253 if [ -n "${chan}" ] ; then
254 iwconfig "${IFACE}" channel "${chan}"
255 elif [ -n "${freq}" ] ; then
256 iwconfig "${IFACE}" freq "${freq}"
257 fi
258 [ -n "${mac}" ] && iwconfig "${IFACE}" ap "${mac}"
259
260 # Finally apply the user Config
261 iwconfig_user_config
262
263 ebegin "Connecting to \"${SSID}\" in ${mode} mode ${w}"
264
265 if [ "${SSID}" != "any" ] && type preassociate >/dev/null 2>/dev/null ; then
266 veinfo "Running preassociate function"
267 veindent
268 ( preassociate )
269 local e=$?
270 veoutdent
271 if [ ${e} -eq 0 ] ; then
272 veend 1 "preassociate \"${SSID}\" on ${IFACE} failed"
273 return 1
274 fi
275 fi
276
277 if ! iwconfig_wait_for_association ; then
278 eend 1
279 return 1
280 fi
281 eend 0
282
283 if [ "${SSID}" = "any" ]; then
284 SSID="$(_get_ssid)"
285 iwconfig_associate
286 return $?
287 fi
288
289 iwconfig_report
290
291 if type postassociate >/dev/null 2>/dev/null ; then
292 veinfo "Running postassociate function"
293 veindent
294 ( postassociate )
295 veoutdent
296 fi
297
298 return 0
299 }
300
301 iwconfig_scan() {
302 local x= i=0 scan=
303 einfo "Scanning for access points"
304 eindent
305
306 # Sleep if required
307 eval x=\$sleep_scan_${IFVAR}
308 [ -n "${x}" ] && sleep "${x}"
309
310 while [ ${i} -lt 3 ] ; do
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
324 i=$((${i} + 1))
325 done
326
327 if [ -z "${scan}" ] ; then
328 ewarn "${iface} does not support scanning"
329 eoutdent
330 eval x=\$adhoc_ssid_${IFVAR}
331 [ -n "${x}" ] && return 0
332 if [ -n "${preferred_aps}" ] ; then
333 [ "${associate_order}" = "forcepreferred" ] || \
334 [ "${associate_order}" = "forcepreferredonly" ] && return 0
335 fi
336 eerror "You either need to set a preferred_aps list in /etc/conf.d/wireless"
337 eerror " preferred_aps=\"SSID1 SSID2\""
338 eerror " and set associate_order_${IFVAR}=\"forcepreferred\""
339 eerror " or set associate_order_${IFVAR}=\"forcepreferredonly\""
340 eerror "or hardcode the SSID to \"any\" and let the driver find an Access Point"
341 eerror " ssid_${IFVAR}=\"any\""
342 eerror "or configure defaulting to Ad-Hoc when Managed fails"
343 eerror " adhoc_ssid_${IFVAR}=\"WLAN\""
344 eerror "or hardcode the SSID against the interface (not recommended)"
345 eerror " ssid_${IFVAR}=\"SSID\""
346 return 1
347 fi
348
349 local OIFS=$IFS
350 APS=-1
351 eval set -- ${scan}
352 for line in "$@" ; do
353 case "${line}" in
354 *Address:*)
355 APS=$((${APS} + 1))
356 eval MAC_${APS}=\""$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]')"\"
357 eval QUALITY_${APS}=0
358 ;;
359 *ESSID:*)
360 x=${line#*\"}
361 x=${x%*\"}
362 eval SSID_${APS}=\$x
363 ;;
364 *Mode:*)
365 x="$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]')"
366 if [ "${x}" = "master" ] ; then
367 eval MODE_${APS}=\"managed\"
368 else
369 eval MODE_${APS}=\$x
370 fi
371 ;;
372 *'Encryption key:'*)
373 x=${line#*:}
374 eval ENC_${APS}=\$x
375 ;;
376 #*Frequency:*)
377 # freq[i]="${line#*:}"
378 # x="${freq[i]#* }"
379 # freq[i]="${freq[i]%% *}${x:0:1}"
380 # ;;
381 *Channel:*)
382 x=${line#*:}
383 x=${x%% *}
384 eval CHAN_${APS}=\$x
385 ;;
386 *Quality*)
387 x=${line#*:}
388 x=${x%/*}
389 x="$(echo "${x}" | sed -e 's/[^[:digit:]]//g')"
390 x=${x:-0}
391 eval QUALITY_${APS}=\$x
392 ;;
393 esac
394 done
395
396 if [ -z "${MAC_0}" ]; then
397 ewarn "no access points found"
398 eoutdent
399 return 1
400 fi
401
402 # Sort based on quality
403 local i=0 k=1 a= b= x= t=
404 while [ ${i} -lt ${APS} ] ; do
405 k=$((${i} + 1))
406 while [ ${k} -le ${APS} ] ; do
407 eval a=\$QUALITY_${i}
408 [ -z "${a}" ] && break
409 eval b=\$QUALITY_${k}
410 if [ -n "${b}" -a "${a}" -lt "${b}" ] ; then
411 for x in MAC SSID CHAN QUALITY ENC ; do
412 eval t=\$${x}_${i}
413 eval ${x}_${i}=\$${x}_${k}
414 eval ${x}_${k}=\$t
415 done
416 fi
417 k=$((${k} + 1))
418 done
419 i=$((${i} + 1))
420 done
421
422 # Strip any duplicates
423 local i=0 k=1 a= b=
424 while [ ${i} -lt ${APS} ] ; do
425 k=$((${i} + 1))
426 while [ ${k} -le ${APS} ] ; do
427 eval a=\$MAC_${i}
428 eval b=\$MAC_${k}
429 if [ "${a}" = "${b}" ] ; then
430 eval a=\$QUALITY_${i}
431 eval b=\$QUALITY_${k}
432 local u=${k}
433 [ -n "${a}" -a -n "${b}" -a "${a}" -lt "${b}" ] && u=${i}
434 unset MAC_${u} SSID_${u} CHAN_${u} QUALITY_${u} ENC_${u}
435 fi
436 k=$((${k} + 1))
437 done
438 i=$((${i} + 1))
439 done
440
441 local i=0 e= m= black= s=
442 eval "$(_get_array "blacklist_aps")"
443 black="$@"
444
445 while [ ${i} -le ${APS} ] ; do
446 eval x=\$MAC_${i}
447 if [ -z "${x}" ] ; then
448 i=$((${i} + 1))
449 continue
450 fi
451
452 eval m=\$MODE_${i}
453 eval s=\$SSID_${i}
454 eval q=\$QUALITY_${i}
455 eval e=\$ENC_${i}
456 if [ -n "${e}" -a "${e}" != "off" ] ; then
457 e=", encrypted"
458 else
459 e=""
460 fi
461 if [ -z "${s}" ] ; then
462 einfo "Found ${x}, ${m}${e}"
463 else
464 einfo "Found \"${s}\" at ${x}, ${m}${e}"
465 fi
466
467 x="$(echo "${x}" | sed -e 's/://g')"
468 eval x=\$mac_ssid_${x}
469 if [ -n "${x}" ] ; then
470 eval SSID_${i}=\$x
471 s=${x}
472 eindent
473 einfo "mapping to \"${x}\""
474 eoutdent
475 fi
476
477 eval "$(_get_array "blacklist_aps")"
478 for x in "$@" ; do
479 if [ "${x}" = "${s}" ] ; then
480 ewarn "${s} has been blacklisted - not connecting"
481 unset SSID_${i} MAC_${i} CHAN_${i} QUALITY_${i} ENC_${i}
482 fi
483 done
484 i=$((${i} + 1))
485 done
486 eoutdent
487 }
488
489 iwconfig_force_preferred() {
490 [ -z "${preferred_aps}" ] && return 1
491
492 ewarn "Trying to force preferred in case they are hidden"
493 eval "(_get_array "preferred_aps")"
494 local ssid=
495 for ssid in "$@"; do
496 local found_AP=false i=0 e=
497 while [ ${i} -le ${APS} ] ; do
498 eval e=\$SSID_${i}
499 if [ "${e}" = "${ssid}" ] ; then
500 found_AP=true
501 break
502 fi
503 i=$((${i} + 1))
504 done
505 if ! ${found_AP} ; then
506 SSID=${e}
507 iwconfig_associate && return 0
508 fi
509 done
510
511 ewarn "Failed to associate with any preferred access points on ${IFACE}"
512 return 1
513 }
514
515 iwconfig_connect_preferred() {
516 local ssid= i= mode= mac= enc= freq= chan=
517
518 eval "$(_get_array preferred_aps)"
519 for ssid in "$@"; do
520 i=0
521 while [ ${i} -le ${APS} ] ; do
522 eval e=\$SSID_${i}
523 if [ "${e}" = "${ssid}" ] ; then
524 SSID=${e}
525 eval mode=\$MODE_${i}
526 eval mac=\$MAC_${i}
527 eval enc=\$ENC_${i}
528 eval freq=\$FREQ_${i}
529 eval chan=\$CHAN_${i}
530 iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \
531 "${chan}" && return 0
532 fi
533 i=$((${i} + 1))
534 done
535 done
536
537 return 1
538 }
539
540 iwconfig_connect_not_preferred() {
541 local ssid= i=0 mode= mac= enc= freq= chan= pref=false
542
543 while [ ${i} -le ${APS} ] ; do
544 eval e=\$SSID_${i}
545 if [ -n "${e}" ] ; then
546 eval "$(_get_array preferred_aps)"
547 for ssid in "$@" ; do
548 if [ "${e}" = "${ssid}" ] ; then
549 pref=true
550 break
551 fi
552 done
553
554 if ! ${pref} ; then
555 SSID=${e}
556 eval mode=\$MODE_${i}
557 eval mac=\$MAC_${i}
558 eval enc=\$ENC_${i}
559 eval freq=\$FREQ_${i}
560 eval chan=\$CHAN_${i}
561 iwconfig_associate "${mode}" "${mac}" "${enc}" "${freq}" \
562 "${chan}" && return 0
563 fi
564 fi
565 i=$((${i} + 1))
566 done
567
568 return 1
569 }
570
571 iwconfig_defaults() {
572 local x=
573 for x in txpower rate rts frag ; do
574 iwconfig "${IFACE}" "${x}" auto 2>/dev/null
575 done
576
577 # Release the AP forced
578 # Must do ap and then ssid otherwise scanning borks
579 iwconfig "${IFACE}" ap off 2>/dev/null
580 iwconfig "${IFACE}" essid off 2>/dev/null
581 }
582
583 iwconfig_configure() {
584 local x APS
585 eval SSID=\$ssid_${IFVAR}
586
587 # Support old variable
588 [ -z "${SSID}" ] && eval SSID=\$essid_${IFVAR}
589
590 # Setup ad-hoc mode?
591 eval x=\$mode_${IFVAR}
592 x=${x:-managed}
593 if [ "${x}" = "ad-hoc" -o "${x}" = "master" ] ; then
594 iwconfig_setup_specific "${x}"
595 return $?
596 fi
597
598 if [ "${x}" != "managed" -a "${x}" != "auto" ] ; then
599 eerror "Only managed, ad-hoc, master and auto modes are supported"
600 return 1
601 fi
602
603 # Has an SSID been forced?
604 if [ -n "${SSID}" ]; then
605 iwconfig_set_mode "${x}"
606 iwconfig_associate && return 0
607 [ "${SSID}" = "any" ] && iwconfig_force_preferred && return 0
608
609 eval SSID=\$adhoc_ssid_${IFVAR}
610 if [ -n "${SSID}" ]; then
611 iwconfig_setup_specific ad-hoc
612 return $?
613 fi
614 return 1
615 fi
616
617 # Do we have a preferred Access Point list specific to the interface?
618 # x="preferred_aps_${ifvar}[@]"
619 # [[ -n ${!x} ]] && preferred_aps=( "${!x}" )
620
621 # # Do we have a blacklist Access Point list specific to the interface?
622 # x="blacklist_aps_${ifvar}[@]"
623 # [[ -n ${!x} ]] && blacklist_aps=( "${!x}" )
624
625 # Are we forcing preferred only?
626 eval x=\$associate_order_${IFVAR}
627 [ -n "${x}" ] && associate_order=${x}
628 associate_order=${associate_order:-any}
629 if [ "${associate_order}" = "forcepreferredonly" ]; then
630 iwconfig_force_preferred && return 0
631 else
632 iwconfig_scan || return 1
633 iwconfig_connect_preferred && return 0
634 [ "${associate_order}" = "forcepreferred" ] || \
635 [ "${associate_order}" = "forceany" ] && \
636 iwconfig_force_preferred && return 0
637 [ "${associate_order}" = "any" ] || \
638 [ "${associate_order}" = "forceany" ] && \
639 iwconfig_connect_not_preferred && return 0
640 fi
641
642 e="associate with"
643 [ -z "${MAC_0}" ] && e="find"
644 [ "${preferred_aps}" = "force" ] || \
645 [ "${preferred_aps}" = "forceonly" ] && \
646 e="force"
647 e="Couldn't ${e} any access points on ${IFACE}"
648
649 eval SSID=\$adhoc_ssid_${IFVAR}
650 if [ -n "${SSID}" ]; then
651 ewarn "${e}"
652 iwconfig_setup_specific ad-hoc
653 return $?
654 fi
655
656 eerror "${e}"
657 return 1
658 }
659
660 iwconfig_pre_start() {
661 # We don't configure wireless if we're being called from
662 # the background
663 ${IN_BACKGROUND} && return 0
664
665 save_options "SSID" ""
666 _exists || return 0
667
668 if ! _is_wireless ; then
669 veinfo "Wireless extensions not found for ${IFACE}"
670 return 0
671 fi
672
673 # Warn about old file - we want to punt it really
674 if [ -e /etc/conf.d/wireless ] ; then
675 ewarn "/etc/conf.d/wireless is deprecated"
676 ewarn "Please put all settings into /etc/conf.d/net"
677 . /etc/conf.d/wireless
678 fi
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
685 iwconfig_defaults
686 iwconfig_user_config
687
688 # Set the base metric to be 2000
689 metric=2000
690
691 # Check for rf_kill - only ipw supports this at present, but other
692 # cards may in the future.
693 if [ -e /sys/class/net/"${IFACE}"/device/rf_kill ] ; then
694 if [ $(cat /sys/class/net/"${IFACE}"/device/rf_kill) != "0" ] ; then
695 eerror "Wireless radio has been killed for interface ${IFACE}"
696 return 1
697 fi
698 fi
699
700 einfo "Configuring wireless network for ${IFACE}"
701
702 # Are we a proper IEEE device?
703 # Most devices reutrn IEEE 802.11b/g - but intel cards return IEEE
704 # in lower case and RA cards return RAPCI or similar
705 # which really sucks :(
706 # For the time being, we will test prism54 not loading firmware
707 # which reports NOT READY!
708 x="$(iwconfig_get_type)"
709 if [ "${x}" = "NOT READY!" ]; then
710 eerror "Looks like there was a probem loading the firmware for ${IFACE}"
711 return 1
712 fi
713
714 if iwconfig_configure ; then
715 save_options "SSID" "${SSID}"
716 return 0
717 fi
718
719 eerror "Failed to configure wireless for ${IFACE}"
720 iwconfig_defaults
721 iwconfig "${IFACE}" txpower off 2>/dev/null
722 unset SSID SSIDVAR
723 _down
724 return 1
725 }
726
727 iwconfig_post_stop() {
728 ${IN_BACKGROUND} && return 0
729 _exists || return 0
730 iwconfig_defaults
731 iwconfig "${IFACE}" txpower off 2>/dev/null
732 }
733
734 # vim: set ts=4

  ViewVC Help
Powered by ViewVC 1.1.20