jablonka.czprosek.czf

wifimon

Subversion Repositories:
[/] [trunk/] [wifimon] - Blame information for rev 32

 

Line No. Rev Author Line
12simandl#!/bin/bash
23simandl# authors : Petr Simandl www.simandl.cz
322simandl# : Fyzik, Covex, Tydyt, Thunder.m
430simandl# release date : 12/04/2006
52simandl# name : wifimon
621simandl# description : hostap and madwifi powered card monitoring
72simandl# license : GPL
821simandl######################################################################
92simandl 
1032simandlwl_version="0.5.7pre7"
1111simandl 
1221simandl######################################################################
13#custom settings
14 
1529simandlPATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
1613simandl 
1730simandlwl_wlancf=`which wlanconfig 2>/dev/null `
18wl_iwccmd=`which iwconfig 2>/dev/null`
19wl_iwlcmd=`which iwlist 2>/dev/null`
20wl_ifccmd=`which ifconfig 2>/dev/null`
21wl_hnmcmd=`which hostname 2>/dev/null`
22wl_awkcmd=`which awk 2>/dev/null`
2314simandl 
24wl_tptcmde=""
25wl_clrcmde=""
26 
2719simandlwl_sysdev="/proc/sys/dev/"
2814simandlwl_hostap="/proc/net/hostap/"
2927simandlwl_madwifi="/proc/net/madwifi/"
3014simandlwl_wireless="/proc/net/wireless"
31wl_arp="/proc/net/arp"
32wl_dhcpcnf="/etc/dhcpd.conf"
3330simandlwl_dhcplss="/var/lib/dhcpd/dhcpd.leases"
3417simandl# wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
35# wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
3614simandl 
3721simandlwl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
38wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
39wl_footer="</pre></body></html>"
4014simandl 
4121simandlwlm_no_managed_or_master=" neni ani Master ani Managed..."
42wlm_number_of_clients="Pocet asociovanych klientu : "
43wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
44#wlm_no_managed_or_master=" is not Master or Managed..."
45#wlm_number_of_clients="Number of associated clients : "
46 
47wlch_signal="="
48wlch_noise="*"
49 
50######################################################################
51#testing basic setings
52 
5312simandlif [ "$wl_iwccmd x" = " x" ]
54 then
55 echo "iwconfig not found"
56 exit 1
57fi
582simandl 
5921simandlif [ "$wl_iwlcmd x" = " x" ]
60 then
61 echo "iwlist not found"
62 exit 1
63fi
64 
6514simandlif [ "$wl_ifccmd x" = " x" ]
66 then
67 echo "ifconfig not found"
68 exit 1
69fi
704simandl 
7114simandlif [ "$wl_hnmcmd x" = " x" ]
72 then
73 echo "hostname not found"
74 exit 1
75fi
76 
77if [ "$wl_awkcmd x" = " x" ]
78 then
79 echo "awk not found"
80 exit 1
81fi
82 
83if [ -e $wl_wireless ]
84 then
85 wl_nop=1
86 else
87 echo "$wl_wireless not found"
88 exit 1
89fi
90 
91if [ -e $wl_arp ]
92 then
93 wl_nop=1
94 else
95 echo "$wl_arp not found"
96 exit 1
97fi
98 
9922simandl#dhcp support
100#if not found trying to set alternative location
101if [ ! -f $wl_dhcpcnf ]; then
102 wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
103fi
104 
105if [ ! -f $wl_dhcplss ]; then
106 wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
107fi
108 
109#if not found a message is printed and /dev/null is used instead
11014simandlif [ -e $wl_dhcpcnf ]
111 then
112 wl_nop=1
113 else
114 echo "$wl_dhcpcnf not found"
115 wl_dhcpcnf="/dev/null"
116fi
117 
11830simandlif [ ! -e $wl_dhcplss ]
11914simandl then
120 echo "$wl_dhcplss not found"
121 wl_dhcplss="/dev/null"
122fi
12321simandl######################################################################
12414simandl 
12524simandlif [ -d ${wl_hostap}wlan0 ]
12621simandl then
127 wlf_hostap=1
128 else
129# echo "${wl_hostap}wlan0 not found"
130 wlf_hostap=0
131fi
1327simandl 
13327simandlif [ -d ${wl_sysdev}ath ]
13421simandl then
135 wlf_madwifi=1
136 else
137# echo "${wl_sysdev}ath0 not found"
138 wlf_madwifi=0
139fi
1407simandl 
14129simandlwlf_wlancf=1
142if [ "$wl_wlancf x" = " x" ]
143 then
144 wlf_wlancf=0
145# echo "wlanconfig not found"
146# exit 1
147fi
148 
14921simandlif [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ]
150 then
15124simandl echo "${wl_hostap}wlan0 not found"
152 echo "${wl_sysdev}ath0 not found"
15321simandl exit 1
154fi
15511simandl 
15629simandl 
1572simandl######################################################################
15821simandl# procedures
159######################################################################
16011simandlw_col()
16110simandl{
16215simandlwlc_red=`tput setaf 1` # ruda (Red)
163wlc_green=`tput setaf 2` # zelena (Lime)
164wlc_brown=`tput setaf 3` # zluta (Yellow)
165wlc_blue=`tput setaf 4` # modra (Blue)
166wlc_magenta=`tput setaf 5` # fialova (Fuchsia)
167wlc_lblue=`tput setaf 6` # svetle modra (Aqua)
168wlc_grey=`tput setaf 7` # bila (White)
16911simandlwlc_std=`tput sgr0`
170 
17115simandlwlc_pkts=$wlc_red # Rx,Tx info color
17211simandlwlc_ip=$wlc_lblue # ip address color
173wlc_mac=$wlc_magenta # mac address color
17415simandlwlc_name=$wlc_magenta # host name color
17511simandlwlc_sig=$wlc_red # signal number color
176wlc_bar=$wlc_green # signal bar color
17715simandlwlc_noise=$wlc_red # Signal noise color
17810simandl}
179######################################################################
18015simandlw_colh()
181{
182 wlh_pkts="Olive" # signal number color html
183 wlh_ip="Blue" # ip address color html
184 wlh_mac="Fuchsia" # mac address color html
185 wlh_name="Fuchsia" # Host name color html
186 wlh_sig="Red" # signal number color html
187 wlh_bar="Lime" # signal bar color html
188 wlh_noise="Red" # Signal noise color html
189 
190 wlc_pkts="<font color=\"$wlh_pkts\">"
191 wlc_ip="<font color=\"$wlh_ip\">"
192 wlc_mac="<font color=\"$wlh_mac\">"
193 wlc_name="<font color=\"$wlh_name\">"
194 wlc_sig="<font color=\"$wlh_sig\">"
195 wlc_bar="<font color=\"$wlh_bar\">"
196 wlc_noise="<font color=\"$wlh_noise\">"
197 wlc_std="</font>"
198}
199######################################################################
2004simandlw_bw()
201{
20215simandl wlc_pkts=""
2036simandl wlc_ip=""
204 wlc_mac=""
205 wlc_sig=""
206 wlc_bar=""
20715simandl wlc_noise=""
2086simandl wlc_std=""
2094simandl}
210######################################################################
2112simandlw_bar()
212{
21311simandl wl_neg=`expr $wl_cnt \< 0 `
214 if [ "$wl_neg" -eq 1 ]
215 then
21615simandl echo -n "${wlc_noise}"
21711simandl wl_cnt=$(($wl_cnt * -1 ))
218 wl_bar=$wlch_noise
219 else
22015simandl echo -n "${wlc_bar}"
22111simandl wl_bar=$wlch_signal
222 fi
2232simandl until [ "$wl_cnt" -eq -1 ]
224 do
22511simandl echo -n "$wl_bar"
2262simandl wl_cnt=$(($wl_cnt - 1 ))
227 done
228 printf " \n"
2296simandl echo -n "${wlc_std}"
23011simandl# tput sgr0
2312simandl} # w_bar
232 
233######################################################################
23413simandlw_pkts()
235{
236 wl_macpkts=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'rx\[|tx\[' | sed 's/=/ /g'`
23714simandl wl_nt1=`echo $wl_macpkts | $wl_awkcmd '{print $2}'`
238 wl_nt2=`echo $wl_macpkts | $wl_awkcmd '{print $4}'`
239 wl_nt5=`echo $wl_macpkts | $wl_awkcmd '{print $6}'`
240 wl_nt11=`echo $wl_macpkts | $wl_awkcmd '{print $8}'`
241 wl_nr1=`echo $wl_macpkts | $wl_awkcmd '{print $10}'`
242 wl_nr2=`echo $wl_macpkts | $wl_awkcmd '{print $12}'`
243 wl_nr5=`echo $wl_macpkts | $wl_awkcmd '{print $14}'`
244 wl_nr11=`echo $wl_macpkts | $wl_awkcmd '{print $16}'`
24513simandl 
246 if [ $wcm_ppkts -eq 1 ]
247 then
248 wl_pksize=$((98))
249 wl_nt=$(($wl_nt1 + $wl_nt2 + wl_nt5 + wl_nt11))
250 if [ "$wl_nt1" -eq 0 ]
251 then
252 wl_nt1n="00"
253 else
254 wl_nt1n=$(($wl_pksize * $wl_nt1 / $wl_nt + 1))
255 [ "$wl_nt1n" -lt 10 ] && wl_nt1n="0"$wl_nt1n
256 fi
257 if [ "$wl_nt2" -eq 0 ]
258 then
259 wl_nt2n="00"
260 else
261 wl_nt2n=$(($wl_pksize * $wl_nt2 / $wl_nt + 1))
262 [ "$wl_nt2n" -lt 10 ] && wl_nt2n="0"$wl_nt2n
263 fi
264 if [ "$wl_nt5" -eq 0 ]
265 then
266 wl_nt5n="00"
267 else
268 wl_nt5n=$(($wl_pksize * $wl_nt5 / $wl_nt + 1))
269 [ "$wl_nt5n" -lt 10 ] && wl_nt5n="0"$wl_nt5n
270 fi
271 if [ "$wl_nt11" -eq 0 ]
272 then
273 wl_nt11n="00"
274 else
275 wl_nt11n=$(($wl_pksize * $wl_nt11 / $wl_nt + 1))
276 [ "$wl_nt11n" -lt 10 ] && wl_nt11n="0"$wl_nt11n
277 fi
278 wl_nr=$((1 + $wl_nr1 + $wl_nr2 + wl_nr5 + wl_nr11))
279 if [ "$wl_nr1" -eq 0 ]
280 then
281 wl_nr1n="00"
282 else
283 wl_nr1n=$(($wl_pksize * $wl_nr1 / $wl_nr + 1))
284 [ "$wl_nr1n" -lt 10 ] && wl_nr1n="0"$wl_nr1n
285 fi
286 if [ "$wl_nr2" -eq 0 ]
287 then
288 wl_nr2n="00"
289 else
290 wl_nr2n=$(($wl_pksize * $wl_nr2 / $wl_nr + 1))
291 [ "$wl_nr2n" -lt 10 ] && wl_nr2n="0"$wl_nr2n
292 fi
293 if [ "$wl_nr5" -eq 0 ]
294 then
295 wl_nr5n="00"
296 else
297 wl_nr5n=$(($wl_pksize * $wl_nr5 / $wl_nr + 1))
298 [ "$wl_nr5n" -lt 10 ] && wl_nr5n="0"$wl_nr5n
299 fi
300 if [ "$wl_nr11" -eq 0 ]
301 then
302 wl_nr11n="00"
303 else
304 wl_nr11n=$(($wl_pksize * $wl_nr11 / $wl_nr + 1))
305 [ "$wl_nr11n" -lt 10 ] && wl_nr11n="0"$wl_nr11n
306 fi
30715simandl echo -n "Tx"${wlc_pkts} $wl_nt1n $wl_nt2n $wl_nt5n $wl_nt11n ${wlc_std}""
308 echo -n "Rx"${wlc_pkts} $wl_nr1n $wl_nr2n $wl_nr5n $wl_nr11n ${wlc_std}""
30913simandl fi
310 
311 [ $wcm_pkts -eq 1 ] && echo -n "Tx" $wl_nt1 $wl_nt2 $wl_nt5 $wl_nt11 "Rx" $wl_nr1 $wl_nr2 $wl_nr5 $wl_nr11 ""
312 
313} # w_pkts
314######################################################################
31517simandlw_managed()
316{ echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
31724simandl echo -n `$wl_ifccmd $wl_iface | grep -E "inet addr|inet adr" | $wl_awkcmd '{print $2}' | sed s/ad*r://g`" " # IP adresa mastera z ifconfig
31815simandl 
31918simandl if [ $wcm_macoff -eq 0 ]
32015simandl then
32125simandl wl_mac=`echo -n $wl_iwctxt | $wl_awkcmd '{print $8}'`
32218simandl echo -n "${wlc_mac}$wl_mac${wlc_std} "
32315simandl fi
32426simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}'
32515simandl 
32624simandl wl_wtxt=`cat $wl_wireless | grep $wl_iface | $wl_awkcmd '{print $3,$4,$5}' | sed 's/\.//g'`
32714simandl wl_quality=`echo $wl_wtxt | $wl_awkcmd '{print $1}'`
328 wl_signal=`echo $wl_wtxt | $wl_awkcmd '{print $2}'`
3292simandl wl_signal=$(($wl_signal - 256))
33014simandl wl_noise=`echo $wl_wtxt | $wl_awkcmd '{print $3}'`
3312simandl wl_noise=$(($wl_noise - 256))
3325simandl echo "Quality:${wlc_sig}$wl_quality${wlc_std}/92 Signal level:$wl_signal Noise level:$wl_noise "
3332simandl wl_cnt=$wl_quality
334 w_bar
335 echo
336} # w_managed
337 
338######################################################################
339w_master()
34017simandl{ if [ $wcm_oneline -eq 0 ]
34121simandl then
342 echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
343 if [ $wcm_macoff -eq 1 ]
344 then
34529simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$10,$11,$12" "}'
34621simandl else
34729simandl echo $wl_iwctxt | $wl_awkcmd '{print $6,$8,$10,$11,$12" "}'
34821simandl fi
349 else
35026simandl echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11,$12" "}' | sed 's/ [^": ]*:/ /g'
35121simandl fi
352 
353 if [ -d $wl_hostap$wl_iface ]
35415simandl then
35521simandl wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
356 wl_macs=`ls $wl_hostap$wl_iface | grep 00`
3575simandl fi
35821simandl 
35927simandl if [ -d $wl_madwifi$wl_iface ]
36021simandl then
36128simandl wl_numcl=`$wl_wlancf $wl_iface list sta | grep -c ^[0..9]`
362# wl_numcl=`cat $wl_madwifi$wl_iface/associated_sta | grep -c macaddr`
363# wl_macs=`cat $wl_madwifi$wl_iface/associated_sta | tr "<" "#" | tr ">" "#" | tr " " "#" | tr "\n" "#" | tr "m" "\n" `
364 wl_macs=`$wl_wlancf $wl_iface list sta | grep ^[0..9] | tr " " "#"`
36521simandl fi
36629simandl 
367 if [ -d $wl_sysdev$wl_iface ]
368 then
369 wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00`
370 wl_macs=`iwlist $wl_iface peers | grep 00 | awk '{print $1}'`
371 fi
372 
3732simandl echo $wlm_number_of_clients $wl_numcl
37413simandl 
3755simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
37613simandl 
37721simandl for wl_mac in $wl_macs
3782simandl do
37921simandl if [ -d $wl_hostap$wl_iface ]
380 then
381 wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
38222simandl wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal[=|:]//g'`
383 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence[=|:]//g'`
38421simandl fi
385 
38627simandl if [ -d $wl_madwifi$wl_iface ]
38721simandl then
38828simandl wl_signal=`echo $wl_mac | tr "#" " " | $wl_awkcmd '{print $5}'`
389 wl_rxtx=`echo $wl_mac | tr "#" " " | $wl_awkcmd '{print "rate="$4" tx="$8" rx="$9}'`
39027simandl wl_silence="0"
39128simandl wl_mac=`echo $wl_mac | tr "#" " " | $wl_awkcmd '{print $1}'`
39221simandl fi
39329simandl 
394 if [ -d $wl_sysdev$wl_iface ]
395 then
396 wl_macparam=`$wl_iwlcmd $wl_iface peers | grep $wl_mac`
397 wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $5}' | sed 's/level[=|:]//g'`
398 wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $8}' | sed 's/level[=|:]//g'`
399 fi
400 
40111simandl wl_cnt=$(($wl_signal - $wl_silence))
40214simandl wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky
40313simandl 
40414simandl wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'`
405 if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ]
406 then
407 wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac -B 1 | $wl_awkcmd '{print$2,$3}' | grep -i $wl_mac -v | $wl_awkcmd '{print$1}'`
408 if [ "$wl_name" = "" ]
409 then
41017simandl wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'`
41114simandl wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' `
412 fi
413 fi
41421simandl if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] && [ -d $wl_hostap$wl_iface ]
41513simandl then
416 w_pkts
417 fi
418 
4195simandl if [ $wcm_oneline -eq 0 ]
420 then
42115simandl echo -n "${wlc_name}$wl_name${wlc_std} "
4225simandl echo -n "${wlc_ip}$wl_ipc${wlc_std} "
42315simandl if [ $wcm_macoff -eq 0 ]
424 then
425 echo -n "${wlc_mac}$wl_mac${wlc_std} "
426 fi
427 if [ $wcm_threeline -eq 1 ]
428 then
429 echo ""
430 echo -n " "
431 fi
432 echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} "
433 if [ $wcm_rxtx -eq 0 ]
434 then
435 echo ""
436 else
43721simandl if [ -d $wl_hostap$wl_iface ]
438 then
43932simandl echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}'
44021simandl fi
44128simandl if [ -d $wl_madwifi$wl_iface ]
442 then
44332simandl echo -n $wl_rxtx
444 echo ""
44528simandl fi
44632simandl# echo ""
44715simandl fi
4485simandl w_bar
449 else
45015simandl if [ $wcm_macoff -eq 0 ]
451 then
452 echo -n "${wlc_mac}$wl_mac${wlc_std} "
453 fi
454 echo -n "${wlc_sig}$wl_cnt${wlc_std} "
45517simandl echo -n "$wl_name "
4565simandl w_bar
457 fi
4584simandl done
45911simandl 
460 echo
4612simandl} # w_master
462 
463######################################################################
464w_iface()
46526simandl{ wl_iwctxt=`$wl_iwccmd $wl_iface 2>/dev/null | grep -v 'Device|Some|Extension' | sed 's/ dBm/dBm/' | sed 's/ GHz/GHz/' | sed 's/ Mb/Mb/' | sed 's/ Nick/_Nick/' | sed 's/Access Point/Access_Point/'`
46614simandl wl_mode=`echo $wl_iwctxt | $wl_awkcmd '{print $5}' | sed 's/Mode://g'`
4672simandl if [ "a$wl_mode" = "aManaged" ]
468 then
469 w_managed
4708simandl elif [ "a$wl_mode" = "aAd-Hoc" ]
471 then
472 w_managed
4732simandl elif [ "a$wl_mode" = "aMaster" ]
474 then
475 w_master
476 else
47724simandl echo $wl_iface $wlm_no_managed_or_master
4782simandl echo
479 fi
480}
481 
482######################################################################
48311simandlw_version()
484{
485 echo wifimon $wl_version
486 exit 0
487}
488######################################################################
4895simandlw_help()
490{
49121simandl echo Monitorovani wifi karet pouzivajicich hostap nebo madwifi ovladace
4923simandl echo Pouziti: wifimon [param]
493 echo param:
49411simandl echo -v vypise verzi
4955simandl echo -html generovani html stranky
49613simandl echo -col barevny vypis na obrazovku
4975simandl echo -once vypsani jen jednoho vypisu a pak program skonci
498 echo -oneline vypsani klientu na jednu linku
49915simandl echo -threeline vypsani klienta na trech radcich
50021simandl echo -macoff vypnuti zobrazeni MAC adres
501 echo -wlan0 -ath0 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
502 echo nasledujici parametry ovlivnuji jen karty s hostap:
50315simandl echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta
50413simandl echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
505 echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
5063simandl echo bez parametru cyklicky vypis na obrazovku
5075simandl exit 0
508}
509######################################################################
510######################################################################
5112simandl 
5125simandlwl_unknown=""
513wl_cnt=1
514wcm_clear=1
515wcm_once=0
51624simandlwcm_col=0
5175simandlwcm_oneline=0
51815simandlwcm_threeline=0
5195simandlwcm_html=0
52015simandlwcm_rxtx=1
52113simandlwcm_ppkts=0
522wcm_pkts=0
5235simandlwcm_ifc=""
52415simandlwcm_macoff=0
5255simandl 
5266simandl# parsing input parameters
5275simandlwhile [ "a$1" != "a" ]
528do
529 case $1 in
53011simandl -v)
531 w_version
532 ;;
5335simandl -help)
534 w_help
535 ;;
536 -once)
537 wcm_once=1
538 shift
539 ;;
540 -oneline)
541 wcm_oneline=1
542 shift
543 ;;
54415simandl -threeline)
545 wcm_threeline=1
546 shift
547 ;;
54811simandl -col)
54924simandl wcm_col=1
5505simandl shift
551 ;;
552 -html)
553 wcm_html=1
554 shift
555 ;;
55615simandl -rxtxoff)
557 wcm_rxtx=0
558 shift
559 ;;
56013simandl -ppkts)
561 wcm_ppkts=1
562 shift
563 ;;
564 -pkts)
565 wcm_pkts=1
566 shift
567 ;;
56815simandl -macoff)
569 wcm_macoff=1
570 shift
571 ;;
5725simandl *)
573 wl_flg=0
57419simandl#wlan check
57521simandl if [ $wlf_hostap -eq 1 ]
5765simandl then
57721simandl for wl_iface in `ls $wl_hostap`
578 do
57924simandl if [ "a-$wl_iface" = "a$1" ]
58021simandl then
581 wcm_ifc="$wcm_ifc $wl_iface"
582 wl_flg=1
583 fi
584 done
585 fi
58619simandl# ath check
58721simandl if [ $wlf_madwifi -eq 1 ]
58819simandl then
58927simandl for wl_iface in `ls $wl_madwifi | grep "ath[0-9]"`
59021simandl do
59124simandl if [ "a-$wl_iface" = "a$1" ]
59221simandl then
593 wcm_ifc="$wcm_ifc $wl_iface"
594 wl_flg=1
595 fi
596 done
59731simandl for wl_iface in `ls $wl_sysdev | grep "ath[0-9]"`
598 do
599 if [ "a-$wl_iface" = "a$1" ]
600 then
601 wcm_ifc="$wcm_ifc $wl_iface"
602 wl_flg=1
603 fi
604 done
60521simandl fi
6065simandl if [ $wl_flg -eq 0 ]
60721simandl then
608 wl_unknown="$wl_unknown$1 "
6095simandl fi
610 shift
611 esac
612done
613 
6146simandl# printing the list of bad parameters (if there are some)
6155simandlif [ "a$wl_unknown" != "a" ]
616then
617 echo "$wlm_unknown $wl_unknown"
618 w_help
619fi
62029simandl 
6216simandl# if no interface is selected then all available are choosen
6225simandlif [ "a$wcm_ifc" = "a" ]
623then
62421simandl if [ $wlf_hostap -eq 1 ]
625 then
626 wcm_ifc=`ls $wl_hostap `
627 fi
628 if [ $wlf_madwifi -eq 1 ]
629 then
63029simandl wcm_ifc=`echo $wcm_ifc ; ls $wl_sysdev | grep "ath[0-9]" ; ls $wl_madwifi | grep "ath[0-9]"`
63121simandl fi
6325simandlfi
633 
6346simandl# setting for old and last same value to avoid double clear after start
635wl_numcllast=0
636wl_numclold=0
637for wl_iface in $wcm_ifc
638do
63921simandl if [ -d $wl_hostap$wl_iface ]
640 then
641 wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
642 wl_numcllast=$(($wl_numcllast + $wl_numcl))
643 fi
64427simandl if [ -d $wl_madwifi$wl_iface ]
64521simandl then
64632simandl wl_mode=`$wl_iwccmd $wl_iface 2>/dev/null | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`
64721simandl if [ "a$wl_mode" = "aMaster" ]
648 then
64932simandl wl_numcl=`$wl_wlancf $wl_iface list sta 2>/dev/null | grep -c ^[0..9]`
65021simandl wl_numcllast=$(($wl_numcllast + $wl_numcl))
651 fi
652 fi
65329simandl if [ -d $wl_sysdev$wl_iface ]
654 then
655 wl_mode=`$wl_iwccmd $wl_iface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`
656 if [ "a$wl_mode" = "aMaster" ]
657 then
658 wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00`
659 wl_numcllast=$(($wl_numcllast + $wl_numcl))
660 fi
661 fi
662 
6636simandldone
664wl_numclold=$wl_numcllast
665 
66611simandlif [ $wcm_col -eq 0 ]
6676simandlthen
668 w_bw
66911simandlelse
67015simandl if [ $wcm_html -eq 1 ]
671 then
672 w_colh
673 else
674 w_col
675 fi
6766simandlfi
677 
67813simandlif [ $wcm_html -eq 1 ]
679then
680 [ $wcm_once -eq 1 ] && echo $wl_header || echo $wl_header_refresh
681 for wl_iface in $wcm_ifc
682 do
683 w_iface
684 done
685 echo $wl_footer
686 exit 0
687fi
688 
68915simandl#this is main loop and it will be executed forever
6906simandlwhile [ 1 ]
6915simandl do
69214simandl 
693 # when the number of associated klients has changed we will set for clear screen
6945simandl if [ $wl_numcllast -ne $wl_numclold ]
695 then
696 wl_numclold=$wl_numcllast
697 wcm_clear=1
698 fi
69914simandl 
700 #if it is set for clear screen we will do it except we produce single report
701 if [ $wcm_clear -eq 1 -a $wcm_once -eq 0 ]
7025simandl then
70314simandl echo -n $wl_clrcmde
7045simandl wcm_clear=0
705 fi
706 wl_numcllast=0
70711simandl 
70814simandl #for cyclic report we are trying to set cursor to the top left screen corner
709 if [ $wcm_once -eq 0 ]
710 then
711 echo -n $wl_tptcmde
712 fi
713 
714 #make report for all desired interfaces
71513simandl for wl_iface in $wcm_ifc
716 do
717 w_iface
718 done
719 
72014simandl #when a single report is needed than we are exiting
7215simandl if [ $wcm_once -eq 1 ]
722 then
723 exit 0
724 fi
725 sleep 1
7266simandldone
7275simandl 
728exit 0
729 

Powered by WebSVN 2.2.1