diff --git a/files/usr/local/bin/wscan b/files/usr/local/bin/wscan index 81a4e9a0..596e8abd 100755 --- a/files/usr/local/bin/wscan +++ b/files/usr/local/bin/wscan @@ -186,8 +186,8 @@ sub pushAP if($ssid eq "") { $ssid = "(hidden)" } - if($key eq "off") { $key = " " } - else { $key = "*" } + if($key eq "none") { $key = " " } + else { $key = "*" } $mac =~ /^(\w\w):(\w\w):(\w\w):(\w\w):(\w\w):(\w\w)/; $mac1 = $1 . $2 . $3; @@ -248,36 +248,35 @@ die "bad interface" if not defined $iface; if($raw) { - system("/usr/sbin/iwlist $iface scan"); + system("/usr/bin/iwinfo $iface scan"); exit; } while(1) { - open(FILE, "/usr/sbin/iwlist $iface scan 2>&1 |") or die "iwlist failed"; + open(FILE, "/usr/bin/iwinfo $iface scan 2>&1 |") or die "iwinfo failed"; $mode = ""; @list = (); ++$iters; while($line = ) { - if($line =~ /\s+Cell \d+ - Address: (\S+)/) + if($line =~ /Cell \d+ - Address: (\S+)/) { - if ( $lastseen < 10000 ) { pushAP($signal, $chan, $key, $ssid, $mac, $mode) } + pushAP($signal, $chan, $key, $ssid, $mac, $mode); $mac = $1; $mode = ""; } - if($line =~ /\bESSID:"(.*)"/) { $ssid = $1 } - if($line =~ /\bMode:(\S+)/) { $mode = $1 } - if($line =~ /\bChannel:(\d+)/) { $chan = $1 } - if($line =~ /\bSignal level=([\d-]+)/) { $signal = $1 } - if($line =~ /\bEncryption key:(\w+)/) { $key = $1 } - if($line =~ /\bExtra: Last beacon: (\d+)ms/) { $lastseen = $1 } + if($line =~ /\bESSID: "(.*)"/) { $ssid = $1 } + if($line =~ /\bMode: (\S+)/) { $mode = $1 } + if($line =~ /\bChannel: (\d+)/) { $chan = $1 } + if($line =~ /\bSignal: ([\d-]+)/) { $signal = $1 } + if($line =~ /\bEncryption: (\w+)/) { $key = $1 } } close(FILE); - if ( $lastseen < 10000 ) { pushAP($signal, $chan, $key, $ssid, $mac, $mode) } + pushAP($signal, $chan, $key, $ssid, $mac, $mode); sleep 1 if not scalar @list and $loops != 1; if(not $batch) diff --git a/files/www/cgi-bin/channelmaps.pm b/files/www/cgi-bin/channelmaps.pm index ae55646b..247edc50 100644 --- a/files/www/cgi-bin/channelmaps.pm +++ b/files/www/cgi-bin/channelmaps.pm @@ -99,9 +99,10 @@ sub is_channel_valid # We don't have the device band in the data file so lets fall back to checking manually else { my $channelok=0; - foreach (`iwlist wlan0 channel`) + foreach (`iwinfo wlan0 channels`) { next unless /Channel $channel/; + next if /\[restricted\]/; $channelok=1; } return $channelok; @@ -125,11 +126,12 @@ sub rf_channels_list else { my %channels = (); - foreach (`iwlist wlan0 channel` ) + foreach (`iwinfo wlan0 freqlist` ) { - next unless /([0-9]+) : ([0-9]+.[0-9]+)/; - my $channelnum = $1; - my $channelfreq = $2; + next unless /([0-9]+.[0-9]+) Ghz \(Channel ([0-9]+)\)/; + next if /\[restricted\]/; + my $channelnum = $2; + my $channelfreq = $1; $channelnum =~s/^0+//g; $channels->{$channelnum} = "$channelfreq GHZ" ; } diff --git a/files/www/cgi-bin/perlfunc.pm b/files/www/cgi-bin/perlfunc.pm index 4f91ee02..50d0654c 100644 --- a/files/www/cgi-bin/perlfunc.pm +++ b/files/www/cgi-bin/perlfunc.pm @@ -1,4 +1,4 @@ -############################# +########################## # html functions # emit the http server response @@ -83,13 +83,13 @@ sub read_query_string # c-style fgets for read_postdata + $stdinbuffer = ""; sub fgets { my($size) = @_; my $line = ""; - while(1) { unless(length $stdinbuffer) @@ -118,14 +118,14 @@ sub fgets # (from STDIN in method=post form) sub read_postdata { + if ( $ENV{REQUEST_METHOD} != "POST" || !$ENV{CONTENT_LENGTH}){ return; }; my ($line, $parm, $file, $handle, $tmp); my $state = "boundary"; my ($boundary) = $ENV{CONTENT_TYPE} =~ /boundary=(\S+)/ if $ENV{CONTENT_TYPE}; my $parsedebug = 0; push(@parse_errors, "[$boundary]") if $parsedebug; - while(length ($line = fgets(1000))) - { + { $line =~ s/[\r\n]+$//; # chomp doesn't strip \r! #print "[$state] $line
\n"; @@ -546,25 +546,15 @@ sub save_setup sub get_wifi_signal { - # CMLARA: - # this would be easy if /proc/net/wireless updated automatically, but it doesn't. - # the hack is to re-scan - # also iwlist doesnt correctly limit to single ssid - # and we have to call from 2 programs now instead of 1 - my ($ssid) = (`uci -q get wireless.\@wifi-iface[0].ssid`); - chomp $ssid; + my $wifiintf = `uci -q get network.wifi.ifname`; + chomp $wifiintf; my ($SignalLevel) = "N/A"; my ($NoiseFloor) = "N/A"; - foreach(`iwlist $_[0] scanning essid "$ssid" |tr '\n' ' '|sed 's/Cell \\([0-9]\\{2,\\}\\) - Address:/\\nCell \\1 - Address:/g'|grep -i "$ssid"`) + foreach(`iwinfo $wifiintf info`) { - next unless /.*Signal level=([\d\-]+) dBm.* Extra: Last beacon: ([\d]+)ms/; - if ( $2 < 10000 ) {$SignalLevel=$1;} - } - - foreach(`iw dev $_[0] survey dump|grep -A 1 \"\\[in use\\]\"`) - { - next unless /([\d\-]+) dBm/; - $NoiseFloor=$1; + next unless /.*Signal: ([\d\-]+) dBm.*Noise: ([\d\-]+) dBm/; + $SignalLevel=$1; + $NoiseFloor=$2; } if ( $SignalLevel == "N/A" || $NoiseFloor == "N/A" ) @@ -592,9 +582,9 @@ sub get_free_mem { foreach(`free`) { - next unless /^\s+Mem[:]/; + next unless /^Mem[:]/; my @tmp = split /\s+/, $_; - return $tmp[4] + $tmp[6]; + return $tmp[3] + $tmp[5]; } return "N/A"; } diff --git a/files/www/cgi-bin/setup b/files/www/cgi-bin/setup index b67d1efd..720995d0 100755 --- a/files/www/cgi-bin/setup +++ b/files/www/cgi-bin/setup @@ -5,7 +5,6 @@ $debug = 0; BEGIN {push @INC, '/www/cgi-bin'}; use perlfunc; use channelmaps; - # # load the config parms # @@ -95,7 +94,7 @@ $parms{dmz_dhcp_limit} = $dmz_dhcp_limit = $dmz_dhcp_end - $dmz_dhcp_start; unless($parms{reload}) { - ($wifi_txpower) = `iwconfig wlan0 2>/dev/null` =~ /Tx-Power=(\d+)/; + ($wifi_txpower) = `iwinfo wlan0 info 2>/dev/null` =~ /Tx-Power: (\d+)/; if (wifi_useschains()){ $wifi_txant = `cat /sys/kernel/debug/ieee80211/phy0/ath9k/tx_chainmask`; $wifi_rxant = `cat /sys/kernel/debug/ieee80211/phy0/ath9k/rx_chainmask`; @@ -146,7 +145,7 @@ if($parms{button_apply} or $parms{button_save}) $cmd .= "ifup wifi_mon >/dev/null 2>&1;"; } $cmd .= "iw phy phy0 set distance $wifi_distance >/dev/null 2>&1;"; - $cmd .= "iwconfig wlan0 txpower $wifi_txpower >/dev/null 2>&1;"; + $cmd .= "iw dev wlan0 set txpower fixed ${wifi_txpower}00 >/dev/null 2>&1;"; system $cmd; } diff --git a/files/www/cgi-bin/status b/files/www/cgi-bin/status index 35eef4cd..17055c95 100755 --- a/files/www/cgi-bin/status +++ b/files/www/cgi-bin/status @@ -1,10 +1,9 @@ -#!/usr/bin/perl - -$debug = 0; +#!/usr/bin/perl +$| = 1; +$debug = 1; BEGIN {push @INC, '/www/cgi-bin'}; use perlfunc; - # collect some variables $node = nvram_get("node"); $node = "NOCALL" if $node eq ""; @@ -212,7 +211,7 @@ push @col2, "system time" . `date +'%a %b %e %Y
%T % $uptime = `uptime`; $uptime =~ s/^ ..:..:.. up //; -($uptime, $load) = $uptime =~ /(.*), load average: (.*)/; +($uptime, $load) = $uptime =~ /(.*), load average: (.*)/; push @col2, "uptime
load average$uptime
$load"; $str = "free spaceflash = ";