]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/wirelessclient.cgi
Merge remote-tracking branch 'origin/master' into next
[ipfire-2.x.git] / html / cgi-bin / wirelessclient.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Team <info@ipfire.org> #
6 # #
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. #
11 # #
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. #
16 # #
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/>. #
19 # #
20 ###############################################################################
21
22 # DEVICE,ENABLED,MODE,WPA_MODE,SSID,PSK,PRIO
23 # wlan0,on,WPA2,,Use This One Mum,ThisIsTheKey,2
24
25 use strict;
26
27 # enable only the following on debugging purpose
28 use warnings;
29 use CGI::Carp 'fatalsToBrowser';
30
31 require '/var/ipfire/general-functions.pl';
32 require "${General::swroot}/lang.pl";
33 require "${General::swroot}/header.pl";
34
35 #workaround to suppress a warning when a variable is used only once
36 my @dummy = ( ${Header::colouryellow} );
37 undef (@dummy);
38
39 # Files used
40 my $setting = "${General::swroot}/main/settings";
41 our $datafile = "${General::swroot}/ethernet/wireless";
42
43 my %color = ();
44 my %mainsettings = ();
45 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
46 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
47
48 our %settings = ();
49 our %netsettings = ();
50
51 $settings{'ID'} = '';
52 $settings{'INTERFACE'} = '';
53 $settings{'ENABLED'} = '';
54 $settings{'ENCRYPTION'} = '';
55 $settings{'WPA_MODE'} = '';
56 $settings{'SSID'} = '';
57 $settings{'PSK'} = '';
58 $settings{'PRIO'} = '';
59
60 $settings{'ACTION'} = ''; # add/edit/remove
61 $settings{'ID'} = ''; # point record for ACTION
62
63 my $errormessage = '';
64 my $warnmessage = '';
65
66 &Header::showhttpheaders();
67
68 #Get GUI values
69 &Header::getcgihash(\%settings);
70
71 # Load multiline data
72 our @configs = ();
73 if (open(FILE, "$datafile")) {
74 @configs = <FILE>;
75 close (FILE);
76 }
77
78 &General::readhash("${General::swroot}/main/settings", \%settings);
79 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
80
81 # Toggle enable/disable field.
82 if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
83 my @update;
84
85 foreach my $line (@configs) {
86 chomp($line);
87 my @config = split(/\,/, $line);
88
89 # Update the entry with the matching ID.
90 if ($config[0] eq $settings{'ID'}) {
91 # Toggle enabled/disabled status.
92
93 if ($config[2] eq 'on') {
94 $config[2] = 'off';
95 } else {
96 $config[2] = 'on';
97 }
98
99 $line = join(',', @config);
100 }
101
102 push(@update, $line."\n");
103 }
104
105 # Save updated configuration settings.
106 open(FILE, ">$datafile") or die 'wlan client datafile error';
107 print FILE @update;
108 close(FILE);
109
110 @configs = @update;
111
112 # Update configuration files.
113 &BuildConfiguration();
114
115 # Reset ACTION.
116 $settings{'ACTION'} = '';
117 }
118
119 if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
120 # Validate input data.
121 $errormessage = ValidateInput("add");
122
123 unless ($errormessage) {
124 # Search for the next free id.
125 my $next_id = NextID();
126
127 my @config = ($next_id);
128 push(@config, $settings{'INTERFACE'});
129 push(@config, $settings{'ENABLED'});
130 push(@config, $settings{'ENCRYPTION'});
131 push(@config, $settings{'WPA_MODE'});
132 push(@config, $settings{'SSID'});
133 push(@config, $settings{'PSK'});
134 push(@config, $settings{'PRIO'});
135
136 # Add the new configuration and write all the stuff to the configuration file.
137 my $line = join(',', @config) . "\n";
138 push(@configs, $line);
139
140 # Save updated configuration settings.
141 open(FILE, ">$datafile") or die 'wlan client datafile error';
142 print FILE @configs;
143 close(FILE);
144
145 # Update configuration files.
146 &BuildConfiguration();
147
148 # Reset ACTION.
149 $settings{'ACTION'} = '';
150 }
151 }
152
153 if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
154 foreach my $line (@configs) {
155 chomp($line);
156 my @config = split(/\,/, $line);
157
158 if ($config[0] eq $settings{'ID'}) {
159 $settings{'ID'} = $config[0];
160 $settings{'INTERFACE'} = $config[1];
161 $settings{'ENABLED'} = $config[2];
162 $settings{'ENCRYPTION'} = $config[3];
163 $settings{'WPA_MODE'} = $config[4];
164 $settings{'SSID'} = $config[5];
165 $settings{'PSK'} = $config[6];
166 $settings{'PRIO'} = $config[7];
167 }
168 }
169 }
170
171 if ($settings{'ACTION'} eq $Lang::tr{'update'}) {
172 $errormessage = ValidateInput("update");
173
174 unless ($errormessage) {
175 my @update;
176 foreach my $line (@configs) {
177 chomp($line);
178 my @config = split(/\,/, $line);
179
180 # Update the entry with the matching ID.
181 if ($config[0] eq $settings{'ID'}) {
182 # Update all configuration settings.
183 # ID and INTERFACE cannot be changed.
184 $config[2] = $settings{'ENABLED'};
185 $config[3] = $settings{'ENCRYPTION'};
186 $config[4] = $settings{'WPA_MODE'};
187 $config[5] = $settings{'SSID'};
188 $config[6] = $settings{'PSK'};
189 $config[7] = $settings{'PRIO'};
190
191 $line = join(',', @config);
192 }
193
194 push(@update, $line."\n");
195 }
196
197 # Save updated configuration settings.
198 open(FILE, ">$datafile") or die 'wlan client datafile error';
199 print FILE @update;
200 close(FILE);
201
202 @configs = @update;
203
204 # Update configuration files.
205 &BuildConfiguration();
206
207 # Reset ACTION.
208 $settings{'ACTION'} = '';
209 }
210 }
211
212 if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
213 my @update;
214
215 foreach my $line (@configs) {
216 chomp($line);
217 my @config = split(/\,/, $line);
218
219 # Skip the to be removed entry.
220 if ($config[0] eq $settings{'ID'}) {
221 next;
222 }
223
224 push(@update, $line."\n");
225 }
226
227 # Save updated configuration settings.
228 open(FILE, ">$datafile") or die 'wlan client datafile error';
229 print FILE @update;
230 close(FILE);
231
232 @configs = @update;
233
234 # Update configuration files.
235 &BuildConfiguration();
236
237 # Reset ACTION.
238 $settings{'ACTION'} = '';
239 }
240
241 if ($settings{'ACTION'} eq '') { # First launch from GUI
242 &showMainBox();
243 } else {
244 # Action has been set, so show the edit box.
245 &showEditBox();
246 }
247
248 sub showMainBox() {
249 &Header::openpage($Lang::tr{'wlan client configuration'}, 1, '');
250 &Header::openbigbox('100%', 'left', '', $errormessage);
251
252 &Header::openbox('100%', 'left', $Lang::tr{'wlan client configuration'});
253
254 print <<END;
255 <form method='POST' action='$ENV{'SCRIPT_NAME'}' style='text-align: center;'>
256 <input type='submit' name='ACTION' value='$Lang::tr{'wlan client new network'}' />
257 </form>
258
259 <br><hr><br>
260
261 <table width="100%" class='tbl'>
262 <tr>
263 <th align='center'>$Lang::tr{'wlan client ssid'}</th>
264 <th align='center'>$Lang::tr{'wlan client encryption'}</th>
265 <th align='center'>$Lang::tr{'priority'}</th>
266 <th></th>
267 <th></th>
268 <th></th>
269 </tr>
270 END
271
272 #
273 # Print each line of @configs list
274 #
275
276 my $key = 0;
277 my $col="";
278 foreach my $line (@configs) {
279 # Skip commented lines.
280 my $firstchar = substr($line, 0, 1);
281 next if ($firstchar eq "#");
282
283 chomp($line);
284 my @config = split(/\,/,$line);
285
286 #Choose icon for checkbox
287 my $gif = '';
288 my $gdesc = '';
289 if ($config[2] eq 'on' ) {
290 $gif = 'on.gif';
291 $gdesc = $Lang::tr{'click to disable'};
292 } else {
293 $gif = 'off.gif';
294 $gdesc = $Lang::tr{'click to enable'};
295 }
296
297 # Colorize each line
298 if ($key % 2) {
299 print "<tr>";
300 $col="bgcolor='$color{'color20'}'";
301 } else {
302 print "<tr>";
303 $col="bgcolor='$color{'color22'}'";
304 }
305
306 my $encryption_mode = $Lang::tr{'unknown'};
307 if ($config[3] eq "NONE") {
308 $encryption_mode = $Lang::tr{'wlan client encryption none'};
309 } elsif ($config[3] eq "WEP") {
310 $encryption_mode = $Lang::tr{'wlan client encryption wep'};
311 } elsif ($config[3] eq "WPA") {
312 $encryption_mode = $Lang::tr{'wlan client encryption wpa'};
313 } elsif ($config[3] eq "WPA2") {
314 $encryption_mode = $Lang::tr{'wlan client encryption wpa2'};
315 }
316
317 if (($config[3] eq "WPA") || ($config[3] eq "WPA2")) {
318 my $wpa_pairwise = "$Lang::tr{'wlan client ccmp'} $Lang::tr{'wlan client and'} $Lang::tr{'wlan client tkip'}";
319 my $wpa_group = "$Lang::tr{'wlan client ccmp'} $Lang::tr{'wlan client and'} $Lang::tr{'wlan client tkip'}";
320
321 if ($config[4] eq "CCMP-CCMP") {
322 $wpa_pairwise = $Lang::tr{'wlan client ccmp'};
323 $wpa_group = $Lang::tr{'wlan client ccmp'};
324 } elsif ($config[4] eq "CCMP-TKIP") {
325 $wpa_pairwise = $Lang::tr{'wlan client ccmp'};
326 $wpa_group = $Lang::tr{'wlan client tkip'};
327 } elsif ($config[4] eq "TKIP-TKIP") {
328 $wpa_pairwise = $Lang::tr{'wlan client tkip'};
329 $wpa_group = $Lang::tr{'wlan client tkip'};
330 }
331
332 $encryption_mode .= "<hr>";
333 $encryption_mode .= "<strong>$Lang::tr{'wlan client pairwise key algorithm'}</strong>: ";
334 $encryption_mode .= $wpa_pairwise;
335 $encryption_mode .= "<br>";
336 $encryption_mode .= "<strong>$Lang::tr{'wlan client group key algorithm'}</strong>: ";
337 $encryption_mode .= $wpa_group;
338 }
339
340 print <<END;
341 <td align='center' $col>$config[5]</td>
342 <td align='center' $col>$encryption_mode</td>
343 <td align='center' $col>$config[7]</td>
344 <td align='center' width='5%' $col>
345 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
346 <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
347 <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
348 <input type='hidden' name='ID' value='$config[0]' />
349 </form>
350 </td>
351 <td align='center' width='5%' $col>
352 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
353 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
354 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
355 <input type='hidden' name='ID' value='$config[0]' />
356 </form>
357 </td>
358 <td align='center' width='5%' $col>
359 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
360 <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
361 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
362 <input type='hidden' name='ID' value='$config[0]' />
363 </form>
364 </td>
365 </tr>
366 END
367 $key++;
368 }
369 print "</table>";
370
371 # If table contains entries, print 'Key to action icons'
372 if ($key) {
373 print <<END;
374 <table>
375 <tr>
376 <td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
377 <td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
378 <td class='base'>$Lang::tr{'click to disable'}</td>
379 <td>&nbsp;&nbsp;</td>
380 <td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
381 <td class='base'>$Lang::tr{'click to enable'}</td>
382 <td>&nbsp;&nbsp;</td>
383 <td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
384 <td class='base'>$Lang::tr{'edit'}</td>
385 <td>&nbsp;&nbsp;</td>
386 <td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
387 <td class='base'>$Lang::tr{'remove'}</td>
388 </tr>
389 </table>
390 END
391 }
392
393 &Header::closebox();
394
395 # Show status box.
396 &ShowStatus();
397
398 &Header::closebigbox();
399 &Header::closepage();
400 }
401
402 sub showEditBox() {
403 &Header::openpage($Lang::tr{'wlan client configuration'}, 1, '');
404 &Header::openbigbox('100%', 'left', '', $errormessage);
405
406 if ($errormessage) {
407 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
408 print "<font class='base'>$errormessage&nbsp;</font>";
409 &Header::closebox();
410 }
411
412 my $buttontext = $Lang::tr{'add'};
413 if ($settings{'ID'} ne '') {
414 $buttontext = $Lang::tr{'update'};
415 &Header::openbox('100%', 'left', $Lang::tr{'wlan client edit entry'});
416 } else {
417 &Header::openbox('100%', 'left', $Lang::tr{'wlan client new entry'});
418 $settings{'ENABLED'} = 'on';
419 }
420 my $action = $buttontext;
421
422 my %checked = ();
423 $checked{'ENABLED'} = ($settings{'ENABLED'} ne 'on' ) ? '' : "checked='checked'";
424
425 my %selected = ();
426 $selected{'ENCRYPTION'} = ();
427 $selected{'ENCRYPTION'}{'NONE'} = '';
428 $selected{'ENCRYPTION'}{'WPA2'} = '';
429 $selected{'ENCRYPTION'}{'WPA'} = '';
430 $selected{'ENCRYPTION'}{'WEP'} = '';
431 $selected{'ENCRYPTION'}{$settings{'ENCRYPTION'}} = "selected='selected'";
432
433 $selected{'WPA_MODE'} = ();
434 $selected{'WPA_MODE'}{''} = '';
435 $selected{'WPA_MODE'}{'CCMP-CCMP'} = '';
436 $selected{'WPA_MODE'}{'CCMP-TKIP'} = '';
437 $selected{'WPA_MODE'}{'TKIP-TKIP'} = '';
438 $selected{'WPA_MODE'}{$settings{'WPA_MODE'}} = "selected='selected'";
439
440 $selected{'PRIO'} = ();
441 $selected{'PRIO'}{'0'} = '';
442 $selected{'PRIO'}{'1'} = '';
443 $selected{'PRIO'}{'2'} = '';
444 $selected{'PRIO'}{'3'} = '';
445 $selected{'PRIO'}{'4'} = '';
446 $selected{'PRIO'}{$settings{'PRIO'}} = "selected='selected'";
447
448 print <<END;
449 <form method='POST' action='$ENV{'SCRIPT_NAME'}'>
450 <input type='hidden' name='ID' value='$settings{'ID'}'>
451
452 <table width='100%'>
453 <tr>
454 <td class='base' width='20%'>$Lang::tr{'wlan client ssid'}:</td>
455 <td width='40%'><input type='text' name='SSID' value="$settings{'SSID'}" size='25'/></td>
456 <td class='base' width='10%'>$Lang::tr{'enabled'}</td>
457 <td width='30%'><input type='checkbox' name='ENABLED' $checked{'ENABLED'} /></td>
458 </tr>
459 <tr>
460 <td class='base' width='20%'>$Lang::tr{'wlan client encryption'}:</td>
461 <td width='40%'>
462 <select name='ENCRYPTION'>
463 <option value="NONE" $selected{'ENCRYPTION'}{'NONE'}>$Lang::tr{'wlan client encryption none'}</option>
464 <option value="WPA2" $selected{'ENCRYPTION'}{'WPA2'}>$Lang::tr{'wlan client encryption wpa2'}</option>
465 <option value="WPA" $selected{'ENCRYPTION'}{'WPA'}>$Lang::tr{'wlan client encryption wpa'}</option>
466 <option value="WEP" $selected{'ENCRYPTION'}{'WEP'}>$Lang::tr{'wlan client encryption wep'}</option>
467 </select>
468 </td>
469 <td colspan="2" width='40%'></td>
470 </tr>
471 <tr>
472 <td class='base' width='20%'>$Lang::tr{'wlan client psk'}:&nbsp;</td>
473 <td width='40%'><input type='password' name='PSK' value="$settings{'PSK'}" size='25'/></td>
474 <td colspan="2" width='40%'></td>
475 </tr>
476 </table>
477
478 <br>
479 <hr>
480
481 <strong>
482 $Lang::tr{'wlan client advanced settings'}:
483 </strong>
484
485 <table width='100%'>
486 <tr>
487 <td class='base' width='20%'>
488 $Lang::tr{'wlan client wpa mode'}:
489 </td>
490 <td width='40%'>
491 <select name='WPA_MODE'>
492 <option value="" $selected{'WPA_MODE'}{''}>$Lang::tr{'wlan client wpa mode all'}</option>
493 <option value="CCMP-CCMP" $selected{'WPA_MODE'}{'CCMP-CCMP'}>$Lang::tr{'wlan client wpa mode ccmp ccmp'}</option>
494 <option value="CCMP-TKIP" $selected{'WPA_MODE'}{'CCMP-TKIP'}>$Lang::tr{'wlan client wpa mode ccmp tkip'}</option>
495 <option value="TKIP-TKIP" $selected{'WPA_MODE'}{'TKIP-TKIP'}>$Lang::tr{'wlan client wpa mode tkip tkip'}</option>
496 </select>
497 </td>
498 <td colspan="2" width='40%'>
499 <em>($Lang::tr{'wlan client pairwise key group key'})</em>
500 </td>
501 </tr>
502 <tr>
503 <td class='base' width='20%'>
504 $Lang::tr{'priority'}:
505 </td>
506 <td width='40%'>
507 <select name='PRIO'>
508 <option value="0" $selected{'PRIO'}{'0'}>0 ($Lang::tr{'most preferred'})</option>
509 <option value="1" $selected{'PRIO'}{'1'}>1</option>
510 <option value="2" $selected{'PRIO'}{'2'}>2</option>
511 <option value="3" $selected{'PRIO'}{'3'}>3</option>
512 <option value="4" $selected{'PRIO'}{'4'}>4 ($Lang::tr{'least preferred'})</option>
513 </select>
514 </td>
515 <td colspan="2" width='40%'></td>
516 </tr>
517 </table>
518
519 <br>
520 <hr>
521
522 <table width='100%'>
523 <tr>
524 <td width='50%' align='center'>
525 <input type='hidden' name='ACTION' value='$action' />
526 <input type='submit' name='SUBMIT' value='$buttontext' />
527 </td>
528 </tr>
529 </table>
530 </form>
531 END
532 &Header::closebox();
533
534 &Header::closebigbox();
535 &Header::closepage();
536 }
537
538 sub ShowStatus() {
539 my $device = $netsettings{'RED_DEV'};
540
541 # Exit if no device is configured.
542 return if ($device eq "");
543
544 # Exit if wpa_supplicant is not running on this interface.
545 #return if (! -e "/var/run/wpa_supplicant/$device");
546
547 open(FILE, "/usr/local/bin/wirelessclient status |");
548
549 my %status = ();
550 while (<FILE>) {
551 chomp($_);
552
553 my ($key, $value) = split("=", $_);
554 $status{$key} = $value;
555 }
556
557 close(FILE);
558
559 # End here, if no there is no input.
560 return if (!keys %status);
561
562 &Header::openbox('100%', 'left', $Lang::tr{'status'});
563
564 if ($status{'ssid'} eq "") {
565 print "<p>$Lang::tr{'wlan client disconnected'}</p>";
566
567 } else {
568 print <<END;
569 <table width='100%'>
570 <tr>
571 <td width='20%'>
572 $Lang::tr{'wlan client ssid'}
573 </td>
574 <td width='80%'>
575 $status{'ssid'}
576 </td>
577 </tr>
578 <tr>
579 <td width='20%'>
580 $Lang::tr{'wlan client bssid'}
581 </td>
582 <td width='80%'>
583 $status{'bssid'}
584 </td>
585 </tr>
586 END
587
588 if (($status{'pairwise_cipher'} ne "NONE") || ($status{'group_cipher'} ne "NONE")) {
589 print <<END;
590 <tr>
591 <td colspan='2'>
592 <strong>$Lang::tr{'wlan client encryption wpa'}</strong>
593 </td>
594 </tr>
595 <tr>
596 <td width='20%'>
597 $Lang::tr{'wlan client pairwise cipher'}
598 </td>
599 <td width='80%'>
600 $status{'pairwise_cipher'}
601 </td>
602 </tr>
603 <tr>
604 <td width='20%'>
605 $Lang::tr{'wlan client group cipher'}
606 </td>
607 <td width='80%'>
608 $status{'group_cipher'}
609 </td>
610 </tr>
611 END
612 }
613
614 print "</table>";
615 }
616
617 &Header::closebox();
618 }
619
620 sub BuildConfiguration() {
621 system("/usr/local/bin/wirelessclient restart");
622 }
623
624 sub NextID() {
625 my $highest_id = 0;
626 foreach my $line (@configs) {
627 # Skip commented lines.
628 my $firstchar = substr($line, 0, 1);
629 next if ($firstchar eq "#");
630
631 my @config = split(/\,/, $line);
632 if ($config[0] > $highest_id) {
633 $highest_id = $config[0];
634 }
635 }
636
637 return $highest_id + 1;
638 }
639
640 sub DuplicateSSID($) {
641 my $ssid = shift;
642
643 foreach my $line (@configs) {
644 # Skip commented lines.
645 my $firstchar = substr($line, 0, 1);
646 next if ($firstchar eq "#");
647
648 my @config = split(/\,/, $line);
649 if ($config[5] eq $ssid) {
650 return 1;
651 }
652 }
653
654 return 0;
655 }
656
657 sub ValidKeyLength($$) {
658 my $algo = shift;
659 my $key = shift;
660
661 my $key_length = length($key);
662
663 if ($algo eq "WEP") {
664 # Key must be 13 or 26 characters.
665 if (($key_length == 13) || ($key_length == 26)) {
666 return 0;
667 }
668
669 return 1;
670
671 } elsif (($algo eq "WPA2") || ($algo eq "WPA")) {
672 # Key must be between 8 and 63 chars.
673 if (($key_length >= 8) && ($key_length <= 63)) {
674 return 0;
675 }
676
677 return 1;
678 }
679
680 # Say okay for all other algorithms.
681 return 0;
682 }
683
684 sub ValidateInput($) {
685 my $mode = shift;
686
687 # Check for duplicate SSIDs.
688 if (($mode eq "add") && (DuplicateSSID($settings{'SSID'}))) {
689 return "$Lang::tr{'wlan client duplicate ssid'}: $settings{'SSID'}";
690
691 # Check for invalid key length.
692 } elsif (ValidKeyLength($settings{'ENCRYPTION'}, $settings{'PSK'})) {
693 return "$Lang::tr{'wlan client invalid key length'}";
694
695 }
696
697 # Reset WPA mode, if WPA(2) is not selected.
698 if (($settings{'ENCRYPTION'} ne "WPA") && ($settings{'ENCRYPTION'} ne "WPA2")) {
699 $settings{'WPA_MODE'} = '';
700 }
701
702 if ($settings{'ENABLED'} ne "") {
703 $settings{'ENABLED'} = 'on';
704 } else {
705 $settings{'ENABLED'} = 'off';
706 }
707
708 return;
709 }