#!/bin/sh # first parameter: currently connected bssid wan_ap_lower=`echo $1 | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` equal() { case "$1" in "$2") return 0 ;; *) return 255 ;; esac } S_FILE=/tmp/.graphsurvey rm -f $S_FILE touch $S_FILE if [ ! -f /tmp/survey.lock ]; then touch /tmp/survey.lock . /etc/functions.sh config_load fon config_get mode wan mode if [ "`ifconfig | grep -q ath2; echo "$?"`" -eq "1" ]; then ifconfig ath2 0.0.0.0 up ath2switched=true fi ifconfig ath2 >/dev/null 2>&1 && { iwlist ath2 scanning 1>/dev/null 2>&1 # seems to help wlanconfig to see something on first try wlanconfig ath2 list ap 2>/dev/null | grep -v ^SSID | while read line; do enccode=0 # 0 no encryption # 1 WEP # 2 WPA # 4 WPA2 ssid=`echo "$line"|cut -d":" -f1` ssid=${ssid%% 00:*} #fix ssid with spaces ssid=${ssid%%00} line=${line##$ssid} ssid=`echo $ssid | cut -c-14` noSSID=0 equal "$ssid" "" && { ssid="<hidden>" noSSID="1" } bssid=`echo $line|cut -d" " -f1` chan=`echo $line|cut -d" " -f2` signal=`echo $line|cut -d" " -f4|cut -d":" -f1` [ $signal -lt 1 ] && signal=1 [ $signal -gt 100 ] && signal=100 encswitch="$(iwlist ath2 scanning 2>/dev/null | grep -iA5 "$bssid" | grep "Encryption key" | awk -F":" '{print $2}')" case $encswitch in on) encWPA2=$(iwlist ath2 scanning 2>/dev/null | grep -iA14 "$bssid" | grep "WPA2 Version 1" | awk '{print $3}') encWPA1=$(iwlist ath2 scanning 2>/dev/null | grep -iA14 "$bssid" | grep "WPA Version 1" | awk '{print $2}') equal "$encWPA2" "802.11i/WPA2" && enccode=$(expr $enccode + 4); equal "$encWPA1" "WPA" && enccode=$(expr $enccode + 2); equal "$encWPA2" "" && equal "$encWPA1" "" && enccode=$(expr $enccode + 1); ;; off) enccode=0 ;; esac case $enccode in 6) enc="WPA" encpic="wpa-wpa2" ;; 4) enc="WPA" encpic="wpa2" ;; 2) enc="WPA" encpic="wpa" ;; 1) enc="WEP" encpic="wep" ;; 0) enc="OPEN" encpic="open" ;; *) encpic="unknown" ;; esac equal "$bssid" "$wan_ap_lower" && encpic="${encpic}_linked" spacerwidth=`expr 100 - $signal` spacerwidth=`expr $spacerwidth \* 420 / 100` echo "$ssid ; $bssid ; $encswitch ; $enccode ; $enc ;" >/dev/console # generate html code for graphical site survey echo "" >>$S_FILE echo "" >>$S_FILE equal "$noSSID" "1" && echo "$ssid ch${chan}
" >>$S_FILE equal "$noSSID" "0" && echo "$ssid ch${chan}
" >>$S_FILE echo "" >>$S_FILE echo "" >>$S_FILE equal "$noSSID" "1" && echo "
" >>$S_FILE equal "$noSSID" "0" && echo "
" >>$S_FILE echo "" >>$S_FILE done } if [ "$ath2switched" = "true" ]; then ifconfig ath2 down fi rm -f /tmp/survey.lock fi