diff --git a/html/cgi-bin/wlanap.cgi b/html/cgi-bin/wlanap.cgi
index 83270b92b..1e5da201e 100755
--- a/html/cgi-bin/wlanap.cgi
+++ b/html/cgi-bin/wlanap.cgi
@@ -35,8 +35,8 @@ require '/var/ipfire/header.pl';
my $debug = 0;
my $i = 0;
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'} | ";
# get rid of used only once warnings
my @onlyonce = ( $Header::colourgreen, $Header::colourred );
@@ -46,32 +46,26 @@ my %selected=();
my %checked=();
my %color = ();
my %mainsettings = ();
+my %netsettings=();
+my %wlanapsettings=();
my $channel = '';
my $txpower = '';
&General::readhash("${General::swroot}/main/settings", \%mainsettings);
&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/var/ipfire/ethernet/settings", \%netsettings);
-my %wlanapsettings=();
$wlanapsettings{'APMODE'} = 'on';
-$wlanapsettings{'BOOTSTART'} = 'on';
+$wlanapsettings{'INTERFACE'} = $netsettings{'BLUE_DEV'};
$wlanapsettings{'SSID'} = 'IPFire';
$wlanapsettings{'HIDESSID'} = 'off';
-$wlanapsettings{'ENC'} = 'wpa'; # none / wep / wpa / wep+wpa
-$wlanapsettings{'ANTENNA'} = 'both';
+$wlanapsettings{'ENC'} = 'wpa'; # none / wpa
$wlanapsettings{'TXPOWER'} = 'auto';
# $wlanapsettings{'CC'} = '276'; # CountryCode, 276 = Germany
-$wlanapsettings{'CHAN'} = '5';
-
-$wlanapsettings{'WEPKEY1'} = 'BF715772DADA8A3E7AFFA5C26B';
-$wlanapsettings{'WEPKEY2'} = '';
-$wlanapsettings{'WEPKEY3'} = '';
-$wlanapsettings{'WEPKEY4'} = '';
-$wlanapsettings{'USEDKEY'} = '1';
-
+$wlanapsettings{'CHAN'} = '05';
$wlanapsettings{'PWD'} = 'IPFire-2.x';
$wlanapsettings{'PSK'} = '69eb868ed7b3cc36d767b729048c9c585234723d1eafbe66e5a16957b7c85e9c';
-$wlanapsettings{'WPA'} = '3';
+$wlanapsettings{'WPA'} = '1';
$wlanapsettings{'SYSLOGLEVEL'} = '0';
$wlanapsettings{'DEBUG'} = '4';
@@ -80,32 +74,19 @@ $wlanapsettings{'DRIVER'} = 'MADWIFI'; # UNKNOWN / MADWIFI / RT2500 /
# WLANMODE= (a/b/g)
&General::readhash("/var/ipfire/wlanap/settings", \%wlanapsettings);
-my %netsettings=();
-&General::readhash("/var/ipfire/ethernet/settings", \%netsettings);
-
my %cgiparams=();
$cgiparams{'ACTION'} = '';
$cgiparams{'RUNNING'} = 'off';
$cgiparams{'APMODE'} = 'on';
-$cgiparams{'BOOTSTART'} = 'on';
$cgiparams{'SSID'} = 'IPFire';
$cgiparams{'HIDESSID'} = 'off';
$cgiparams{'ENC'} = 'wpa'; # none / wep / wpa / wep+wpa
-$cgiparams{'ANTENNA'} = 'both';
$cgiparams{'TXPOWER'} = 'auto';
-$cgiparams{'CHAN'} = '5';
-
-$cgiparams{'WEPKEY1'} = 'BF715772DADA8A3E7AFFA5C26B';
-$cgiparams{'WEPKEY2'} = '';
-$cgiparams{'WEPKEY3'} = '';
-$cgiparams{'WEPKEY4'} = '';
-$cgiparams{'USEDKEY'} = '1';
-$cgiparams{'WEPPWD'} = '';
-$cgiparams{'WEPKEYCALC'} = '';
+$cgiparams{'CHAN'} = '05';
$cgiparams{'PWD'} = 'IPFire-2.x';
$cgiparams{'PSK'} = '69eb868ed7b3cc36d767b729048c9c585234723d1eafbe66e5a16957b7c85e9c';
-$cgiparams{'WPA'} = '3';
+$cgiparams{'WPA'} = '1';
$cgiparams{'SYSLOGLEVEL'} = '0';
$cgiparams{'DEBUG'} = '4';
@@ -116,43 +97,18 @@ $cgiparams{'DEBUG'} = '4';
if ( $cgiparams{'ACTION'} eq "$Lang::tr{'save'}" ){
$wlanapsettings{'APMODE'} = $cgiparams{'APMODE'};
- $wlanapsettings{'BOOTSTART'} = $cgiparams{'BOOTSTART'};
$wlanapsettings{'SSID'} = $cgiparams{'SSID'};
$wlanapsettings{'HIDESSID'} = $cgiparams{'HIDESSID'};
$wlanapsettings{'ENC'} = $cgiparams{'ENC'};
- $wlanapsettings{'ANTENNA'} = $cgiparams{'ANTENNA'};
$wlanapsettings{'CHAN'} = $cgiparams{'CHAN'};
$wlanapsettings{'TXPOWER'} = $cgiparams{'TXPOWER'};
- $wlanapsettings{'WEPKEY1'} = $cgiparams{'WEPKEY1'};
- $wlanapsettings{'WEPKEY2'} = $cgiparams{'WEPKEY2'};
- $wlanapsettings{'WEPKEY3'} = $cgiparams{'WEPKEY3'};
- $wlanapsettings{'WEPKEY4'} = $cgiparams{'WEPKEY4'};
- $wlanapsettings{'USEDKEY'} = $cgiparams{'USEDKEY'};
-
$wlanapsettings{'PWD'} = $cgiparams{'PWD'};
$wlanapsettings{'PSK'} = $cgiparams{'PSK'};
$wlanapsettings{'WPA'} = $cgiparams{'WPA'};
$wlanapsettings{'SYSLOGLEVEL'}= $cgiparams{'SYSLOGLEVEL'};
$wlanapsettings{'DEBUG'} = $cgiparams{'DEBUG'};
- # verify WEP keys, allowed characters are 0..9A..F, length must be 10 or 26 characters
- for $i ( 1 .. 4 ){
- my $wepkey = $wlanapsettings{"WEPKEY${i}"};
- next if ( $wepkey eq '' );
- if ( (length($wepkey) != 10) && (length($wepkey) != 26) ){
- $errormessage .= "Invalid length in WEP Key $i. Key must be 10 or 26 characters.
";
- next;
- }
-
- if ( $wepkey !~ /[0-9A-Fa-f]$/ ){
- $errormessage .= "Invalid character in WEP Key $i. Only A..F and 0..9 allowed.
";
- next;
- }
-
- $wlanapsettings{"WEPKEY${i}"} = uc($wepkey);
- }
-
# verify WPA Passphrase, must be 8 .. 63 characters
if ( (length($wlanapsettings{'PWD'}) < 8) || (length($wlanapsettings{'PWD'}) > 63) ){
$errormessage .= "Invalid length in WPA Passphrase. Must be between 8 and 63 characters.
";
@@ -168,15 +124,6 @@ if ( $cgiparams{'ACTION'} eq "$Lang::tr{'save'}" ){
system("/usr/local/bin/wlanapctrl start >/dev/null 2>&1");
}elsif ( $cgiparams{'ACTION'} eq 'Stop' ){
system("/usr/local/bin/wlanapctrl stop >/dev/null 2>&1");
-}elsif ( $cgiparams{'ACTION'} eq 'Calc WEP Key' ){
- $cgiparams{'WEPKEYCALC'} = '';
- $errormessage = "Invalid length in WEP Passphrase. Must be exactly 13 characters.
" if ( length($cgiparams{'WEPPWD'}) != 13 );
-
- if ( $errormessage eq '' ){
- $cgiparams{'WEPKEYCALC'} = uc(&WEPKeyCalc($cgiparams{'WEPPWD'}));
- }
-}elsif ( $cgiparams{'ACTION'} eq 'Random WEP Key' ){
- $cgiparams{'WEPKEYCALC'} = &WEPKeyRandom();
}
&Header::openpage('WLAN', 1, '', '');
@@ -184,7 +131,7 @@ if ( $cgiparams{'ACTION'} eq "$Lang::tr{'save'}" ){
print "";
@@ -366,32 +272,25 @@ if ( $wlan_card_status eq '' ){
&Header::closepage();
exit 0;
}
-
-#
-# WLAN settings
-#
-&Header::openbox('100%', 'left', "WLAN Settings");
print <
-| Access Point: | |
+
+
-
-END
-;
-&Header::closebox();
-
-
-#
-# WEP
-#
-&Header::openbox('100%', 'left', "WEP Configuration");
-print <
-| Key 1: | |
-Key 2: | |
-Key 3: | |
-Key 4: | |
-| WEP Key to Use: |
-
- |
-
-
-
-END
-;
-&Header::closebox();
-
-
-#
-# WPA
-#
-&Header::openbox('100%', 'left', "WPA Configuration");
-print <
| Passphrase: | |
| WPA Version: |
|
| Loglevel (hostapd): |
@@ -481,47 +328,39 @@ print <
| Debuglevel (hostapd): |
| |
-
-
-| |
- |
+
+
END
;
-&Header::closebox();
+
+my $status = `cat /proc/net/madwifi/$netsettings{'BLUE_DEV'}/associated_sta`;
+print <
+
+END
+;
+&Header::closebox();
print "";
&Header::closebigbox();
&Header::closepage();
-sub WEPKeyRandom{
- my $length = 26; # 10 is also allowed
- my $string = "0123456789ABCDEF";
- my @chars = split(//,$string);
- my $n = @chars;
- my $index;
- my $key = '';
- for ( $i = 0; $i < $length; $i++){
- $index = int(rand $n);
- $key = $key . $chars[$index];
- }
- return $key;
-}
-
-sub WEPKeyCalc{
- require Digest::MD5;
- return substr Digest::MD5::md5_hex( substr( shift() x 64, 0, 64 ) ), 0, 26;
-}
-
sub WriteConfig{
&General::writehash("/var/ipfire/wlanap/settings", \%wlanapsettings);
}
@@ -531,30 +370,85 @@ sub WriteConfig_hostapd{
open (CONFIGFILE, ">/var/ipfire/wlanap/hostapd.conf");
print CONFIGFILE <$Lang::tr{'stopped'}";
+ my $pid = '';
+ my $testcmd = '';
+ my $exename;
+
+ $cmd =~ /(^[a-z]+)/;
+ $exename = $1;
+
+ if (open(FILE, "/var/run/${cmd}.pid"))
+ {
+ $pid = ; chomp $pid;
+ close FILE;
+ if (open(FILE, "/proc/${pid}/status"))
+ {
+ while ()
+ {
+ if (/^Name:\W+(.*)/)
+ {
+ $testcmd = $1;
+ }
+ }
+ close FILE;
+ if ($testcmd =~ /$exename/)
+ {
+ $status = "$Lang::tr{'running'} | ";
+ }
+ }
+ }
+ return $status;
+ }
diff --git a/src/initscripts/init.d/hostapd b/src/initscripts/init.d/hostapd
index 2d228b303..5fdb7057b 100644
--- a/src/initscripts/init.d/hostapd
+++ b/src/initscripts/init.d/hostapd
@@ -2,6 +2,11 @@
. /etc/sysconfig/rc
. ${rc_functions}
+CHANNEL="05"
+TXPOWER="auto"
+INTERFACE="blue0"
+eval $(/usr/local/bin/readhash /var/ipfire/wlanpap/settings)
+
case "${1}" in
start)
boot_mesg "Starting hostapd... "
@@ -10,18 +15,19 @@ case "${1}" in
sed -i -e "s|#LoadPlugin wireless|LoadPlugin wireless|g" /etc/collectd.conf
# Set Atheros Card to master mode
- /usr/bin/wlanconfig blue0 destroy > /dev/null
- /usr/bin/wlanconfig blue0 create wlandev wifi0 wlanmode ap > /dev/null
+ /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
+ /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode ap > /dev/null
# Set other cards to master mode
#/usr/sbin/iwconfig blue0 mode master
- if [ "$(/usr/sbin/iwconfig blue0 | /bin/grep "Mode:Master")" == "" ]; then
+ if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then
boot_mesg "Error! Can't set wlan master mode"
echo_failure;
exit 1;
else
- /usr/sbin/iwconfig blue0 channel 05
+ /usr/sbin/iwconfig $INTERFACE channel $CHANNEL
+ /usr/sbin/iwconfig $INTERFACE channel $TXPOWER
/usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf /dev/tty12 2>&1 &
evaluate_retval
fi
@@ -31,8 +37,72 @@ case "${1}" in
boot_mesg "Stopping hostapd..."
# Set Atheros Card to Managed mode
- /usr/bin/wlanconfig blue0 destroy > /dev/null
- /usr/bin/wlanconfig blue0 create wlandev wifi0 wlanmode sta > /dev/null
+ /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
+ /usr/bin/wlanconfig #!/bin/sh
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+CHANNEL="05"
+TXPOWER="auto"
+INTERFACE="blue0"
+eval $(/usr/local/bin/readhash /var/ipfire/wlanpap/settings)
+
+case "${1}" in
+ start)
+ boot_mesg "Starting hostapd... "
+ mkdir -p /var/run/hostapd
+ # enable wlan module of collectd
+ sed -i -e "s|#LoadPlugin wireless|LoadPlugin wireless|g" /etc/collectd.conf
+
+ # Set Atheros Card to master mode
+ /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
+ /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode ap > /dev/null
+
+ # Set other cards to master mode
+ #/usr/sbin/iwconfig blue0 mode master
+
+ if [ "$(/usr/sbin/iwconfig $INTERFACE | /bin/grep "Mode:Master")" == "" ]; then
+ boot_mesg "Error! Can't set wlan master mode"
+ echo_failure;
+ exit 1;
+ else
+ /usr/sbin/iwconfig $INTERFACE channel $CHANNEL
+ /usr/sbin/iwconfig $INTERFACE channel $TXPOWER
+ /usr/bin/hostapd -P /var/run/hostapd /etc/hostapd.conf /dev/tty12 2>&1 &
+ evaluate_retval
+ fi
+ ;;
+
+ stop)
+ boot_mesg "Stopping hostapd..."
+
+ # Set Atheros Card to Managed mode
+ /usr/bin/wlanconfig $INTERFACE destroy > /dev/null
+ /usr/bin/wlanconfig $INTERFACE create wlandev wifi0 wlanmode sta > /dev/null
+
+ # Set other cards to master mode
+ #/usr/sbin/iwconfig blue0 mode Managed
+
+ killproc /usr/bin/hostapd
+ evaluate_retval
+ ;;
+
+ restart)
+ ${0} stop
+ sleep 1
+ ${0} start
+ ;;
+
+ status)
+ statusproc /usr/bin/hostapd
+ ;;
+
+ *)
+ echo "Usage: ${0} {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+ create wlandev wifi0 wlanmode sta > /dev/null
# Set other cards to master mode
#/usr/sbin/iwconfig blue0 mode Managed