-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
interfaces.php
3630 lines (3162 loc) · 120 KB
/
interfaces.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
interfaces.php
*/
/* ====================================================================
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
* Copyright (c) 2006 Daniel S. Haischt
*
* Some or all of this file is based on the m0n0wall project which is
* Copyright (c) 2004 Manuel Kasper (BSD 2 clause)
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgment:
* "This product includes software developed by the pfSense Project
* for use in the pfSense software distribution. (http://www.pfsense.org/).
*
* 4. The names "pfSense" and "pfSense Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* coreteam@pfsense.org.
*
* 5. Products derived from this software may not be called "pfSense"
* nor may "pfSense" appear in their names without prior written
* permission of the Electric Sheep Fencing, LLC.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
*
* "This product includes software developed by the pfSense Project
* for use in the pfSense software distribution (http://www.pfsense.org/).
*
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/
##|+PRIV
##|*IDENT=page-interfaces
##|*NAME=Interfaces: WAN
##|*DESCR=Allow access to the 'Interfaces' page.
##|*MATCH=interfaces.php*
##|-PRIV
require_once("guiconfig.inc");
require_once("ipsec.inc");
require_once("functions.inc");
require_once("captiveportal.inc");
require_once("filter.inc");
require_once("shaper.inc");
require_once("rrd.inc");
require_once("vpn.inc");
require_once("xmlparse_attr.inc");
define("ANTENNAS", false);
if (isset($_POST['referer'])) {
$referer = $_POST['referer'];
} else {
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/interfaces.php');
}
// Get configured interface list
$ifdescrs = get_configured_interface_with_descr(false, true);
$if = "wan";
if ($_REQUEST['if']) {
$if = $_REQUEST['if'];
}
if (empty($ifdescrs[$if])) {
header("Location: interfaces.php");
exit;
}
define("CRON_MONTHLY_PATTERN", "0 0 1 * *");
define("CRON_WEEKLY_PATTERN", "0 0 * * 0");
define("CRON_DAILY_PATTERN", "0 0 * * *");
define("CRON_HOURLY_PATTERN", "0 * * * *");
if (!is_array($pconfig)) {
$pconfig = array();
}
if (!is_array($config['ppps'])) {
$config['ppps'] = array();
}
if (!is_array($config['ppps']['ppp'])) {
$config['ppps']['ppp'] = array();
}
$a_ppps = &$config['ppps']['ppp'];
function remove_bad_chars($string) {
return preg_replace('/[^a-z_0-9]/i', '', $string);
}
if (!is_array($config['gateways']['gateway_item'])) {
$config['gateways']['gateway_item'] = array();
}
$a_gateways = &$config['gateways']['gateway_item'];
$wancfg = &$config['interfaces'][$if];
$old_wancfg = $wancfg;
$old_wancfg['realif'] = get_real_interface($if);
$old_ppps = $a_ppps;
// Populate page descr if it does not exist.
if ($if == "wan" && !$wancfg['descr']) {
$wancfg['descr'] = "WAN";
} else if ($if == "lan" && !$wancfg['descr']) {
$wancfg['descr'] = "LAN";
}
/* NOTE: The code here is used to set the $pppid for the curious */
foreach ($a_ppps as $pppid => $ppp) {
if ($wancfg['if'] == $ppp['if']) {
break;
}
}
$type_disabled = (substr($wancfg['if'], 0, 3) == 'gre') ? 'disabled' : '';
if ($wancfg['if'] == $a_ppps[$pppid]['if']) {
$pconfig['pppid'] = $pppid;
$pconfig['ptpid'] = $a_ppps[$pppid]['ptpid'];
$pconfig['port'] = $a_ppps[$pppid]['ports'];
if ($a_ppps[$pppid]['type'] == "ppp") {
$pconfig['ppp_username'] = $a_ppps[$pppid]['username'];
$pconfig['ppp_password'] = base64_decode($a_ppps[$pppid]['password']);
$pconfig['phone'] = $a_ppps[$pppid]['phone'];
$pconfig['apn'] = $a_ppps[$pppid]['apn'];
} else if ($a_ppps[$pppid]['type'] == "pppoe") {
$pconfig['pppoe_username'] = $a_ppps[$pppid]['username'];
$pconfig['pppoe_password'] = base64_decode($a_ppps[$pppid]['password']);
$pconfig['provider'] = $a_ppps[$pppid]['provider'];
$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
$pconfig['pppoe_idletimeout'] = $a_ppps[$pppid]['idletimeout'];
/* ================================================ */
/* = force a connection reset at a specific time? = */
/* ================================================ */
if (isset($a_ppps[$pppid]['pppoe-reset-type'])) {
$pconfig['pppoe-reset-type'] = $a_ppps[$pppid]['pppoe-reset-type'];
$itemhash = getMPDCRONSettings($a_ppps[$pppid]['if']);
if ($itemhash) {
$cronitem = $itemhash['ITEM'];
}
if (isset($cronitem)) {
$resetTime = "{$cronitem['minute']} {$cronitem['hour']} {$cronitem['mday']} {$cronitem['month']} {$cronitem['wday']}";
} else {
$resetTime = NULL;
}
//log_error("ResetTime:".$resetTime);
if ($a_ppps[$pppid]['pppoe-reset-type'] == "custom") {
if ($cronitem) {
$pconfig['pppoe_pr_custom'] = true;
$pconfig['pppoe_resetminute'] = $cronitem['minute'];
$pconfig['pppoe_resethour'] = $cronitem['hour'];
if ($cronitem['mday'] != "*" && $cronitem['month'] != "*") {
$pconfig['pppoe_resetdate'] = "{$cronitem['month']}/{$cronitem['mday']}/" . date("Y");
}
}
} else if ($a_ppps[$pppid]['pppoe-reset-type'] == "preset") {
$pconfig['pppoe_pr_preset'] = true;
switch ($resetTime) {
case CRON_MONTHLY_PATTERN:
$pconfig['pppoe_monthly'] = true;
break;
case CRON_WEEKLY_PATTERN:
$pconfig['pppoe_weekly'] = true;
break;
case CRON_DAILY_PATTERN:
$pconfig['pppoe_daily'] = true;
break;
case CRON_HOURLY_PATTERN:
$pconfig['pppoe_hourly'] = true;
break;
}
}
} // End force pppoe reset at specific time
// End if type == pppoe
} else if ($a_ppps[$pppid]['type'] == "pptp" || $a_ppps[$pppid]['type'] == "l2tp") {
$pconfig['pptp_username'] = $a_ppps[$pppid]['username'];
$pconfig['pptp_password'] = base64_decode($a_ppps[$pppid]['password']);
$pconfig['pptp_localip'] = explode(",", $a_ppps[$pppid]['localip']);
$pconfig['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']);
$pconfig['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']);
$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
$pconfig['pptp_idletimeout'] = $a_ppps[$pppid]['timeout'];
}
} else {
$pconfig['ptpid'] = interfaces_ptpid_next();
$pppid = count($a_ppps);
}
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
$pconfig['alias-address'] = $wancfg['alias-address'];
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
$pconfig['dhcprejectfrom'] = $wancfg['dhcprejectfrom'];
$pconfig['adv_dhcp_pt_timeout'] = $wancfg['adv_dhcp_pt_timeout'];
$pconfig['adv_dhcp_pt_retry'] = $wancfg['adv_dhcp_pt_retry'];
$pconfig['adv_dhcp_pt_select_timeout'] = $wancfg['adv_dhcp_pt_select_timeout'];
$pconfig['adv_dhcp_pt_reboot'] = $wancfg['adv_dhcp_pt_reboot'];
$pconfig['adv_dhcp_pt_backoff_cutoff'] = $wancfg['adv_dhcp_pt_backoff_cutoff'];
$pconfig['adv_dhcp_pt_initial_interval'] = $wancfg['adv_dhcp_pt_initial_interval'];
$pconfig['adv_dhcp_pt_values'] = $wancfg['adv_dhcp_pt_values'];
$pconfig['adv_dhcp_send_options'] = $wancfg['adv_dhcp_send_options'];
$pconfig['adv_dhcp_request_options'] = $wancfg['adv_dhcp_request_options'];
$pconfig['adv_dhcp_required_options'] = $wancfg['adv_dhcp_required_options'];
$pconfig['adv_dhcp_option_modifiers'] = $wancfg['adv_dhcp_option_modifiers'];
$pconfig['adv_dhcp_config_advanced'] = $wancfg['adv_dhcp_config_advanced'];
$pconfig['adv_dhcp_config_file_override'] = $wancfg['adv_dhcp_config_file_override'];
$pconfig['adv_dhcp_config_file_override_path'] = $wancfg['adv_dhcp_config_file_override_path'];
$pconfig['adv_dhcp6_interface_statement_send_options'] = $wancfg['adv_dhcp6_interface_statement_send_options'];
$pconfig['adv_dhcp6_interface_statement_request_options'] = $wancfg['adv_dhcp6_interface_statement_request_options'];
$pconfig['adv_dhcp6_interface_statement_information_only_enable'] = $wancfg['adv_dhcp6_interface_statement_information_only_enable'];
$pconfig['adv_dhcp6_interface_statement_script'] = $wancfg['adv_dhcp6_interface_statement_script'];
$pconfig['adv_dhcp6_id_assoc_statement_address_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_address_enable'];
$pconfig['adv_dhcp6_id_assoc_statement_address'] = $wancfg['adv_dhcp6_id_assoc_statement_address'];
$pconfig['adv_dhcp6_id_assoc_statement_address_id'] = $wancfg['adv_dhcp6_id_assoc_statement_address_id'];
$pconfig['adv_dhcp6_id_assoc_statement_address_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_pltime'];
$pconfig['adv_dhcp6_id_assoc_statement_address_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_address_vltime'];
$pconfig['adv_dhcp6_id_assoc_statement_prefix_enable'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_enable'];
$pconfig['adv_dhcp6_id_assoc_statement_prefix'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix'];
$pconfig['adv_dhcp6_id_assoc_statement_prefix_id'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_id'];
$pconfig['adv_dhcp6_id_assoc_statement_prefix_pltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'];
$pconfig['adv_dhcp6_id_assoc_statement_prefix_vltime'] = $wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'];
$pconfig['adv_dhcp6_prefix_interface_statement_sla_id'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_id'];
$pconfig['adv_dhcp6_prefix_interface_statement_sla_len'] = $wancfg['adv_dhcp6_prefix_interface_statement_sla_len'];
$pconfig['adv_dhcp6_authentication_statement_authname'] = $wancfg['adv_dhcp6_authentication_statement_authname'];
$pconfig['adv_dhcp6_authentication_statement_protocol'] = $wancfg['adv_dhcp6_authentication_statement_protocol'];
$pconfig['adv_dhcp6_authentication_statement_algorithm'] = $wancfg['adv_dhcp6_authentication_statement_algorithm'];
$pconfig['adv_dhcp6_authentication_statement_rdm'] = $wancfg['adv_dhcp6_authentication_statement_rdm'];
$pconfig['adv_dhcp6_key_info_statement_keyname'] = $wancfg['adv_dhcp6_key_info_statement_keyname'];
$pconfig['adv_dhcp6_key_info_statement_realm'] = $wancfg['adv_dhcp6_key_info_statement_realm'];
$pconfig['adv_dhcp6_key_info_statement_keyid'] = $wancfg['adv_dhcp6_key_info_statement_keyid'];
$pconfig['adv_dhcp6_key_info_statement_secret'] = $wancfg['adv_dhcp6_key_info_statement_secret'];
$pconfig['adv_dhcp6_key_info_statement_expire'] = $wancfg['adv_dhcp6_key_info_statement_expire'];
$pconfig['adv_dhcp6_config_advanced'] = $wancfg['adv_dhcp6_config_advanced'];
$pconfig['adv_dhcp6_config_file_override'] = $wancfg['adv_dhcp6_config_file_override'];
$pconfig['adv_dhcp6_config_file_override_path'] = $wancfg['adv_dhcp6_config_file_override_path'];
$pconfig['dhcp_plus'] = isset($wancfg['dhcp_plus']);
$pconfig['descr'] = remove_bad_chars($wancfg['descr']);
$pconfig['enable'] = isset($wancfg['enable']);
if (is_array($config['aliases']['alias'])) {
foreach ($config['aliases']['alias'] as $alias) {
if ($alias['name'] == $wancfg['descr']) {
$input_errors[] = sprintf(gettext("Sorry, an alias with the name %s already exists."), $wancfg['descr']);
}
}
}
switch ($wancfg['ipaddr']) {
case "dhcp":
$pconfig['type'] = "dhcp";
break;
case "pppoe":
case "pptp":
case "l2tp":
case "ppp":
$pconfig['type'] = $wancfg['ipaddr'];
break;
default:
if (is_ipaddrv4($wancfg['ipaddr'])) {
$pconfig['type'] = "staticv4";
$pconfig['ipaddr'] = $wancfg['ipaddr'];
$pconfig['subnet'] = $wancfg['subnet'];
$pconfig['gateway'] = $wancfg['gateway'];
} else {
$pconfig['type'] = "none";
}
break;
}
switch ($wancfg['ipaddrv6']) {
case "slaac":
$pconfig['type6'] = "slaac";
break;
case "dhcp6":
$pconfig['dhcp6-duid'] = $wancfg['dhcp6-duid'];
if (!isset($wancfg['dhcp6-ia-pd-len'])) {
$wancfg['dhcp6-ia-pd-len'] = "none";
}
$pconfig['dhcp6-ia-pd-len'] = $wancfg['dhcp6-ia-pd-len'];
$pconfig['dhcp6-ia-pd-send-hint'] = isset($wancfg['dhcp6-ia-pd-send-hint']);
$pconfig['type6'] = "dhcp6";
$pconfig['dhcp6prefixonly'] = isset($wancfg['dhcp6prefixonly']);
$pconfig['dhcp6usev4iface'] = isset($wancfg['dhcp6usev4iface']);
break;
case "6to4":
$pconfig['type6'] = "6to4";
break;
case "track6":
$pconfig['type6'] = "track6";
$pconfig['track6-interface'] = $wancfg['track6-interface'];
if ($wancfg['track6-prefix-id'] == "") {
$pconfig['track6-prefix-id'] = 0;
} else {
$pconfig['track6-prefix-id'] = $wancfg['track6-prefix-id'];
}
$pconfig['track6-prefix-id--hex'] = sprintf("%x", $pconfig['track6-prefix-id']);
break;
case "6rd":
$pconfig['prefix-6rd'] = $wancfg['prefix-6rd'];
if ($wancfg['prefix-6rd-v4plen'] == "") {
$wancfg['prefix-6rd-v4plen'] = "0";
}
$pconfig['prefix-6rd-v4plen'] = $wancfg['prefix-6rd-v4plen'];
$pconfig['type6'] = "6rd";
$pconfig['gateway-6rd'] = $wancfg['gateway-6rd'];
break;
default:
if (is_ipaddrv6($wancfg['ipaddrv6'])) {
$pconfig['type6'] = "staticv6";
$pconfig['ipaddrv6'] = $wancfg['ipaddrv6'];
$pconfig['subnetv6'] = $wancfg['subnetv6'];
$pconfig['gatewayv6'] = $wancfg['gatewayv6'];
} else {
$pconfig['type6'] = "none";
}
break;
}
$pconfig['blockpriv'] = isset($wancfg['blockpriv']);
$pconfig['blockbogons'] = isset($wancfg['blockbogons']);
$pconfig['spoofmac'] = $wancfg['spoofmac'];
$pconfig['mtu'] = $wancfg['mtu'];
$pconfig['mss'] = $wancfg['mss'];
/* Wireless interface? */
if (isset($wancfg['wireless'])) {
/* Sync first to be sure it displays the actual settings that will be used */
interface_sync_wireless_clones($wancfg, false);
/* Get wireless modes */
$wlanif = get_real_interface($if);
if (!does_interface_exist($wlanif)) {
interface_wireless_clone($wlanif, $wancfg);
}
$wlanbaseif = interface_get_wireless_base($wancfg['if']);
preg_match("/^(.*?)([0-9]*)$/", $wlanbaseif, $wlanbaseif_split);
$wl_modes = get_wireless_modes($if);
$wl_chaninfo = get_wireless_channel_info($if);
$wl_sysctl_prefix = 'dev.' . $wlanbaseif_split[1] . '.' . $wlanbaseif_split[2];
$wl_sysctl = get_sysctl(
array(
"{$wl_sysctl_prefix}.diversity",
"{$wl_sysctl_prefix}.txantenna",
"{$wl_sysctl_prefix}.rxantenna",
"{$wl_sysctl_prefix}.slottime",
"{$wl_sysctl_prefix}.acktimeout",
"{$wl_sysctl_prefix}.ctstimeout"));
$wl_regdomain_xml_attr = array();
$wl_regdomain_xml = parse_xml_regdomain($wl_regdomain_xml_attr);
$wl_regdomains = &$wl_regdomain_xml['regulatory-domains']['rd'];
$wl_regdomains_attr = &$wl_regdomain_xml_attr['regulatory-domains']['rd'];
$wl_countries = &$wl_regdomain_xml['country-codes']['country'];
$wl_countries_attr = &$wl_regdomain_xml_attr['country-codes']['country'];
$pconfig['persistcommonwireless'] = isset($config['wireless']['interfaces'][$wlanbaseif]);
$pconfig['standard'] = $wancfg['wireless']['standard'];
$pconfig['mode'] = $wancfg['wireless']['mode'];
$pconfig['protmode'] = $wancfg['wireless']['protmode'];
$pconfig['ssid'] = $wancfg['wireless']['ssid'];
$pconfig['channel'] = $wancfg['wireless']['channel'];
$pconfig['txpower'] = $wancfg['wireless']['txpower'];
$pconfig['diversity'] = $wancfg['wireless']['diversity'];
$pconfig['txantenna'] = $wancfg['wireless']['txantenna'];
$pconfig['rxantenna'] = $wancfg['wireless']['rxantenna'];
$pconfig['distance'] = $wancfg['wireless']['distance'];
$pconfig['regdomain'] = $wancfg['wireless']['regdomain'];
$pconfig['regcountry'] = $wancfg['wireless']['regcountry'];
$pconfig['reglocation'] = $wancfg['wireless']['reglocation'];
$pconfig['wme_enable'] = isset($wancfg['wireless']['wme']['enable']);
if (isset($wancfg['wireless']['puren']['enable'])) {
$pconfig['puremode'] = '11n';
} else if (isset($wancfg['wireless']['pureg']['enable'])) {
$pconfig['puremode'] = '11g';
} else {
$pconfig['puremode'] = 'any';
}
$pconfig['apbridge_enable'] = isset($wancfg['wireless']['apbridge']['enable']);
$pconfig['authmode'] = $wancfg['wireless']['authmode'];
$pconfig['hidessid_enable'] = isset($wancfg['wireless']['hidessid']['enable']);
$pconfig['auth_server_addr'] = $wancfg['wireless']['auth_server_addr'];
$pconfig['auth_server_port'] = $wancfg['wireless']['auth_server_port'];
$pconfig['auth_server_shared_secret'] = $wancfg['wireless']['auth_server_shared_secret'];
$pconfig['auth_server_addr2'] = $wancfg['wireless']['auth_server_addr2'];
$pconfig['auth_server_port2'] = $wancfg['wireless']['auth_server_port2'];
$pconfig['auth_server_shared_secret2'] = $wancfg['wireless']['auth_server_shared_secret2'];
if (is_array($wancfg['wireless']['wpa'])) {
$pconfig['debug_mode'] = $wancfg['wireless']['wpa']['debug_mode'];
$pconfig['macaddr_acl'] = $wancfg['wireless']['wpa']['macaddr_acl'];
$pconfig['mac_acl_enable'] = isset($wancfg['wireless']['wpa']['mac_acl_enable']);
$pconfig['wpa_mode'] = $wancfg['wireless']['wpa']['wpa_mode'];
$pconfig['wpa_key_mgmt'] = $wancfg['wireless']['wpa']['wpa_key_mgmt'];
$pconfig['wpa_pairwise'] = $wancfg['wireless']['wpa']['wpa_pairwise'];
$pconfig['wpa_group_rekey'] = $wancfg['wireless']['wpa']['wpa_group_rekey'];
$pconfig['wpa_gmk_rekey'] = $wancfg['wireless']['wpa']['wpa_gmk_rekey'];
$pconfig['wpa_strict_rekey'] = isset($wancfg['wireless']['wpa']['wpa_strict_rekey']);
$pconfig['passphrase'] = $wancfg['wireless']['wpa']['passphrase'];
$pconfig['ieee8021x'] = isset($wancfg['wireless']['wpa']['ieee8021x']['enable']);
$pconfig['rsn_preauth'] = isset($wancfg['wireless']['wpa']['rsn_preauth']);
$pconfig['ext_wpa_sw'] = $wancfg['wireless']['wpa']['ext_wpa_sw'];
$pconfig['wpa_enable'] = isset($wancfg['wireless']['wpa']['enable']);
}
$pconfig['mac_acl'] = $wancfg['wireless']['mac_acl'];
}
if ($_POST['apply']) {
unset($input_errors);
if (!is_subsystem_dirty('interfaces')) {
$input_errors[] = gettext("You have already applied your settings!");
} else {
unlink_if_exists("{$g['tmp_path']}/config.cache");
clear_subsystem_dirty('interfaces');
if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
foreach ($toapplylist as $ifapply => $ifcfgo) {
if (isset($config['interfaces'][$ifapply]['enable'])) {
interface_bring_down($ifapply, false, $ifcfgo);
interface_configure($ifapply, true);
} else {
interface_bring_down($ifapply, true, $ifcfgo);
if (isset($config['dhcpd'][$ifapply]['enable']) ||
isset($config['dhcpdv6'][$ifapply]['enable'])) {
services_dhcpd_configure();
}
}
}
}
/* restart snmp so that it binds to correct address */
services_snmpd_configure();
/* sync filter configuration */
setup_gateways_monitor();
clear_subsystem_dirty('interfaces');
filter_configure();
enable_rrd_graphing();
if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
clear_subsystem_dirty('staticroutes');
}
}
@unlink("{$g['tmp_path']}/.interfaces.apply");
header("Location: interfaces.php?if={$if}");
exit;
} else if ($_POST && $_POST['enable'] != "yes") {
unset($wancfg['enable']);
if (isset($wancfg['wireless'])) {
interface_sync_wireless_clones($wancfg, false);
}
write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
mark_subsystem_dirty('interfaces');
if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
} else {
$toapplylist = array();
}
$toapplylist[$if]['ifcfg'] = $wancfg;
$toapplylist[$if]['ppps'] = $a_ppps;
/* we need to be able remove IP aliases for IPv6 */
file_put_contents("{$g['tmp_path']}/.interfaces.apply", serialize($toapplylist));
header("Location: interfaces.php?if={$if}");
exit;
} else if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
if (is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
$pconfig['track6-prefix-id'] = intval($_POST['track6-prefix-id--hex'], 16);
} else {
$pconfig['track6-prefix-id'] = 0;
}
conf_mount_rw();
/* filter out spaces from descriptions */
$_POST['descr'] = remove_bad_chars($_POST['descr']);
/* okay first of all, cause we are just hiding the PPPoE HTML
* fields related to PPPoE resets, we are going to unset $_POST
* vars, if the reset feature should not be used. Otherwise the
* data validation procedure below, may trigger a false error
* message.
*/
if (empty($_POST['pppoe-reset-type'])) {
unset($_POST['pppoe_pr_type']);
unset($_POST['pppoe_resethour']);
unset($_POST['pppoe_resetminute']);
unset($_POST['pppoe_resetdate']);
unset($_POST['pppoe_pr_preset_val']);
}
/* description unique? */
foreach ($ifdescrs as $ifent => $ifdescr) {
if ($if != $ifent && $ifdescr == $_POST['descr']) {
$input_errors[] = gettext("An interface with the specified description already exists.");
break;
}
}
if (is_numeric($_POST['descr'])) {
$input_errors[] = gettext("The interface description cannot contain only numbers.");
}
/* input validation */
if (isset($config['dhcpd']) && isset($config['dhcpd'][$if]['enable']) && (!preg_match("/^staticv4/", $_POST['type']))) {
$input_errors[] = gettext("The DHCP Server is active on this interface and it can be used only with a static IP configuration. Please disable the DHCP Server service on this interface first, then change the interface configuration.");
}
if (isset($config['dhcpdv6']) && isset($config['dhcpdv6'][$if]['enable']) && (!preg_match("/^staticv6/", $_POST['type6']))) {
$input_errors[] = gettext("The DHCP6 Server is active on this interface and it can be used only with a static IPv6 configuration. Please disable the DHCPv6 Server service on this interface first, then change the interface configuration.");
}
switch (strtolower($_POST['type'])) {
case "staticv4":
$reqdfields = explode(" ", "ipaddr subnet gateway");
$reqdfieldsn = array(gettext("IPv4 address"), gettext("Subnet bit count"), gettext("Gateway"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "none":
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $vip) {
if (is_ipaddrv4($vip['subnet']) && $vip['interface'] == $if) {
$input_errors[] = gettext("This interface is referenced by IPv4 VIPs. Please delete those before setting the interface to 'none' configuration.");
}
}
}
break;
case "ppp":
$reqdfields = explode(" ", "port phone");
$reqdfieldsn = array(gettext("Modem Port"), gettext("Phone Number"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "pppoe":
if ($_POST['pppoe_dialondemand']) {
$reqdfields = explode(" ", "pppoe_username pppoe_password pppoe_dialondemand pppoe_idletimeout");
$reqdfieldsn = array(gettext("PPPoE username"), gettext("PPPoE password"), gettext("Dial on demand"), gettext("Idle timeout value"));
} else {
$reqdfields = explode(" ", "pppoe_username pppoe_password");
$reqdfieldsn = array(gettext("PPPoE username"), gettext("PPPoE password"));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "pptp":
if ($_POST['pptp_dialondemand']) {
$reqdfields = explode(" ", "pptp_username pptp_password pptp_local0 pptp_subnet0 pptp_remote0 pptp_dialondemand pptp_idletimeout");
$reqdfieldsn = array(gettext("PPTP username"), gettext("PPTP password"), gettext("PPTP local IP address"), gettext("PPTP subnet"), gettext("PPTP remote IP address"), gettext("Dial on demand"), gettext("Idle timeout value"));
} else {
$reqdfields = explode(" ", "pptp_username pptp_password pptp_local0 pptp_subnet0 pptp_remote0");
$reqdfieldsn = array(gettext("PPTP username"), gettext("PPTP password"), gettext("PPTP local IP address"), gettext("PPTP subnet"), gettext("PPTP remote IP address"));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "l2tp":
if ($_POST['pptp_dialondemand']) {
$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote0 pptp_dialondemand pptp_idletimeout");
$reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address"), gettext("Dial on demand"), gettext("Idle timeout value"));
} else {
$reqdfields = explode(" ", "pptp_username pptp_password pptp_remote0");
$reqdfieldsn = array(gettext("L2TP username"), gettext("L2TP password"), gettext("L2TP remote IP address"));
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
break;
}
switch (strtolower($_POST['type6'])) {
case "staticv6":
$reqdfields = explode(" ", "ipaddrv6 subnetv6 gatewayv6");
$reqdfieldsn = array(gettext("IPv6 address"), gettext("Subnet bit count"), gettext("Gateway"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
break;
case "none":
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $vip) {
if (is_ipaddrv6($vip['subnet']) && $vip['interface'] == $if) {
$input_errors[] = gettext("This interface is referenced by IPv6 VIPs. Please delete those before setting the interface to 'none' configuration.");
}
}
}
break;
case "dhcp6":
if (in_array($wancfg['ipaddrv6'], array())) {
$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
}
if ($_POST['dhcp6-ia-pd-send-hint'] && strtolower($_POST['dhcp6-ia-pd-len']) == 'none') {
$input_errors[] = gettext('DHCPv6 Prefix Delegation size must be provided when Send IPv6 prefix hint flag is checked');
}
break;
case "6rd":
foreach ($ifdescrs as $ifent => $ifdescr) {
if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
if ($config[interfaces][$ifent]['prefix-6rd'] == $_POST['prefix-6rd']) {
$input_errors[] = gettext("You can only have one interface configured in 6rd with same prefix.");
break;
}
}
}
if (!is_ipaddrv4($_POST['gateway-6rd'])) {
$input_errors[] = gettext("6RD Border Gateway must be an IPv4 address.");
}
if (in_array($wancfg['ipaddrv6'], array())) {
$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
}
break;
case "6to4":
foreach ($ifdescrs as $ifent => $ifdescr) {
if ($if != $ifent && ($config[interfaces][$ifent]['ipaddrv6'] == $_POST['type6'])) {
$input_errors[] = sprintf(gettext("You can only have one interface configured as 6to4."), $_POST['type6']);
break;
}
}
if (in_array($wancfg['ipaddrv6'], array())) {
$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
}
break;
case "track6":
/* needs to check if $track6-prefix-id is used on another interface */
if (in_array($wancfg['ipaddrv6'], array())) {
$input_errors[] = sprintf(gettext("You have to reassign the interface to be able to configure as %s."), $_POST['type6']);
}
if ($_POST['track6-prefix-id--hex'] != "" && !is_numeric("0x" . $_POST['track6-prefix-id--hex'])) {
$input_errors[] = gettext("You must enter a valid hexadecimal number for the IPv6 prefix ID.");
} else {
$track6_prefix_id = intval($_POST['track6-prefix-id--hex'], 16);
if ($track6_prefix_id < 0 || $track6_prefix_id > $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) {
$input_errors[] = gettext("You specified an IPv6 prefix ID that is out of range.") .
" ({$_POST['track6-interface']}) - (0) - (" . sprintf('%x', $_POST['ipv6-num-prefix-ids-' . $_POST['track6-interface']]) . ")";
} else {
foreach ($ifdescrs as $ifent => $ifdescr) {
if ($if == $ifent) {
continue;
}
if ($config['interfaces'][$ifent]['ipaddrv6'] == 'track6' &&
$config['interfaces'][$ifent]['track6-interface'] == $_POST['track6-interface'] &&
$config['interfaces'][$ifent]['track6-prefix-id'] == $track6_prefix_id) {
$input_errors[] = sprintf(gettext("This track6 prefix ID is already being used in %s."), $ifdescr);
}
}
}
}
break;
}
/* normalize MAC addresses - lowercase and convert Windows-ized hyphenated MACs to colon delimited */
$staticroutes = get_staticroutes(true);
$_POST['spoofmac'] = strtolower(str_replace("-", ":", $_POST['spoofmac']));
if ($_POST['ipaddr']) {
if (!is_ipaddrv4($_POST['ipaddr'])) {
$input_errors[] = gettext("A valid IPv4 address must be specified.");
} else {
$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddr'], $if, true, true, $_POST['subnet']);
if (count($where_ipaddr_configured)) {
$subnet_conflict_text = sprintf(gettext("IPv4 address %s is being used by or overlaps with:"), $_POST['ipaddr'] . "/" . $_POST['subnet']);
foreach ($where_ipaddr_configured as $subnet_conflict) {
$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
}
$input_errors[] = $subnet_conflict_text;
}
/* Do not accept network or broadcast address, except if subnet is 31 or 32 */
if ($_POST['subnet'] < 31) {
if ($_POST['ipaddr'] == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
$input_errors[] = gettext("This IPv4 address is the network address and cannot be used");
} else if ($_POST['ipaddr'] == gen_subnet_max($_POST['ipaddr'], $_POST['subnet'])) {
$input_errors[] = gettext("This IPv4 address is the broadcast address and cannot be used");
}
}
foreach ($staticroutes as $route_subnet) {
list($network, $subnet) = explode("/", $route_subnet);
if ($_POST['subnet'] == $subnet && $network == gen_subnet($_POST['ipaddr'], $_POST['subnet'])) {
$input_errors[] = gettext("This IPv4 address conflicts with a Static Route.");
break;
}
unset($network, $subnet);
}
}
}
if ($_POST['ipaddrv6']) {
if (!is_ipaddrv6($_POST['ipaddrv6'])) {
$input_errors[] = gettext("A valid IPv6 address must be specified.");
} else {
if (ip_in_subnet($_POST['ipaddrv6'], "fe80::/10")) {
$input_errors[] = gettext("IPv6 link local addresses cannot be configured as an interface IP.");
}
$where_ipaddr_configured = where_is_ipaddr_configured($_POST['ipaddrv6'], $if, true, true, $_POST['subnetv6']);
if (count($where_ipaddr_configured)) {
$subnet_conflict_text = sprintf(gettext("IPv6 address %s is being used by or overlaps with:"), $_POST['ipaddrv6'] . "/" . $_POST['subnetv6']);
foreach ($where_ipaddr_configured as $subnet_conflict) {
$subnet_conflict_text .= " " . convert_friendly_interface_to_friendly_descr($subnet_conflict['if']) . " (" . $subnet_conflict['ip_or_subnet'] . ")";
}
$input_errors[] = $subnet_conflict_text;
}
foreach ($staticroutes as $route_subnet) {
list($network, $subnet) = explode("/", $route_subnet);
if ($_POST['subnetv6'] == $subnet && $network == gen_subnetv6($_POST['ipaddrv6'], $_POST['subnetv6'])) {
$input_errors[] = gettext("This IPv6 address conflicts with a Static Route.");
break;
}
unset($network, $subnet);
}
}
}
if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
$input_errors[] = gettext("A valid subnet bit count must be specified.");
}
if (($_POST['subnetv6'] && !is_numeric($_POST['subnetv6']))) {
$input_errors[] = gettext("A valid subnet bit count must be specified.");
}
if (($_POST['alias-address'] && !is_ipaddrv4($_POST['alias-address']))) {
$input_errors[] = gettext("A valid alias IP address must be specified.");
}
if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
$input_errors[] = gettext("A valid alias subnet bit count must be specified.");
}
if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom'])) {
$input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from.");
}
if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) {
$match = false;
foreach ($a_gateways as $gateway) {
if (in_array($_POST['gateway'], $gateway)) {
$match = true;
}
}
foreach ($a_gateways as $gateway) {
if (in_array($_POST['gatewayv6'], $gateway)) {
$match = true;
}
}
if (!$match) {
$input_errors[] = gettext("A valid gateway must be specified.");
}
}
if (($_POST['provider'] && !is_domain($_POST['provider']))) {
$input_errors[] = gettext("The service name contains invalid characters.");
}
if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
$input_errors[] = gettext("The idle timeout value must be an integer.");
}
if ($_POST['pppoe_resethour'] != "" && !is_numericint($_POST['pppoe_resethour']) &&
$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
}
if ($_POST['pppoe_resetminute'] != "" && !is_numericint($_POST['pppoe_resetminute']) &&
$_POST['pppoe_resetminute'] >= 0 && $_POST['pppoe_resetminute'] <=59) {
$input_errors[] = gettext("A valid PPPoE reset minute must be specified (0-59).");
}
if ($_POST['pppoe_resetdate'] != "" && !is_numeric(str_replace("/", "", $_POST['pppoe_resetdate']))) {
$input_errors[] = gettext("A valid PPPoE reset date must be specified (mm/dd/yyyy).");
}
if (($_POST['pptp_local0'] && !is_ipaddrv4($_POST['pptp_local0']))) {
$input_errors[] = gettext("A valid PPTP local IP address must be specified.");
}
if (($_POST['pptp_subnet0'] && !is_numeric($_POST['pptp_subnet0']))) {
$input_errors[] = gettext("A valid PPTP subnet bit count must be specified.");
}
if (($_POST['pptp_remote0'] && !is_ipaddrv4($_POST['pptp_remote0']) && !is_hostname($_POST['gateway'][$iface]))) {
$input_errors[] = gettext("A valid PPTP remote IP address must be specified.");
}
if (($_POST['pptp_idletimeout'] != "") && !is_numericint($_POST['pptp_idletimeout'])) {
$input_errors[] = gettext("The idle timeout value must be an integer.");
}
if (($_POST['spoofmac'] && !is_macaddr($_POST['spoofmac']))) {
$input_errors[] = gettext("A valid MAC address must be specified.");
}
if ($_POST['mtu']) {
if (!is_numericint($_POST['mtu'])) {
$input_errors[] = "MTU must be an integer.";
}
if (substr($wancfg['if'], 0, 3) == 'gif') {
$min_mtu = 1280;
$max_mtu = 8192;
} else {
$min_mtu = 576;
$max_mtu = 9000;
}
if ($_POST['mtu'] < $min_mtu || $_POST['mtu'] > $max_mtu) {
$input_errors[] = sprintf(gettext("The MTU must be between %d and %d bytes."), $min_mtu, $max_mtu);
}
unset($min_mtu, $max_mtu);
if (stristr($wancfg['if'], "_vlan")) {
$realhwif_array = get_parent_interface($wancfg['if']);
// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
$parent_realhwif = $realhwif_array[0];
$parent_if = convert_real_interface_to_friendly_interface_name($parent_realhwif);
if (!empty($parent_if) && !empty($config['interfaces'][$parent_if]['mtu'])) {
if ($_POST['mtu'] > intval($config['interfaces'][$parent_if]['mtu'])) {
$input_errors[] = gettext("The MTU of a VLAN cannot be greater than that of its parent interface.");
}
}
} else {
foreach ($config['interfaces'] as $idx => $ifdata) {
if (($idx == $if) || !preg_match('/_vlan[0-9]/', $ifdata['if'])) {
continue;
}
$realhwif_array = get_parent_interface($ifdata['if']);
// Need code to handle MLPPP if we ever use $realhwif for MLPPP handling
$parent_realhwif = $realhwif_array[0];
if ($parent_realhwif != $wancfg['if']) {
continue;
}
if (isset($ifdata['mtu']) && $ifdata['mtu'] > $_POST['mtu']) {
$input_errors[] = sprintf(gettext("Interface %s (VLAN) has MTU set to a larger value"), $ifdata['descr']);
}
}
}
}
if ($_POST['mss'] != '') {
if (!is_numericint($_POST['mss']) || ($_POST['mss'] < 576 || $_POST['mss'] > 65535)) {
$input_errors[] = gettext("The MSS must be an integer between 576 and 65535 bytes.");
}
}
/* Wireless interface? */
if (isset($wancfg['wireless'])) {
$reqdfields = array("mode");
$reqdfieldsn = array(gettext("Mode"));
if ($_POST['mode'] == 'hostap') {
$reqdfields[] = "ssid";
$reqdfieldsn[] = gettext("SSID");
if (isset($_POST['channel']) && $_POST['channel'] == "0") {
// auto channel with hostap is broken, prevent this for now.
$input_errors[] = gettext("A specific channel, not auto, must be selected for Access Point mode.");
}
}
if (stristr($_POST['standard'], '11n')) {
if (!($_POST['wme_enable'])) {
$input_errors[] = gettext("802.11n standards require enabling WME.");
}
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
check_wireless_mode();
if (isset($_POST['wpa_group_rekey']) && (!is_numericint($_POST['wpa_group_rekey']) || $_POST['wpa_group_rekey'] < 1 || $_POST['wpa_group_rekey'] > 9999)) {
$input_errors[] = gettext("Key Rotation must be an integer between 1 and 9999.");
}
if (isset($_POST['wpa_gmk_rekey']) && (!is_numericint($_POST['wpa_gmk_rekey']) || $_POST['wpa_gmk_rekey'] < 1 || $_POST['wpa_gmk_rekey'] > 9999)) {
$input_errors[] = gettext("Master Key Regeneration must be an integer between 1 and 9999.");
}
if (isset($_POST['wpa_group_rekey']) && isset($_POST['wpa_gmk_rekey'])) {
if ($_POST['wpa_group_rekey'] > $_POST['wpa_gmk_rekey']) {
$input_errors[] = gettext("Master Key Regeneration must be greater than Key Rotation.");
}
}
if (!empty($_POST['auth_server_addr'])) {
if (!is_domain($_POST['auth_server_addr']) && !is_ipaddr($_POST['auth_server_addr'])) {
$input_errors[] = gettext("802.1X Authentication Server must be an IP or hostname.");
}
}
if (!empty($_POST['auth_server_addr2'])) {
if (!is_domain($_POST['auth_server_addr2']) && !is_ipaddr($_POST['auth_server_addr2'])) {
$input_errors[] = gettext("Secondary 802.1X Authentication Server must be an IP or hostname.");
}
}
if (!empty($_POST['auth_server_port'])) {
if (!is_port($_POST['auth_server_port'])) {
$input_errors[] = gettext("802.1X Authentication Server Port must be a valid port number (1-65535).");
}
}
if (!empty($_POST['auth_server_port2'])) {
if (!is_port($_POST['auth_server_port2'])) {
$input_errors[] = gettext("Secondary 802.1X Authentication Server Port must be a valid port number (1-65535).");
}
}
if (isset($_POST['channel']) && !is_numericint($_POST['channel'])) {
if (!is_numericint($_POST['channel'])) {
$input_errors[] = gettext("Invalid channel specified.");
} else {
if ($_POST['channel'] > 255 || $_POST['channel'] < 0) {
$input_errors[] = gettext("Channel must be between 0-255.");
}
}
}
if (!empty($_POST['distance']) && !is_numericint($_POST['distance'])) {
$input_errors[] = gettext("Distance must be an integer.");
}
if (isset($_POST['standard']) && (stristr($_POST['standard'], '11na') || stristr($_POST['standard'], '11a'))) {
if ($_POST['channel'] != 0 && $_POST['channel'] < 15) {
$input_errors[] = gettext("Channel selected is not valid for 802.11a or 802.11na.");
}
}
if (isset($_POST['standard']) && ($_POST['standard'] == "11b" || $_POST['standard'] == "11g")) {
if ($_POST['channel'] > 14) {
$input_errors[] = gettext("Channel selected is not valid for 802.11b or 802.11g.");
}
}
if (!empty($_POST['protmode']) && !in_array($_POST['protmode'], array("off", "cts", "rtscts"))) {
$input_errors[] = gettext("Invalid option chosen for OFDM Protection Mode");
}
if ($_POST['passphrase']) {
$passlen = strlen($_POST['passphrase']);
if ($passlen < 8 || $passlen > 63) {
$input_errors[] = gettext("The WPA passphrase must be between 8 and 63 characters long.");
}
}
if ($_POST['wpa_enable'] == "yes") {
if (empty($_POST['passphrase']) && stristr($_POST['wpa_key_mgmt'], "WPA-PSK")) {
$input_errors[] = gettext("A WPA Passphrase must be specified when WPA PSK is enabled.");
}
}
}
if (!$input_errors) {
// These 3 fields can be a list of multiple data items when used for MLPPP.
// The UI in this code only processes the first of the list, so save the data here then we can preserve any other entries.
$poriginal['pptp_localip'] = explode(",", $a_ppps[$pppid]['localip']);
$poriginal['pptp_subnet'] = explode(",", $a_ppps[$pppid]['subnet']);
$poriginal['pptp_remote'] = explode(",", $a_ppps[$pppid]['gateway']);
if ($wancfg['ipaddr'] != $_POST['type']) {
if (in_array($wancfg['ipaddr'], array("ppp", "pppoe", "pptp", "l2tp"))) {
$wancfg['if'] = $a_ppps[$pppid]['ports'];
unset($a_ppps[$pppid]);
} else if ($wancfg['ipaddr'] == "dhcp") {
kill_dhclient_process($wancfg['if']);
}
if ($wancfg['ipaddrv6'] == "dhcp6") {
$pid = find_dhcp6c_process($wancfg['if']);
if ($pid) {
posix_kill($pid, SIGTERM);
}
}
}
$ppp = array();
if ($wancfg['ipaddr'] != "ppp") {
unset($wancfg['ipaddr']);
}
if ($wancfg['ipaddrv6'] != "ppp") {
unset($wancfg['ipaddrv6']);
}
unset($wancfg['subnet']);
unset($wancfg['gateway']);
unset($wancfg['subnetv6']);
unset($wancfg['gatewayv6']);
unset($wancfg['dhcphostname']);
unset($wancfg['dhcprejectfrom']);
unset($wancfg['dhcp6-duid']);
unset($wancfg['dhcp6-ia-pd-len']);
unset($wancfg['dhcp6-ia-pd-send-hint']);
unset($wancfg['dhcp6prefixonly']);
unset($wancfg['dhcp6usev4iface']);
unset($wancfg['track6-interface']);
unset($wancfg['track6-prefix-id']);
unset($wancfg['prefix-6rd']);
unset($wancfg['prefix-6rd-v4plen']);
unset($wancfg['gateway-6rd']);
unset($wancfg['adv_dhcp_pt_timeout']);
unset($wancfg['adv_dhcp_pt_retry']);
unset($wancfg['adv_dhcp_pt_select_timeout']);
unset($wancfg['adv_dhcp_pt_reboot']);
unset($wancfg['adv_dhcp_pt_backoff_cutoff']);
unset($wancfg['adv_dhcp_pt_initial_interval']);