|
Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
| 2 |
############################################################################# |
| 3 |
# Copyright 2000 The Aerospace Corporation. |
| 4 |
# All rights reserved. |
| 5 |
# |
| 6 |
# Redistribution and use in source and binary forms, with or without |
| 7 |
# modification, are permitted provided that the following conditions |
| 8 |
# are met: |
| 9 |
# 1. Redistributions of source code must retain the above copyright |
| 10 |
# notice, this list of conditions, and the following disclaimer. |
| 11 |
# 2. Redistributions in binary form must reproduce the above copyright |
| 12 |
# notice, this list of conditions, and the following disclaimer in the |
| 13 |
# documentation and/or other materials provided with the distribution. |
| 14 |
# 3. The name of The Aerospace Corporation may not be used to endorse or |
| 15 |
# promote products derived from this software. |
| 16 |
# |
| 17 |
# THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND |
| 18 |
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 20 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE |
| 21 |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 23 |
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 24 |
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 |
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 |
# SUCH DAMAGE. |
| 28 |
# |
| 29 |
# $FreeBSD$ |
| 30 |
# |
| 31 |
|
| 32 |
# |
| 33 |
# config_802.11 |
| 34 |
# |
| 35 |
# The interface to be configured is passed via the |
| 36 |
# preifconfig_interface environmental variable. Upon successful |
| 37 |
# configuration of an interface, the preifconfig_ifconfig variable is |
| 38 |
# set if the secessful configuration sets its |
| 39 |
# ieee802_11_<config>_ifconfig variable. |
| 40 |
# |
| 41 |
# The current version supports wi and an adaptors. |
| 42 |
# |
| 43 |
|
| 44 |
ieee802_11_set_config() { ( |
| 45 |
wicontrol="/usr/sbin/wicontrol -i ${preifconfig_interface}" |
| 46 |
ancontrol="/usr/sbin/ancontrol -i ${preifconfig_interface}" |
| 47 |
# ancontrol="echo ancontrol -i ${preifconfig_interface}" |
| 48 |
|
| 49 |
# Convert inputs to cannonical form. All general arguments are |
| 50 |
# cleaned here to reduce the code in the interface specific |
| 51 |
# portion of the code. |
| 52 |
# |
| 53 |
eval mode=\$ieee802_11_${config}_mode |
| 54 |
case ${mode} in |
| 55 |
[Aa][Dd]-[Hh][Oo][Cc]|[Aa][Dd][Hh][Oo][Cc]) |
| 56 |
mode="ad-hoc" |
| 57 |
;; |
| 58 |
[Ii][Nn][Ff][Rr][Aa]*|[Bb][Ss][Ss]) |
| 59 |
mode="infrastructure" |
| 60 |
;; |
| 61 |
*) |
| 62 |
mode="" |
| 63 |
;; |
| 64 |
esac |
| 65 |
|
| 66 |
eval ssid=\${ieee802_11_${config}_ssid-_unset_} |
| 67 |
if [ "${ssid}" != "_unset_" ]; then |
| 68 |
ssid1=${ssid} |
| 69 |
ssid2="_unset_" |
| 70 |
else |
| 71 |
ssids=1 |
| 72 |
while : ; do |
| 73 |
eval ssid=\${ieee802_11_${config}_ssid${ssids}-_unset_} |
| 74 |
if [ "${ssid}" != "_unset_" ]; then |
| 75 |
eval ssid${ssids}=${ssid} |
| 76 |
ssids=`expr ${ssids} + 1` |
| 77 |
else |
| 78 |
break |
| 79 |
fi |
| 80 |
done |
| 81 |
fi |
| 82 |
|
| 83 |
eval station_name=\${ieee802_11_${config}_station_name-_unset_} |
| 84 |
|
| 85 |
eval rate=\$ieee802_11_${config}_rate |
| 86 |
case ${rate} in |
| 87 |
1|2|5.5|11) |
| 88 |
;; |
| 89 |
5) |
| 90 |
rate="5.5" |
| 91 |
;; |
| 92 |
[Aa][Uu][Tt][Oo]) |
| 93 |
rate="auto" |
| 94 |
;; |
| 95 |
*) |
| 96 |
rate="" |
| 97 |
;; |
| 98 |
esac |
| 99 |
|
| 100 |
eval powermanagement=\$ieee802_11_${config}_powermanagement |
| 101 |
case ${powermanagement} in |
| 102 |
[Nn][Oo]) |
| 103 |
powermanagement="no" |
| 104 |
;; |
| 105 |
[Yy][Ee][Ss]) |
| 106 |
powermanagement="yes" |
| 107 |
;; |
| 108 |
[Cc][Aa][Mm]) |
| 109 |
powermanagement="cam" |
| 110 |
;; |
| 111 |
[Pp][Ss][Pp]) |
| 112 |
powermanagement="psp" |
| 113 |
;; |
| 114 |
[Cc][Aa][Mm]-[Pp][Ss][Pp]) |
| 115 |
powermanagement="cam-psp" |
| 116 |
;; |
| 117 |
*) |
| 118 |
powermanagement="" |
| 119 |
;; |
| 120 |
esac |
| 121 |
|
| 122 |
eval channel=\$ieee802_11_${config}_channel |
| 123 |
case ${channel} in |
| 124 |
1|2|3|4|5|6|7|8|9|10|11|12|13|14) |
| 125 |
;; |
| 126 |
*) |
| 127 |
channel="" |
| 128 |
;; |
| 129 |
esac |
| 130 |
|
| 131 |
eval wep=\$ieee802_11_${config}_wep |
| 132 |
case ${wep} in |
| 133 |
[Nn][Oo]) |
| 134 |
wep="no" |
| 135 |
;; |
| 136 |
[Yy][Ee][Ss]) |
| 137 |
wep="yes" |
| 138 |
;; |
| 139 |
*) |
| 140 |
wep="" |
| 141 |
;; |
| 142 |
esac |
| 143 |
|
| 144 |
eval wep_mixed_ok=\$ieee802_11_${config}_wep_mixed_ok |
| 145 |
case ${wep_mixed_ok} in |
| 146 |
[Nn][Oo]) |
| 147 |
wep_mixed_ok="no" |
| 148 |
;; |
| 149 |
[Yy][Ee][Ss]) |
| 150 |
wep_mixed_ok="yes" |
| 151 |
;; |
| 152 |
*) |
| 153 |
wep_mixed_ok="" |
| 154 |
;; |
| 155 |
esac |
| 156 |
|
| 157 |
eval wep_tx_key=\$ieee802_11_${config}_wep_tx_key |
| 158 |
case ${wep_tx_key} in |
| 159 |
1|2|3|4) |
| 160 |
;; |
| 161 |
*) |
| 162 |
wep_tx_key="" |
| 163 |
;; |
| 164 |
esac |
| 165 |
|
| 166 |
eval wep_key1=\${ieee802_11_${config}_wep_key1-_unset_} |
| 167 |
eval wep_key2=\${ieee802_11_${config}_wep_key2-_unset_} |
| 168 |
eval wep_key3=\${ieee802_11_${config}_wep_key3-_unset_} |
| 169 |
eval wep_key4=\${ieee802_11_${config}_wep_key4-_unset_} |
| 170 |
|
| 171 |
eval mac=\${ieee802_11_${config}_mac-_unset_} |
| 172 |
|
| 173 |
eval rts_threshold=\$ieee802_11_${config}_rts_threshold |
| 174 |
case ${rts_threshold} in |
| 175 |
[0-9]|[1-9][0-9]|[1-9][0-9][0-9]|[12][0-9][0-9][0-9]) |
| 176 |
if [ ${rts_threshold} -gt 2347 ]; then |
| 177 |
rts_threshold="max" |
| 178 |
fi |
| 179 |
;; |
| 180 |
[Mm][Aa][Xx]*) |
| 181 |
rts_threshold="max" |
| 182 |
;; |
| 183 |
*) |
| 184 |
rts_threshold="" |
| 185 |
;; |
| 186 |
esac |
| 187 |
|
| 188 |
# Each interface type needs to be handled differently due to |
| 189 |
# differences in the control programs and custom options. |
| 190 |
# |
| 191 |
case ${preifconfig_interface} in |
| 192 |
wi[0-9]*) |
| 193 |
# handle general options |
| 194 |
# |
| 195 |
if [ -n "${mode}" ]; then |
| 196 |
case ${mode} in |
| 197 |
ad-hoc) |
| 198 |
${wicontrol} -p 3 |
| 199 |
;; |
| 200 |
infrastructure) |
| 201 |
${wicontrol} -p 1 |
| 202 |
;; |
| 203 |
esac |
| 204 |
fi |
| 205 |
|
| 206 |
if [ "${ssid1}" != "_unset_" ]; then |
| 207 |
${wicontrol} -n "${ssid1}" |
| 208 |
fi |
| 209 |
|
| 210 |
if [ "${station_name}" != "_unset_" ]; then |
| 211 |
${wicontrol} -s "${station_name}" |
| 212 |
fi |
| 213 |
|
| 214 |
# I think these values are probably correct for modern |
| 215 |
# cards. However, my tests indicate that the value you |
| 216 |
# select has little to do with the speed at which you |
| 217 |
# operate. |
| 218 |
# |
| 219 |
if [ -n "${rate}" ]; then |
| 220 |
case ${rate} in |
| 221 |
1) |
| 222 |
${wicontrol} -t 1 |
| 223 |
;; |
| 224 |
2) |
| 225 |
${wicontrol} -t 2 |
| 226 |
;; |
| 227 |
5.5) |
| 228 |
${wicontrol} -t 4 |
| 229 |
;; |
| 230 |
11) |
| 231 |
${wicontrol} -t 5 |
| 232 |
;; |
| 233 |
auto) |
| 234 |
${wicontrol} -t 3 |
| 235 |
;; |
| 236 |
esac |
| 237 |
fi |
| 238 |
|
| 239 |
if [ -n "${powermanagement}" ]; then |
| 240 |
case ${powermanagement} in |
| 241 |
no) |
| 242 |
${wicontrol} -P 0 |
| 243 |
;; |
| 244 |
*) |
| 245 |
${wicontrol} -P 1 |
| 246 |
;; |
| 247 |
esac |
| 248 |
fi |
| 249 |
|
| 250 |
if [ -n "${channel}" ]; then |
| 251 |
${wicontrol} -f ${channel} |
| 252 |
fi |
| 253 |
|
| 254 |
if [ -n "${wep}" ]; then |
| 255 |
case ${wep} in |
| 256 |
no) |
| 257 |
${wicontrol} -e 0 |
| 258 |
;; |
| 259 |
yes) |
| 260 |
${wicontrol} -e 1 |
| 261 |
;; |
| 262 |
esac |
| 263 |
fi |
| 264 |
|
| 265 |
# wep_mixed_ok isn't an option for wi devices |
| 266 |
|
| 267 |
if [ -n "${wep_tx_key}" ]; then |
| 268 |
${wicontrol} -T ${wep_tx_key} |
| 269 |
fi |
| 270 |
|
| 271 |
if [ "${wep_key1}" != "_unset_" ]; then |
| 272 |
${wicontrol} -k "${wep_key1}" -v 1 |
| 273 |
fi |
| 274 |
if [ "${wep_key2}" != "_unset_" ]; then |
| 275 |
${wicontrol} -k "${wep_key2}" -v 2 |
| 276 |
fi |
| 277 |
if [ "${wep_key3}" != "_unset_" ]; then |
| 278 |
${wicontrol} -k "${wep_key3}" -v 3 |
| 279 |
fi |
| 280 |
if [ "${wep_key4}" != "_unset_" ]; then |
| 281 |
${wicontrol} -k "${wep_key4}" -v 4 |
| 282 |
fi |
| 283 |
|
| 284 |
if [ -n "${rts_threshold}" ]; then |
| 285 |
case ${rts_threshold} in |
| 286 |
max) |
| 287 |
${wicontrol} -r 2347 |
| 288 |
;; |
| 289 |
*) |
| 290 |
${wicontrol} -r ${rts_threshold} |
| 291 |
;; |
| 292 |
esac |
| 293 |
fi |
| 294 |
|
| 295 |
# Handle wi specific options |
| 296 |
# |
| 297 |
eval wi_create_IBSS=\$ieee802_11_${config}_wi_create_IBSS |
| 298 |
case ${wi_create_IBSS} in |
| 299 |
[Nn][Oo]) |
| 300 |
${wicontrol} -c 0 |
| 301 |
;; |
| 302 |
[Yy][Ee][Ss]) |
| 303 |
${wicontrol} -c 1 |
| 304 |
;; |
| 305 |
*) |
| 306 |
;; |
| 307 |
esac |
| 308 |
|
| 309 |
eval wi_ssid=\${ieee802_11_${config}_wi_ssid-_unset_} |
| 310 |
if [ "${wi_ssid}" != "_unset_" ]; then |
| 311 |
${wicontrol} -q "${wi_ssid}" |
| 312 |
fi |
| 313 |
|
| 314 |
eval wi_ap_density=\$ieee802_11_${config}_wi_ap_density |
| 315 |
case ${wi_ap_density} in |
| 316 |
[Ll][Oo][Ww]|1) |
| 317 |
${wicontrol} -a 1 |
| 318 |
;; |
| 319 |
[Mm][Ee][Dd][Ii][Uu][Mm]|2) |
| 320 |
${wicontrol} -a 2 |
| 321 |
;; |
| 322 |
[Hh][Ii][Gg][Hh]|3) |
| 323 |
${wicontrol} -a 3 |
| 324 |
;; |
| 325 |
*) |
| 326 |
;; |
| 327 |
esac |
| 328 |
|
| 329 |
eval wi_max_data_len=\$ieee802_11_${config}_wi_max_data_len |
| 330 |
if [ -n "${wi_max_data_length}" ]; then |
| 331 |
${wicontrol} -d ${wi_max_data_length} |
| 332 |
fi |
| 333 |
|
| 334 |
eval wi_sleep_interval=\$ieee802_11_${config}_wi_sleep_interval |
| 335 |
if [ -n "${wi_sleep_interval}" ]; then |
| 336 |
${wicontrol} -S ${wi_sleep_interval} |
| 337 |
fi |
| 338 |
|
| 339 |
;; |
| 340 |
an[0-9]*) |
| 341 |
# handle general options |
| 342 |
# |
| 343 |
if [ -n "${mode}" ]; then |
| 344 |
case ${mode} in |
| 345 |
ad-hoc) |
| 346 |
${ancontrol} -o 0 |
| 347 |
;; |
| 348 |
infrastructure) |
| 349 |
${ancontrol} -o 1 |
| 350 |
;; |
| 351 |
esac |
| 352 |
fi |
| 353 |
|
| 354 |
if [ "${ssid1}" != "_unset_" ]; then |
| 355 |
${ancontrol} -v 1 -n "${ssid1}" |
| 356 |
if [ "${ssid2}" != "_unset_" ]; then |
| 357 |
${ancontrol} -v 2 -n "${ssid2}" |
| 358 |
if [ "${ssid3}" != "_unset_" ]; then |
| 359 |
${ancontrol} -v 3 -n "${ssid3}" |
| 360 |
fi |
| 361 |
fi |
| 362 |
fi |
| 363 |
|
| 364 |
if [ "${station_name}" != "_unset_" ]; then |
| 365 |
${ancontrol} -l "${station_name}" |
| 366 |
fi |
| 367 |
|
| 368 |
if [ -n "${rate}" ]; then |
| 369 |
case ${rate} in |
| 370 |
1) |
| 371 |
${ancontrol} -t 1 |
| 372 |
;; |
| 373 |
2) |
| 374 |
${ancontrol} -t 2 |
| 375 |
;; |
| 376 |
5.5) |
| 377 |
${ancontrol} -t 3 |
| 378 |
;; |
| 379 |
11) |
| 380 |
${ancontrol} -t 4 |
| 381 |
;; |
| 382 |
auto) |
| 383 |
${ancontrol} -t 0 |
| 384 |
;; |
| 385 |
esac |
| 386 |
fi |
| 387 |
|
| 388 |
if [ -n "${powermanagement}" ]; then |
| 389 |
case ${powermanagement} in |
| 390 |
no) |
| 391 |
${ancontrol} -s 0 |
| 392 |
;; |
| 393 |
# XXX: I think CAM is the right choice for YES, |
| 394 |
# but I'm not actually sure. Maybe what I need |
| 395 |
# is the 802.11b spec. |
| 396 |
yes) |
| 397 |
${ancontrol} -s 1 |
| 398 |
;; |
| 399 |
cam) |
| 400 |
${ancontrol} -s 1 |
| 401 |
;; |
| 402 |
psp) |
| 403 |
${ancontrol} -s 2 |
| 404 |
;; |
| 405 |
cam-psp) |
| 406 |
${ancontrol} -s 3 |
| 407 |
;; |
| 408 |
esac |
| 409 |
fi |
| 410 |
|
| 411 |
if [ -n "${channel}" ]; then |
| 412 |
${ancontrol} -c ${channel} |
| 413 |
fi |
| 414 |
|
| 415 |
# Hmm, not sure how this works |
| 416 |
if [ -n "${wep_mixed_ok}" ]; then |
| 417 |
case ${wep_mixed_ok} in |
| 418 |
no) |
| 419 |
# Turn off |
| 420 |
;; |
| 421 |
yes) |
| 422 |
# Turn on |
| 423 |
;; |
| 424 |
esac |
| 425 |
fi |
| 426 |
|
| 427 |
if [ "${wep_key1}" != "_unset_" ]; then |
| 428 |
${ancontrol} -v 1 -k "${wep_key1}" |
| 429 |
fi |
| 430 |
if [ "${wep_key2}" != "_unset_" ]; then |
| 431 |
${ancontrol} -v 3 -k "${wep_key2}" |
| 432 |
fi |
| 433 |
if [ "${wep_key3}" != "_unset_" ]; then |
| 434 |
${ancontrol} -v 5 -k "${wep_key3}" |
| 435 |
fi |
| 436 |
if [ "${wep_key4}" != "_unset_" ]; then |
| 437 |
${ancontrol} -v 7 -k "${wep_key4}" |
| 438 |
fi |
| 439 |
|
| 440 |
# XXX Hack around missing feature in ancontrol |
| 441 |
if [ -n "${wep_tx_key}" ]; then |
| 442 |
case ${wep_tx_key} in |
| 443 |
1) |
| 444 |
${ancontrol} -v 1 -k "${wep_key1}" |
| 445 |
;; |
| 446 |
2) |
| 447 |
${ancontrol} -v 3 -k "${wep_key2}" |
| 448 |
;; |
| 449 |
3) |
| 450 |
${ancontrol} -v 5 -k "${wep_key3}" |
| 451 |
;; |
| 452 |
4) |
| 453 |
${ancontrol} -v 7 -k "${wep_key4}" |
| 454 |
;; |
| 455 |
esac |
| 456 |
fi |
| 457 |
|
| 458 |
# Needs to be after key setting for some reason |
| 459 |
if [ -n "${wep}" ]; then |
| 460 |
case ${wep} in |
| 461 |
no) |
| 462 |
${ancontrol} -W 0 |
| 463 |
;; |
| 464 |
yes) |
| 465 |
${ancontrol} -W 1 |
| 466 |
;; |
| 467 |
esac |
| 468 |
fi |
| 469 |
|
| 470 |
if [ -n "${rts_threshold}" ]; then |
| 471 |
case ${rts_threshold} in |
| 472 |
max) |
| 473 |
${ancontrol} -r 2312 |
| 474 |
;; |
| 475 |
*) |
| 476 |
${ancontrol} -r ${rts_threshold} |
| 477 |
;; |
| 478 |
esac |
| 479 |
fi |
| 480 |
|
| 481 |
|
| 482 |
# Handle an specific options |
| 483 |
# |
| 484 |
eval an_ap1=\${ieee802_11_${config}_an_ap1-_unset_} |
| 485 |
eval an_ap2=\${ieee802_11_${config}_an_ap2-_unset_} |
| 486 |
eval an_ap3=\${ieee802_11_${config}_an_ap3-_unset_} |
| 487 |
eval an_ap4=\${ieee802_11_${config}_an_ap4-_unset_} |
| 488 |
if [ "${an_ap1}" != "_unset_" ]; then |
| 489 |
${ancontrol} -v 1 -a "${an_ap1}" |
| 490 |
fi |
| 491 |
if [ "${an_ap2}" != "_unset_" ]; then |
| 492 |
${ancontrol} -v 2 -a "${an_ap2}" |
| 493 |
fi |
| 494 |
if [ "${an_ap3}" != "_unset_" ]; then |
| 495 |
${ancontrol} -v 3 -a "${an_ap3}" |
| 496 |
fi |
| 497 |
if [ "${an_ap4}" != "_unset_" ]; then |
| 498 |
${ancontrol} -v 4 -a "${an_ap4}" |
| 499 |
fi |
| 500 |
|
| 501 |
eval an_beacon_period=\$ieee802_11_${config}_an_beacon_period |
| 502 |
if [ -n "${an_beacon_period}" ]; then |
| 503 |
${ancontrol} -b ${an_beacon_period} |
| 504 |
fi |
| 505 |
|
| 506 |
eval an_tx_diversity=\$ieee802_11_${config}_an_diversity |
| 507 |
eval an_rx_diversity=\$ieee802_11_${config}_an_diversity |
| 508 |
case "${an_tx_diversity}" in |
| 509 |
'') |
| 510 |
;; |
| 511 |
[Ff][Aa][Cc][Tt][Oo][Rr][Yy]|0) |
| 512 |
${ancontrol} -v 1 -d 0 |
| 513 |
;; |
| 514 |
[Aa][Nn][Tt][Ee][Nn][Nn][Aa]1|1) |
| 515 |
${ancontrol} -v 1 -d 1 |
| 516 |
;; |
| 517 |
[Aa][Nn][Tt][Ee][Nn][Nn][Aa]2|2) |
| 518 |
${ancontrol} -v 1 -d 2 |
| 519 |
;; |
| 520 |
[Bb][Oo][Tt][Hh]|3) |
| 521 |
${ancontrol} -v 1 -d 3 |
| 522 |
;; |
| 523 |
esac |
| 524 |
case "${an_rx_diversity}" in |
| 525 |
'') |
| 526 |
;; |
| 527 |
[Ff][Aa][Cc][Tt][Oo][Rr][Yy]|0) |
| 528 |
${ancontrol} -v 0 -d 0 |
| 529 |
;; |
| 530 |
[Aa][Nn][Tt][Ee][Nn][Nn][Aa]1|1) |
| 531 |
${ancontrol} -v 0 -d 1 |
| 532 |
;; |
| 533 |
[Aa][Nn][Tt][Ee][Nn][Nn][Aa]2|2) |
| 534 |
${ancontrol} -v 0 -d 2 |
| 535 |
;; |
| 536 |
[Bb][Oo][Tt][Hh]|3) |
| 537 |
${ancontrol} -v 0 -d 3 |
| 538 |
;; |
| 539 |
esac |
| 540 |
|
| 541 |
eval an_net_join_timeout=\$ieee802_11_${config}_an_net_join_timeout |
| 542 |
if [ -n "${an_net_join_timeout}" ]; then |
| 543 |
${ancontrol} -j ${an_net_join_timeout} |
| 544 |
fi |
| 545 |
|
| 546 |
eval an_tx_power=\$ieee802_11_${config}_an_tx_power |
| 547 |
if [ -n "${an_tx_power}" ]; then |
| 548 |
${ancontrol} -p ${an_net_tx_power} |
| 549 |
fi |
| 550 |
|
| 551 |
eval an_frag_threshold=\$ieee802_11_${config}_an_frag_threshold |
| 552 |
if [ -n "${an_frag_threshold}" ]; then |
| 553 |
${ancontrol} -f ${an_frag_threshold} |
| 554 |
fi |
| 555 |
|
| 556 |
;; |
| 557 |
*) |
| 558 |
;; |
| 559 |
esac |
| 560 |
) } |
| 561 |
|
| 562 |
ieee802_11_check_status() { |
| 563 |
eval ieee802_11_mode=\$ieee802_11_${config}_mode |
| 564 |
case ${ieee802_11_mode} in |
| 565 |
[Aa][Dd]-[Hh][Oo][Cc]|[Aa][Dd][Hh][Oo][Cc]) |
| 566 |
ieee802_11_mode="ad-hoc" |
| 567 |
;; |
| 568 |
[Ii][Nn][Ff][Rr][Aa]*|[Bb][Ss][Ss]) |
| 569 |
ieee802_11_mode="infrastructure" |
| 570 |
;; |
| 571 |
*) |
| 572 |
ieee802_11_mode="" |
| 573 |
;; |
| 574 |
esac |
| 575 |
|
| 576 |
case ${preifconfig_interface} in |
| 577 |
wi[0-9]*) |
| 578 |
if [ `wicontrol -i ${preifconfig_interface} | sed -e '/^Comms.*/!d' -e 's/.*\[ \([0-9]*\) .*/\1/` -gt 0 ]; then |
| 579 |
ieee802_11_is_synced="yes" |
| 580 |
else |
| 581 |
ieee802_11_is_synced="no" |
| 582 |
fi |
| 583 |
;; |
| 584 |
an[0-9]*) |
| 585 |
case ${ieee802_11_mode} in |
| 586 |
ad-hoc) |
| 587 |
if [ -n "`ancontrol -i ${preifconfig_interface} -S | sed -e '/^Operating.*/!d' -e '/.*synced.*/!d'`" ]; then |
| 588 |
ieee802_11_is_synced="yes" |
| 589 |
else |
| 590 |
ieee802_11_is_synced="no" |
| 591 |
fi |
| 592 |
;; |
| 593 |
infrastructure) |
| 594 |
if [ -n "`ancontrol -i ${preifconfig_interface} -S | sed -e '/^Current AP name.*/!d' -e 's/.*\[ *\([a-zA-Z0-9-]*\) *\].*/\1/'`" ]; then |
| 595 |
ieee802_11_is_synced="yes" |
| 596 |
else |
| 597 |
ieee802_11_is_synced="no" |
| 598 |
fi |
| 599 |
;; |
| 600 |
esac |
| 601 |
;; |
| 602 |
*) |
| 603 |
ieee802_11_is_synced="no" |
| 604 |
esac |
| 605 |
} |
| 606 |
|
| 607 |
# Select the specific config(s) for this interface or else take the default |
| 608 |
# |
| 609 |
eval ieee802_11_config=\$ieee802_11_config_${preifconfig_interface} |
| 610 |
if [ -z "${ieee802_11_config}" ]; then |
| 611 |
ieee802_11_config=${ieee802_11_config_default} |
| 612 |
fi |
| 613 |
|
| 614 |
# If the config is auto then try all the configs |
| 615 |
# |
| 616 |
case ${ieee802_11_config} in |
| 617 |
[Aa][Uu][Tt][Oo]) |
| 618 |
ieee802_11_config=${ieee802_11_configs} |
| 619 |
;; |
| 620 |
esac |
| 621 |
|
| 622 |
sleep 1 |
| 623 |
|
| 624 |
# Try each config in turn until we get one that works or we give up and |
| 625 |
# use the last one. |
| 626 |
# |
| 627 |
for config in ${ieee802_11_config}; do |
| 628 |
echo -n "Trying IEEE 802.11 config '$config' on ${preifconfig_interface}..." |
| 629 |
ieee802_11_set_config |
| 630 |
ifconfig ${preifconfig_interface} up |
| 631 |
if [ ${ieee802_11_association_timeout} -gt 0 ]; then |
| 632 |
echo -n "sleeping ${ieee802_11_association_timeout}sec..." |
| 633 |
sleep ${ieee802_11_association_timeout} |
| 634 |
fi |
| 635 |
ieee802_11_check_status |
| 636 |
ifconfig ${preifconfig_interface} down |
| 637 |
if [ "$ieee802_11_is_synced" = "yes" ]; then |
| 638 |
echo succeded |
| 639 |
eval preifconfig_ifconfig=\${ieee802_11_${config}_ifconfig} |
| 640 |
break |
| 641 |
else |
| 642 |
echo failed |
| 643 |
fi |
| 644 |
done |