1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/wireless-tools/rocknet_wireless.sh
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
12 iwdetect_mangle_cells
() {
13 local essid
=none mode
= encryption
= quality
=
16 mkdir
-p $rocknet_tmp_base/$if/
18 iwlist
$if scan |
while read line
; do
19 if [[ $line = *ESSID
* ]]; then
20 [ -n "$essid" ] && echo -e "$essid\t$mode\t$encryption\t$quality"
21 essid
="$( echo "$line" | sed -e 's,.*"\
(.
*\
)",\1,g' )"
25 elif [[ $line = Mode
:* ]]; then
27 elif [[ $line = Encryption
* ]]; then
29 elif [[ $line = *Quality
* ]]; then
30 quality
=$
( echo "$line" |
sed -e 's,:\([^ ]*\),:\1\n,g' |
sed -e 's,^.*:,,g' |
head -n 2 |
tr '\n' '\t' )
31 elif [ -z "$line" ]; then
32 [ "$essid" != "none" ] && echo -e "$essid\t$mode\t$encryption\t$quality"
34 done > $rocknet_tmp_base/$if/detected_cells
36 iwdetect_select_cell
() {
37 local networkfile
=${1:-/etc/conf/network-nettab}
38 local essid
= key
= extra
=
41 if [ -f $networkfile ]; then
42 while read -r essid key extra
; do
43 line
="$( grep -e "^
$essid" $rocknet_tmp_base/$if/detected_cells )"
44 if [ -n "$line" ]; then
45 echo "'$essid' selected..."
46 echo "$line" |
( read -r -d '\t' essid mode encryption quality signal
;
47 iwconfig
$if essid
"$essid"
49 Master
) iwconfig
$if mode Managed
;;
50 Ad-Hoc
) iwconfig
$if mode
"Ad-Hoc" ;;
51 *) echo "WARNING: Unknown mode '$mode'." ;;
58 echo "INFO: to use iwdetect you need to set a $networkfile."
63 addcode up
4 2 "ip link set $if up"
64 addcode up
4 3 "iwdetect_mangle_cells"
65 addcode up
4 4 "iwdetect_select_cell $1"
66 addcode down
4 5 "iwconfig $if essid any"
70 addcode up
4 5 "iwconfig $if essid $*"
71 addcode down
4 5 "iwconfig $if essid any"
75 addcode up
4 5 "iwconfig $if nwid $*"
76 addcode down
4 5 "iwconfig $if nwid off"
80 addcode up
4 5 "iwconfig $if domain $*"
81 addcode down
4 5 "iwconfig $if domain off"
85 addcode up
4 5 "iwconfig $if freq $*"
89 addcode up
4 5 "iwconfig $if channel $*"
93 addcode up
4 5 "iwconfig $if sens $*"
97 addcode up
4 4 "iwconfig $if mode $*"
98 addcode down
4 4 "iwconfig $if mode Auto"
102 addcode up
4 5 "iwconfig $if ap $*"
103 addcode down
4 5 "iwconfig $if ap any"
107 addcode up
4 5 "iwconfig $if nick $*"
111 addcode up
4 5 "iwconfig $if rate $*"
112 addcode down
4 5 "iwconfig $if rate auto"
116 addcode up
4 5 "iwconfig $if rts $*"
120 addcode up
4 5 "iwconfig $if frag $*"
124 addcode up
4 5 "iwconfig $if key $*"
125 addcode down
4 5 "iwconfig $if key off"
129 addcode up
4 5 "iwconfig $if enc $*"
130 addcode down
4 5 "iwconfig $if enc off"
134 addcode up
4 5 "iwconfig $if power $*"
138 addcode up
4 5 "iwconfig $if txpower $*"
139 addcode down
4 5 "iwconfig $if txpower auto"
143 addcode up
4 5 "iwconfig $if retry $*"
147 addcode up
4 9 "iwconfig $if commit"