2016-05-13 18:02:04 +02:00
|
|
|
|
2016-11-21 17:45:35 +01:00
|
|
|
|
2016-05-13 18:02:04 +02:00
|
|
|
wifi_ifphylist() {
|
2016-12-07 16:47:17 +01:00
|
|
|
if [ "$1" = "phy" ]; then
|
|
|
|
iw phy | grep Wiphy | cut -d ' ' -f 2
|
2016-12-08 16:08:08 +01:00
|
|
|
else
|
|
|
|
iw dev | grep Interface | cut -d ' ' -f 2
|
2016-12-07 16:47:17 +01:00
|
|
|
fi
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_iflist(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_ifphylist
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_phylist(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_ifphylist phy
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_scan_dump(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_scan $1 | tr '(' ' ' | \
|
|
|
|
awk '/^BSS / { printf "'$1' %s ",$2} /freq:/ { printf "%s ",$2 } /signal:/ { printf "%s ",$2 } /SSID:/ { printf "%s\n",$2 } '
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_scan() {
|
2016-12-07 16:47:17 +01:00
|
|
|
local key="wifi_scan_dump_$1"
|
2016-12-07 13:31:54 +01:00
|
|
|
if ! zaf_fromcache "$key"; then
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_real_scan "$1" | zaf_tocache_stdin "$key" 300
|
|
|
|
fi
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_real_scan() {
|
2016-12-07 16:47:17 +01:00
|
|
|
zaf_sudo iw dev "$1" scan
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_channel_dump(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_scan "$1" >/dev/null
|
|
|
|
zaf_sudo iw dev $1 survey dump | tr -s '\t ' | \
|
|
|
|
awk '/frequency:/ { printf "'$1' %i ",$2 } /noise:/ {printf "%i ",$2 } /active time:/ {printf "%i ",$4 } /busy time:/ {printf "%i ",$4 } /receive time:/ {printf "%i ",$4 } /transmit time:/ {printf "%i \n",$4 }'
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_if_discovery(){
|
|
|
|
wifi_iflist | grep '^[a-z].*' | zaf_discovery "{#IF}"
|
|
|
|
}
|
|
|
|
|
|
|
|
wifi_phy_discovery(){
|
2016-12-08 16:08:08 +01:00
|
|
|
wifi_phylist | grep '^[a-z].*' | zaf_discovery "{#DEV}"
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_channels_discovery(){
|
2016-12-07 16:47:17 +01:00
|
|
|
local devs
|
|
|
|
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
|
|
|
for dev in $devs; do wifi_channel_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#FREQ}" "{#NOISE}"
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_neigh_discovery(){
|
2016-12-07 16:47:17 +01:00
|
|
|
local devs
|
|
|
|
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
|
|
|
for dev in $devs; do wifi_scan_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#BSS}" "{#FREQ}" "{#SIGNAL}" "{#SSID}"
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_channel_noise(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $noise)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_channel_activetime(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $active)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_channel_busytime(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $busy)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_channel_receivetime(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $receive)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_channel_transmittime(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_channel_dump $1 | grep "^$1 $2" | (read dev freq noise active busy receive transmit; echo $transmit)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_neigh_channel(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_scan_dump $1 | grep "^$1 $2" | (
|
|
|
|
read dev bss freq signal ssid;
|
|
|
|
if [ -n "$freq" ]; then
|
|
|
|
echo $freq
|
|
|
|
else
|
|
|
|
echo "0"
|
|
|
|
fi
|
|
|
|
)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_neigh_signal(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_scan_dump $1 | grep "^$1 $2" | (
|
|
|
|
read dev bss freq signal ssid;
|
|
|
|
if [ -n "$signal" ]; then
|
|
|
|
echo $signal
|
|
|
|
else
|
|
|
|
echo "-200"
|
|
|
|
fi
|
|
|
|
)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_neigh_ssid(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_scan_dump $1 | grep "^$1 $2" | (
|
|
|
|
read dev bss freq signal ssid;
|
|
|
|
if [ -n "$ssid" ]; then
|
|
|
|
echo $ssid
|
|
|
|
else
|
|
|
|
echo "N/A"
|
|
|
|
fi
|
|
|
|
)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_clients(){
|
2016-12-07 16:47:17 +01:00
|
|
|
zaf_sudo iw dev $1 station dump | grep ^Station | wc -l
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_clients_dump(){
|
2016-12-07 16:47:17 +01:00
|
|
|
zaf_sudo iw dev $1 station dump | awk '/^Station / { printf "'$1' %s ",$2} /signal:/ { printf "%s ",$2 } /tx bitrate:/ { printf "%s ",$3 } /rx bitrate:/ { printf "%s\n",$3 } '
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_clients_discovery(){
|
2016-12-07 16:47:17 +01:00
|
|
|
local devs
|
|
|
|
[ -n "$1" ] && devs="$1" || devs="$(wifi_iflist)"
|
|
|
|
for dev in $devs; do wifi_clients_dump $dev 2>/dev/null; done | zaf_discovery "{#DEV}" "{#STATION}" "{#SIGNAL}" "{#TXRATE}" "{#RXRATE}"
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_client_signal(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_clients_dump $1 | grep "^$1 $2" | (
|
|
|
|
read dev station signal tx rx;
|
|
|
|
if [ -n "$signal" ]; then
|
|
|
|
echo $signal
|
|
|
|
else
|
|
|
|
echo "-200"
|
|
|
|
fi
|
|
|
|
)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_client_rxrate(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_clients_dump $1 | grep "^$1 $2" | (
|
|
|
|
read dev station signal tx rx;
|
|
|
|
if [ -n "$rx" ]; then
|
|
|
|
echo $rx
|
|
|
|
else
|
|
|
|
echo "0"
|
|
|
|
fi
|
|
|
|
)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wifi_client_txrate(){
|
2016-12-07 16:47:17 +01:00
|
|
|
wifi_clients_dump $1 | grep "^$1 $2" | (
|
|
|
|
read dev station signal tx rx;
|
|
|
|
if [ -n "$tx" ]; then
|
|
|
|
echo $tx
|
|
|
|
else
|
|
|
|
echo "0"
|
|
|
|
fi
|
|
|
|
)
|
2016-05-13 18:02:04 +02:00
|
|
|
}
|
|
|
|
|