From 661dc23e18792efca5140cae975805dd44bcf798 Mon Sep 17 00:00:00 2001 From: Conrad Lara - KG6JEI Date: Sun, 19 Jul 2015 23:22:45 -0700 Subject: [PATCH] bugfix: wscan does not show channels sometimes. We should of used the freq: field, not sure why I did not use it to begin with. Corrected and added a small function to convert from frequency to channel. --- files/usr/local/bin/wscan | 40 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/files/usr/local/bin/wscan b/files/usr/local/bin/wscan index 929788d7..e6a79693 100755 --- a/files/usr/local/bin/wscan +++ b/files/usr/local/bin/wscan @@ -50,13 +50,49 @@ sub usage exit; } +sub freq_to_chan +{ + my ($freq) = @_; + + if ($freq < 256 ) + { + return $freq; + } + elsif ($freq == 2484) + { + return "14"; + } + elsif ($freq == 2407) + { + return 0; + } + elsif ($freq < 2484) + { + return ($freq-2407)/5; + } + elsif ($freq < 5000) + { + return ($freq-4000)/5; + } + elsif ($freq < 6000) + { + return ($freq-5000)/5; + } + else + { + return $freq; + } +} + sub pushAP { - my($signal, $chan, $key, $ssid, $host, $mac, $mode) = @_; + my($signal, $freq, $key, $ssid, $host, $mac, $mode) = @_; return if $mac eq ""; return if $openap and ($key ne "" or $mode ne "ESS"); + $chan=freq_to_chan($freq); + if($ssid eq "") { $ssid = "(hidden)" } if($chan eq "") { $chan = "?" } @@ -159,7 +195,7 @@ while(1) if($line =~ /\bSSID: unknown/) { $ssid = "unknown" } if($line =~ /\bcapability: (ESS|IBSS)/ and $mode eq "") { $mode = $1 } - if($line =~ /\bchannel ([\d-]+)/) { $chan = $1 } + if($line =~ /\bfreq: (\d+)/) { $chan = $1 } if($line =~ /\bsignal: ([\d-]+)/) { $signal = $1 } if($line =~ /\bGroup cipher:(.+)/) { $key = $1 } }