X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fwlanap.cgi;h=844c395e2f7738dddd26cd3c36ad5bcfe8577c93;hb=415cbcecfae2330a8c4211dc4c17e8a98ee4f64b;hp=58c6376feac996a2bdb018370bdc0e63ce9cf48e;hpb=5627b4c9f276f480dffd93d264288de4b936bad7;p=ipfire-2.x.git diff --git a/html/cgi-bin/wlanap.cgi b/html/cgi-bin/wlanap.cgi index 58c6376fea..844c395e2f 100644 --- a/html/cgi-bin/wlanap.cgi +++ b/html/cgi-bin/wlanap.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2005-2013 IPFire Team # +# Copyright (C) 2007-2014 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -35,9 +35,10 @@ require '/var/ipfire/header.pl'; my $debug = 0; my $status = ''; my $errormessage = ''; -my $status_started = "$Lang::tr{'running'}"; -my $status_stopped = "$Lang::tr{'stopped'}"; - +my $status_started = "$Lang::tr{'running'}"; +my $status_stopped = "$Lang::tr{'stopped'}"; +my $count=0; +my $col=''; # get rid of used only once warnings my @onlyonce = ( $Header::colourgreen, $Header::colourred ); undef @onlyonce; @@ -64,13 +65,13 @@ $wlanapsettings{'SSID'} = 'IPFire'; $wlanapsettings{'HIDESSID'} = 'off'; $wlanapsettings{'ENC'} = 'wpa2'; # none / wpa1 /wpa2 $wlanapsettings{'TXPOWER'} = 'auto'; -$wlanapsettings{'CHANNEL'} = '05'; +$wlanapsettings{'CHANNEL'} = '6'; $wlanapsettings{'COUNTRY'} = '00'; $wlanapsettings{'HW_MODE'} = 'g'; $wlanapsettings{'PWD'} = 'IPFire-2.x'; $wlanapsettings{'SYSLOGLEVEL'} = '0'; $wlanapsettings{'DEBUG'} = '4'; -$wlanapsettings{'DRIVER'} = 'MADWIFI'; +$wlanapsettings{'DRIVER'} = 'NL80211'; $wlanapsettings{'HTCAPS'} = ''; &General::readhash("/var/ipfire/wlanap/settings", \%wlanapsettings); @@ -151,12 +152,9 @@ if ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'save'}" ){ }elsif ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'stop'}" ){ system("/usr/local/bin/wlanapctrl stop >/dev/null 2>&1"); $memory=0; -}elsif ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'restart'}" ){ - system("/usr/local/bin/wlanapctrl restart >/dev/null 2>&1"); - pid(); } -&Header::openpage('Wireless LAN', 1, '', ''); +&Header::openpage('', 1, '', ''); &Header::openbigbox('100%', 'left', '', $errormessage); if ( $errormessage ){ @@ -260,21 +258,40 @@ if ( -d '/sys/class/net/mon.'.$wlanapsettings{'INTERFACE'} ) { $monwlaninterface = 'mon.'.$wlanapsettings{'INTERFACE'}; } -my @channellist_cmd = `iwlist $monwlaninterface channel 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" | grep -v "no IR" | grep -v "passive scanning" 2>/dev/null`; +# get available channels + +my @temp; +foreach (@channellist_cmd){ +$_ =~ /(.*) \[(\d+)(.*)\]/; +$channel = $2;chomp $channel; +if ( $channel =~ /\d+/ ){push(@temp,$channel + 0);} +} +@channellist = @temp; +} else { +@channellist_cmd = `iwlist $monwlaninterface channel|tail -n +2 2>/dev/null`; # get available channels my @temp; foreach (@channellist_cmd){ $_ =~ /(.*)Channel (\d+)(.*):/; $channel = $2;chomp $channel; -if ( $channel =~ /\d+/ ){push(@temp,$channel);} +if ( $channel =~ /\d+/ ){push(@temp,$channel + 0);} +} +@channellist = @temp; } -my @channellist = @temp; my @countrylist_cmd = `regdbdump /usr/lib/crda/regulatory.bin 2>/dev/null`; # get available country codes -my @temp; +my @temp = "00"; foreach (@countrylist_cmd){ $_ =~ /country (.*):/; $country = $1;chomp $country; @@ -289,15 +306,6 @@ if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){ } # get available power -my @temp; -foreach (@txpower_cmd){ -$_ =~ /(\s)(\d+)(\s)dBm(\s)(.*)(\W)(\d+)(.*)/; -$txpower = $7;chomp $txpower; -if ( $txpower =~ /\d+/ ){push(@temp,$txpower."mW");} -} -my @txpower = @temp; -push(@txpower,"auto"); - $selected{'SYSLOGLEVEL'}{$wlanapsettings{'SYSLOGLEVEL'}} = "selected='selected'"; $selected{'DEBUG'}{$wlanapsettings{'DEBUG'}} = "selected='selected'"; @@ -306,64 +314,48 @@ $selected{'DEBUG'}{$wlanapsettings{'DEBUG'}} = "selected='selected'"; # &Header::openbox('100%', 'center', "WLAN AP"); print < + END ; if ( $wlan_card_status ne '' ){ - print ""; - print ""; + print ""; + print ""; print $wlan_card_status eq 'up' ? $status_started : $status_stopped; - print ""; + print""; + print ""; print $wlan_ap_status eq 'up' ? $status_started : $status_stopped; + if ( ($memory != 0) && (@pid[0] ne "///") ){ + print ""; + print ""; + print ""; + print ""; + }else{ + print""; + print ""; + print ""; + } }else{ - print "
$Lang::tr{'wlanap wlan services'}
$Lang::tr{'wlanap wlan card'} ($wlanapsettings{'DRIVER'})
$Lang::tr{'service'}StatusPID$Lang::tr{'memory'}$Lang::tr{'action'}
$Lang::tr{'wlanap wlan card'} ($wlanapsettings{'DRIVER'})
$Lang::tr{'wlanap access point'}
$Lang::tr{'wlanap access point'}@pid[0]$memory KB
$message"; + print "
$message"; } print "
"; -if ( ($memory != 0) && (@pid[0] ne "///") && ($wlan_card_status ne '') ){ - print ""; - print ""; - print ""; - print ""; - print ""; +if ( $wlan_card_status eq '' ){ + print "
"; + print "
PID$Lang::tr{'memory'}
"; + print ""; + print ""; print ""; - print ""; - print ""; - print ""; - print ""; + print ""; + print ""; + print ""; + print ""; + print ""; print ""; print "
hostapd    @pid[0]$memory KB
 
"; } -if ( $wlan_card_status ne '' ){ -print "
"; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print "
 
"; -}else{ -print "
"; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print "

 
"; -} - if ( $wlan_card_status eq '' ){ &Header::closebox(); &Header::closebigbox(); @@ -371,13 +363,25 @@ if ( $wlan_card_status eq '' ){ exit 0; } print < +

- - +
$Lang::tr{'wlanap wlan settings'} -
SSID: 
+ + + + + + - - END ; @@ -417,34 +412,23 @@ END END ; } - -print < - + + + END ; - -if ( $wlanapsettings{'DRIVER'} eq 'MADWIFI' ){ - print ""; -} else { - print "" -} print < - + + +
$Lang::tr{'wlanap wlan settings'}

SSID: 
SSID Broadcast: on | off
$Lang::tr{'wlanap country'}:  +
HW Mode: 
$Lang::tr{'wlanap encryption'}:  - -
$Lang::tr{'wlanap country'}:  -
Tx Power:  +print<
$Lang::tr{'wlanap encryption'}:  + +
Passphrase: 

Passphrase: 
HT Caps: 
HT Caps: 
Tx Power: 
Loglevel (hostapd): 

END ; if ( $wlanapsettings{'INTERFACE'} =~ /green0/ ){ print < - +
+ + +
$Lang::tr{'mac filter'}
Mac Filter:  +
@@ -497,25 +485,57 @@ print < END ; - -if ( $wlanapsettings{'DRIVER'} eq 'MADWIFI' ){ - $status = `wlanconfig $wlanapsettings{'INTERFACE'} list`; -} +my @status; if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){ - $status = `iw dev $wlanapsettings{'INTERFACE'} station dump`; + @status = `iw dev $wlanapsettings{'INTERFACE'} info && iw dev $wlanapsettings{'INTERFACE'} station dump && echo ""`; } print < - - - - -
$Lang::tr{'wlanap wlan status'}
@channellist_cmd
@txpower_cmd
$status
+ + +END +; + +for (my $i=0;$i<$#status;$i++){ + +if (@status[$i]=~"^Station ") { $count++; } +if ($count % 2){ + $col="bgcolor='$color{'color20'}'"; + }else{ + $col="bgcolor='$color{'color22'}'"; + } + print""; + if (! @status[$i]=~"^/t" ) { $count++; } +} + $count++; + +foreach my $nr (@channellist_cmd){ + if ($count % 2){ + $col="bgcolor='$color{'color20'}'"; + }else{ + $col="bgcolor='$color{'color22'}'"; + } + print""; + $count++; +} + +for (my $i=0;$i<$#txpower_cmd;$i=$i+2){ + if ($count % 2){ + $col="bgcolor='$color{'color20'}'"; + }else{ + $col="bgcolor='$color{'color22'}'"; + } + print ""; + $count++; +} +print "
$Lang::tr{'wlanap wlan status'}
@status[$i]
$nr
@txpower_cmd[$i]

"; +print < - - +
WLan Clients
+ +
$Lang::tr{'wlan clients'}
 $Lang::tr{'wlanap link wireless'}
 $Lang::tr{'wlanap link dhcp'}

END ; @@ -535,6 +555,7 @@ driver=$wlanapsettings{'DRIVER_HOSTAPD'} interface=$wlanapsettings{'INTERFACE'} country_code=$wlanapsettings{'COUNTRY'} ieee80211d=1 +ieee80211h=1 channel=$wlanapsettings{'CHANNEL'} END ;