]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
hostapd: change channellist and status for dfs channels.
authorArne Fitzenreiter <arne_f@ipfire.org>
Wed, 19 Mar 2014 18:00:47 +0000 (19:00 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Wed, 19 Mar 2014 18:00:47 +0000 (19:00 +0100)
html/cgi-bin/wlanap.cgi

index c544f7338dc27b3897f4c5cf35864e5f8e837913..5b2490da06c036ee7e430538e09dd11c38e43fc4 100644 (file)
@@ -258,7 +258,25 @@ if ( -d '/sys/class/net/mon.'.$wlanapsettings{'INTERFACE'} ) {
        $monwlaninterface =  'mon.'.$wlanapsettings{'INTERFACE'};
 }
 
        $monwlaninterface =  'mon.'.$wlanapsettings{'INTERFACE'};
 }
 
-my @channellist_cmd = `iwlist $monwlaninterface channel|tail -n +2 2>/dev/null`;
+my @channellist_cmd;
+my @channellist;
+
+if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){
+my $wiphy = `iw dev $wlanapsettings{'INTERFACE'} info | grep wiphy | cut -d" " -f2`;
+chomp $wiphy;
+
+@channellist_cmd = `iw phy phy$wiphy info | grep " MHz \\\[" | grep -v "(disabled)" | grep -v "no IBSS)" 2>/dev/null`;
+# get available channels
+
+my @temp;
+foreach (@channellist_cmd){
+$_ =~ /(.*) \[(\d+)(.*)\]/;
+$channel = $2;chomp $channel;
+if ( $channel =~ /\d+/ ){push(@temp,$channel);}
+}
+@channellist = @temp;
+} else {
+@channellist_cmd = `iwlist $monwlaninterface channel|tail -n +2 2>/dev/null`;
 # get available channels
 
 my @temp;
 # get available channels
 
 my @temp;
@@ -267,7 +285,8 @@ $_ =~ /(.*)Channel (\d+)(.*):/;
 $channel = $2;chomp $channel;
 if ( $channel =~ /\d+/ ){push(@temp,$channel);}
 }
 $channel = $2;chomp $channel;
 if ( $channel =~ /\d+/ ){push(@temp,$channel);}
 }
-my @channellist = @temp;
+@channellist = @temp;
+}
 
 my @countrylist_cmd = `regdbdump /usr/lib/crda/regulatory.bin 2>/dev/null`;
 # get available country codes
 
 my @countrylist_cmd = `regdbdump /usr/lib/crda/regulatory.bin 2>/dev/null`;
 # get available country codes
@@ -488,12 +507,12 @@ print <<END
 </table>
 END
 ;
 </table>
 END
 ;
-
+my @status;
 if ( $wlanapsettings{'DRIVER'} eq 'MADWIFI' ){
 if ( $wlanapsettings{'DRIVER'} eq 'MADWIFI' ){
-        $status =  `wlanconfig $wlanapsettings{'INTERFACE'} list`;
+        @status =  `wlanconfig $wlanapsettings{'INTERFACE'} list`;
 }
 if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){
 }
 if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){
-        $status =  `iw dev $wlanapsettings{'INTERFACE'} station dump`;
+        @status =  `iw dev $wlanapsettings{'INTERFACE'} info && iw dev $wlanapsettings{'INTERFACE'} station dump`;
 }
 print <<END
 <br />
 }
 print <<END
 <br />
@@ -501,33 +520,37 @@ print <<END
 <tr><th colspan='3' bgcolor='$color{'color20'}' align='left'><strong>$Lang::tr{'wlanap wlan status'}</strong></th></tr>
 END
 ;
 <tr><th colspan='3' bgcolor='$color{'color20'}' align='left'><strong>$Lang::tr{'wlanap wlan status'}</strong></th></tr>
 END
 ;
-foreach my $nr (@channellist_cmd){
-       my ($chan,$freq) = split(':',$nr);
-       if ($count % 2){
+
+for (my $i=0;$i<$#status;$i++){
+
+if (@status[$i]=~"^Station ") { $count++; }
+if ($count % 2){
                $col="bgcolor='$color{'color20'}'";
        }else{
                $col="bgcolor='$color{'color22'}'";
        }
                $col="bgcolor='$color{'color20'}'";
        }else{
                $col="bgcolor='$color{'color22'}'";
        }
-       print"<tr><td $col>$chan</td><td $col>:</td><td $col>$freq</td></tr>";
-       $count++;
+       print"<tr><td colspan='3' $col><pre>@status[$i]</pre></td></tr>";
+       if (! @status[$i]=~"^/t" ) { $count++; }
 }
 }
-if ($count % 2){
+       $count++;
+
+foreach my $nr (@channellist_cmd){
+       if ($count % 2){
                $col="bgcolor='$color{'color20'}'";
        }else{
                $col="bgcolor='$color{'color22'}'";
        }
                $col="bgcolor='$color{'color20'}'";
        }else{
                $col="bgcolor='$color{'color22'}'";
        }
-if ($status){
-       print"<tr><td colspan='3' $col><pre>$status</pre></td></tr>";
+       print"<tr><td colspan='3' $col>$nr</td></tr>";
        $count++;
 }
        $count++;
 }
-for (my $i=0;$i<$#txpower_cmd;$i=$i+4){
-       next if (@txpower_cmd[$i] =~ /mon/i);
+
+for (my $i=0;$i<$#txpower_cmd;$i=$i+2){
        if ($count % 2){
                $col="bgcolor='$color{'color20'}'";
        }else{
                $col="bgcolor='$color{'color22'}'";
        }
        if ($count % 2){
                $col="bgcolor='$color{'color20'}'";
        }else{
                $col="bgcolor='$color{'color22'}'";
        }
-       print "<tr><td $col>@txpower_cmd[$i]</td><td $col>@txpower_cmd[$i+1]</td><td $col>@txpower_cmd[$i+2]</td></tr>";
+       print "<tr><td $col>@txpower_cmd[$i]</td></tr>";
        $count++;
 }
 print "</table><br>";
        $count++;
 }
 print "</table><br>";