1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../wireless-tools/rocknet_wireless.sh
5 # Copyright (C) 2004 - 2005 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License. A copy of the
12 # GNU General Public License can be found in the file COPYING.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 iwdetect_mangle_cells
() {
16 local essid
=none mode
= encryption
= quality
=
19 mkdir
-p $rocknet_tmp_base/$if/
21 iwlist
$if scan |
while read line
; do
22 if [[ $line = *ESSID
* ]]; then
23 [ -n "$essid" ] && echo -e "$essid\t$mode\t$encryption\t$quality"
24 essid
="$( echo "$line" | sed -e 's,.*"\
(.
*\
)",\1,g' )"
28 elif [[ $line = Mode
:* ]]; then
30 elif [[ $line = Encryption
* ]]; then
32 elif [[ $line = *Quality
* ]]; then
33 quality
=$
( echo "$line" |
sed -e 's,:\([^ ]*\),:\1\n,g' |
sed -e 's,^.*:,,g' |
head -n 2 |
tr '\n' '\t' )
34 elif [ -z "$line" ]; then
35 [ "$essid" != "none" ] && echo -e "$essid\t$mode\t$encryption\t$quality"
37 done > $rocknet_tmp_base/$if/detected_cells
39 iwdetect_select_cell
() {
40 local networkfile
=${1:-/etc/conf/network-nettab}
41 local essid
= key
= extra
=
44 if [ -f $networkfile ]; then
45 while read -r essid key extra
; do
46 line
="$( grep -e "^
$essid" $rocknet_tmp_base/$if/detected_cells )"
47 if [ -n "$line" ]; then
48 echo "'$essid' selected..."
49 echo "$line" |
( read -r -d '\t' essid mode encryption quality signal
;
50 iwconfig
$if essid
"$essid"
52 Master
) iwconfig
$if mode Managed
;;
53 Ad-Hoc
) iwconfig
$if mode
"Ad-Hoc" ;;
54 *) echo "WARNING: Unknown mode '$mode'." ;;
61 echo "INFO: to use iwdetect you need to set a $networkfile."
66 addcode up
4 2 "ip link set $if up"
67 addcode up
4 3 "iwdetect_mangle_cells"
68 addcode up
4 4 "iwdetect_select_cell $1"
69 addcode down
4 5 "iwconfig $if essid any"
73 addcode up
4 5 "iwconfig $if essid $*"
74 addcode down
4 5 "iwconfig $if essid any"
78 addcode up
4 5 "iwconfig $if nwid $*"
79 addcode down
4 5 "iwconfig $if nwid off"
83 addcode up
4 5 "iwconfig $if domain $*"
84 addcode down
4 5 "iwconfig $if domain off"
88 addcode up
4 5 "iwconfig $if freq $*"
92 addcode up
4 5 "iwconfig $if channel $*"
96 addcode up
4 5 "iwconfig $if sens $*"
100 addcode up
4 4 "iwconfig $if mode $*"
101 addcode down
4 4 "iwconfig $if mode Auto"
105 addcode up
4 5 "iwconfig $if ap $*"
106 addcode down
4 5 "iwconfig $if ap any"
110 addcode up
4 5 "iwconfig $if nick $*"
114 addcode up
4 5 "iwconfig $if rate $*"
115 addcode down
4 5 "iwconfig $if rate auto"
119 addcode up
4 5 "iwconfig $if rts $*"
123 addcode up
4 5 "iwconfig $if frag $*"
127 addcode up
4 5 "iwconfig $if key $*"
128 addcode down
4 5 "iwconfig $if key off"
132 addcode up
4 5 "iwconfig $if enc $*"
133 addcode down
4 5 "iwconfig $if enc off"
137 addcode up
4 5 "iwconfig $if power $*"
141 addcode up
4 5 "iwconfig $if txpower $*"
142 addcode down
4 5 "iwconfig $if txpower auto"
146 addcode up
4 5 "iwconfig $if retry $*"
150 addcode up
4 9 "iwconfig $if commit"