X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fwlanap.cgi;h=e18afd6022ea8a856b82a4f4ee0fc6648ea30220;hp=0bb42ae312440c33525a169b2ef415f43cf731aa;hb=3827d1f6bf2c6b01080bc44ae41009ead9bbcfc7;hpb=76b59637b9b184cbae9e6db758ec19dedb995fa6 diff --git a/html/cgi-bin/wlanap.cgi b/html/cgi-bin/wlanap.cgi index 0bb42ae31..e18afd602 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-2011 IPFire Team # +# Copyright (C) 2005-2013 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; @@ -49,6 +50,7 @@ my %mainsettings = (); my %netsettings=(); my %wlanapsettings=(); my $channel = ''; +my $country = ''; my $txpower = ''; &General::readhash("${General::swroot}/main/settings", \%mainsettings); @@ -64,6 +66,7 @@ $wlanapsettings{'HIDESSID'} = 'off'; $wlanapsettings{'ENC'} = 'wpa2'; # none / wpa1 /wpa2 $wlanapsettings{'TXPOWER'} = 'auto'; $wlanapsettings{'CHANNEL'} = '05'; +$wlanapsettings{'COUNTRY'} = '00'; $wlanapsettings{'HW_MODE'} = 'g'; $wlanapsettings{'PWD'} = 'IPFire-2.x'; $wlanapsettings{'SYSLOGLEVEL'} = '0'; @@ -122,11 +125,16 @@ if ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'wlanap del interface'}" ){ } if ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'save'}" ){ - # verify WPA Passphrase, must be 8 .. 63 characters - only wiht enabled enc - if (($wlanapsettings{'ENC'} eq "wpa1") || ($wlanapsettings{'ENC'} eq "wpa2")){ + # verify WPA Passphrase - only with enabled enc + if (($wlanapsettings{'ENC'} eq "wpa1") || ($wlanapsettings{'ENC'} eq "wpa2") || ($wlanapsettings{'ENC'} eq "wpa1+2")){ + # must be 8 .. 63 characters if ( (length($wlanapsettings{'PWD'}) < 8) || (length($wlanapsettings{'PWD'}) > 63)){ $errormessage .= "$Lang::tr{'wlanap invalid wpa'}
"; } + # only ASCII alowed + if ( !($wlanapsettings{'PWD'} !~ /[^\x00-\x7f]/) ){ + $errormessage .= "$Lang::tr{'wlanap invalid wpa'}
"; + } } if ( $errormessage eq '' ){ @@ -144,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 ){ @@ -232,17 +237,28 @@ END } } +# Change old "n" to "gn" +if ( $wlanapsettings{'HW_MODE'} eq 'n' ) { + $wlanapsettings{'HW_MODE'}='gn'; +} + $checked{'HIDESSID'}{'off'} = ''; $checked{'HIDESSID'}{'on'} = ''; $checked{'HIDESSID'}{$wlanapsettings{'HIDESSID'}} = "checked='checked'"; $selected{'ENC'}{$wlanapsettings{'ENC'}} = "selected='selected'"; $selected{'CHANNEL'}{$wlanapsettings{'CHANNEL'}} = "selected='selected'"; +$selected{'COUNTRY'}{$wlanapsettings{'COUNTRY'}} = "selected='selected'"; $selected{'TXPOWER'}{$wlanapsettings{'TXPOWER'}} = "selected='selected'"; $selected{'HW_MODE'}{$wlanapsettings{'HW_MODE'}} = "selected='selected'"; $selected{'MACMODE'}{$wlanapsettings{'MACMODE'}} = "selected='selected'"; -my @channellist_cmd = `iwlist $wlanapsettings{'INTERFACE'} channel 2>/dev/null`; +my $monwlaninterface = $wlanapsettings{'INTERFACE'}; +if ( -d '/sys/class/net/mon.'.$wlanapsettings{'INTERFACE'} ) { + $monwlaninterface = 'mon.'.$wlanapsettings{'INTERFACE'}; +} + +my @channellist_cmd = `iwlist $monwlaninterface channel|tail -n +2 2>/dev/null`; # get available channels my @temp; @@ -253,8 +269,23 @@ if ( $channel =~ /\d+/ ){push(@temp,$channel);} } my @channellist = @temp; -my @txpower_cmd = `iwlist $wlanapsettings{'INTERFACE'} txpower 2>/dev/null`; -# get available channels +my @countrylist_cmd = `regdbdump /usr/lib/crda/regulatory.bin 2>/dev/null`; +# get available country codes + +my @temp; +foreach (@countrylist_cmd){ +$_ =~ /country (.*):/; +$country = $1;chomp $country; +if ( $country =~ /[0,A-Z][0,A-Z]/ ) {push(@temp,$country);} +} +my @countrylist = @temp; + +my @txpower_cmd = `iwlist $monwlaninterface txpower 2>/dev/null`; +if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){ + # There is a bug with NL80211 only all devices can displayed + @txpower_cmd = `iwlist txpower 2>/dev/null | sed -e "s|unknown transmit-power information.||g"`; +} +# get available power my @temp; foreach (@txpower_cmd){ @@ -273,64 +304,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(); @@ -338,39 +353,71 @@ if ( $wlan_card_status eq '' ){ exit 0; } print < +

- - +
$Lang::tr{'wlanap wlan settings'} -
SSID: 
+ + + + + + +END +; +if ( scalar @channellist > 0 ){ + print <" +} else { + print < +END +; +} +print< - + END ; -foreach $channel (@channellist){ - print ""; -} - print < +" } print < - +
$Lang::tr{'wlanap wlan settings'}

SSID: 
SSID Broadcast: on | off
$Lang::tr{'wlanap country'}:  +
HW Mode: 
$Lang::tr{'wlanap channel'}:  +
$Lang::tr{'wlanap channel'}:  + +

$Lang::tr{'wlanap encryption'}: 
$Lang::tr{'wlanap channel'}:  -
Passphrase: 

HT Caps: 
Tx Power:  END ; @@ -385,8 +432,6 @@ if ( $wlanapsettings{'DRIVER'} eq 'MADWIFI' ){ print "
Passphrase: 
HT Caps: 
Loglevel (hostapd): 

END ; if ( $wlanapsettings{'INTERFACE'} =~ /green0/ ){ print < - +
+ + +
$Lang::tr{'mac filter'}
Mac Filter:  +
@@ -448,16 +497,46 @@ if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){ } print < - - - - -
$Lang::tr{'wlanap wlan status'}
@channellist_cmd
@txpower_cmd
$status
+ + +END +; +foreach my $nr (@channellist_cmd){ + my ($chan,$freq) = split(':',$nr); + if ($count % 2){ + $col="bgcolor='$color{'color20'}'"; + }else{ + $col="bgcolor='$color{'color22'}'"; + } + print""; + $count++; +} +if ($count % 2){ + $col="bgcolor='$color{'color20'}'"; + }else{ + $col="bgcolor='$color{'color22'}'"; + } +if ($status){ + print""; + $count++; +} +for (my $i=0;$i<$#txpower_cmd;$i=$i+4){ + if ($count % 2){ + $col="bgcolor='$color{'color20'}'"; + }else{ + $col="bgcolor='$color{'color22'}'"; + } + print ""; + $count++; +} +print "
$Lang::tr{'wlanap wlan status'}
$chan:$freq
$status
@txpower_cmd[$i]@txpower_cmd[$i+1]@txpower_cmd[$i+2]

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

END ; @@ -471,14 +550,25 @@ sub WriteConfig_hostapd{ open (CONFIGFILE, ">/var/ipfire/wlanap/hostapd.conf"); print CONFIGFILE <