]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/wlanap.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # WLAN AP cgi based on wlanap.cgi written by Markus Hoffmann & Olaf Westrik
27 # enable only the following on debugging purpose
29 #use CGI::Carp 'fatalsToBrowser';
31 require '/var/ipfire/general-functions.pl';
32 require '/var/ipfire/lang.pl';
33 require '/var/ipfire/header.pl';
37 my $errormessage = '';
38 my $status_started = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><strong>$Lang::tr{'running'}</strong></font></td>";
39 my $status_stopped = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><strong>$Lang::tr{'stopped'}</strong></font></td>";
42 # get rid of used only once warnings
43 my @onlyonce = ( $Header::colourgreen
, $Header::colourred
);
49 my %mainsettings = ();
51 my %wlanapsettings=();
56 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
57 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
58 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
60 $wlanapsettings{'APMODE'} = 'on';
61 $wlanapsettings{'ACTION'} = '';
62 $wlanapsettings{'MACMODE'} = '0';
63 $wlanapsettings{'INTERFACE'} = '';
64 $wlanapsettings{'SSID'} = 'IPFire';
65 $wlanapsettings{'HIDESSID'} = 'off';
66 $wlanapsettings{'ENC'} = 'wpa2'; # none / wpa1 /wpa2
67 $wlanapsettings{'TXPOWER'} = 'auto';
68 $wlanapsettings{'CHANNEL'} = '05';
69 $wlanapsettings{'COUNTRY'} = '00';
70 $wlanapsettings{'HW_MODE'} = 'g';
71 $wlanapsettings{'PWD'} = 'IPFire-2.x';
72 $wlanapsettings{'SYSLOGLEVEL'} = '0';
73 $wlanapsettings{'DEBUG'} = '4';
74 $wlanapsettings{'DRIVER'} = 'MADWIFI';
75 $wlanapsettings{'HTCAPS'} = '';
77 &General
::readhash
("/var/ipfire/wlanap/settings", \
%wlanapsettings);
78 &Header
::getcgihash
(\
%wlanapsettings);
80 my @macs = $wlanapsettings{'MACS'};
82 delete $wlanapsettings{'__CGI__'};
83 delete $wlanapsettings{'x'};
84 delete $wlanapsettings{'y'};
85 delete $wlanapsettings{'MACS'};
86 delete $wlanapsettings{'ACCEPT_MACS'};
87 delete $wlanapsettings{'DENY_MACS'};
89 &Header
::showhttpheaders
();
93 my $errormessage = '';
101 open(FILE
, '/usr/local/bin/addonctrl hostapd status | ');
104 $string = join("", @hostapd);
105 $string =~ s/[a-z_]//gi;
106 $string =~ s/\[[0-1]\;[0-9]+//gi;
107 $string =~ s/[\(\)\.]//gi;
110 @pid = split(/\s/,$string);
111 if (open(FILE
, "/proc/$pid[0]/statm")){
113 @memory = split(/ /,$temp);
122 if ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'wlanap del interface'}" ){
123 delete $wlanapsettings{'INTERFACE'};
124 &General
::writehash
("/var/ipfire/wlanap/settings", \
%wlanapsettings);
127 if ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'save'}" ){
128 # verify WPA Passphrase - only with enabled enc
129 if (($wlanapsettings{'ENC'} eq "wpa1") || ($wlanapsettings{'ENC'} eq "wpa2") || ($wlanapsettings{'ENC'} eq "wpa1+2")){
130 # must be 8 .. 63 characters
131 if ( (length($wlanapsettings{'PWD'}) < 8) || (length($wlanapsettings{'PWD'}) > 63)){
132 $errormessage .= "$Lang::tr{'wlanap invalid wpa'}<br />";
135 if ( !($wlanapsettings{'PWD'} !~ /[^\x00-\x7f]/) ){
136 $errormessage .= "$Lang::tr{'wlanap invalid wpa'}<br />";
140 if ( $errormessage eq '' ){
141 &General
::writehash
("/var/ipfire/wlanap/settings", \
%wlanapsettings);
142 &WriteConfig_hostapd
();
144 system("/usr/local/bin/wlanapctrl restart >/dev/null 2>&1");
147 }elsif ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'wlanap interface'}" ){
148 &General
::writehash
("/var/ipfire/wlanap/settings", \
%wlanapsettings);
149 }elsif ( ($wlanapsettings{'ACTION'} eq "$Lang::tr{'start'}") && ($memory == 0) ){
150 system("/usr/local/bin/wlanapctrl start >/dev/null 2>&1");
152 }elsif ( $wlanapsettings{'ACTION'} eq "$Lang::tr{'stop'}" ){
153 system("/usr/local/bin/wlanapctrl stop >/dev/null 2>&1");
157 &Header
::openpage
('', 1, '', '');
158 &Header
::openbigbox
('100%', 'left', '', $errormessage);
160 if ( $errormessage ){
161 &Header
::openbox
('100%', 'center', $Lang::tr
{'error messages'});
162 print "<class name='base'>$errormessage\n";
163 print " </class>\n";
168 # Found this usefull piece of code in BlockOutTraffic AddOn 8-)
173 &Header
::openbox
('100%', 'center', 'DEBUG');
175 foreach my $line (sort keys %wlanapsettings) {
176 print "$line = '$wlanapsettings{$line}'<br />\n";
179 print " Count: $debugCount\n";
186 # Driver and status detection
188 my $wlan_card_status = 'dummy';
189 my $wlan_ap_status = '';
192 $selected{'INTERFACE'}{'green0'} = '';
193 $selected{'INTERFACE'}{'blue0'} = '';
194 $selected{'ENC'}{$wlanapsettings{'INTERFACE'}} = "selected='selected'";
196 if ( ($wlanapsettings{'INTERFACE'} eq '') ){
197 $message = $Lang::tr
{'wlanap select interface'};
198 &Header
::openbox
('100%', 'center', "WLAN AP");
201 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
202 <select name='INTERFACE'>
205 if ( $netsettings{'BLUE_DEV'} ne ''){
206 print "<option value='blue0' $selected{'INTERFACE'}{'blue0'}>blue0</option>";
209 <option value='green0' $selected{'INTERFACE'}{'green0'}>green0</option>
213 <input type='submit' name='ACTION' value='$Lang::tr{'wlanap interface'}' /></form>
217 &Header
::closebigbox
();
218 &Header
::closepage
();
221 my $cmd_out = `/usr/sbin/iwconfig $wlanapsettings{'INTERFACE'} 2>/dev/null`;
223 if ( $cmd_out eq '' ){
224 $message = "$Lang::tr{'wlanap no interface'}";
225 $wlan_card_status = '';
227 $cmd_out = `/sbin/ifconfig | /bin/grep $wlanapsettings{'INTERFACE'}`;
228 if ( $cmd_out eq '' ){
229 $wlan_card_status = 'down';
231 $wlan_card_status = 'up';
232 $cmd_out = `/usr/sbin/iwconfig $wlanapsettings{'INTERFACE'} | /bin/grep "Mode:Master"`;
233 if ( $cmd_out ne '' ){
234 $wlan_ap_status = 'up';
240 # Change old "n" to "gn"
241 if ( $wlanapsettings{'HW_MODE'} eq 'n' ) {
242 $wlanapsettings{'HW_MODE'}='gn';
245 $checked{'HIDESSID'}{'off'} = '';
246 $checked{'HIDESSID'}{'on'} = '';
247 $checked{'HIDESSID'}{$wlanapsettings{'HIDESSID'}} = "checked='checked'";
249 $selected{'ENC'}{$wlanapsettings{'ENC'}} = "selected='selected'";
250 $selected{'CHANNEL'}{$wlanapsettings{'CHANNEL'}} = "selected='selected'";
251 $selected{'COUNTRY'}{$wlanapsettings{'COUNTRY'}} = "selected='selected'";
252 $selected{'TXPOWER'}{$wlanapsettings{'TXPOWER'}} = "selected='selected'";
253 $selected{'HW_MODE'}{$wlanapsettings{'HW_MODE'}} = "selected='selected'";
254 $selected{'MACMODE'}{$wlanapsettings{'MACMODE'}} = "selected='selected'";
256 my $monwlaninterface = $wlanapsettings{'INTERFACE'};
257 if ( -d
'/sys/class/net/mon.'.$wlanapsettings{'INTERFACE'} ) {
258 $monwlaninterface = 'mon.'.$wlanapsettings{'INTERFACE'};
264 if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){
265 my $wiphy = `iw dev $wlanapsettings{'INTERFACE'} info | grep wiphy | cut -d" " -f2`;
268 @channellist_cmd = `iw phy phy$wiphy info | grep " MHz \\\[" | grep -v "(disabled)" | grep -v "no IBSS" | grep -v "passive scanning" 2>/dev/null`;
269 # get available channels
272 foreach (@channellist_cmd){
273 $_ =~ /(.*) \[(\d+)(.*)\]/;
274 $channel = $2;chomp $channel;
275 if ( $channel =~ /\d+/ ){push(@temp,$channel);}
277 @channellist = @temp;
279 @channellist_cmd = `iwlist $monwlaninterface channel|tail -n +2 2>/dev/null`;
280 # get available channels
283 foreach (@channellist_cmd){
284 $_ =~ /(.*)Channel (\d+)(.*):/;
285 $channel = $2;chomp $channel;
286 if ( $channel =~ /\d+/ ){push(@temp,$channel);}
288 @channellist = @temp;
291 my @countrylist_cmd = `regdbdump /usr/lib/crda/regulatory.bin 2>/dev/null`;
292 # get available country codes
295 foreach (@countrylist_cmd){
296 $_ =~ /country (.*):/;
297 $country = $1;chomp $country;
298 if ( $country =~ /[0,A-Z][0,A-Z]/ ) {push(@temp,$country);}
300 my @countrylist = @temp;
302 my @txpower_cmd = `iwlist $monwlaninterface txpower 2>/dev/null`;
303 if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){
304 # There is a bug with NL80211 only all devices can displayed
305 @txpower_cmd = `iwlist txpower 2>/dev/null | sed -e "s|unknown transmit-power information.||g"`;
307 # get available power
310 foreach (@txpower_cmd){
311 $_ =~ /(\s)(\d+)(\s)dBm(\s)(.*)(\W)(\d+)(.*)/;
312 $txpower = $7;chomp $txpower;
313 if ( $txpower =~ /\d+/ ){push(@temp,$txpower."mW");}
316 push(@txpower,"auto");
318 $selected{'SYSLOGLEVEL'}{$wlanapsettings{'SYSLOGLEVEL'}} = "selected='selected'";
319 $selected{'DEBUG'}{$wlanapsettings{'DEBUG'}} = "selected='selected'";
324 &Header
::openbox
('100%', 'center', "WLAN AP");
326 <table width='80%' cellspacing='1' class='tbl'>
330 if ( $wlan_card_status ne '' ){
331 print "<tr><th align='left' width='50%'><strong>$Lang::tr{'service'}</strong></th><th width='22%'>Status</th><th width='10%'>PID</th><th width='15%'>$Lang::tr{'memory'}</th><th colspan='2'width='5%'>$Lang::tr{'action'}</th></tr>";
332 print "<tr><td class='base'>$Lang::tr{'wlanap wlan card'} ($wlanapsettings{'DRIVER'})</td>";
333 print $wlan_card_status eq 'up' ?
$status_started : $status_stopped;
334 print"<td colspan='4'></td></tr>";
335 print "<tr><td class='base' bgcolor='$color{'color22'}'>$Lang::tr{'wlanap access point'}</td>";
336 print $wlan_ap_status eq 'up' ?
$status_started : $status_stopped;
337 if ( ($memory != 0) && (@pid[0] ne "///") ){
338 print "<td bgcolor='$color{'color22'}' align='center'>@pid[0]</td>";
339 print "<td bgcolor='$color{'color22'}' align='center'>$memory KB</td>";
340 print "<td bgcolor='$color{'color22'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='$Lang::tr{'start'}' /><input type='image' alt='$Lang::tr{'start'}' title='$Lang::tr{'start'}' src='/images/go-up.png' /></form></td>";
341 print "<td bgcolor='$color{'color22'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='$Lang::tr{'stop'}' /><input type='image' alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' /></form></td>";
343 print"<td colspan='2' bgcolor='$color{'color22'}'></td>";
344 print "<td bgcolor='$color{'color22'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='$Lang::tr{'start'}' /><input type='image' alt='$Lang::tr{'start'}' title='$Lang::tr{'start'}' src='/images/go-up.png' /></form></td>";
345 print "<td bgcolor='$color{'color22'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='$Lang::tr{'stop'}' /><input type='image' alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' /></form></td>";
349 print "<tr><td class='base'>$message";
353 if ( $wlan_card_status eq '' ){
355 print "<table width='80%' cellspacing='0' border='0'>";
356 print "<tr align='center'>";
357 print "<td colspan='4'></td>";
359 print "<tr align='center'>";
360 print "<td width='40%'> </td>";
361 print "<td width='20%'><form method='post' action='/cgi-bin/wlanap.cgi'><input type='submit' name='ACTION' value='$Lang::tr{'wlanap del interface'}' /></form></td>";
362 print "<td width='20%'></td>";
363 print "<td width='20%'></td>";
368 if ( $wlan_card_status eq '' ){
370 &Header
::closebigbox
();
371 &Header
::closepage
();
376 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
377 <table width='80%' cellspacing='0' class='tbl' border='0'>
378 <tr><th bgcolor='$color{'color20'}' colspan='4' align='left'><strong>$Lang::tr{'wlanap wlan settings'}</strong></th></tr>
379 <tr><td colspan='4'><br></td></tr>
380 <tr><td width='25%' class='base'>SSID: </td><td class='base' colspan='3'><input type='text' name='SSID' size='30' value='$wlanapsettings{'SSID'}' /></td></tr>
381 <!--SSID Broadcast: on => HIDESSID: off -->
382 <tr><td width='25%' class='base'>SSID Broadcast: </td><td class='base' colspan='3'>on <input type='radio' name='HIDESSID' value='off' $checked{'HIDESSID'}{'off'} /> | <input type='radio' name='HIDESSID' value='on' $checked{'HIDESSID'}{'on'} /> off</td></tr>
385 <tr><td width='25%' class='base'>$Lang::tr{'wlanap country'}: </td><td class='base' colspan='3'>
386 <select name='COUNTRY'>
389 foreach $country (@countrylist){
390 print "<option $selected{'COUNTRY'}{$country}>$country</option>";
394 <tr><td width='25%' class='base'>HW Mode: </td><td class='base' colspan='3'>
395 <select name='HW_MODE'>
396 <option value='a' $selected{'HW_MODE'}{'a'}>802.11a</option>
397 <option value='b' $selected{'HW_MODE'}{'b'}>802.11b</option>
398 <option value='g' $selected{'HW_MODE'}{'g'}>802.11g</option>
399 <option value='an' $selected{'HW_MODE'}{'an'}>802.11an</option>
400 <option value='gn' $selected{'HW_MODE'}{'gn'}>802.11gn</option>
406 if ( scalar @channellist > 0 ){
408 <tr><td width='25%' class='base'>$Lang::tr{'wlanap channel'}: </td><td class='base' colspan='3'>
409 <select name='CHANNEL'>
412 foreach $channel (@channellist){
413 print "<option $selected{'CHANNEL'}{$channel}>$channel</option>";
415 print "</select></td></tr>"
418 <tr><td width='25%' class='base'>$Lang::tr{'wlanap channel'}: </td><td class='base' colspan='3'>
419 <input type='text' name='CHANNEL' size='10' value='$wlanapsettings{'CHANNEL'}' />
425 <tr><td colspan='4'><br></td></tr>
426 <tr><td width='25%' class='base'>$Lang::tr{'wlanap encryption'}: </td><td class='base' colspan='3'>
428 <option value='none' $selected{'ENC'}{'none'}>$Lang::tr{'wlanap none'}</option>
429 <option value='wpa1' $selected{'ENC'}{'wpa1'}>WPA1</option>
430 <option value='wpa2' $selected{'ENC'}{'wpa2'}>WPA2</option>
431 <option value='wpa1+2' $selected{'ENC'}{'wpa1+2'}>WPA1+2</option>
434 <tr><td width='25%' class='base'>Passphrase: </td><td class='base' colspan='3'><input type='text' name='PWD' size='30' value='$wlanapsettings{'PWD'}' /></td></tr>
435 <tr><td colspan='4'><br></td></tr>
439 <tr><td width='25%' class='base'>HT Caps: </td><td class='base' colspan='3'><input type='text' name='HTCAPS' size='30' value='$wlanapsettings{'HTCAPS'}' /></td></tr>
440 <tr><td width='25%' class='base'>Tx Power: </td><td class='base' colspan='3'>
444 if ( $wlanapsettings{'DRIVER'} eq 'MADWIFI' ){
445 print "<select name='TXPOWER'>";
446 foreach $txpower (@txpower){
447 print "<option $selected{'TXPOWER'}{$txpower}>$txpower</option> dBm";
449 print " </select></td></tr>";
451 print "<input type='text' name='TXPOWER' size='10' value='$wlanapsettings{'TXPOWER'}' /></td></tr>"
454 <tr><td width='25%' class='base'>Loglevel (hostapd): </td><td class='base' width='25%'>
455 <select name='SYSLOGLEVEL'>
456 <option value='0' $selected{'SYSLOGLEVEL'}{'0'}>0 ($Lang::tr{'wlanap verbose'})</option>
457 <option value='1' $selected{'SYSLOGLEVEL'}{'1'}>1 ($Lang::tr{'wlanap debugging'})</option>
458 <option value='2' $selected{'SYSLOGLEVEL'}{'2'}>2 ($Lang::tr{'wlanap informations'})</option>
459 <option value='3' $selected{'SYSLOGLEVEL'}{'3'}>3 ($Lang::tr{'wlanap notifications'})</option>
460 <option value='4' $selected{'SYSLOGLEVEL'}{'4'}>4 ($Lang::tr{'wlanap warnings'})</option>
463 <td width='25%' class='base'>Debuglevel (hostapd): </td><td class='base' width='25%'>
464 <select name='DEBUG'>
465 <option value='0' $selected{'DEBUG'}{'0'}>0 ($Lang::tr{'wlanap verbose'})</option>
466 <option value='1' $selected{'DEBUG'}{'1'}>1 ($Lang::tr{'wlanap debugging'})</option>
467 <option value='2' $selected{'DEBUG'}{'2'}>2 ($Lang::tr{'wlanap informations'})</option>
468 <option value='3' $selected{'DEBUG'}{'3'}>3 ($Lang::tr{'wlanap notifications'})</option>
469 <option value='4' $selected{'DEBUG'}{'4'}>4 ($Lang::tr{'wlanap warnings'})</option>
472 <tr><td colspan='4'><br></td></tr>
476 if ( $wlanapsettings{'INTERFACE'} =~ /green0/ ){
479 <table width='80%' cellspacing='0' class='tbl' border='1'>
481 <th colspan='3' align='left'>$Lang::tr{'mac filter'}</th>
483 <td width='25%' class='base'>Mac Filter: </td><td class='base' width='25%'>
484 <select name='MACMODE'>
485 <option value='0' $selected{'MACMODE'}{'0'}>0 (off)</option>
486 <option value='1' $selected{'MACMODE'}{'1'}>1 (Accept MACs)</option>
487 <option value='2' $selected{'MACMODE'}{'2'}>2 (Deny MACs)</option>
489 </td><td colspan='2'>Mac Adress List (one per line)<br /><textarea name='MACS' cols='20' rows='5' wrap='off'>
492 print `cat /var/ipfire/wlanap/macfile`;
501 <table width='80%' cellspacing='0'>
502 <tr><td align='center'>
503 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
504 <input type='hidden' name='ACTION' value=$Lang::tr{'save'} />
505 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' /></form></td>
511 if ( $wlanapsettings{'DRIVER'} eq 'MADWIFI' ){
512 @status = `wlanconfig $wlanapsettings{'INTERFACE'} list`;
514 if ( $wlanapsettings{'DRIVER'} eq 'NL80211' ){
515 @status = `iw dev $wlanapsettings{'INTERFACE'} info && iw dev $wlanapsettings{'INTERFACE'} station dump && echo ""`;
519 <table width='80%' cellspacing='0' class='tbl'>
520 <tr><th colspan='3' bgcolor='$color{'color20'}' align='left'><strong>$Lang::tr{'wlanap wlan status'}</strong></th></tr>
524 for (my $i=0;$i<$#status;$i++){
526 if (@status[$i]=~"^Station ") { $count++; }
528 $col="bgcolor='$color{'color20'}'";
530 $col="bgcolor='$color{'color22'}'";
532 print"<tr><td colspan='3' $col><pre>@status[$i]</pre></td></tr>";
533 if (! @status[$i]=~"^/t" ) { $count++; }
537 foreach my $nr (@channellist_cmd){
539 $col="bgcolor='$color{'color20'}'";
541 $col="bgcolor='$color{'color22'}'";
543 print"<tr><td colspan='3' $col>$nr</td></tr>";
547 for (my $i=0;$i<$#txpower_cmd;$i=$i+2){
549 $col="bgcolor='$color{'color20'}'";
551 $col="bgcolor='$color{'color22'}'";
553 print "<tr><td $col>@txpower_cmd[$i]</td></tr>";
556 print "</table><br>";
559 <table width='80%' cellspacing='0' class='tbl' border='0'>
560 <tr><td bgcolor='$color{'color20'}' align='left'><strong>$Lang::tr{'wlan clients'}</strong></td></tr>
561 <tr><td> <a href="/cgi-bin/wireless.cgi">$Lang::tr{'wlanap link wireless'}</a></td></tr>
562 <tr><td> <a href="/cgi-bin/dhcp.cgi">$Lang::tr{'wlanap link dhcp'}</a></td></tr>
563 <tr><td><br></td></tr>
569 &Header
::closebigbox
();
570 &Header
::closepage
();
572 sub WriteConfig_hostapd
{
573 $wlanapsettings{'DRIVER_HOSTAPD'} = lc($wlanapsettings{'DRIVER'});
575 open (CONFIGFILE
, ">/var/ipfire/wlanap/hostapd.conf");
576 print CONFIGFILE
<<END
577 driver=$wlanapsettings{'DRIVER_HOSTAPD'}
578 ######################### basic hostapd configuration ##########################
580 interface=$wlanapsettings{'INTERFACE'}
581 country_code=$wlanapsettings{'COUNTRY'}
584 channel=$wlanapsettings{'CHANNEL'}
587 if ( $wlanapsettings{'HW_MODE'} eq 'an' ){
588 print CONFIGFILE
<<END
592 ht_capab=$wlanapsettings{'HTCAPS'}
596 }elsif ( $wlanapsettings{'HW_MODE'} eq 'gn' ){
597 print CONFIGFILE
<<END
601 ht_capab=$wlanapsettings{'HTCAPS'}
606 print CONFIGFILE
<<END
607 hw_mode=$wlanapsettings{'HW_MODE'}
613 print CONFIGFILE
<<END
615 logger_syslog_level=$wlanapsettings{'SYSLOGLEVEL'}
617 logger_stdout_level=$wlanapsettings{'DEBUG'}
618 dump_file=/tmp/hostapd.dump
620 ctrl_interface=/var/run/hostapd
621 ctrl_interface_group=0
624 if ( $wlanapsettings{'HIDESSID'} eq 'on' ){
625 print CONFIGFILE
<<END
626 ssid=$wlanapsettings{'SSID'}
627 ignore_broadcast_ssid=2
632 print CONFIGFILE
<<END
633 ssid=$wlanapsettings{'SSID'}
634 ignore_broadcast_ssid=0
640 if ( $wlanapsettings{'ENC'} eq 'wpa1'){
641 print CONFIGFILE
<<END
642 ######################### wpa hostapd configuration ############################
645 wpa_passphrase=$wlanapsettings{'PWD'}
650 }elsif ( $wlanapsettings{'ENC'} eq 'wpa2'){
651 print CONFIGFILE
<<END
652 ######################### wpa hostapd configuration ############################
655 wpa_passphrase=$wlanapsettings{'PWD'}
660 } elsif ( $wlanapsettings{'ENC'} eq 'wpa1+2'){
661 print CONFIGFILE
<<END
662 ######################### wpa hostapd configuration ############################
665 wpa_passphrase=$wlanapsettings{'PWD'}
674 open (MACFILE
, ">/var/ipfire/wlanap/macfile");
678 if ( $_ ne "" ){print MACFILE
$_;}